Tweak theme_test so it passes when --track-widget-creation is used. (#16717)

This commit is contained in:
Jacob Richman 2018-04-18 17:46:20 -07:00 committed by GitHub
parent ec7b46e30b
commit 044dfdb446
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
},