Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6ed1ed8

Browse files
author
Emmanuel Garcia
committed
Ensure no exception
1 parent 89a2c96 commit 6ed1ed8

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

runtime/no_dart_plugin_registrant_unittests.cc

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#include "flutter/runtime/dart_isolate.h"
66

77
#include "flutter/fml/paths.h"
8-
#include "flutter/testing/fixture_test.h"
98
#include "flutter/runtime/dart_vm.h"
109
#include "flutter/runtime/dart_vm_lifecycle.h"
1110
#include "flutter/testing/dart_isolate_runner.h"
11+
#include "flutter/testing/fixture_test.h"
1212
#include "flutter/testing/testing.h"
1313

1414
namespace flutter {
@@ -17,8 +17,8 @@ namespace testing {
1717
const std::string kernel_file_name = "no_plugin_registrant_kernel_blob.bin";
1818

1919
class DartIsolateTest : public FixtureTest {
20-
public:
21-
DartIsolateTest() : FixtureTest(kernel_file_name) {}
20+
public:
21+
DartIsolateTest() : FixtureTest(kernel_file_name) {}
2222
};
2323

2424
TEST_F(DartIsolateTest, DartPluginRegistrantIsNotPresent) {
@@ -36,7 +36,14 @@ TEST_F(DartIsolateTest, DartPluginRegistrantIsNotPresent) {
3636
latch.Signal();
3737
})));
3838

39-
const auto settings = CreateSettingsForFixture();
39+
auto settings = CreateSettingsForFixture();
40+
auto did_throw_exception = false;
41+
settings.unhandled_exception_callback = [&](const std::string& error,
42+
const std::string& stack_trace) {
43+
did_throw_exception = true;
44+
return true;
45+
};
46+
4047
auto vm_ref = DartVMRef::Create(settings);
4148
auto thread = CreateNewThread();
4249
TaskRunners task_runners(GetCurrentTestName(), //
@@ -46,11 +53,10 @@ TEST_F(DartIsolateTest, DartPluginRegistrantIsNotPresent) {
4653
thread //
4754
);
4855

49-
50-
auto kernel_file_path = fml::paths::JoinPaths({GetFixturesPath(), kernel_file_name});
51-
auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners,
52-
"main", {},
53-
kernel_file_path);
56+
auto kernel_file_path =
57+
fml::paths::JoinPaths({GetFixturesPath(), kernel_file_name});
58+
auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
59+
{}, kernel_file_path);
5460

5561
ASSERT_TRUE(isolate);
5662
ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
@@ -59,6 +65,7 @@ TEST_F(DartIsolateTest, DartPluginRegistrantIsNotPresent) {
5965

6066
ASSERT_EQ(messages.size(), 1u);
6167
ASSERT_EQ(messages[0], "main() was called");
68+
ASSERT_FALSE(did_throw_exception);
6269
}
6370

6471
} // namespace testing

0 commit comments

Comments
 (0)