Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
wip
  • Loading branch information
szakarias committed May 8, 2017
commit 43dbdddd4df64d0c9b5859017394161a2551229b
4 changes: 4 additions & 0 deletions packages/path-provider/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ flutter:
dependencies:
flutter:
sdk: flutter

dev_dependencies:
flutter_test:
sdk: flutter
42 changes: 42 additions & 0 deletions packages/path-provider/test/path_provider_test.dart
Original file line number Diff line number Diff line change
@@ -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<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')]));
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));
});
}
20 changes: 20 additions & 0 deletions packages/url-launcher/test/url_launcher_test.dart
Original file line number Diff line number Diff line change
@@ -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<MethodCall> log = <MethodCall>[];

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

await UrlLauncher.launch('http://example.com/');

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