@@ -90,6 +90,8 @@ void main() {
9090 await tester.pump ();
9191
9292 if (runAsync) {
93+ // Await a small delay to allow the PerformanceController to complete
94+ // initialization.
9395 await Future .delayed (const Duration (seconds: 1 ));
9496 }
9597
@@ -114,6 +116,24 @@ void main() {
114116 expect (find.text ('Performance' ), findsOneWidget);
115117 });
116118
119+ testWidgetsWithWindowSize ('builds initial content' , windowSize, (
120+ WidgetTester tester,
121+ ) async {
122+ await tester.runAsync (() async {
123+ await pumpPerformanceScreen (tester, runAsync: true );
124+ await tester.pumpAndSettle ();
125+ expect (find.byType (PerformanceScreenBody ), findsOneWidget);
126+ expect (find.byType (WebPerformanceScreenBody ), findsNothing);
127+ expect (find.byType (PerformanceControls ), findsOneWidget);
128+ expect (find.byType (FlutterFramesChart ), findsOneWidget);
129+ expect (find.byType (TabbedPerformanceView ), findsOneWidget);
130+ expect (
131+ find.text ('Select a frame above to view analysis data.' ),
132+ findsOneWidget,
133+ );
134+ });
135+ });
136+
117137 testWidgetsWithWindowSize (
118138 'builds initial content for Dart web app' ,
119139 windowSize,
@@ -128,10 +148,15 @@ void main() {
128148 wrap (Builder (builder: PerformanceScreen ().build)),
129149 );
130150 await tester.pumpAndSettle ();
131-
151+ expect (find. byType ( PerformanceScreenBody ), findsNothing);
132152 expect (find.byType (WebPerformanceScreenBody ), findsOneWidget);
153+ expect (
154+ markdownFinder (
155+ 'How to use Chrome DevTools for performance profiling' ,
156+ ),
157+ findsOneWidget,
158+ );
133159
134- // Make sure NO Flutter-specific information is included:
135160 expect (
136161 markdownFinder ('The Flutter framework emits timeline events' ),
137162 findsNothing,
@@ -152,17 +177,41 @@ void main() {
152177 wrap (Builder (builder: PerformanceScreen ().build)),
153178 );
154179 await tester.pumpAndSettle ();
155-
180+ expect (find. byType ( PerformanceScreenBody ), findsNothing);
156181 expect (find.byType (WebPerformanceScreenBody ), findsOneWidget);
182+ expect (
183+ markdownFinder (
184+ 'How to use Chrome DevTools for performance profiling' ,
185+ ),
186+ findsOneWidget,
187+ );
157188
158- // Make sure Flutter-specific information IS included:
159189 expect (
160190 markdownFinder ('The Flutter framework emits timeline events' ),
161191 findsOneWidget,
162192 );
163193 },
164194 );
165195
196+ testWidgetsWithWindowSize (
197+ 'builds initial content for non-flutter app' ,
198+ windowSize,
199+ (WidgetTester tester) async {
200+ await tester.runAsync (() async {
201+ mockConnectedApp (
202+ fakeServiceConnection.serviceManager.connectedApp! ,
203+ isFlutterApp: false ,
204+ );
205+ await pumpPerformanceScreen (tester, runAsync: true );
206+ await tester.pumpAndSettle ();
207+ expect (find.byType (PerformanceControls ), findsOneWidget);
208+ expect (find.byType (FlutterFramesChart ), findsNothing);
209+ expect (find.byType (TabbedPerformanceView ), findsOneWidget);
210+ expect (find.byType (TimelineEventsTabView ), findsOneWidget);
211+ });
212+ },
213+ );
214+
166215 group ('controls' , () {
167216 testWidgetsWithWindowSize (
168217 'can expand and collapse flutter frames chart' ,
@@ -173,38 +222,169 @@ void main() {
173222 await tester.pumpAndSettle ();
174223
175224 final chartButtonFinder = find.byType (VisibilityButton );
225+ expect (chartButtonFinder, findsOneWidget);
176226
177- // The flutter frames chart is visible.
178227 expect (find.byType (FramesChartControls ), findsOneWidget);
228+ expect (
229+ preferences.performance.showFlutterFramesChart.value,
230+ isTrue,
231+ );
179232
180233 await tester.tap (chartButtonFinder);
181234 await tester.pumpAndSettle ();
182235
183- // The flutter frames chart should no longer be visible.
184236 expect (find.byType (FramesChartControls ), findsNothing);
237+ expect (
238+ preferences.performance.showFlutterFramesChart.value,
239+ isFalse,
240+ );
185241
186242 await tester.tap (chartButtonFinder);
187243 await tester.pumpAndSettle ();
188244
189- // The flutter frames chart should be visible again.
190245 expect (find.byType (FramesChartControls ), findsOneWidget);
246+ expect (
247+ preferences.performance.showFlutterFramesChart.value,
248+ isTrue,
249+ );
250+ });
251+ },
252+ );
253+
254+ testWidgetsWithWindowSize ('opens enhance tracing overlay' , windowSize, (
255+ WidgetTester tester,
256+ ) async {
257+ await tester.runAsync (() async {
258+ await pumpPerformanceScreen (tester, runAsync: true );
259+ await tester.pumpAndSettle ();
260+ expect (find.text ('Enhance Tracing' ), findsOneWidget);
261+ await tester.tap (find.text ('Enhance Tracing' ));
262+ await tester.pumpAndSettle ();
263+ expect (
264+ find.richTextContaining ('frame times may be negatively affected' ),
265+ findsOneWidget,
266+ );
267+ expect (
268+ find.richTextContaining (
269+ 'you will need to reproduce activity in your app' ,
270+ ),
271+ findsOneWidget,
272+ );
273+ expect (
274+ find.richTextContaining ('Trace widget builds' ),
275+ findsOneWidget,
276+ );
277+ expect (find.richTextContaining ('Trace layouts' ), findsOneWidget);
278+ expect (find.richTextContaining ('Trace paints' ), findsOneWidget);
279+ expect (
280+ find.richTextContaining ('Trace platform channels' ),
281+ findsOneWidget,
282+ );
283+ expect (find.byType (MoreInfoLink ), findsNWidgets (4 ));
284+ });
285+ });
286+
287+ testWidgetsWithWindowSize (
288+ 'opens more debugging options overlay' ,
289+ windowSize,
290+ (WidgetTester tester) async {
291+ await tester.runAsync (() async {
292+ await pumpPerformanceScreen (tester, runAsync: true );
293+ await tester.pumpAndSettle ();
294+ expect (find.text ('More debugging options' ), findsOneWidget);
295+ await tester.tap (find.text ('More debugging options' ));
296+ await tester.pumpAndSettle ();
297+ expect (
298+ find.richTextContaining (
299+ 'After toggling a rendering layer on/off, '
300+ 'reproduce the activity in your app to see the effects' ,
301+ ),
302+ findsOneWidget,
303+ );
304+ expect (
305+ find.richTextContaining ('Render Clip layers' ),
306+ findsOneWidget,
307+ );
308+ expect (
309+ find.richTextContaining ('Render Opacity layers' ),
310+ findsOneWidget,
311+ );
312+ expect (
313+ find.richTextContaining ('Render Physical Shape layers' ),
314+ findsOneWidget,
315+ );
316+ expect (
317+ find.richTextContaining (
318+ "These debugging options aren't available in profile mode. "
319+ 'To use them, run your app in debug mode.' ,
320+ ),
321+ findsOneWidget,
322+ );
323+ expect (find.byType (MoreInfoLink ), findsNWidgets (3 ));
324+ });
325+ },
326+ );
327+
328+ testWidgetsWithWindowSize (
329+ 'hides warning in debugging options overlay when in debug mode' ,
330+ windowSize,
331+ (WidgetTester tester) async {
332+ when (
333+ fakeServiceConnection
334+ .serviceManager
335+ .connectedApp!
336+ .isProfileBuildNow,
337+ ).thenReturn (false );
338+
339+ await tester.runAsync (() async {
340+ await pumpPerformanceScreen (tester, runAsync: true );
341+ await tester.pumpAndSettle ();
342+ expect (find.text ('More debugging options' ), findsOneWidget);
343+ await tester.tap (find.text ('More debugging options' ));
344+ await tester.pumpAndSettle ();
345+
346+ expect (
347+ find.richTextContaining (
348+ "These debugging options aren't available in profile mode. "
349+ 'To use them, run your app in debug mode.' ,
350+ ),
351+ findsNothing,
352+ );
191353 });
192354 },
193355 );
194356 });
195357
196358 group ('RebuildStatsView' , () {
359+ late FakeServiceConnectionManager fakeServiceConnection;
197360 late RebuildCountModel model;
198361 late ValueNotifier <FlutterFrame ?> selectedFrame;
199362
200363 setUp (() {
364+ fakeServiceConnection = FakeServiceConnectionManager ();
365+ final app = fakeServiceConnection.serviceManager.connectedApp! ;
366+ when (app.initialized).thenReturn (Completer ()..complete (true ));
367+ when (app.isDartWebAppNow).thenReturn (false );
368+ when (app.isFlutterAppNow).thenReturn (true );
369+ when (app.isDartCliAppNow).thenReturn (false );
370+ when (app.isDartWebApp).thenAnswer ((_) async => false );
371+ when (app.isProfileBuild).thenAnswer ((_) async => false );
372+ setGlobal (ServiceConnectionManager , fakeServiceConnection);
373+ setGlobal (IdeTheme , IdeTheme ());
374+ setGlobal (NotificationService , NotificationService ());
375+ setGlobal (BannerMessagesController , BannerMessagesController ());
376+ setGlobal (PreferencesController , PreferencesController ());
377+ setGlobal (OfflineDataController , OfflineDataController ());
201378 model = RebuildCountModel ();
202379 selectedFrame = ValueNotifier <FlutterFrame ?>(null );
203380 });
204381
205382 testWidgets ('shows message when running in profile mode' , (
206383 WidgetTester tester,
207384 ) async {
385+ final app = fakeServiceConnection.serviceManager.connectedApp! ;
386+ when (app.isProfileBuildNow).thenReturn (true );
387+
208388 await tester.pumpWidget (
209389 wrapWithControllers (
210390 RebuildStatsView (model: model, selectedFrame: selectedFrame),
@@ -221,6 +401,9 @@ void main() {
221401 testWidgets ('shows normal UI when running in debug mode' , (
222402 WidgetTester tester,
223403 ) async {
404+ final app = fakeServiceConnection.serviceManager.connectedApp! ;
405+ when (app.isProfileBuildNow).thenReturn (false );
406+
224407 await tester.pumpWidget (
225408 wrapWithControllers (
226409 RebuildStatsView (model: model, selectedFrame: selectedFrame),
0 commit comments