@@ -39,11 +39,9 @@ @interface FlutterEngine (Test)
39
39
}
40
40
41
41
TEST_F (FlutterEngineTest, HasNonNullExecutableName) {
42
- // Launch the test entrypoint.
43
42
FlutterEngine* engine = GetFlutterEngine ();
44
43
std::string executable_name = [[engine executableName ] UTF8String ];
45
44
ASSERT_FALSE (executable_name.empty ());
46
- EXPECT_TRUE ([engine runWithEntrypoint: @" executableNameNotNull" ]);
47
45
48
46
// Block until notified by the Dart test of the value of Platform.executable.
49
47
fml::AutoResetWaitableEvent latch;
@@ -53,6 +51,10 @@ @interface FlutterEngine (Test)
53
51
EXPECT_EQ (executable_name, dart_string);
54
52
latch.Signal ();
55
53
}));
54
+
55
+ // Launch the test entrypoint.
56
+ EXPECT_TRUE ([engine runWithEntrypoint: @" executableNameNotNull" ]);
57
+
56
58
latch.Wait ();
57
59
}
58
60
@@ -76,6 +78,11 @@ @interface FlutterEngine (Test)
76
78
}
77
79
78
80
TEST_F (FlutterEngineTest, CanLogToStdout) {
81
+ // Block until completion of print statement.
82
+ fml::AutoResetWaitableEvent latch;
83
+ AddNativeCallback (" SignalNativeTest" ,
84
+ CREATE_NATIVE_ENTRY ([&](Dart_NativeArguments args) { latch.Signal (); }));
85
+
79
86
// Replace stdout stream buffer with our own.
80
87
std::stringstream buffer;
81
88
std::streambuf* old_buffer = std::cout.rdbuf ();
@@ -86,10 +93,6 @@ @interface FlutterEngine (Test)
86
93
EXPECT_TRUE ([engine runWithEntrypoint: @" canLogToStdout" ]);
87
94
EXPECT_TRUE (engine.running );
88
95
89
- // Block until completion of print statement.
90
- fml::AutoResetWaitableEvent latch;
91
- AddNativeCallback (" SignalNativeTest" ,
92
- CREATE_NATIVE_ENTRY ([&](Dart_NativeArguments args) { latch.Signal (); }));
93
96
latch.Wait ();
94
97
95
98
// Restore old stdout stream buffer.
@@ -101,19 +104,7 @@ @interface FlutterEngine (Test)
101
104
}
102
105
103
106
TEST_F (FlutterEngineTest, BackgroundIsBlack) {
104
- // Launch the test entrypoint.
105
107
FlutterEngine* engine = GetFlutterEngine ();
106
- EXPECT_TRUE ([engine runWithEntrypoint: @" backgroundTest" ]);
107
- EXPECT_TRUE (engine.running );
108
-
109
- NSString * fixtures = @(flutter::testing::GetFixturesPath ());
110
- FlutterDartProject* project = [[FlutterDartProject alloc ]
111
- initWithAssetsPath: fixtures
112
- ICUDataPath: [fixtures stringByAppendingString: @" /icudtl.dat" ]];
113
- FlutterViewController* viewController = [[FlutterViewController alloc ] initWithProject: project];
114
- [viewController loadView ];
115
- viewController.flutterView .frame = CGRectMake (0 , 0 , 800 , 600 );
116
- [engine setViewController: viewController];
117
108
118
109
// Latch to ensure the entire layer tree has been generated and presented.
119
110
fml::AutoResetWaitableEvent latch;
@@ -127,12 +118,8 @@ @interface FlutterEngine (Test)
127
118
}
128
119
latch.Signal ();
129
120
}));
130
- latch.Wait ();
131
- }
132
121
133
- TEST_F (FlutterEngineTest, CanOverrideBackgroundColor) {
134
122
// Launch the test entrypoint.
135
- FlutterEngine* engine = GetFlutterEngine ();
136
123
EXPECT_TRUE ([engine runWithEntrypoint: @" backgroundTest" ]);
137
124
EXPECT_TRUE (engine.running );
138
125
@@ -144,7 +131,12 @@ @interface FlutterEngine (Test)
144
131
[viewController loadView ];
145
132
viewController.flutterView .frame = CGRectMake (0 , 0 , 800 , 600 );
146
133
[engine setViewController: viewController];
147
- viewController.flutterView .backgroundColor = [NSColor whiteColor ];
134
+
135
+ latch.Wait ();
136
+ }
137
+
138
+ TEST_F (FlutterEngineTest, CanOverrideBackgroundColor) {
139
+ FlutterEngine* engine = GetFlutterEngine ();
148
140
149
141
// Latch to ensure the entire layer tree has been generated and presented.
150
142
fml::AutoResetWaitableEvent latch;
@@ -158,6 +150,21 @@ @interface FlutterEngine (Test)
158
150
}
159
151
latch.Signal ();
160
152
}));
153
+
154
+ // Launch the test entrypoint.
155
+ EXPECT_TRUE ([engine runWithEntrypoint: @" backgroundTest" ]);
156
+ EXPECT_TRUE (engine.running );
157
+
158
+ NSString * fixtures = @(flutter::testing::GetFixturesPath ());
159
+ FlutterDartProject* project = [[FlutterDartProject alloc ]
160
+ initWithAssetsPath: fixtures
161
+ ICUDataPath: [fixtures stringByAppendingString: @" /icudtl.dat" ]];
162
+ FlutterViewController* viewController = [[FlutterViewController alloc ] initWithProject: project];
163
+ [viewController loadView ];
164
+ viewController.flutterView .frame = CGRectMake (0 , 0 , 800 , 600 );
165
+ [engine setViewController: viewController];
166
+ viewController.flutterView .backgroundColor = [NSColor whiteColor ];
167
+
161
168
latch.Wait ();
162
169
}
163
170
@@ -425,17 +432,17 @@ @interface FlutterEngine (Test)
425
432
}
426
433
427
434
TEST_F (FlutterEngineTest, NativeCallbacks) {
428
- FlutterEngine* engine = GetFlutterEngine ();
429
- EXPECT_TRUE ([engine runWithEntrypoint: @" nativeCallback" ]);
430
- EXPECT_TRUE (engine.running );
431
-
432
435
fml::AutoResetWaitableEvent latch;
433
436
bool latch_called = false ;
434
-
435
437
AddNativeCallback (" SignalNativeTest" , CREATE_NATIVE_ENTRY ([&](Dart_NativeArguments args) {
436
438
latch_called = true ;
437
439
latch.Signal ();
438
440
}));
441
+
442
+ FlutterEngine* engine = GetFlutterEngine ();
443
+ EXPECT_TRUE ([engine runWithEntrypoint: @" nativeCallback" ]);
444
+ EXPECT_TRUE (engine.running );
445
+
439
446
latch.Wait ();
440
447
ASSERT_TRUE (latch_called);
441
448
}
0 commit comments