From 044dfdb44672c239064246466c9a54d622f9a710 Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Wed, 18 Apr 2018 17:46:20 -0700 Subject: [PATCH] Tweak theme_test so it passes when --track-widget-creation is used. (#16717) --- .../flutter/test/material/theme_test.dart | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/packages/flutter/test/material/theme_test.dart b/packages/flutter/test/material/theme_test.dart index fe1f90942d..d25b1a0d38 100644 --- a/packages/flutter/test/material/theme_test.dart +++ b/packages/flutter/test/material/theme_test.dart @@ -299,43 +299,30 @@ void main() { testBuildCalled = 0; ThemeData themeData = new ThemeData(primaryColor: const Color(0xFF000000)); - await tester.pumpWidget( - new Theme( + Widget buildTheme() { + return new Theme( data: themeData, child: const Test(), - ), - ); + ); + } + + await tester.pumpWidget(buildTheme()); expect(testBuildCalled, 1); // Pump the same widgets again. - await tester.pumpWidget( - new Theme( - data: themeData, - child: const Test(), - ), - ); + await tester.pumpWidget(buildTheme()); // No repeated build calls to the child since it's the same theme data. expect(testBuildCalled, 1); // New instance of theme data but still the same content. themeData = new ThemeData(primaryColor: const Color(0xFF000000)); - await tester.pumpWidget( - new Theme( - data: themeData, - child: const Test(), - ), - ); + await tester.pumpWidget(buildTheme()); // Still no repeated calls. expect(testBuildCalled, 1); // Different now. themeData = new ThemeData(primaryColor: const Color(0xFF222222)); - await tester.pumpWidget( - new Theme( - data: themeData, - child: const Test(), - ), - ); + await tester.pumpWidget(buildTheme()); // Should call build again. expect(testBuildCalled, 2); },