Skip to content

Commit

Permalink
[cloud_functions] add a driver test (flutter#1346)
Browse files Browse the repository at this point in the history
  • Loading branch information
collinjackson authored Mar 15, 2019
1 parent 6aef375 commit e99d1aa
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 26 deletions.
4 changes: 4 additions & 0 deletions packages/cloud_functions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.2+1

* Added a driver test.

## 0.1.2

* Specifying a version for Cloud Functions CocoaPod dependency to prevent build errors on iOS.
Expand Down
4 changes: 4 additions & 0 deletions packages/cloud_functions/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_driver:
sdk: flutter
test: any


flutter:
uses-material-design: true
Expand Down
37 changes: 37 additions & 0 deletions packages/cloud_functions/example/test/cloud_functions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2019, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:async';
import 'package:flutter_driver/driver_extension.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:cloud_functions/cloud_functions.dart';

void main() {
final Completer<String> completer = Completer<String>();
enableFlutterDriverExtension(handler: (_) => completer.future);
tearDownAll(() => completer.complete(null));

group('$CloudFunctions', () {
test('call', () async {
final dynamic response = await CloudFunctions.instance.call(
functionName: 'repeat',
parameters: <String, dynamic>{
'message': 'foo',
'count': 1,
},
);
expect(response['repeat_message'], 'foo');
expect(response['repeat_count'], 2);
final dynamic response2 = await CloudFunctions.instance.call(
functionName: 'repeat',
parameters: <String, dynamic>{
'message': 'bar',
'count': 42,
},
);
expect(response2['repeat_message'], 'bar');
expect(response2['repeat_count'], 43);
});
});
}
15 changes: 15 additions & 0 deletions packages/cloud_functions/example/test/cloud_functions_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2019, the Chromium project authors. Please see the AUTHORS file
// for details. 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 '../lib/main.dart';

void main() {
testWidgets('CloudFunctions example widget test',
(WidgetTester tester) async {
await tester.pumpWidget(MyApp());
expect(find.text('Cloud Functions example app'), findsOneWidget);
});
}
25 changes: 0 additions & 25 deletions packages/cloud_functions/example/test/widget_test.dart

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2019, the Chromium project authors. Please see the AUTHORS file
// for details. 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_driver/flutter_driver.dart';

Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
await driver.requestData(null, timeout: const Duration(minutes: 1));
driver.close();
}
5 changes: 4 additions & 1 deletion packages/cloud_functions/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: cloud_functions
description: Flutter plugin for Cloud Functions.
version: 0.1.2
version: 0.1.2+1
author: Flutter Team <[email protected]>
homepage: https://github.com/flutter/plugins/tree/master/packages/cloud_functions

Expand All @@ -18,6 +18,9 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_driver:
sdk: flutter
test: any

environment:
sdk: ">=2.0.0-dev.28.0 <3.0.0"
Expand Down

0 comments on commit e99d1aa

Please sign in to comment.