This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Reland Dart plugin registrant #25496
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b4c0ba2
Revert "Revert "Call Dart plugin registrant if available (#23813)" (#…
d0f084e
Rework plugin registrant
ab50fec
Fix error message
47bc3da
snake case
222b0aa
Remove arg
a62131d
Remove useless comment
53c0304
Move to a separate method
3d0765e
Clean up
1b426a7
Remove log
89a2c96
Explicitly test no dart plugin registrant
6ed1ed8
Ensure no exception
22ceaff
Add flag use_target_as_artifact_prefix
63194ab
Fix comment
b82b102
Fix test
3b87215
Comments
2d988d3
comments
6badc8c
Merge remote-tracking branch 'upstream/master' into reland_registrant
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// 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. | ||
|
||
void passMessage(String message) native 'PassMessage'; | ||
|
||
void main() { | ||
passMessage('main() was called'); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// 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 "flutter/runtime/dart_isolate.h" | ||
|
||
#include "flutter/fml/paths.h" | ||
#include "flutter/runtime/dart_vm.h" | ||
#include "flutter/runtime/dart_vm_lifecycle.h" | ||
#include "flutter/testing/dart_isolate_runner.h" | ||
#include "flutter/testing/fixture_test.h" | ||
#include "flutter/testing/testing.h" | ||
|
||
namespace flutter { | ||
namespace testing { | ||
|
||
const std::string kernel_file_name = "no_plugin_registrant_kernel_blob.bin"; | ||
const std::string elf_file_name = "no_plugin_registrant_app_elf_snapshot.so"; | ||
|
||
class DartIsolateTest : public FixtureTest { | ||
public: | ||
DartIsolateTest() : FixtureTest(kernel_file_name, elf_file_name, "") {} | ||
}; | ||
|
||
TEST_F(DartIsolateTest, DartPluginRegistrantIsNotPresent) { | ||
ASSERT_FALSE(DartVMRef::IsInstanceRunning()); | ||
|
||
std::vector<std::string> messages; | ||
fml::AutoResetWaitableEvent latch; | ||
|
||
AddNativeCallback( | ||
"PassMessage", | ||
CREATE_NATIVE_ENTRY(([&latch, &messages](Dart_NativeArguments args) { | ||
auto message = tonic::DartConverter<std::string>::FromDart( | ||
Dart_GetNativeArgument(args, 0)); | ||
messages.push_back(message); | ||
latch.Signal(); | ||
}))); | ||
|
||
auto settings = CreateSettingsForFixture(); | ||
auto did_throw_exception = false; | ||
settings.unhandled_exception_callback = [&](const std::string& error, | ||
const std::string& stack_trace) { | ||
did_throw_exception = true; | ||
return true; | ||
}; | ||
|
||
auto vm_ref = DartVMRef::Create(settings); | ||
auto thread = CreateNewThread(); | ||
TaskRunners task_runners(GetCurrentTestName(), // | ||
thread, // | ||
thread, // | ||
thread, // | ||
thread // | ||
); | ||
|
||
auto kernel_path = | ||
fml::paths::JoinPaths({GetFixturesPath(), kernel_file_name}); | ||
auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main", | ||
{}, kernel_path); | ||
|
||
ASSERT_TRUE(isolate); | ||
ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running); | ||
|
||
latch.Wait(); | ||
|
||
ASSERT_EQ(messages.size(), 1u); | ||
ASSERT_EQ(messages[0], "main() was called"); | ||
ASSERT_FALSE(did_throw_exception); | ||
} | ||
|
||
} // namespace testing | ||
} // namespace flutter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add an explicit test that there is no error when the class is absent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would require a different location for the test. Since such tests require a new Dart main file, the Dart tooling complains about duplicated output file:
Any suggestion @chinmaygarde ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could try to update
//testing/testing.gni
to support multiple Dart snapshot targets. Or just create another testing target if it's easier - e.g.executable("runtime_plugin_missing_unittests") { .... }
that depends on its owntest_fixtures("runtime_plugin_missing_fixtures")
which specifies a different Dart file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it might be enough to just add another
test_fixtures
target and have the existing runtime executable depend on it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I see, that is probably what you did already. You'll want to update testing.gni so that you can tell it to use a different file name at line 159.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Done