Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,6 @@ FILE: ../../../flutter/shell/common/canvas_spy.h
FILE: ../../../flutter/shell/common/canvas_spy_unittests.cc
FILE: ../../../flutter/shell/common/context_options.cc
FILE: ../../../flutter/shell/common/context_options.h
FILE: ../../../flutter/shell/common/dart_native_benchmarks.cc
FILE: ../../../flutter/shell/common/display.h
FILE: ../../../flutter/shell/common/display_manager.cc
FILE: ../../../flutter/shell/common/display_manager.h
Expand Down
16 changes: 10 additions & 6 deletions runtime/dart_isolate_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,11 @@ TEST_F(DartIsolateTest, CanRunDartCodeCodeSynchronously) {

TEST_F(DartIsolateTest, CanRegisterNativeCallback) {
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
AddNativeCallback(
"NotifyNative",
CREATE_NATIVE_ENTRY(([this](Dart_NativeArguments args) { Signal(); })));
AddNativeCallback("NotifyNative",
CREATE_NATIVE_ENTRY(([this](Dart_NativeArguments args) {
FML_LOG(ERROR) << "Hello from Dart!";
Signal();
})));
const auto settings = CreateSettingsForFixture();
auto vm_ref = DartVMRef::Create(settings);
auto thread = CreateNewThread();
Expand Down Expand Up @@ -522,9 +524,11 @@ TEST_F(DartIsolateTest, DISABLED_ValidLoadingUnitSucceeds) {
}

ASSERT_FALSE(DartVMRef::IsInstanceRunning());
AddNativeCallback(
"NotifyNative",
CREATE_NATIVE_ENTRY(([this](Dart_NativeArguments args) { Signal(); })));
AddNativeCallback("NotifyNative",
CREATE_NATIVE_ENTRY(([this](Dart_NativeArguments args) {
FML_LOG(ERROR) << "Hello from Dart!";
Signal();
})));
AddNativeCallback(
"NotifySuccess", CREATE_NATIVE_ENTRY([this](Dart_NativeArguments args) {
auto bool_handle = Dart_GetNativeArgument(args, 0);
Expand Down
6 changes: 1 addition & 5 deletions shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,13 @@ if (enable_unittests) {
}

shell_host_executable("shell_benchmarks") {
sources = [
"dart_native_benchmarks.cc",
"shell_benchmarks.cc",
]
sources = [ "shell_benchmarks.cc" ]

deps = [
":shell_unittests_fixtures",
"//flutter/benchmarking",
"//flutter/flow",
"//flutter/testing:dart",
"//flutter/testing:fixture_test",
"//flutter/testing:testing_lib",
]
}
Expand Down
103 changes: 0 additions & 103 deletions shell/common/dart_native_benchmarks.cc

This file was deleted.

7 changes: 0 additions & 7 deletions shell/common/fixtures/shell_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ void sayHiFromFixturesAreFunctionalMain() native 'SayHiFromFixturesAreFunctional

void notifyNative() native 'NotifyNative';

@pragma('vm:entry-point')
void thousandCallsToNative() {
for (int i = 0; i < 1000; i++) {
notifyNative();
}
}

void secondaryIsolateMain(String message) {
print('Secondary isolate got message: ' + message);
notifyNative();
Expand Down
2 changes: 0 additions & 2 deletions testing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ source_set("fixture_test") {
testonly = true

sources = [
"dart_fixture.cc",
"dart_fixture.h",
"fixture_test.cc",
"fixture_test.h",
]
Expand Down
72 changes: 0 additions & 72 deletions testing/dart_fixture.cc

This file was deleted.

49 changes: 0 additions & 49 deletions testing/dart_fixture.h

This file was deleted.

62 changes: 58 additions & 4 deletions testing/fixture_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,71 @@

#include "flutter/testing/fixture_test.h"

#include "flutter/testing/dart_fixture.h"

namespace flutter {
namespace testing {

FixtureTest::FixtureTest() : DartFixture() {}
FixtureTest::FixtureTest()
: FixtureTest("kernel_blob.bin",
kDefaultAOTAppELFFileName,
kDefaultAOTAppELFSplitFileName) {}

FixtureTest::FixtureTest(std::string kernel_filename,
std::string elf_filename,
std::string elf_split_filename)
: DartFixture(kernel_filename, elf_filename, elf_split_filename) {}
: native_resolver_(std::make_shared<TestDartNativeResolver>()),
split_aot_symbols_(
LoadELFSplitSymbolFromFixturesIfNeccessary(elf_split_filename)),
kernel_filename_(kernel_filename),
assets_dir_(fml::OpenDirectory(GetFixturesPath(),
false,
fml::FilePermission::kRead)),
aot_symbols_(LoadELFSymbolFromFixturesIfNeccessary(elf_filename)) {}

Settings FixtureTest::CreateSettingsForFixture() {
Settings settings;
settings.leak_vm = false;
settings.task_observer_add = [](intptr_t, fml::closure) {};
settings.task_observer_remove = [](intptr_t) {};
settings.isolate_create_callback = [this]() {
native_resolver_->SetNativeResolverForIsolate();
};
settings.enable_observatory = false;
SetSnapshotsAndAssets(settings);
return settings;
}

void FixtureTest::SetSnapshotsAndAssets(Settings& settings) {
if (!assets_dir_.is_valid()) {
return;
}

settings.assets_dir = assets_dir_.get();

// In JIT execution, all snapshots are present within the binary itself and
// don't need to be explicitly supplied by the embedder. In AOT, these
// snapshots will be present in the application AOT dylib.
if (DartVM::IsRunningPrecompiledCode()) {
FML_CHECK(PrepareSettingsForAOTWithSymbols(settings, aot_symbols_));
} else {
settings.application_kernels = [this]() -> Mappings {
std::vector<std::unique_ptr<const fml::Mapping>> kernel_mappings;
auto kernel_mapping =
fml::FileMapping::CreateReadOnly(assets_dir_, kernel_filename_);
if (!kernel_mapping || !kernel_mapping->IsValid()) {
FML_LOG(ERROR) << "Could not find kernel blob for test fixture not "
"running in precompiled mode.";
return kernel_mappings;
}
kernel_mappings.emplace_back(std::move(kernel_mapping));
return kernel_mappings;
};
}
}

void FixtureTest::AddNativeCallback(std::string name,
Dart_NativeFunction callback) {
native_resolver_->AddNativeCallback(std::move(name), callback);
}

} // namespace testing
} // namespace flutter
Loading