Tweak theme_test so it passes when --track-widget-creation is used. (#16717)
This commit is contained in:
parent
ec7b46e30b
commit
044dfdb446
@ -299,43 +299,30 @@ void main() {
|
|||||||
testBuildCalled = 0;
|
testBuildCalled = 0;
|
||||||
ThemeData themeData = new ThemeData(primaryColor: const Color(0xFF000000));
|
ThemeData themeData = new ThemeData(primaryColor: const Color(0xFF000000));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
Widget buildTheme() {
|
||||||
new Theme(
|
return new Theme(
|
||||||
data: themeData,
|
data: themeData,
|
||||||
child: const Test(),
|
child: const Test(),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await tester.pumpWidget(buildTheme());
|
||||||
expect(testBuildCalled, 1);
|
expect(testBuildCalled, 1);
|
||||||
|
|
||||||
// Pump the same widgets again.
|
// Pump the same widgets again.
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(buildTheme());
|
||||||
new Theme(
|
|
||||||
data: themeData,
|
|
||||||
child: const Test(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
// No repeated build calls to the child since it's the same theme data.
|
// No repeated build calls to the child since it's the same theme data.
|
||||||
expect(testBuildCalled, 1);
|
expect(testBuildCalled, 1);
|
||||||
|
|
||||||
// New instance of theme data but still the same content.
|
// New instance of theme data but still the same content.
|
||||||
themeData = new ThemeData(primaryColor: const Color(0xFF000000));
|
themeData = new ThemeData(primaryColor: const Color(0xFF000000));
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(buildTheme());
|
||||||
new Theme(
|
|
||||||
data: themeData,
|
|
||||||
child: const Test(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
// Still no repeated calls.
|
// Still no repeated calls.
|
||||||
expect(testBuildCalled, 1);
|
expect(testBuildCalled, 1);
|
||||||
|
|
||||||
// Different now.
|
// Different now.
|
||||||
themeData = new ThemeData(primaryColor: const Color(0xFF222222));
|
themeData = new ThemeData(primaryColor: const Color(0xFF222222));
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(buildTheme());
|
||||||
new Theme(
|
|
||||||
data: themeData,
|
|
||||||
child: const Test(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
// Should call build again.
|
// Should call build again.
|
||||||
expect(testBuildCalled, 2);
|
expect(testBuildCalled, 2);
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user