From d4868b9c800a2d87e9b30f1c30fed6e93cf99c95 Mon Sep 17 00:00:00 2001 From: Mehmet Fidanboylu Date: Tue, 12 Dec 2017 14:34:51 -0800 Subject: [PATCH] Add test for interim state of the animation to make sure we are transitioning the border color the right way. (#13499) --- ...ate_test.dart => expansion_tile_test.dart} | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) rename packages/flutter/test/material/{expansion_tile_initial_state_test.dart => expansion_tile_test.dart} (79%) diff --git a/packages/flutter/test/material/expansion_tile_initial_state_test.dart b/packages/flutter/test/material/expansion_tile_test.dart similarity index 79% rename from packages/flutter/test/material/expansion_tile_initial_state_test.dart rename to packages/flutter/test/material/expansion_tile_test.dart index 730f54b98e..799fe53292 100644 --- a/packages/flutter/test/material/expansion_tile_initial_state_test.dart +++ b/packages/flutter/test/material/expansion_tile_test.dart @@ -7,6 +7,8 @@ import 'package:flutter/widgets.dart'; import 'package:flutter/material.dart'; void main() { + final Color _dividerColor = const Color(0x1f333333); + testWidgets('ExpansionTile initial state', (WidgetTester tester) async { final Key topKey = new UniqueKey(); final Key expandedKey = const PageStorageKey('expanded'); @@ -16,6 +18,10 @@ void main() { final Key tileKey = new UniqueKey(); await tester.pumpWidget(new MaterialApp( + theme: new ThemeData( + platform: TargetPlatform.iOS, + dividerColor: _dividerColor, + ), home: new Material( child: new SingleChildScrollView( child: new Column( @@ -62,7 +68,6 @@ void main() { of: find.byKey(key), matching: find.byType(Container), )); - final Color dividerColor = Theme.of(tester.element(find.text('Collapsed'))).dividerColor; expect(getHeight(topKey), getHeight(expandedKey) - getHeight(tileKey) - 2.0); expect(getHeight(topKey), getHeight(collapsedKey) - 2.0); @@ -70,8 +75,8 @@ void main() { BoxDecoration expandedContainerDecoration = getContainer(expandedKey).decoration; expect(expandedContainerDecoration.color, Colors.red); - expect(expandedContainerDecoration.border.top.color, dividerColor); - expect(expandedContainerDecoration.border.bottom.color, dividerColor); + expect(expandedContainerDecoration.border.top.color, _dividerColor); + expect(expandedContainerDecoration.border.bottom.color, _dividerColor); BoxDecoration collapsedContainerDecoration = getContainer(collapsedKey).decoration; expect(collapsedContainerDecoration.color, Colors.transparent); @@ -83,6 +88,16 @@ void main() { await tester.tap(find.text('Default')); await tester.pump(); + + // Pump to the middle of the animation for expansion. + await tester.pump(const Duration(milliseconds: 100)); + final BoxDecoration collapsingContainerDecoration = getContainer(collapsedKey).decoration; + expect(collapsingContainerDecoration.color, Colors.transparent); + // Opacity should change but color component should remain the same. + expect(collapsingContainerDecoration.border.top.color, const Color(0x15333333)); + expect(collapsingContainerDecoration.border.bottom.color, const Color(0x15333333)); + + // Pump all the way to the end now. await tester.pump(const Duration(seconds: 1)); expect(getHeight(topKey), getHeight(expandedKey) - 2.0); @@ -98,7 +113,7 @@ void main() { // Collapsed should be expanded now. collapsedContainerDecoration = getContainer(collapsedKey).decoration; expect(collapsedContainerDecoration.color, Colors.transparent); - expect(collapsedContainerDecoration.border.top.color, dividerColor); - expect(collapsedContainerDecoration.border.bottom.color, dividerColor); + expect(collapsedContainerDecoration.border.top.color, _dividerColor); + expect(collapsedContainerDecoration.border.bottom.color, _dividerColor); }); }