Skip to content

Commit

Permalink
[fuchsia] Migrate unittests to CFv2 (flutter#32878)
Browse files Browse the repository at this point in the history
  • Loading branch information
arbreng authored May 7, 2022
1 parent 09c935b commit ec0e5b6
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 337 deletions.
2 changes: 1 addition & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ group("flutter") {
}

# Compile all benchmark targets if enabled.
if (enable_unittests && !is_win) {
if (enable_unittests && !is_win && !is_fuchsia) {
public_deps += [
"//flutter/display_list:display_list_benchmarks",
"//flutter/fml:fml_benchmarks",
Expand Down
5 changes: 1 addition & 4 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1932,13 +1932,11 @@ FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/meta/dart_jit_product_
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/meta/dart_jit_product_runner.cmx
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/meta/dart_jit_runner.cml
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/meta/dart_jit_runner.cmx
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/meta/dart_zircon_test.cmx
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/meta/jit_product_runtime
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/meta/jit_runtime
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/service_isolate.cc
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/service_isolate.h
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/vmservice/empty.dart
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/vmservice/meta/vmservice.cmx
FILE: ../../../flutter/shell/platform/fuchsia/flutter/accessibility_bridge.cc
FILE: ../../../flutter/shell/platform/fuchsia/flutter/accessibility_bridge.h
FILE: ../../../flutter/shell/platform/fuchsia/flutter/accessibility_bridge_unittest.cc
Expand Down Expand Up @@ -2006,7 +2004,6 @@ FILE: ../../../flutter/shell/platform/fuchsia/flutter/meta/flutter_jit_product_r
FILE: ../../../flutter/shell/platform/fuchsia/flutter/meta/flutter_jit_product_runner.cmx
FILE: ../../../flutter/shell/platform/fuchsia/flutter/meta/flutter_jit_runner.cml
FILE: ../../../flutter/shell/platform/fuchsia/flutter/meta/flutter_jit_runner.cmx
FILE: ../../../flutter/shell/platform/fuchsia/flutter/meta/flutter_runner_tests.cmx
FILE: ../../../flutter/shell/platform/fuchsia/flutter/meta/jit_product_runtime
FILE: ../../../flutter/shell/platform/fuchsia/flutter/meta/jit_runtime
FILE: ../../../flutter/shell/platform/fuchsia/flutter/platform_view.cc
Expand All @@ -2018,8 +2015,8 @@ FILE: ../../../flutter/shell/platform/fuchsia/flutter/pointer_delegate_unittests
FILE: ../../../flutter/shell/platform/fuchsia/flutter/program_metadata.h
FILE: ../../../flutter/shell/platform/fuchsia/flutter/runner.cc
FILE: ../../../flutter/shell/platform/fuchsia/flutter/runner.h
FILE: ../../../flutter/shell/platform/fuchsia/flutter/runner_tzdata_missing_unittest.cc
FILE: ../../../flutter/shell/platform/fuchsia/flutter/runner_tzdata_unittest.cc
FILE: ../../../flutter/shell/platform/fuchsia/flutter/runner_unittest.cc
FILE: ../../../flutter/shell/platform/fuchsia/flutter/software_surface.cc
FILE: ../../../flutter/shell/platform/fuchsia/flutter/software_surface.h
FILE: ../../../flutter/shell/platform/fuchsia/flutter/software_surface_producer.cc
Expand Down
13 changes: 13 additions & 0 deletions display_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/fuchsia/sdk.gni")
import("//flutter/common/config.gni")
import("//flutter/testing/testing.gni")

Expand Down Expand Up @@ -111,6 +112,12 @@ if (enable_unittests) {
# Required for M_PI and others.
defines += [ "_USE_MATH_DEFINES" ]
}

# This is needed for //third_party/googletest for linking zircon symbols.
if (is_fuchsia) {
libs =
[ "${fuchsia_sdk_path}/arch/${target_cpu}/sysroot/lib/libzircon.so" ]
}
}

executable("display_list_rendertests") {
Expand All @@ -132,6 +139,12 @@ if (enable_unittests) {
# Required for M_PI and others.
defines += [ "_USE_MATH_DEFINES" ]
}

# This is needed for //third_party/googletest for linking zircon symbols.
if (is_fuchsia) {
libs =
[ "${fuchsia_sdk_path}/arch/${target_cpu}/sysroot/lib/libzircon.so" ]
}
}
}

Expand Down
1 change: 1 addition & 0 deletions fml/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ if (enable_unittests) {
"//flutter/testing",
]

# This is needed for //third_party/googletest for linking zircon symbols.
if (is_fuchsia) {
libs =
[ "${fuchsia_sdk_path}/arch/${target_cpu}/sysroot/lib/libzircon.so" ]
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/fuchsia/dart-pkg/zircon/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ flutter_component("channel_test_flutter_component") {
main_package = "channel_test"
component_name = "channel_test"
main_dart = "channel_test.dart"
manifest = rebase_path("meta/channel_test.cmx")
manifest = rebase_path("meta/channel_test.cml")
deps = [ ":dart_library" ]
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
program: {
data: "data/channel_test",
},
}
10 changes: 0 additions & 10 deletions shell/platform/fuchsia/dart-pkg/zircon/test/meta/channel_test.cmx

This file was deleted.

15 changes: 0 additions & 15 deletions shell/platform/fuchsia/dart_runner/meta/dart_zircon_test.cmx

This file was deleted.

20 changes: 0 additions & 20 deletions shell/platform/fuchsia/dart_runner/vmservice/meta/vmservice.cmx

This file was deleted.

61 changes: 56 additions & 5 deletions shell/platform/fuchsia/flutter/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ if (enable_unittests) {
"keyboard_unittest.cc",
"platform_view_unittest.cc",
"pointer_delegate_unittests.cc",
"runner_unittest.cc",
"tests/engine_unittests.cc",
"tests/fake_flatland_unittests.cc",
"tests/fake_session_unittests.cc",
Expand Down Expand Up @@ -539,11 +538,50 @@ if (enable_unittests) {
] + flutter_deps
}

executable("flutter_runner_tzdata_missing_unittests") {
testonly = true

output_name = "flutter_runner_tzdata_missing_tests"

sources = [ "runner_tzdata_missing_unittest.cc" ]

# This is needed for //third_party/googletest for linking zircon symbols.
libs = [ "$fuchsia_sdk_path/arch/$target_cpu/sysroot/lib/libzircon.so" ]

# The use of these dependencies is temporary and will be moved behind the
# embedder API.
flutter_deps = [
"//flutter/lib/ui",
"//flutter/shell/platform/common/client_wrapper:client_wrapper_library_stubs",
"//third_party/dart/runtime:libdart_jit",
"//third_party/dart/runtime/platform:libdart_platform_jit",
]

deps = [
":flutter_runner_fixtures",
":flutter_runner_sources",
"//flutter/testing",
] + flutter_deps
}

fuchsia_test_archive("flutter_runner_tests") {
deps = [ ":flutter_runner_unittests" ]

binary = "$target_name"

resources = [
{
path = rebase_path("//third_party/icu/common/icudtl.dat")
dest = "icudtl.dat"
},
]
}

fuchsia_test_archive("flutter_runner_tzdata_tests") {
deps = [ ":flutter_runner_tzdata_unittests" ]

binary = "$target_name"

resources = [
{
path = rebase_path("//third_party/icu/common/icudtl.dat")
Expand All @@ -565,12 +603,10 @@ if (enable_unittests) {
dest = "tzdata/zoneinfo64.res"
},
]

cmx_file = rebase_path("meta/$target_name.cmx")
}

fuchsia_test_archive("flutter_runner_tzdata_tests") {
deps = [ ":flutter_runner_tzdata_unittests" ]
fuchsia_test_archive("flutter_runner_tzdata_missing_tests") {
deps = [ ":flutter_runner_tzdata_missing_unittests" ]

binary = "$target_name"

Expand All @@ -588,6 +624,18 @@ if (enable_unittests) {
binary = "fml_unittests"
}

fuchsia_test_archive("display_list_tests") {
deps = [ "//flutter/display_list:display_list_unittests" ]

binary = "display_list_unittests"
}

fuchsia_test_archive("display_list_render_tests") {
deps = [ "//flutter/display_list:display_list_rendertests" ]

binary = "display_list_rendertests"
}

fuchsia_test_archive("flow_tests") {
deps = [ "//flutter/flow:flow_unittests" ]

Expand Down Expand Up @@ -817,9 +865,12 @@ if (enable_unittests) {

deps = [
":dart_utils_tests",
":display_list_render_tests",
":display_list_tests",
":embedder_tests",
":flow_tests",
":flutter_runner_tests",
":flutter_runner_tzdata_missing_tests",
":flutter_runner_tzdata_tests",
":fml_tests",
":runtime_tests",
Expand Down
34 changes: 0 additions & 34 deletions shell/platform/fuchsia/flutter/meta/flutter_runner_tests.cmx

This file was deleted.

2 changes: 1 addition & 1 deletion shell/platform/fuchsia/flutter/runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Runner final
// Called from SetupICU, for testing only. Returns false on error.
static bool SetupTZDataInternal();
#if defined(FRIEND_TEST)
FRIEND_TEST(RunnerTest, TZData);
FRIEND_TEST(RunnerTZDataTest, LoadsWithTZDataPresent);
FRIEND_TEST(RunnerTZDataTest, LoadsWithoutTZDataPresent);
#endif // defined(FRIEND_TEST)

Expand Down
20 changes: 20 additions & 0 deletions shell/platform/fuchsia/flutter/runner_tzdata_missing_unittest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <gtest/gtest.h>

#include "runner.h"
#include "third_party/icu/source/i18n/unicode/timezone.h"

namespace flutter_runner {

// This test has not been configured with tzdata files. This test shows that
// even without the data files, the runner continues initialization. It will
// use whatever the base data exists in icudtl.dat.
TEST(RunnerTZDataTest, LoadsWithoutTZDataPresent) {
bool success = Runner::SetupICUInternal();
ASSERT_TRUE(success) << "failed to load set up ICU data";
}

} // namespace flutter_runner
24 changes: 19 additions & 5 deletions shell/platform/fuchsia/flutter/runner_tzdata_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,31 @@

#include <gtest/gtest.h>

#include <cstdlib>

#include "runner.h"
#include "third_party/icu/source/i18n/unicode/timezone.h"

namespace flutter_runner {

// This test has not been configured with tzdata files. This test shows that
// even without the data files, the runner continues initialization. It will
// use whatever the base data exists in icudtl.dat.
TEST(RunnerTZDataTest, LoadsWithoutTZDataPresent) {
TEST(RunnerTZDataTest, LoadsWithTZDataPresent) {
// TODO(fxbug.dev/69570): Move to cml file if env_vars gains supported for the
// gtest_runner.
setenv("ICU_TIMEZONE_FILES_DIR", "/pkg/data/tzdata", true);

UErrorCode err = U_ZERO_ERROR;
const auto version_before = std::string(icu::TimeZone::getTZDataVersion(err));
ASSERT_EQ(U_ZERO_ERROR, err) << "unicode error: " << u_errorName(err);

// This loads the tzdata. In Fuchsia, we force the data from this package
// to be version 2019a, so that we can test the resource load.
bool success = Runner::SetupICUInternal();
ASSERT_TRUE(success) << "failed to load set up ICU data";
ASSERT_TRUE(success) << "failed to load timezone data";

const auto version_after = std::string(icu::TimeZone::getTZDataVersion(err));
ASSERT_EQ(U_ZERO_ERROR, err) << "unicode error: " << u_errorName(err);

EXPECT_EQ("2019a", version_after);
}

} // namespace flutter_runner
33 changes: 0 additions & 33 deletions shell/platform/fuchsia/flutter/runner_unittest.cc

This file was deleted.

Loading

0 comments on commit ec0e5b6

Please sign in to comment.