blob: be30c177743a1d2c1d6bddfe7730366e659bdf9a [file] [log] [blame]
// Copyright 2024, the Dart project authors. Please see the AUTHORS file
// for details. 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:deps/browsers/chrome.dart';
import 'package:deps/package.dart';
import 'package:file/file.dart';
import 'package:file/local.dart';
import 'package:test/test.dart';
const baseUrl =
'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/1.2.3';
void main() {
test('chromedriver package', () async {
final chrome = ChromeDriverPackage('linux-amd64', '1.2.3');
expect(chrome.name, 'dart/third_party/chromedriver/linux-amd64');
expect(
chrome.source, Uri.parse('$baseUrl/linux64/chromedriver-linux64.zip'));
});
test('chrome package', () async {
final chrome = ChromePackage('linux-amd64', '1.2.3');
expect(chrome.name, 'dart/browsers/chrome/linux-amd64');
expect(chrome.source, Uri.parse('$baseUrl/linux64/chrome-linux64.zip'));
});
test('chrome windows package', () async {
final chrome = ChromePackage('windows-amd64', '1.2.3');
expect(chrome.name, 'dart/browsers/chrome/windows-amd64');
expect(chrome.source, Uri.parse('$baseUrl/win64/chrome-win64.zip'));
});
test('chrome mac package', () async {
final chrome = ChromePackage('mac-amd64', '1.2.3');
expect(chrome.source, Uri.parse('$baseUrl/mac-x64/chrome-mac-x64.zip'));
});
group('build chrome', () {
final fileSystem = LocalFileSystem();
late Directory workingDir;
setUp(() async =>
workingDir = await fileSystem.systemTempDirectory.createTemp());
tearDown(() async => await workingDir.delete(recursive: true));
const data = {
'linux-amd64': [
'/chrome',
'/chrome/google-chrome',
],
'mac-arm64': [
'/Google Chrome.app',
'/Google Chrome.app/Contents',
'/Google Chrome.app/Contents/MacOS',
'/Google Chrome.app/Contents/MacOS/Google Chrome',
],
'windows-amd64': [
'/Chrome',
'/Chrome/Application',
'/Chrome/Application/chrome.exe',
],
};
for (final MapEntry(key: platform, value: expected) in data.entries) {
test('build chrome on $platform', () async {
final chrome = ChromePackage(platform, '1.2.3');
final dir = await chrome.build(
[fileSystem.file('test/data/chrome-$platform.zip')], workingDir);
expect(
dir
.listSync(recursive: true)
.map((f) => f.path.substring(dir.path.length)),
unorderedEquals(expected));
expect(await chrome.check(dir), isTrue);
});
}
});
group('integration test', () {
final fileSystem = LocalFileSystem();
late Directory workingDir;
setUp(() async =>
workingDir = await fileSystem.systemTempDirectory.createTemp());
tearDown(() async => await workingDir.delete(recursive: true));
for (final platform in [
'linux-amd64',
'mac-amd64',
'mac-arm64',
'windows-amd64'
]) {
test('chromedriver $platform', () async {
await dryRun(
() async => ChromeDriverPackage(platform, '116.0.5845.82')
.create(workingDir, false),
true);
});
test('chrome $platform', () async {
await dryRun(
() async => ChromePackage(platform, '116.0.5845.82')
.create(workingDir, false),
true);
});
}
});
}