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

Add tests in path_provider and url_launcher plugins #22

Merged
merged 6 commits into from
May 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/path-provider/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 5 additions & 1 deletion packages/path-provider/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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 <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins
Expand All @@ -13,3 +13,7 @@ flutter:
dependencies:
flutter:
sdk: flutter

dev_dependencies:
flutter_test:
sdk: flutter
55 changes: 55 additions & 0 deletions packages/path-provider/test/path_provider_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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() {
const channel = const MethodChannel('plugins.flutter.io/path_provider');
final List<MethodCall> log = <MethodCall>[];
String response;

channel.setMockMethodCallHandler((MethodCall methodCall) async {
log.add(methodCall);
return response;
});

tearDown(() {
log.clear();
});

test('getTemporaryDirectory test', () async {
response = null;
Directory directory = await getTemporaryDirectory();
expect(log, equals(<MethodCall>[new MethodCall('getTemporaryDirectory')]));
expect(directory, isNull);
});

test('getApplicationDocumentsDirectory test', () async {
response = null;
Directory directory = await getApplicationDocumentsDirectory();
expect(
log,
equals(<MethodCall>[new MethodCall('getApplicationDocumentsDirectory')]),
);
expect(directory, isNull);
});

test('TemporaryDirectory path test', () async {
final String fakePath = "/foo/bar/baz";
response = fakePath;
Directory directory = await getTemporaryDirectory();
expect(directory.path, equals(fakePath));
});

test('ApplicationDocumentsDirectory path test', () async {
final String fakePath = "/foo/bar/baz";
response = fakePath;
Directory directory = await getApplicationDocumentsDirectory();
expect(directory.path, equals(fakePath));
});
}
8 changes: 6 additions & 2 deletions packages/url-launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
## [0.3.4] - 2017-05-08

* Add test.

## [0.3.3] - 2017-05-05

* Change to buildToolsVersion

## [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

Expand Down
4 changes: 4 additions & 0 deletions packages/url-launcher/ios/Classes/UrlLauncherPlugin.h
Original file line number Diff line number Diff line change
@@ -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 <Flutter/Flutter.h>

@interface UrlLauncherPlugin : NSObject
Expand Down
4 changes: 4 additions & 0 deletions packages/url-launcher/ios/Classes/UrlLauncherPlugin.m
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion packages/url-launcher/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: url_launcher

version: 0.3.3
version: 0.3.4
description: A Flutter plugin for launching a URL
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins
Expand All @@ -13,3 +13,7 @@ flutter:
dependencies:
flutter:
sdk: flutter

dev_dependencies:
flutter_test:
sdk: flutter
34 changes: 34 additions & 0 deletions packages/url-launcher/test/url_launcher_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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';
import 'package:url_launcher/url_launcher.dart';

void main() {
const channel = const MethodChannel('plugins.flutter.io/url_launcher');
final List<MethodCall> log = <MethodCall>[];
channel.setMockMethodCallHandler((MethodCall methodCall) async {
log.add(methodCall);
});

tearDown(() {
log.clear();
});

test('canLaunch test', () async {
await canLaunch('http://example.com/');
expect(
log,
equals(<MethodCall>[new MethodCall('canLaunch', 'http://example.com/')]),
);
log.clear();
});

test('launch test', () async {
await launch('http://example.com/');
expect(log,
equals(<MethodCall>[new MethodCall('launch', 'http://example.com/')]));
});
}