diff --git a/starboard/nplb/BUILD.gn b/starboard/nplb/BUILD.gn index 33997e67e144..447d95032cf3 100644 --- a/starboard/nplb/BUILD.gn +++ b/starboard/nplb/BUILD.gn @@ -309,6 +309,14 @@ target(gtest_target_type, "nplb") { [ "//starboard/nplb/compiler_compliance/cpp_compiler_version_check.cc" ] } + if (is_win) { + sources += + [ "//starboard/nplb/time_zone_with_expect_value_win.cc" ] + } else { + sources += + [ "//starboard/nplb/time_zone_with_expect_value.cc" ] + } + configs += [ "//starboard/build/config:starboard_implementation" ] if (sb_enable_cast_codec_tests) { configs += [ ":cast_codec_tests" ] diff --git a/starboard/nplb/time_zone_get_current_test.cc b/starboard/nplb/time_zone_get_current_test.cc index e4f5a27b1d0c..ce2e840826b1 100644 --- a/starboard/nplb/time_zone_get_current_test.cc +++ b/starboard/nplb/time_zone_get_current_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "time_zone_with_expect_value.h" + #include "starboard/extension/time_zone.h" #include "starboard/nplb/time_constants.h" #include "starboard/system.h" @@ -25,20 +27,6 @@ namespace starboard { namespace nplb { namespace { -struct TimeZoneWithExpectValue { - TimeZoneWithExpectValue(std::string timeZoneName_, - SbTimeZone expectedStandardValue_, - SbTimeZone expectedDaylightValue_) - : timeZoneName{timeZoneName_}, - expectedStandardValue{expectedStandardValue_}, - expectedDaylightValue{expectedDaylightValue_} {} - - std::string timeZoneName; - - SbTimeZone expectedStandardValue; - SbTimeZone expectedDaylightValue; -}; - class SbTimeZoneGetCurrentSetTimeZoneTest : public testing::Test, public testing::WithParamInterface { @@ -80,39 +68,6 @@ TEST(SbTimeZoneGetCurrentTest, IsKindOfSane) { EXPECT_LE(zone, 24 * 60); } -#if defined(_WIN32) - -std::array timeZonesWithExpectedTimeValues{ - TimeZoneWithExpectValue("UTC", 0, 0), - TimeZoneWithExpectValue("Atlantic Standard Time", 240, 180), - TimeZoneWithExpectValue("Eastern Standard Time", 300, 240), - TimeZoneWithExpectValue("Central Standard Time", 360, 300), - TimeZoneWithExpectValue("Mountain Standard Time", 420, 360), - TimeZoneWithExpectValue("Pacific Standard Time", 480, 420), - TimeZoneWithExpectValue("Yukon Standard Time", 420, 420), - TimeZoneWithExpectValue("Samoa Standard Time", -780, -780), - TimeZoneWithExpectValue("China Standard Time", -480, -480), - TimeZoneWithExpectValue("Central European Standard Time", -60, -120), - TimeZoneWithExpectValue("Omsk Standard Time", -360, -360), - TimeZoneWithExpectValue("Cen. Australia Standard Time", -570, -630)}; - -#else - -std::array timeZonesWithExpectedTimeValues{ - TimeZoneWithExpectValue("UTC", 0, 0), - TimeZoneWithExpectValue("America/Puerto_Rico", 240, 240), - TimeZoneWithExpectValue("America/New_York", 300, 300), - TimeZoneWithExpectValue("US/Eastern", 300, 300), - TimeZoneWithExpectValue("America/Chicago", 360, 360), - TimeZoneWithExpectValue("US/Mountain", 420, 420), - TimeZoneWithExpectValue("US/Pacific", 480, 480), - TimeZoneWithExpectValue("US/Alaska", 540, 540), - TimeZoneWithExpectValue("Pacific/Honolulu", 600, 600), - TimeZoneWithExpectValue("US/Samoa", 660, 660), - TimeZoneWithExpectValue("Pacific/Guam", -600, -600)}; - -#endif - TEST_P(SbTimeZoneGetCurrentSetTimeZoneTest, IsKindOfSane) { EXPECT_TRUE(time_zone_extension->SetTimeZone(GetParam().timeZoneName.c_str())); auto zone = SbTimeZoneGetCurrent(); diff --git a/starboard/nplb/time_zone_with_expect_value.cc b/starboard/nplb/time_zone_with_expect_value.cc new file mode 100644 index 000000000000..65580ca5d52a --- /dev/null +++ b/starboard/nplb/time_zone_with_expect_value.cc @@ -0,0 +1,19 @@ +#include "time_zone_with_expect_value.h" + +#if !defined(_WIN32) + +const std::array timeZonesWithExpectedTimeValues{ + TimeZoneWithExpectValue("UTC", 0, 0), + TimeZoneWithExpectValue("America/Puerto_Rico", 240, 240), + TimeZoneWithExpectValue("America/New_York", 300, 300), + TimeZoneWithExpectValue("US/Eastern", 300, 300), + TimeZoneWithExpectValue("America/Chicago", 360, 360), + TimeZoneWithExpectValue("US/Mountain", 420, 420), + TimeZoneWithExpectValue("US/Pacific", 480, 480), + TimeZoneWithExpectValue("US/Alaska", 540, 540), + TimeZoneWithExpectValue("Pacific/Honolulu", 600, 600), + TimeZoneWithExpectValue("US/Samoa", 660, 660), + TimeZoneWithExpectValue("Pacific/Guam", -600, -600), + TimeZoneWithExpectValue("Australia/South", -600, -600)}; + +#endif diff --git a/starboard/nplb/time_zone_with_expect_value.h b/starboard/nplb/time_zone_with_expect_value.h new file mode 100644 index 000000000000..49de609c9a0e --- /dev/null +++ b/starboard/nplb/time_zone_with_expect_value.h @@ -0,0 +1,20 @@ +#include "starboard/time_zone.h" + +#include +#include + +struct TimeZoneWithExpectValue { + TimeZoneWithExpectValue(std::string timeZoneName_, + SbTimeZone expectedStandardValue_, + SbTimeZone expectedDaylightValue_) + : timeZoneName{timeZoneName_}, + expectedStandardValue{expectedStandardValue_}, + expectedDaylightValue{expectedDaylightValue_} {} + + std::string timeZoneName; + + SbTimeZone expectedStandardValue; + SbTimeZone expectedDaylightValue; +}; + +extern const std::array timeZonesWithExpectedTimeValues; \ No newline at end of file diff --git a/starboard/nplb/time_zone_with_expect_value_win.cc b/starboard/nplb/time_zone_with_expect_value_win.cc new file mode 100644 index 000000000000..74d9aac7a293 --- /dev/null +++ b/starboard/nplb/time_zone_with_expect_value_win.cc @@ -0,0 +1,19 @@ +#include "time_zone_with_expect_value.h" + +#if defined(_WIN32) + +const std::array timeZonesWithExpectedTimeValues{ + TimeZoneWithExpectValue("UTC", 0, 0), + TimeZoneWithExpectValue("Atlantic Standard Time", 240, 180), + TimeZoneWithExpectValue("Eastern Standard Time", 300, 240), + TimeZoneWithExpectValue("Central Standard Time", 360, 300), + TimeZoneWithExpectValue("Mountain Standard Time", 420, 360), + TimeZoneWithExpectValue("Pacific Standard Time", 480, 420), + TimeZoneWithExpectValue("Yukon Standard Time", 420, 420), + TimeZoneWithExpectValue("Samoa Standard Time", -840, -840), + TimeZoneWithExpectValue("China Standard Time", -480, -480), + TimeZoneWithExpectValue("Central European Standard Time", -60, -120), + TimeZoneWithExpectValue("Omsk Standard Time", -360, -360), + TimeZoneWithExpectValue("Cen. Australia Standard Time", -570, -630)}; + +#endif