Skip to content

Commit

Permalink
Apply review's findings
Browse files Browse the repository at this point in the history
  • Loading branch information
Marek Biolik authored and MarekLuxoft committed Dec 11, 2024
1 parent 2fb481f commit 0120f53
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 47 deletions.
8 changes: 8 additions & 0 deletions starboard/nplb/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
49 changes: 2 additions & 47 deletions starboard/nplb/time_zone_get_current_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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<TimeZoneWithExpectValue> {
Expand Down Expand Up @@ -80,39 +68,6 @@ TEST(SbTimeZoneGetCurrentTest, IsKindOfSane) {
EXPECT_LE(zone, 24 * 60);
}

#if defined(_WIN32)

std::array<TimeZoneWithExpectValue, 12> 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<TimeZoneWithExpectValue, 11> 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();
Expand Down
19 changes: 19 additions & 0 deletions starboard/nplb/time_zone_with_expect_value.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "time_zone_with_expect_value.h"

#if !defined(_WIN32)

const std::array<TimeZoneWithExpectValue, 12> 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
20 changes: 20 additions & 0 deletions starboard/nplb/time_zone_with_expect_value.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "starboard/time_zone.h"

#include <array>
#include <gmock/gmock.h>

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<TimeZoneWithExpectValue, 12> timeZonesWithExpectedTimeValues;
19 changes: 19 additions & 0 deletions starboard/nplb/time_zone_with_expect_value_win.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "time_zone_with_expect_value.h"

#if defined(_WIN32)

const std::array<TimeZoneWithExpectValue, 12> 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

0 comments on commit 0120f53

Please sign in to comment.