OLD | NEW |
---|---|
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 /// An enum of all operating systems supported by Dart. | 5 /// An enum of all operating systems supported by Dart. |
6 /// | 6 /// |
7 /// This is used for selecting which operating systems a test can run on. Even | 7 /// This is used for selecting which operating systems a test can run on. Even |
8 /// for browser tests, this indicates the operating system of the machine | 8 /// for browser tests, this indicates the operating system of the machine |
9 /// running the test runner. | 9 /// running the test runner. |
10 class OperatingSystem { | 10 class OperatingSystem { |
(...skipping 24 matching lines...) Expand all Loading... | |
35 /// system is used. It can't be referenced by name in platform selectors. | 35 /// system is used. It can't be referenced by name in platform selectors. |
36 static const none = const OperatingSystem._("none", "none"); | 36 static const none = const OperatingSystem._("none", "none"); |
37 | 37 |
38 /// A list of all instances of [OperatingSystem] other than [none]. | 38 /// A list of all instances of [OperatingSystem] other than [none]. |
39 static const all = const [windows, macOS, linux, android, iOS]; | 39 static const all = const [windows, macOS, linux, android, iOS]; |
40 | 40 |
41 /// Finds an operating system by its name. | 41 /// Finds an operating system by its name. |
42 /// | 42 /// |
43 /// If no operating system is found, returns [none]. | 43 /// If no operating system is found, returns [none]. |
44 static OperatingSystem find(String name) => | 44 static OperatingSystem find(String name) => |
45 all.firstWhere((platform) => platform.name == name, orElse: () => null); | 45 all.firstWhere((platform) => platform.identifier == name, |
kevmoo
2016/02/26 23:06:20
Rebase oops here – maybe?
| |
46 orElse: () => null); | |
46 | 47 |
47 /// Finds an operating system by the return value from `dart:io`'s | 48 /// Finds an operating system by the return value from `dart:io`'s |
48 /// `Platform.operatingSystem`. | 49 /// `Platform.operatingSystem`. |
49 /// | 50 /// |
50 /// If no operating system is found, returns [none]. | 51 /// If no operating system is found, returns [none]. |
51 static OperatingSystem findByIoName(String name) { | 52 static OperatingSystem findByIoName(String name) { |
52 switch (name) { | 53 switch (name) { |
53 case "windows": return windows; | 54 case "windows": return windows; |
54 case "macos": return macOS; | 55 case "macos": return macOS; |
55 case "linux": return linux; | 56 case "linux": return linux; |
56 case "android": return android; | 57 case "android": return android; |
57 case "ios": return iOS; | 58 case "ios": return iOS; |
58 default: return none; | 59 default: return none; |
59 } | 60 } |
60 } | 61 } |
61 | 62 |
62 /// The human-friendly of the operating system. | 63 /// The human-friendly of the operating system. |
63 final String name; | 64 final String name; |
64 | 65 |
65 /// The identifier used to look up the operating system. | 66 /// The identifier used to look up the operating system. |
66 final String identifier; | 67 final String identifier; |
67 | 68 |
68 /// Whether this is a POSIX-ish operating system. | 69 /// Whether this is a POSIX-ish operating system. |
69 bool get isPosix => this != windows && this != none; | 70 bool get isPosix => this != windows && this != none; |
70 | 71 |
71 const OperatingSystem._(this.name, this.identifier); | 72 const OperatingSystem._(this.name, this.identifier); |
72 | 73 |
73 String toString() => name; | 74 String toString() => name; |
74 } | 75 } |
OLD | NEW |