Chromium Code Reviews

Side by Side Diff: lib/src/backend/test_platform.dart

Issue 1004013002: Add support for evaluating platform selectors. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library unittest.backend.test_platform;
6
5 // TODO(nweiz): support pluggable platforms. 7 // TODO(nweiz): support pluggable platforms.
6 /// An enum of all platforms on which tests can run. 8 /// An enum of all platforms on which tests can run.
7 class TestPlatform { 9 class TestPlatform {
10 // When adding new platforms, be sure to update the baseline and derived
11 // variable tests in test/backend/platform_selector/evaluate_test.
12
8 /// The command-line Dart VM. 13 /// The command-line Dart VM.
9 static const vm = const TestPlatform._("VM", "vm"); 14 static const vm = const TestPlatform._("VM", "vm", isDartVm: true);
10 15
11 /// Google Chrome. 16 /// Google Chrome.
12 static const chrome = const TestPlatform._("Chrome", "chrome"); 17 static const chrome = const TestPlatform._("Chrome", "chrome",
18 isBrowser: true, isDart2js: true, isBlink: true);
Bob Nystrom 2015/03/16 16:54:26 Firefox, Safari, IE, et. al.?
nweiz 2015/03/24 01:03:28 This enum is also used for telling other APIs whic
13 19
14 /// A list of all instances of [TestPlatform]. 20 /// A list of all instances of [TestPlatform].
15 static const all = const [vm, chrome]; 21 static const all = const [vm, chrome];
16 22
17 /// Finds a platform by its identifier string. 23 /// Finds a platform by its identifier string.
18 /// 24 ///
19 /// If no platform is found, returns `null`. 25 /// If no platform is found, returns `null`.
20 static TestPlatform find(String identifier) => 26 static TestPlatform find(String identifier) =>
21 all.firstWhere((platform) => platform.identifier == identifier, 27 all.firstWhere((platform) => platform.identifier == identifier,
22 orElse: () => null); 28 orElse: () => null);
23 29
24 /// The human-friendly name of the platform. 30 /// The human-friendly name of the platform.
25 final String name; 31 final String name;
26 32
27 /// The identifier used to look up the platform. 33 /// The identifier used to look up the platform.
28 final String identifier; 34 final String identifier;
29 35
30 const TestPlatform._(this.name, this.identifier); 36 /// Whether this platform runs the Dart VM in any capacity.
37 final bool isDartVm;
38
39 /// Whether this platform is a browser.
40 final bool isBrowser;
41
42 /// Whether this platform runs Dart compiled with dart2js.
43 final bool isDart2js;
Bob Nystrom 2015/03/16 16:54:26 What about DDC? Should this name be more generic?
nweiz 2015/03/24 01:03:28 Changed to "js".
44
45 /// Whether this platform uses the Blink rendering engine.
46 final bool isBlink;
47
48 const TestPlatform._(this.name, this.identifier, {this.isDartVm: false,
49 this.isBrowser: false, this.isDart2js: false, this.isBlink: false});
31 50
32 String toString() => name; 51 String toString() => name;
33 } 52 }
OLDNEW

Powered by Google App Engine