Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[web] Add Edge support for Flutter Engine unit-tests. (#15641)
* Add Edge support for Flutter Engine unit-tests. This does not include the launcher * Add mapping from browser name to platform. * remove ie from supported browser maps
- Loading branch information
Nurhan Turgut
committed
Jan 15, 2020
1 parent
3291541
commit bc41ab5
Showing
6 changed files
with
193 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# For more information on test and runner configurations: | ||
# | ||
# * https://github.com/dart-lang/test/blob/master/pkgs/test/doc/configuration.md#platforms | ||
|
||
platforms: | ||
- ie | ||
- vm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2013 The Flutter 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:async'; | ||
import 'dart:io'; | ||
|
||
import 'browser.dart'; | ||
import 'common.dart'; | ||
import 'edge_installation.dart'; | ||
|
||
/// A class for running an instance of Edge. | ||
/// | ||
/// Most of the communication with the browser is expected to happen via HTTP, | ||
/// so this exposes a bare-bones API. The browser starts as soon as the class is | ||
/// constructed, and is killed when [close] is called. | ||
/// | ||
/// Any errors starting or running the process are reported through [onExit]. | ||
class Edge extends Browser { | ||
@override | ||
final name = 'Edge'; | ||
|
||
static String version; | ||
|
||
/// Starts a new instance of Safari open to the given [url], which may be a | ||
/// [Uri] or a [String]. | ||
factory Edge(Uri url, {bool debug = false}) { | ||
version = EdgeArgParser.instance.version; | ||
|
||
assert(version != null); | ||
return Edge._(() async { | ||
// TODO(nurhan): Configure info log for LUCI. | ||
final BrowserInstallation installation = await getEdgeInstallation( | ||
version, | ||
infoLog: DevNull(), | ||
); | ||
|
||
// Debug is not a valid option for Edge. Remove it. | ||
String pathToOpen = url.toString(); | ||
if(pathToOpen.contains('debug')) { | ||
int index = pathToOpen.indexOf('debug'); | ||
pathToOpen = pathToOpen.substring(0, index-1); | ||
} | ||
|
||
var process = | ||
await Process.start(installation.executable, ['$pathToOpen','-k']); | ||
|
||
return process; | ||
}); | ||
} | ||
|
||
Edge._(Future<Process> startBrowser()) : super(startBrowser); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright 2013 The Flutter 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:async'; | ||
import 'dart:io' as io; | ||
|
||
import 'package:args/args.dart'; | ||
|
||
import 'common.dart'; | ||
|
||
class EdgeArgParser extends BrowserArgParser { | ||
static final EdgeArgParser _singletonInstance = EdgeArgParser._(); | ||
|
||
/// The [EdgeArgParser] singleton. | ||
static EdgeArgParser get instance => _singletonInstance; | ||
|
||
String _version; | ||
|
||
EdgeArgParser._(); | ||
|
||
@override | ||
void populateOptions(ArgParser argParser) { | ||
argParser | ||
..addOption( | ||
'edge-version', | ||
defaultsTo: 'system', | ||
help: 'The Edge version to use while running tests. The Edge ' | ||
'browser installed on the system is used as the only option now.', | ||
); | ||
} | ||
|
||
@override | ||
void parseOptions(ArgResults argResults) { | ||
_version = argResults['edge-version']; | ||
assert(_version == 'system'); | ||
} | ||
|
||
@override | ||
String get version => _version; | ||
} | ||
|
||
/// Returns the installation of Edge. | ||
/// | ||
/// Currently uses the Edge version installed on the operating system. | ||
/// | ||
/// As explained on the Microsoft help page: `Microsoft Edge comes | ||
/// exclusively with Windows 10 and cannot be downloaded or installed separately.` | ||
/// See: https://support.microsoft.com/en-us/help/17171/microsoft-edge-get-to-know | ||
/// | ||
// TODO(nurhan): Investigate running tests for the tech preview downloads | ||
// from the beta channel. | ||
Future<BrowserInstallation> getEdgeInstallation( | ||
String requestedVersion, { | ||
StringSink infoLog, | ||
}) async { | ||
// For now these tests are aimed to run only on Windows machines local or on LUCI/CI. | ||
// In the future we can investigate to run them on Android or on MacOS. | ||
if (!io.Platform.isWindows) { | ||
throw UnimplementedError( | ||
'Tests for Edge on ${io.Platform.operatingSystem} is' | ||
' not supported.'); | ||
} | ||
|
||
infoLog ??= io.stdout; | ||
|
||
if (requestedVersion == 'system') { | ||
// Since Edge is included in Windows, always assume there will be one on the | ||
// system. | ||
infoLog.writeln('Using the system version that is already installed.'); | ||
return BrowserInstallation( | ||
version: 'system', | ||
executable: PlatformBinding.instance.getCommandToRunEdge(), | ||
); | ||
} else { | ||
infoLog.writeln('Unsupported version $requestedVersion.'); | ||
throw UnimplementedError(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters