Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit e523de8

Browse files
authored
Add tests in path_provider and url_launcher plugins (#22)
1 parent d238a53 commit e523de8

File tree

8 files changed

+118
-6
lines changed

8 files changed

+118
-6
lines changed

packages/path-provider/CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
## [0.1.1] - 2017-05-04
1+
## [0.1.2] - 2017-05-08
2+
3+
* Add test.
24

3-
* Change to README.md
5+
## [0.1.1] - 2017-05-04
46

7+
* Change to README.md.
58

69
## [0.1.0] - 2017-05-03
710

packages/path-provider/pubspec.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: path_provider
22

3-
version: 0.1.1
3+
version: 0.1.2
44
description: A Flutter plugin for getting commonly used locations on the filesystem.
55
author: Flutter Team <[email protected]>
66
homepage: https://github.com/flutter/plugins
@@ -13,3 +13,7 @@ flutter:
1313
dependencies:
1414
flutter:
1515
sdk: flutter
16+
17+
dev_dependencies:
18+
flutter_test:
19+
sdk: flutter
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:io';
6+
7+
import 'package:flutter/services.dart';
8+
import 'package:path_provider/path_provider.dart';
9+
import 'package:test/test.dart';
10+
11+
void main() {
12+
const channel = const MethodChannel('plugins.flutter.io/path_provider');
13+
final List<MethodCall> log = <MethodCall>[];
14+
String response;
15+
16+
channel.setMockMethodCallHandler((MethodCall methodCall) async {
17+
log.add(methodCall);
18+
return response;
19+
});
20+
21+
tearDown(() {
22+
log.clear();
23+
});
24+
25+
test('getTemporaryDirectory test', () async {
26+
response = null;
27+
Directory directory = await getTemporaryDirectory();
28+
expect(log, equals(<MethodCall>[new MethodCall('getTemporaryDirectory')]));
29+
expect(directory, isNull);
30+
});
31+
32+
test('getApplicationDocumentsDirectory test', () async {
33+
response = null;
34+
Directory directory = await getApplicationDocumentsDirectory();
35+
expect(
36+
log,
37+
equals(<MethodCall>[new MethodCall('getApplicationDocumentsDirectory')]),
38+
);
39+
expect(directory, isNull);
40+
});
41+
42+
test('TemporaryDirectory path test', () async {
43+
final String fakePath = "/foo/bar/baz";
44+
response = fakePath;
45+
Directory directory = await getTemporaryDirectory();
46+
expect(directory.path, equals(fakePath));
47+
});
48+
49+
test('ApplicationDocumentsDirectory path test', () async {
50+
final String fakePath = "/foo/bar/baz";
51+
response = fakePath;
52+
Directory directory = await getApplicationDocumentsDirectory();
53+
expect(directory.path, equals(fakePath));
54+
});
55+
}

packages/url-launcher/CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
## [0.3.4] - 2017-05-08
2+
3+
* Add test.
4+
15
## [0.3.3] - 2017-05-05
26

37
* Change to buildToolsVersion
48

59
## [0.3.2] - 2017-05-04
610

7-
* Change to README.md
11+
* Change to README.md.
812

913
## [0.3.1] - 2017-05-01
1014

11-
* Change to README.md
15+
* Change to README.md.
1216

1317
## [0.3.0] - 2017-04-27
1418

packages/url-launcher/ios/Classes/UrlLauncherPlugin.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
15
#import <Flutter/Flutter.h>
26

37
@interface UrlLauncherPlugin : NSObject

packages/url-launcher/ios/Classes/UrlLauncherPlugin.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
15
#import "UrlLauncherPlugin.h"
26

37
@implementation UrlLauncherPlugin {

packages/url-launcher/pubspec.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: url_launcher
22

3-
version: 0.3.3
3+
version: 0.3.4
44
description: A Flutter plugin for launching a URL
55
author: Flutter Team <[email protected]>
66
homepage: https://github.com/flutter/plugins
@@ -13,3 +13,7 @@ flutter:
1313
dependencies:
1414
flutter:
1515
sdk: flutter
16+
17+
dev_dependencies:
18+
flutter_test:
19+
sdk: flutter
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter/services.dart';
6+
import 'package:test/test.dart';
7+
import 'package:url_launcher/url_launcher.dart';
8+
9+
void main() {
10+
const channel = const MethodChannel('plugins.flutter.io/url_launcher');
11+
final List<MethodCall> log = <MethodCall>[];
12+
channel.setMockMethodCallHandler((MethodCall methodCall) async {
13+
log.add(methodCall);
14+
});
15+
16+
tearDown(() {
17+
log.clear();
18+
});
19+
20+
test('canLaunch test', () async {
21+
await canLaunch('http://example.com/');
22+
expect(
23+
log,
24+
equals(<MethodCall>[new MethodCall('canLaunch', 'http://example.com/')]),
25+
);
26+
log.clear();
27+
});
28+
29+
test('launch test', () async {
30+
await launch('http://example.com/');
31+
expect(log,
32+
equals(<MethodCall>[new MethodCall('launch', 'http://example.com/')]));
33+
});
34+
}

0 commit comments

Comments
 (0)