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

Commit a3c2a60

Browse files
committed
Merge remote-tracking branch 'upstream/mastert' into webview_android_load_asset
2 parents 0cc67bb + 40572a7 commit a3c2a60

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3417
-1538
lines changed

.cirrus.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,25 @@ task:
109109
matrix:
110110
CHANNEL: "master"
111111
CHANNEL: "stable"
112-
tool_script:
112+
analyze_tool_script:
113113
- cd script/tool
114114
- dart analyze --fatal-infos
115-
script:
115+
analyze_script:
116116
# DO NOT change the custom-analysis argument here without changing the Dart repo.
117117
# See the comment in script/configs/custom_analysis.yaml for details.
118118
- ./script/tool_runner.sh analyze --custom-analysis=script/configs/custom_analysis.yaml
119+
pathified_analyze_script:
120+
# Re-run analysis with path-based dependencies to ensure that publishing
121+
# the changes won't break analysis of other packages in the respository
122+
# that depend on it.
123+
- ./script/tool_runner.sh make-deps-path-based --target-dependencies-with-non-breaking-updates
124+
# This uses --run-on-dirty-packages rather than --packages-for-branch
125+
# since only the packages changed by 'make-deps-path-based' need to be
126+
# checked.
127+
- dart $PLUGIN_TOOL analyze --run-on-dirty-packages --log-timing --custom-analysis=script/configs/custom_analysis.yaml
128+
# Restore the tree to a clean state, to avoid accidental issues if
129+
# other script steps are added to this task.
130+
- git checkout .
119131
### Android tasks ###
120132
- name: android-build_all_plugins
121133
env:

packages/path_provider/path_provider_macos/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.4
2+
3+
* Switches to a package-internal implementation of the platform interface.
4+
15
## 2.0.3
26

37
* Fixes link in README.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright 2013 The Flutter 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:meta/meta.dart';
9+
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
10+
11+
/// The macOS implementation of [PathProviderPlatform].
12+
class PathProviderMacOS extends PathProviderPlatform {
13+
/// The method channel used to interact with the native platform.
14+
@visibleForTesting
15+
MethodChannel methodChannel =
16+
const MethodChannel('plugins.flutter.io/path_provider_macos');
17+
18+
/// Registers this class as the default instance of [PathProviderPlatform]
19+
static void registerWith() {
20+
PathProviderPlatform.instance = PathProviderMacOS();
21+
}
22+
23+
@override
24+
Future<String?> getTemporaryPath() {
25+
return methodChannel.invokeMethod<String>('getTemporaryDirectory');
26+
}
27+
28+
@override
29+
Future<String?> getApplicationSupportPath() async {
30+
final String? path = await methodChannel
31+
.invokeMethod<String>('getApplicationSupportDirectory');
32+
if (path != null) {
33+
// Ensure the directory exists before returning it, for consistency with
34+
// other platforms.
35+
await Directory(path).create(recursive: true);
36+
}
37+
return path;
38+
}
39+
40+
@override
41+
Future<String?> getLibraryPath() {
42+
return methodChannel.invokeMethod<String>('getLibraryDirectory');
43+
}
44+
45+
@override
46+
Future<String?> getApplicationDocumentsPath() {
47+
return methodChannel
48+
.invokeMethod<String>('getApplicationDocumentsDirectory');
49+
}
50+
51+
@override
52+
Future<String?> getExternalStoragePath() async {
53+
throw UnsupportedError('getExternalStoragePath is not supported on macOS');
54+
}
55+
56+
@override
57+
Future<List<String>?> getExternalCachePaths() async {
58+
throw UnsupportedError('getExternalCachePaths is not supported on macOS');
59+
}
60+
61+
@override
62+
Future<List<String>?> getExternalStoragePaths({
63+
StorageDirectory? type,
64+
}) async {
65+
throw UnsupportedError('getExternalStoragePaths is not supported on macOS');
66+
}
67+
68+
@override
69+
Future<String?> getDownloadsPath() {
70+
return methodChannel.invokeMethod<String>('getDownloadsDirectory');
71+
}
72+
}

packages/path_provider/path_provider_macos/macos/Classes/PathProviderPlugin.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Foundation
88
public class PathProviderPlugin: NSObject, FlutterPlugin {
99
public static func register(with registrar: FlutterPluginRegistrar) {
1010
let channel = FlutterMethodChannel(
11-
name: "plugins.flutter.io/path_provider",
11+
name: "plugins.flutter.io/path_provider_macos",
1212
binaryMessenger: registrar.messenger)
1313
let instance = PathProviderPlugin()
1414
registrar.addMethodCallDelegate(instance, channel: channel)
@@ -25,16 +25,6 @@ public class PathProviderPlugin: NSObject, FlutterPlugin {
2525
if let basePath = path {
2626
let basePathURL = URL.init(fileURLWithPath: basePath)
2727
path = basePathURL.appendingPathComponent(Bundle.main.bundleIdentifier!).path
28-
do {
29-
try FileManager.default.createDirectory(atPath: path!, withIntermediateDirectories: true)
30-
} catch {
31-
result(
32-
FlutterError(
33-
code: "directory_creation_failure",
34-
message: error.localizedDescription,
35-
details: "\(error)"))
36-
return
37-
}
3828
}
3929
result(path)
4030
case "getLibraryDirectory":

packages/path_provider/path_provider_macos/pubspec.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: path_provider_macos
22
description: macOS implementation of the path_provider plugin
33
repository: https://github.com/flutter/plugins/tree/master/packages/path_provider/path_provider_macos
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+path_provider%22
5-
version: 2.0.3
5+
version: 2.0.4
66

77
environment:
88
sdk: ">=2.12.0 <3.0.0"
@@ -14,10 +14,16 @@ flutter:
1414
platforms:
1515
macos:
1616
pluginClass: PathProviderPlugin
17+
dartPluginClass: PathProviderMacOS
1718

1819
dependencies:
1920
flutter:
2021
sdk: flutter
22+
meta: ^1.3.0
23+
path_provider_platform_interface: ^2.0.1
2124

2225
dev_dependencies:
26+
flutter_test:
27+
sdk: flutter
28+
path: ^1.8.0
2329
pedantic: ^1.10.0
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
// Copyright 2013 The Flutter 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:flutter_test/flutter_test.dart';
9+
import 'package:path/path.dart' as p;
10+
import 'package:path_provider_macos/path_provider_macos.dart';
11+
12+
void main() {
13+
TestWidgetsFlutterBinding.ensureInitialized();
14+
15+
group('PathProviderMacOS', () {
16+
late PathProviderMacOS pathProvider;
17+
late List<MethodCall> log;
18+
// These unit tests use the actual filesystem, since an injectable
19+
// filesystem would add a runtime dependency to the package, so everything
20+
// is contained to a temporary directory.
21+
late Directory testRoot;
22+
23+
late String temporaryPath;
24+
late String applicationSupportPath;
25+
late String libraryPath;
26+
late String applicationDocumentsPath;
27+
late String downloadsPath;
28+
29+
setUp(() async {
30+
pathProvider = PathProviderMacOS();
31+
32+
testRoot = Directory.systemTemp.createTempSync();
33+
final String basePath = testRoot.path;
34+
temporaryPath = p.join(basePath, 'temporary', 'path');
35+
applicationSupportPath =
36+
p.join(basePath, 'application', 'support', 'path');
37+
libraryPath = p.join(basePath, 'library', 'path');
38+
applicationDocumentsPath =
39+
p.join(basePath, 'application', 'documents', 'path');
40+
downloadsPath = p.join(basePath, 'downloads', 'path');
41+
42+
log = <MethodCall>[];
43+
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
44+
.setMockMethodCallHandler(pathProvider.methodChannel,
45+
(MethodCall methodCall) async {
46+
log.add(methodCall);
47+
switch (methodCall.method) {
48+
case 'getTemporaryDirectory':
49+
return temporaryPath;
50+
case 'getApplicationSupportDirectory':
51+
return applicationSupportPath;
52+
case 'getLibraryDirectory':
53+
return libraryPath;
54+
case 'getApplicationDocumentsDirectory':
55+
return applicationDocumentsPath;
56+
case 'getDownloadsDirectory':
57+
return downloadsPath;
58+
default:
59+
return null;
60+
}
61+
});
62+
});
63+
64+
tearDown(() {
65+
testRoot.deleteSync(recursive: true);
66+
});
67+
68+
test('getTemporaryPath', () async {
69+
final String? path = await pathProvider.getTemporaryPath();
70+
expect(
71+
log,
72+
<Matcher>[isMethodCall('getTemporaryDirectory', arguments: null)],
73+
);
74+
expect(path, temporaryPath);
75+
});
76+
77+
test('getApplicationSupportPath', () async {
78+
final String? path = await pathProvider.getApplicationSupportPath();
79+
expect(
80+
log,
81+
<Matcher>[
82+
isMethodCall('getApplicationSupportDirectory', arguments: null)
83+
],
84+
);
85+
expect(path, applicationSupportPath);
86+
});
87+
88+
test('getApplicationSupportPath creates the directory if necessary',
89+
() async {
90+
final String? path = await pathProvider.getApplicationSupportPath();
91+
expect(Directory(path!).existsSync(), isTrue);
92+
});
93+
94+
test('getLibraryPath', () async {
95+
final String? path = await pathProvider.getLibraryPath();
96+
expect(
97+
log,
98+
<Matcher>[isMethodCall('getLibraryDirectory', arguments: null)],
99+
);
100+
expect(path, libraryPath);
101+
});
102+
103+
test('getApplicationDocumentsPath', () async {
104+
final String? path = await pathProvider.getApplicationDocumentsPath();
105+
expect(
106+
log,
107+
<Matcher>[
108+
isMethodCall('getApplicationDocumentsDirectory', arguments: null)
109+
],
110+
);
111+
expect(path, applicationDocumentsPath);
112+
});
113+
114+
test('getDownloadsPath', () async {
115+
final String? result = await pathProvider.getDownloadsPath();
116+
expect(
117+
log,
118+
<Matcher>[isMethodCall('getDownloadsDirectory', arguments: null)],
119+
);
120+
expect(result, downloadsPath);
121+
});
122+
123+
test('getExternalCachePaths throws', () async {
124+
expect(pathProvider.getExternalCachePaths(), throwsA(isUnsupportedError));
125+
});
126+
127+
test('getExternalStoragePath throws', () async {
128+
expect(
129+
pathProvider.getExternalStoragePath(), throwsA(isUnsupportedError));
130+
});
131+
132+
test('getExternalStoragePaths throws', () async {
133+
expect(
134+
pathProvider.getExternalStoragePaths(), throwsA(isUnsupportedError));
135+
});
136+
});
137+
}

packages/webview_flutter/webview_flutter_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.5.0
2+
3+
* Adds implementation of the `loadFlutterAsset` method from the platform interface.
4+
15
## 2.4.0
26

37
* Adds support for Android's `WebView.loadData` and `WebView.loadDataWithBaseUrl` methods and implements the `loadFile` and `loadHtmlString` methods from the platform interface.

0 commit comments

Comments
 (0)