forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve test coverage (flutter#7430)
Also, make the exception handling for global key listeners slightly more robust.
- Loading branch information
Showing
18 changed files
with
463 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
void main() { | ||
testWidgets('UniqueKey control test', (WidgetTester tester) async { | ||
Key key = new UniqueKey(); | ||
expect(key, hasOneLineDescription); | ||
expect(key, isNot(equals(new UniqueKey()))); | ||
}); | ||
|
||
testWidgets('ObjectKey control test', (WidgetTester tester) async { | ||
Object a = new Object(); | ||
Object b = new Object(); | ||
Key keyA = new ObjectKey(a); | ||
Key keyA2 = new ObjectKey(a); | ||
Key keyB = new ObjectKey(b); | ||
|
||
expect(keyA, hasOneLineDescription); | ||
expect(keyA, equals(keyA2)); | ||
expect(keyA.hashCode, equals(keyA2.hashCode)); | ||
expect(keyA, isNot(equals(keyB))); | ||
}); | ||
|
||
testWidgets('GlobalKey duplication', (WidgetTester tester) async { | ||
Key key = new GlobalKey(debugLabel: 'problematic'); | ||
|
||
await tester.pumpWidget(new Stack( | ||
children: <Widget>[ | ||
new Container( | ||
key: const ValueKey<int>(1), | ||
), | ||
new Container( | ||
key: const ValueKey<int>(2), | ||
), | ||
new Container( | ||
key: key | ||
), | ||
], | ||
)); | ||
|
||
await tester.pumpWidget(new Stack( | ||
children: <Widget>[ | ||
new Container( | ||
key: const ValueKey<int>(1), | ||
child: new SizedBox(key: key), | ||
), | ||
new Container( | ||
key: const ValueKey<int>(2), | ||
child: new Placeholder(key: key), | ||
), | ||
], | ||
)); | ||
|
||
expect(tester.takeException(), isNotNull); | ||
}); | ||
|
||
testWidgets('GlobalKey notification exception handling', (WidgetTester tester) async { | ||
GlobalKey key = new GlobalKey(); | ||
|
||
await tester.pumpWidget(new Container(key: key)); | ||
|
||
GlobalKey.registerRemoveListener(key, (GlobalKey key) { | ||
throw new Exception('Misbehaving listener'); | ||
}); | ||
|
||
bool didReceiveCallback = false; | ||
GlobalKey.registerRemoveListener(key, (GlobalKey key) { | ||
expect(didReceiveCallback, isFalse); | ||
didReceiveCallback = true; | ||
}); | ||
|
||
await tester.pumpWidget(new Placeholder()); | ||
|
||
expect(tester.takeException(), isNotNull); | ||
expect(didReceiveCallback, isTrue); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/flutter/test/widgets/performance_overlay_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
void main() { | ||
testWidgets('Performance overlay smoke test', (WidgetTester tester) async { | ||
await tester.pumpWidget(new PerformanceOverlay()); | ||
await tester.pumpWidget(new PerformanceOverlay.allEnabled()); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
void main() { | ||
testWidgets('Placeholder control test', (WidgetTester tester) async { | ||
GlobalKey<PlaceholderState> key = new GlobalKey<PlaceholderState>(); | ||
|
||
await tester.pumpWidget(new Placeholder(key: key)); | ||
|
||
key.currentState.child = new Text('target'); | ||
|
||
expect(find.text('target'), findsNothing); | ||
|
||
await tester.pump(); | ||
|
||
expect(find.text('target'), findsOneWidget); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.