Flutter Engine
The Flutter Engine
runner_tzdata_unittest.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include <gtest/gtest.h>
6
7#include <cstdlib>
8
9#include "runner.h"
10#include "third_party/icu/source/i18n/unicode/timezone.h"
11
12namespace flutter_runner {
13
14TEST(RunnerTZDataTest, LoadsWithTZDataPresent) {
15 // TODO(fxbug.dev/69570): Move to cml file if env_vars gains supported for the
16 // gtest_runner.
17 setenv("ICU_TIMEZONE_FILES_DIR", "/pkg/data/tzdata", true);
18
19 UErrorCode err = U_ZERO_ERROR;
20 const auto version_before = std::string(icu::TimeZone::getTZDataVersion(err));
21 ASSERT_EQ(U_ZERO_ERROR, err) << "unicode error: " << u_errorName(err);
22
23 // This loads the tzdata. In Fuchsia, we force the data from this package
24 // to be version 2019a, so that we can test the resource load.
25 bool success = Runner::SetupICUInternal();
26 ASSERT_TRUE(success) << "failed to load timezone data";
27
28 const auto version_after = std::string(icu::TimeZone::getTZDataVersion(err));
29 ASSERT_EQ(U_ZERO_ERROR, err) << "unicode error: " << u_errorName(err);
30
31 EXPECT_EQ("2019a", version_after);
32}
33
34} // namespace flutter_runner
TEST(RunnerTZDataTest, LoadsWithoutTZDataPresent)