From 43dbdddd4df64d0c9b5859017394161a2551229b Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Mon, 8 May 2017 10:20:06 +0200 Subject: [PATCH 1/5] wip --- packages/path-provider/pubspec.yaml | 4 ++ .../test/path_provider_test.dart | 42 +++++++++++++++++++ .../url-launcher/test/url_launcher_test.dart | 20 +++++++++ 3 files changed, 66 insertions(+) create mode 100644 packages/path-provider/test/path_provider_test.dart create mode 100644 packages/url-launcher/test/url_launcher_test.dart diff --git a/packages/path-provider/pubspec.yaml b/packages/path-provider/pubspec.yaml index 1d11c45190ed..2679e6df9eff 100644 --- a/packages/path-provider/pubspec.yaml +++ b/packages/path-provider/pubspec.yaml @@ -13,3 +13,7 @@ flutter: dependencies: flutter: sdk: flutter + +dev_dependencies: + flutter_test: + sdk: flutter \ No newline at end of file diff --git a/packages/path-provider/test/path_provider_test.dart b/packages/path-provider/test/path_provider_test.dart new file mode 100644 index 000000000000..f2069431166f --- /dev/null +++ b/packages/path-provider/test/path_provider_test.dart @@ -0,0 +1,42 @@ +// 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 'dart:io'; + +import 'package:flutter/services.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:test/test.dart'; + +void main() { + test('Path provider control test', () async { + final List log = []; + String response; + const channel = const MethodChannel('plugins.flutter.io/path_provider'); + + channel.setMockMethodCallHandler((MethodCall methodCall) async { + log.add(methodCall); + return response; + }); + + Directory directory = await getTemporaryDirectory(); + + expect(log, equals([new MethodCall('getTemporaryDirectory')])); + expect(directory, isNull); + log.clear(); + + directory = await getApplicationDocumentsDirectory(); + + expect(log, equals([new MethodCall('getApplicationDocumentsDirectory')])); + expect(directory, isNull); + + final String fakePath = "/foo/bar/baz"; + response = fakePath; + + directory = await getTemporaryDirectory(); + expect(directory.path, equals(fakePath)); + + directory = await getApplicationDocumentsDirectory(); + expect(directory.path, equals(fakePath)); + }); +} diff --git a/packages/url-launcher/test/url_launcher_test.dart b/packages/url-launcher/test/url_launcher_test.dart new file mode 100644 index 000000000000..2ad6b894ab4b --- /dev/null +++ b/packages/url-launcher/test/url_launcher_test.dart @@ -0,0 +1,20 @@ +// 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/services.dart'; +import 'package:test/test.dart'; + +void main() { + test('URL launcher control test', () async { + final List log = []; + + SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async { + log.add(methodCall); + }); + + await UrlLauncher.launch('http://example.com/'); + + expect(log, equals([new MethodCall('UrlLauncher.launch', 'http://example.com/')])); + }); +} From fc0b5aa99d68bed0db54b9eac0b26f3b6291f9fb Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Mon, 8 May 2017 10:38:00 +0200 Subject: [PATCH 2/5] url_launcher test + missing copyrights --- packages/path-provider/CHANGELOG.md | 7 +++++-- packages/path-provider/pubspec.yaml | 2 +- packages/url-launcher/CHANGELOG.md | 8 ++++++-- .../url-launcher/ios/Classes/UrlLauncherPlugin.h | 4 ++++ .../url-launcher/ios/Classes/UrlLauncherPlugin.m | 4 ++++ packages/url-launcher/pubspec.yaml | 6 +++++- packages/url-launcher/test/url_launcher_test.dart | 13 +++++++++---- 7 files changed, 34 insertions(+), 10 deletions(-) diff --git a/packages/path-provider/CHANGELOG.md b/packages/path-provider/CHANGELOG.md index 7ebc965d7d59..ee708465d463 100644 --- a/packages/path-provider/CHANGELOG.md +++ b/packages/path-provider/CHANGELOG.md @@ -1,7 +1,10 @@ -## [0.1.1] - 2017-05-04 +## [0.1.2] - 2017-05-08 + +* Add test. -* Change to README.md +## [0.1.1] - 2017-05-04 +* Change to README.md. ## [0.1.0] - 2017-05-03 diff --git a/packages/path-provider/pubspec.yaml b/packages/path-provider/pubspec.yaml index 2679e6df9eff..c0ad13a5f908 100644 --- a/packages/path-provider/pubspec.yaml +++ b/packages/path-provider/pubspec.yaml @@ -1,6 +1,6 @@ name: path_provider -version: 0.1.1 +version: 0.1.2 description: A Flutter plugin for getting commonly used locations on the filesystem. author: Flutter Team homepage: https://github.com/flutter/plugins diff --git a/packages/url-launcher/CHANGELOG.md b/packages/url-launcher/CHANGELOG.md index ecae94bf381a..d8719418065e 100644 --- a/packages/url-launcher/CHANGELOG.md +++ b/packages/url-launcher/CHANGELOG.md @@ -1,10 +1,14 @@ +## [0.3.3] - 2017-05-08 + +* Add test. + ## [0.3.2] - 2017-05-04 -* Change to README.md +* Change to README.md. ## [0.3.1] - 2017-05-01 -* Change to README.md +* Change to README.md. ## [0.3.0] - 2017-04-27 diff --git a/packages/url-launcher/ios/Classes/UrlLauncherPlugin.h b/packages/url-launcher/ios/Classes/UrlLauncherPlugin.h index a827ad7c2ece..0dc931f3cf28 100644 --- a/packages/url-launcher/ios/Classes/UrlLauncherPlugin.h +++ b/packages/url-launcher/ios/Classes/UrlLauncherPlugin.h @@ -1,3 +1,7 @@ +// 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 @interface UrlLauncherPlugin : NSObject diff --git a/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m b/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m index 1b31ddb08328..4bea2265c757 100644 --- a/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m +++ b/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m @@ -1,3 +1,7 @@ +// 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 "UrlLauncherPlugin.h" @implementation UrlLauncherPlugin { diff --git a/packages/url-launcher/pubspec.yaml b/packages/url-launcher/pubspec.yaml index e936e7a9752a..de825ee8c4f4 100644 --- a/packages/url-launcher/pubspec.yaml +++ b/packages/url-launcher/pubspec.yaml @@ -1,6 +1,6 @@ name: url_launcher -version: 0.3.2 +version: 0.3.3 description: A Flutter plugin for launching a URL author: Flutter Team homepage: https://github.com/flutter/plugins @@ -13,3 +13,7 @@ flutter: dependencies: flutter: sdk: flutter + +dev_dependencies: + flutter_test: + sdk: flutter \ No newline at end of file diff --git a/packages/url-launcher/test/url_launcher_test.dart b/packages/url-launcher/test/url_launcher_test.dart index 2ad6b894ab4b..350ac5520d37 100644 --- a/packages/url-launcher/test/url_launcher_test.dart +++ b/packages/url-launcher/test/url_launcher_test.dart @@ -4,17 +4,22 @@ import 'package:flutter/services.dart'; import 'package:test/test.dart'; +import 'package:url_launcher/url_launcher.dart'; void main() { test('URL launcher control test', () async { final List log = []; - - SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async { + const channel = const MethodChannel('plugins.flutter.io/url_launcher'); + + channel.setMockMethodCallHandler((MethodCall methodCall) async { log.add(methodCall); }); - await UrlLauncher.launch('http://example.com/'); + await canLaunch('http://example.com/'); + expect(log, equals([new MethodCall('canLaunch', 'http://example.com/')])); + log.clear(); - expect(log, equals([new MethodCall('UrlLauncher.launch', 'http://example.com/')])); + await launch('http://example.com/'); + expect(log, equals([new MethodCall('launch', 'http://example.com/')])); }); } From 84cb5f59e7ef50c7ddba8d765f1c45903e538f9d Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Mon, 8 May 2017 10:40:27 +0200 Subject: [PATCH 3/5] formatting --- packages/path-provider/test/path_provider_test.dart | 5 ++++- packages/url-launcher/test/url_launcher_test.dart | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/path-provider/test/path_provider_test.dart b/packages/path-provider/test/path_provider_test.dart index f2069431166f..12c7e1e1ad6f 100644 --- a/packages/path-provider/test/path_provider_test.dart +++ b/packages/path-provider/test/path_provider_test.dart @@ -27,7 +27,10 @@ void main() { directory = await getApplicationDocumentsDirectory(); - expect(log, equals([new MethodCall('getApplicationDocumentsDirectory')])); + expect( + log, + equals( + [new MethodCall('getApplicationDocumentsDirectory')])); expect(directory, isNull); final String fakePath = "/foo/bar/baz"; diff --git a/packages/url-launcher/test/url_launcher_test.dart b/packages/url-launcher/test/url_launcher_test.dart index 350ac5520d37..04916488d7d9 100644 --- a/packages/url-launcher/test/url_launcher_test.dart +++ b/packages/url-launcher/test/url_launcher_test.dart @@ -16,10 +16,14 @@ void main() { }); await canLaunch('http://example.com/'); - expect(log, equals([new MethodCall('canLaunch', 'http://example.com/')])); + expect( + log, + equals( + [new MethodCall('canLaunch', 'http://example.com/')])); log.clear(); await launch('http://example.com/'); - expect(log, equals([new MethodCall('launch', 'http://example.com/')])); + expect(log, + equals([new MethodCall('launch', 'http://example.com/')])); }); } From 2a6cc75948fa2b48dcd1a45fa3e6d72c8df0a96e Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Mon, 8 May 2017 13:01:02 +0200 Subject: [PATCH 4/5] split into smaller tests --- .../test/path_provider_test.dart | 40 ++++++++++++------- .../url-launcher/test/url_launcher_test.dart | 17 +++++--- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/packages/path-provider/test/path_provider_test.dart b/packages/path-provider/test/path_provider_test.dart index 12c7e1e1ad6f..6b1536c82e90 100644 --- a/packages/path-provider/test/path_provider_test.dart +++ b/packages/path-provider/test/path_provider_test.dart @@ -9,37 +9,47 @@ import 'package:path_provider/path_provider.dart'; import 'package:test/test.dart'; void main() { - test('Path provider control test', () async { - final List log = []; - String response; - const channel = const MethodChannel('plugins.flutter.io/path_provider'); + const channel = const MethodChannel('plugins.flutter.io/path_provider'); + final List log = []; + String response; - channel.setMockMethodCallHandler((MethodCall methodCall) async { - log.add(methodCall); - return response; - }); + channel.setMockMethodCallHandler((MethodCall methodCall) async { + log.add(methodCall); + return response; + }); - Directory directory = await getTemporaryDirectory(); + tearDown(() { + log.clear(); + }); + test('getTemporaryDirectory test', () async { + response = null; + Directory directory = await getTemporaryDirectory(); expect(log, equals([new MethodCall('getTemporaryDirectory')])); expect(directory, isNull); - log.clear(); - - directory = await getApplicationDocumentsDirectory(); + }); + test('getApplicationDocumentsDirectory test', () async { + response = null; + Directory directory = await getApplicationDocumentsDirectory(); expect( log, equals( [new MethodCall('getApplicationDocumentsDirectory')])); expect(directory, isNull); + }); + test('TemporaryDirectory path test', () async { final String fakePath = "/foo/bar/baz"; response = fakePath; - - directory = await getTemporaryDirectory(); + Directory directory = await getTemporaryDirectory(); expect(directory.path, equals(fakePath)); + }); - directory = await getApplicationDocumentsDirectory(); + test('ApplicationDocumentsDirectory path test', () async { + final String fakePath = "/foo/bar/baz"; + response = fakePath; + Directory directory = await getApplicationDocumentsDirectory(); expect(directory.path, equals(fakePath)); }); } diff --git a/packages/url-launcher/test/url_launcher_test.dart b/packages/url-launcher/test/url_launcher_test.dart index 04916488d7d9..e38ee0b4a0ca 100644 --- a/packages/url-launcher/test/url_launcher_test.dart +++ b/packages/url-launcher/test/url_launcher_test.dart @@ -7,21 +7,26 @@ import 'package:test/test.dart'; import 'package:url_launcher/url_launcher.dart'; void main() { - test('URL launcher control test', () async { - final List log = []; - const channel = const MethodChannel('plugins.flutter.io/url_launcher'); + const channel = const MethodChannel('plugins.flutter.io/url_launcher'); + final List log = []; + channel.setMockMethodCallHandler((MethodCall methodCall) async { + log.add(methodCall); + }); - channel.setMockMethodCallHandler((MethodCall methodCall) async { - log.add(methodCall); - }); + tearDown(() { + log.clear(); + }); + test('canLaunch test', () async { await canLaunch('http://example.com/'); expect( log, equals( [new MethodCall('canLaunch', 'http://example.com/')])); log.clear(); + }); + test('launch test', () async { await launch('http://example.com/'); expect(log, equals([new MethodCall('launch', 'http://example.com/')])); From 87f6f588b9e21c45fce66f6f51bda61acd706785 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Mon, 8 May 2017 13:20:09 +0200 Subject: [PATCH 5/5] formatting --- packages/path-provider/test/path_provider_test.dart | 6 +++--- packages/url-launcher/test/url_launcher_test.dart | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/path-provider/test/path_provider_test.dart b/packages/path-provider/test/path_provider_test.dart index 6b1536c82e90..47cd22b2a70e 100644 --- a/packages/path-provider/test/path_provider_test.dart +++ b/packages/path-provider/test/path_provider_test.dart @@ -33,9 +33,9 @@ void main() { response = null; Directory directory = await getApplicationDocumentsDirectory(); expect( - log, - equals( - [new MethodCall('getApplicationDocumentsDirectory')])); + log, + equals([new MethodCall('getApplicationDocumentsDirectory')]), + ); expect(directory, isNull); }); diff --git a/packages/url-launcher/test/url_launcher_test.dart b/packages/url-launcher/test/url_launcher_test.dart index e38ee0b4a0ca..25cdd74e1a37 100644 --- a/packages/url-launcher/test/url_launcher_test.dart +++ b/packages/url-launcher/test/url_launcher_test.dart @@ -20,9 +20,9 @@ void main() { test('canLaunch test', () async { await canLaunch('http://example.com/'); expect( - log, - equals( - [new MethodCall('canLaunch', 'http://example.com/')])); + log, + equals([new MethodCall('canLaunch', 'http://example.com/')]), + ); log.clear(); });