diff --git a/runtime/fixtures/simple_main.dart b/runtime/fixtures/simple_main.dart index dc744d2777e3bfdcf0f23ee25fcaea0c379564c3..55187d8642bfac24c7acdb24213e70050ab6a551 100644 --- a/runtime/fixtures/simple_main.dart +++ b/runtime/fixtures/simple_main.dart @@ -2,6 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -void simple_main() { +void main() { print("Hello"); } diff --git a/shell/platform/embedder/fixtures/simple_main.dart b/shell/platform/embedder/fixtures/simple_main.dart index 05a37e98348adb708ef82d1249750472d457b8c5..ab73b3a234abf58d9009026cfa184dd11ca56bf2 100644 --- a/shell/platform/embedder/fixtures/simple_main.dart +++ b/shell/platform/embedder/fixtures/simple_main.dart @@ -1 +1 @@ -void main() {} \ No newline at end of file +void main() {} diff --git a/shell/platform/embedder/tests/embedder_unittests.cc b/shell/platform/embedder/tests/embedder_unittests.cc index 6cd3f4d330a6501fc3b0940e542a56361c8d02c9..266cf92e55a4407c72d71f2fb69ca6ee850ee5c6 100644 --- a/shell/platform/embedder/tests/embedder_unittests.cc +++ b/shell/platform/embedder/tests/embedder_unittests.cc @@ -22,17 +22,14 @@ TEST(EmbedderTest, CanLaunchAndShutdownWithValidProjectArgs) { return false; }; - std::string main = - std::string(testing::GetFixturesPath()) + "/simple_main.dart"; - FlutterRendererConfig config = {}; config.type = FlutterRendererType::kSoftware; config.software = renderer; FlutterProjectArgs args = {}; args.struct_size = sizeof(FlutterProjectArgs); - args.assets_path = ""; - args.main_path = main.c_str(); + args.assets_path = testing::GetFixturesPath(); + args.main_path = ""; args.packages_path = ""; FlutterEngine engine = nullptr; diff --git a/testing/testing.gni b/testing/testing.gni index ad5badfe922fe4dc1652b7dfa7e074a827f27bd2..e653933b62a8499a400889b5477915fd8b11c953 100644 --- a/testing/testing.gni +++ b/testing/testing.gni @@ -2,18 +2,21 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//third_party/dart/build/dart/dart_action.gni") + +# Builds test fixtures for a unit test. +# +# Generates a directory structure containing an assets directory and the Dart +# code to execute compiled to kernel, emitted to assets/kernel_blob.bin. template("test_fixtures") { testonly = true assert(defined(invoker.fixtures), "Test fixtures must be specified.") - fixtures_name_target_name = target_name + "_gen_fixtures_name" - fixtures_source_set_target_name = target_name + "_gen_fixtures_source_set" - fixtures_copy_target_name = target_name + "_copy_fixtures" - - fixtures_location = "$target_gen_dir/fixtures" - fixtures_location_file = "$target_gen_dir/test_fixtures_location.cc" + fixtures_location = "$target_gen_dir/$target_name/assets" + fixtures_location_file = "$target_gen_dir/$target_name/test_fixtures_location.cc" + fixtures_name_target_name = target_name + "_gen_fixtures_name" action(fixtures_name_target_name) { script = "$flutter_root/testing/build/gen_fixtures_location_symbol.py" @@ -29,7 +32,9 @@ template("test_fixtures") { ] } + fixtures_source_set_target_name = target_name + "_gen_fixtures_source_set" source_set(fixtures_source_set_target_name) { + testonly = true sources = [ fixtures_location_file, ] @@ -39,16 +44,32 @@ template("test_fixtures") { ] } - copy(fixtures_copy_target_name) { - sources = invoker.fixtures - outputs = [ - "$fixtures_location/{{source_file_part}}", + fixtures_kernel_target_name = target_name + "_kernel" + dart_action(fixtures_kernel_target_name) { + testonly = true + script = "$root_out_dir/frontend_server.dart.snapshot" + + fixture_paths = [] + foreach(fixture, invoker.fixtures) { + fixture_paths += [ rebase_path(fixture) ] + } + inputs = fixture_paths + outputs = ["$fixtures_location/kernel_blob.bin"] + + args = [ + "--sdk-root", rebase_path("$root_out_dir/flutter_patched_sdk"), + "--target", "flutter", + "--output-dill", rebase_path("$fixtures_location/kernel_blob.bin"), + ] + fixture_paths + deps = [ + "//third_party/dart/utils/kernel-service:frontend_server" ] } group(target_name) { + testonly = true deps = [ - ":$fixtures_copy_target_name", + ":$fixtures_kernel_target_name", ":$fixtures_source_set_target_name", ] }