diff --git a/packages/flutter/test/material/chip_test.dart b/packages/flutter/test/material/chip_test.dart new file mode 100644 index 0000000000..f9fea61bcc --- /dev/null +++ b/packages/flutter/test/material/chip_test.dart @@ -0,0 +1,33 @@ +// Copyright 2016 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/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Chip control test', (WidgetTester tester) async { + bool didDeleteChip = false; + await tester.pumpWidget( + new MaterialApp( + home: new Material( + child: new Center( + child: new Chip( + avatar: new CircleAvatar( + child: new Text('C') + ), + label: new Text('Chip'), + onDeleted: () { + didDeleteChip = true; + } + ) + ) + ) + ) + ); + + expect(didDeleteChip, isFalse); + await tester.tap(find.byType(Tooltip)); + expect(didDeleteChip, isTrue); + }); +} diff --git a/packages/flutter/test/material/divider_test.dart b/packages/flutter/test/material/divider_test.dart new file mode 100644 index 0000000000..6c7139d591 --- /dev/null +++ b/packages/flutter/test/material/divider_test.dart @@ -0,0 +1,14 @@ +// Copyright 2016 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/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Divider control test', (WidgetTester tester) async { + await tester.pumpWidget(new Center(child: new Divider())); + RenderBox box = tester.firstRenderObject(find.byType(Divider)); + expect(box.size.height, 15.0); + }); +} diff --git a/packages/flutter/test/material/drawer_test.dart b/packages/flutter/test/material/drawer_test.dart new file mode 100644 index 0000000000..c3625f1e05 --- /dev/null +++ b/packages/flutter/test/material/drawer_test.dart @@ -0,0 +1,35 @@ +// Copyright 2016 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/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Drawer control test', (WidgetTester tester) async { + await tester.pumpWidget( + new Scaffold( + drawer: new Drawer( + child: new Block( + children: [ + new DrawerHeader( + content: new Text('header') + ), + new DrawerItem( + icon: new Icon(Icons.archive), + child: new Text('Archive') + ) + ] + ) + ) + ) + ); + + expect(find.text('Archive'), findsNothing); + ScaffoldState state = tester.firstState(find.byType(Scaffold)); + state.openDrawer(); + await tester.pump(); + await tester.pump(const Duration(seconds: 1)); + expect(find.text('Archive'), findsOneWidget); + }); +} diff --git a/packages/flutter/test/material/floating_action_button_test.dart b/packages/flutter/test/material/floating_action_button_test.dart new file mode 100644 index 0000000000..dafaab63e6 --- /dev/null +++ b/packages/flutter/test/material/floating_action_button_test.dart @@ -0,0 +1,26 @@ +// Copyright 2016 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/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Floating Action Button control test', (WidgetTester tester) async { + bool didPressButton = false; + await tester.pumpWidget( + new Center( + child: new FloatingActionButton( + onPressed: () { + didPressButton = true; + }, + child: new Icon(Icons.add) + ) + ) + ); + + expect(didPressButton, isFalse); + await tester.tap(find.byType(Icon)); + expect(didPressButton, isTrue); + }); +} diff --git a/packages/flutter/test/material/icon_data_test.dart b/packages/flutter/test/material/icon_data_test.dart new file mode 100644 index 0000000000..6ad3a61a8c --- /dev/null +++ b/packages/flutter/test/material/icon_data_test.dart @@ -0,0 +1,14 @@ +// Copyright 2016 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/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('IconData object test', (WidgetTester tester) async { + expect(Icons.account_balance, isNot(equals(Icons.account_box))); + expect(Icons.account_balance.hashCode, isNot(equals(Icons.account_box.hashCode))); + expect(Icons.account_balance, hasOneLineDescription); + }); +} diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart index 7e617361ed..bc1096580f 100644 --- a/packages/flutter_tools/lib/src/commands/test.dart +++ b/packages/flutter_tools/lib/src/commands/test.dart @@ -30,7 +30,7 @@ class TestCommand extends FlutterCommand { defaultsTo: false, negatable: false, help: 'Whether to merge converage data with "coverage/lcov.base.info". ' - 'Implies collecting coverage data. (Linux only)' + 'Implies collecting coverage data. (Requires lcov)' ); argParser.addOption('coverage-path', defaultsTo: 'coverage/lcov.info', @@ -95,6 +95,8 @@ class TestCommand extends FlutterCommand { Status status = logger.startProgress('Collecting coverage information...'); String coverageData = await collector.finalizeCoverage(); status.stop(showElapsedTime: true); + if (coverageData == null) + return false; String coveragePath = argResults['coverage-path']; File coverageFile = new File(coveragePath) @@ -118,10 +120,12 @@ class TestCommand extends FlutterCommand { } if (os.which('lcov') == null) { - printError( - 'Missing "lcov" tool. Unable to merge coverage data.\n' - 'Consider running "sudo apt-get install lcov".' - ); + String installMessage = 'Please install lcov.'; + if (os.isLinux) + installMessage = 'Consider running "sudo apt-get install lcov".'; + else if (os.isMacOS) + installMessage = 'Consider running "brew install lcov".'; + printError('Missing "lcov" tool. Unable to merge coverage data.\n$installMessage'); return false; } diff --git a/packages/flutter_tools/lib/src/test/coverage_collector.dart b/packages/flutter_tools/lib/src/test/coverage_collector.dart index 1f3a35d89c..5d66d3948f 100644 --- a/packages/flutter_tools/lib/src/test/coverage_collector.dart +++ b/packages/flutter_tools/lib/src/test/coverage_collector.dart @@ -62,6 +62,8 @@ class CoverageCollector { assert(enabled); await finishPendingJobs(); printTrace('formating coverage data'); + if (_globalHitmap == null) + return null; Resolver resolver = new Resolver(packagesPath: PackageMap.globalPackagesPath); LcovFormatter formater = new LcovFormatter(resolver); String packagePath = Directory.current.path;