Skip to content

Commit

Permalink
tests: Use scoped_weather_override for widget test
Browse files Browse the repository at this point in the history
  • Loading branch information
wapcaplet committed Dec 31, 2021
1 parent 9f64d1a commit 2ea634b
Showing 1 changed file with 37 additions and 30 deletions.
67 changes: 37 additions & 30 deletions tests/widget_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "player_helpers.h"
#include "morale.h"
#include "options_helpers.h"
#include "weather.h"
#include "weather_type.h"
#include "widget.h"
Expand All @@ -17,12 +18,12 @@ static const move_mode_id move_mode_prone( "prone" );
static const move_mode_id move_mode_run( "run" );
static const move_mode_id move_mode_walk( "walk" );

static const weather_type_id weather_acid_rain( "acid_rain" );
static const weather_type_id weather_cloudy( "cloudy" );
static const weather_type_id weather_drizzle( "drizzle" );
static const weather_type_id weather_portal_storm( "portal_storm" );
static const weather_type_id weather_snowing( "snowing" );
static const weather_type_id weather_sunny( "sunny" );
static const weather_type_id weather_type_acid_rain( "acid_rain" );
static const weather_type_id weather_type_cloudy( "cloudy" );
static const weather_type_id weather_type_drizzle( "drizzle" );
static const weather_type_id weather_type_portal_storm( "portal_storm" );
static const weather_type_id weather_type_snowing( "snowing" );
static const weather_type_id weather_type_sunny( "sunny" );

static const widget_id widget_test_bp_wetness_head_num( "test_bp_wetness_head_num" );
static const widget_id widget_test_bp_wetness_torso_num( "test_bp_wetness_torso_num" );
Expand Down Expand Up @@ -533,43 +534,49 @@ TEST_CASE( "widgets showing avatar attributes", "[widget][avatar]" )
}
}

TEST_CASE( "widgets showing environment features", "[widget][environment]" )
TEST_CASE( "widgets showing weather conditions", "[widget][weather]" )
{
widget weather_w = widget_test_weather_text.obj();

avatar &ava = get_avatar();
clear_avatar();

SECTION( "weather conditions" ) {
weather_manager &weather = get_weather();

weather.weather_override = weather_sunny;
weather.set_nextweather( calendar::turn );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_light_cyan>Sunny</color>" );
SECTION( "sunny" ) {
scoped_weather_override weather_sunny( weather_type_sunny );
REQUIRE( get_weather().weather_id->name.translated() == "Sunny" );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_light_cyan>Sunny</color>" );
}

weather.weather_override = weather_cloudy;
weather.set_nextweather( calendar::turn );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_light_gray>Cloudy</color>" );
SECTION( "cloudy" ) {
scoped_weather_override weather_cloudy( weather_type_cloudy );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_light_gray>Cloudy</color>" );
}

weather.weather_override = weather_drizzle;
weather.set_nextweather( calendar::turn );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_light_blue>Drizzle</color>" );
SECTION( "drizzle" ) {
scoped_weather_override weather_drizzle( weather_type_drizzle );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_light_blue>Drizzle</color>" );
}

weather.weather_override = weather_snowing;
weather.set_nextweather( calendar::turn );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_white>Snowing</color>" );
SECTION( "snowing" ) {
scoped_weather_override weather_snowing( weather_type_snowing );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_white>Snowing</color>" );
}

weather.weather_override = weather_acid_rain;
weather.set_nextweather( calendar::turn );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_green>Acid Rain</color>" );
SECTION( "acid rain" ) {
scoped_weather_override weather_acid_rain( weather_type_acid_rain );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_green>Acid Rain</color>" );
}

weather.weather_override = weather_portal_storm;
weather.set_nextweather( calendar::turn );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_red>Portal Storm</color>" );
SECTION( "portal storm" ) {
scoped_weather_override weather_portal_storm( weather_type_portal_storm );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_red>Portal Storm</color>" );
}

// Cannot see weather when underground
ava.setpos( { 0, 0, -1 } );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_light_gray>Underground</color>" );
SECTION( "cannot see weather when underground" ) {
ava.setpos( tripoint_below );
CHECK( weather_w.layout( ava ) == "Weather: <color_c_light_gray>Underground</color>" );
}
}
}

Expand Down

0 comments on commit 2ea634b

Please sign in to comment.