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 3 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
45 changes: 45 additions & 0 deletions packages/path-provider/test/path_provider_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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<MethodCall> log = <MethodCall>[];
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(<MethodCall>[new MethodCall('getTemporaryDirectory')]));
expect(directory, isNull);
log.clear();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We start a new test here. Should ideally be separated into two invocations of test.

directory = await getApplicationDocumentsDirectory();

expect(
log,
equals(
<MethodCall>[new MethodCall('getApplicationDocumentsDirectory')]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A trailing comma may make dartfmt do something prettier.

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));
});
}
8 changes: 6 additions & 2 deletions packages/url-launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

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.2
version: 0.3.3
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
29 changes: 29 additions & 0 deletions packages/url-launcher/test/url_launcher_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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() {
test('URL launcher control test', () async {
final List<MethodCall> log = <MethodCall>[];
const channel = const MethodChannel('plugins.flutter.io/url_launcher');

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

await canLaunch('http://example.com/');
expect(
log,
equals(
<MethodCall>[new MethodCall('canLaunch', 'http://example.com/')]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

log.clear();

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