Skip to content

Commit

Permalink
update widget tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hnvn committed Jun 22, 2018
1 parent dea0615 commit 842bf13
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 44 deletions.
50 changes: 32 additions & 18 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ packages:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "2.0.5"
csslib:
dependency: transitive
description:
Expand Down Expand Up @@ -94,7 +94,7 @@ packages:
name: html
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.3"
version: "0.13.3+1"
http:
dependency: transitive
description:
Expand All @@ -108,7 +108,7 @@ packages:
name: http_multi_server
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "2.0.5"
http_parser:
dependency: transitive
description:
Expand All @@ -130,6 +130,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.1"
json_rpc_2:
dependency: transitive
description:
name: json_rpc_2
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
kernel:
dependency: transitive
description:
Expand All @@ -150,7 +157,7 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.2+1"
version: "0.12.2"
meta:
dependency: transitive
description:
Expand All @@ -164,7 +171,7 @@ packages:
name: mime
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.6"
version: "0.9.6+1"
multi_server_socket:
dependency: transitive
description:
Expand All @@ -178,7 +185,7 @@ packages:
name: node_preamble
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.1"
version: "1.4.2"
package_config:
dependency: transitive
description:
Expand All @@ -192,14 +199,14 @@ packages:
name: package_resolver
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
version: "1.0.3"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.1"
version: "1.6.1"
plugin:
dependency: transitive
description:
Expand All @@ -213,7 +220,7 @@ packages:
name: pool
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.4"
version: "1.3.5"
pub_semver:
dependency: transitive
description:
Expand All @@ -234,7 +241,7 @@ packages:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.3"
version: "0.7.3+1"
shelf_packages_handler:
dependency: transitive
description:
Expand All @@ -248,14 +255,14 @@ packages:
name: shelf_static
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.7"
version: "0.2.7+1"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.2"
version: "0.2.2+2"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -295,7 +302,7 @@ packages:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.6"
version: "1.6.7+1"
string_scanner:
dependency: transitive
description:
Expand All @@ -316,7 +323,7 @@ packages:
name: test
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.37"
version: "0.12.41"
typed_data:
dependency: transitive
description:
Expand All @@ -338,26 +345,33 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
vm_service_client:
dependency: transitive
description:
name: vm_service_client
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.4+3"
watcher:
dependency: transitive
description:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.7+7"
version: "0.9.7+8"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.7"
version: "1.0.8"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.13"
version: "2.1.14"
sdks:
dart: ">=2.0.0-dev.52.0 <=2.0.0-dev.60.0.flutter-a5e41681e5"
dart: ">=2.0.0-dev.62.0 <=2.0.0-dev.63.0.flutter-4c9689c1d2"
59 changes: 33 additions & 26 deletions test/flip_panel_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,20 @@ import 'dart:async';

void main() {

testWidgets('test flip animation runs periodically', (tester) async {
testWidgets('FlipPanel.builder() can be constructed', (tester) async {
await tester.pumpWidget(FlipPanel.builder(
itemBuilder: (context, index) => Container(),
period: Duration(milliseconds: 1000),
itemsCount: 2));
});

testWidgets('FlipPanel.stream() can be constructed', (tester) async {
await tester.pumpWidget(FlipPanel.stream(
itemStream: Stream.empty(),
itemBuilder: (context, value) => Container()));
});

testWidgets('FlipPanel.builder() completes after expected loop number and displays expected value after animation finished', (tester) async {
final digits = [0, 1, 2, 3];
var count = 0;

Expand All @@ -31,8 +44,7 @@ void main() {
period: Duration(milliseconds: 1000),
duration: Duration(milliseconds: 500),
loop: 2,
itemsCount: digits.length
),
itemsCount: digits.length),
),
),
),
Expand All @@ -50,34 +62,32 @@ void main() {
.widgetList<Text>(find.byType(Text))
.map((widget) => widget.data)
.last,
equals('${digits.last}')
);
equals('${digits.last}'));
});

testWidgets('test flip animation runs from stream', (tester) async {

testWidgets('FlipPanel.stream() displays expected value after animation finished', (tester) async {
StreamController<int> controller = StreamController<int>();

await tester.pumpWidget(
MaterialApp(
home: new Material(
child: Center(
child: FlipPanel.stream(
itemBuilder: (context, value) {
return Container(
color: Colors.black,
padding: EdgeInsets.symmetric(horizontal: 6.0),
child: Text(
'$value',
style: TextStyle(
color: Colors.white,
fontSize: 30.0,
),
itemBuilder: (context, value) {
return Container(
color: Colors.black,
padding: EdgeInsets.symmetric(horizontal: 6.0),
child: Text(
'$value',
style: TextStyle(
color: Colors.white,
fontSize: 30.0,
),
);
},
itemStream: controller.stream,
initValue: 0,
),
);
},
itemStream: controller.stream,
initValue: 0,
),
),
),
Expand All @@ -90,15 +100,12 @@ void main() {

await tester.pumpAndSettle();

// verify the final value displayed
// verify the value displayed
expect(
tester
.widgetList<Text>(find.byType(Text))
.map((widget) => widget.data)
.last,
equals('1')
);

equals('1'));
});

}

0 comments on commit 842bf13

Please sign in to comment.