Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0d2c9670
Commit
0d2c9670
authored
Feb 21, 2017
by
Todd Volkert
Committed by
GitHub
Feb 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve TODOs to migrate from OperatingSystemUtils to Platform (#8314)
parent
ac7954c1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
43 deletions
+33
-43
android_studio.dart
packages/flutter_tools/lib/src/android/android_studio.dart
+1
-1
os.dart
packages/flutter_tools/lib/src/base/os.dart
+0
-7
drive.dart
packages/flutter_tools/lib/src/commands/drive.dart
+3
-3
test.dart
packages/flutter_tools/lib/src/commands/test.dart
+5
-4
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+2
-2
drive_test.dart
packages/flutter_tools/test/drive_test.dart
+13
-20
context.dart
packages/flutter_tools/test/src/context.dart
+9
-6
No files found.
packages/flutter_tools/lib/src/android/android_studio.dart
View file @
0d2c9670
...
...
@@ -100,7 +100,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
String
configuredStudio
=
config
.
getValue
(
'android-studio-dir'
);
if
(
configuredStudio
!=
null
)
{
String
configuredStudioPath
=
configuredStudio
;
if
(
os
.
isMacOS
&&
!
configuredStudioPath
.
endsWith
(
'Contents'
))
if
(
platform
.
isMacOS
&&
!
configuredStudioPath
.
endsWith
(
'Contents'
))
configuredStudioPath
=
fs
.
path
.
join
(
configuredStudioPath
,
'Contents'
);
return
new
AndroidStudio
(
configuredStudioPath
,
configured:
configuredStudio
);
...
...
packages/flutter_tools/lib/src/base/os.dart
View file @
0d2c9670
...
...
@@ -27,13 +27,6 @@ abstract class OperatingSystemUtils {
OperatingSystemUtils
.
_private
();
// TODO(tvolkert): Remove these and migrate callers to Platform
String
get
operatingSystem
=>
platform
.
operatingSystem
;
bool
get
isMacOS
=>
operatingSystem
==
'macos'
;
bool
get
isWindows
=>
operatingSystem
==
'windows'
;
bool
get
isLinux
=>
operatingSystem
==
'linux'
;
/// Make the given file executable. This may be a no-op on some platforms.
ProcessResult
makeExecutable
(
File
file
);
...
...
packages/flutter_tools/lib/src/commands/drive.dart
View file @
0d2c9670
...
...
@@ -8,7 +8,7 @@ import '../android/android_device.dart' show AndroidDevice;
import
'../application_package.dart'
;
import
'../base/file_system.dart'
;
import
'../base/common.dart'
;
import
'../base/
os
.dart'
;
import
'../base/
platform
.dart'
;
import
'../base/process.dart'
;
import
'../build_info.dart'
;
import
'../cache.dart'
;
...
...
@@ -199,7 +199,7 @@ Future<Device> findTargetDevice() async {
}
if
(
os
.
isMacOS
)
{
if
(
platform
.
isMacOS
)
{
// On Mac we look for the iOS Simulator. If available, we use that. Then
// we look for an Android device. If there's one, we use that. Otherwise,
// we launch a new iOS Simulator.
...
...
@@ -225,7 +225,7 @@ Future<Device> findTargetDevice() async {
printError
(
'Failed to start iOS Simulator.'
);
return
null
;
}
}
else
if
(
os
.
isLinux
||
os
.
isWindows
)
{
}
else
if
(
platform
.
isLinux
||
platform
.
isWindows
)
{
// On Linux and Windows, for now, we just grab the first connected device we can find.
if
(
devices
.
isEmpty
)
{
printError
(
'No devices found.'
);
...
...
packages/flutter_tools/lib/src/commands/test.dart
View file @
0d2c9670
...
...
@@ -11,8 +11,9 @@ import '../base/common.dart';
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
import
'../base/process_manager.dart'
;
import
'../base/os.dart'
;
import
'../base/platform.dart'
;
import
'../base/process_manager.dart'
;
import
'../cache.dart'
;
import
'../dart/package_map.dart'
;
import
'../globals.dart'
;
...
...
@@ -112,7 +113,7 @@ class TestCommand extends FlutterCommand {
String
baseCoverageData
=
'coverage/lcov.base.info'
;
if
(
mergeCoverageData
)
{
if
(!
os
.
isLinux
)
{
if
(!
platform
.
isLinux
)
{
printError
(
'Merging coverage data is supported only on Linux because it '
'requires the "lcov" tool.'
...
...
@@ -127,9 +128,9 @@ class TestCommand extends FlutterCommand {
if
(
os
.
which
(
'lcov'
)
==
null
)
{
String
installMessage
=
'Please install lcov.'
;
if
(
os
.
isLinux
)
if
(
platform
.
isLinux
)
installMessage
=
'Consider running "sudo apt-get install lcov".'
;
else
if
(
os
.
isMacOS
)
else
if
(
platform
.
isMacOS
)
installMessage
=
'Consider running "brew install lcov".'
;
printError
(
'Missing "lcov" tool. Unable to merge coverage data.
\n
$installMessage
'
);
return
false
;
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
0d2c9670
...
...
@@ -13,7 +13,7 @@ import 'base/common.dart';
import
'base/file_system.dart'
;
import
'base/io.dart'
;
import
'base/logger.dart'
;
import
'base/
os
.dart'
;
import
'base/
platform
.dart'
;
import
'base/utils.dart'
;
import
'build_info.dart'
;
import
'dart/dependencies.dart'
;
...
...
@@ -157,7 +157,7 @@ abstract class ResidentRunner {
void
registerSignalHandlers
()
{
assert
(
stayResident
);
ProcessSignal
.
SIGINT
.
watch
().
listen
(
_cleanUpAndExit
);
if
(!
os
.
isWindows
)
// TODO(goderbauer): enable on Windows when https://github.com/dart-lang/sdk/issues/28603 is fixed
if
(!
platform
.
isWindows
)
// TODO(goderbauer): enable on Windows when https://github.com/dart-lang/sdk/issues/28603 is fixed
ProcessSignal
.
SIGTERM
.
watch
().
listen
(
_cleanUpAndExit
);
if
(!
supportsServiceProtocol
||
!
supportsRestart
)
return
;
...
...
packages/flutter_tools/test/drive_test.dart
View file @
0d2c9670
...
...
@@ -7,7 +7,7 @@ import 'package:flutter_tools/src/android/android_device.dart';
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/
os
.dart'
;
import
'package:flutter_tools/src/base/
platform
.dart'
;
import
'package:flutter_tools/src/commands/drive.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/ios/simulators.dart'
;
...
...
@@ -232,14 +232,9 @@ void main() {
});
group
(
'findTargetDevice on iOS'
,
()
{
void
setOs
()
{
when
(
os
.
isMacOS
).
thenReturn
(
true
);
when
(
os
.
isLinux
).
thenReturn
(
false
);
when
(
os
.
isWindows
).
thenReturn
(
false
);
}
Platform
macOsPlatform
()
=>
new
FakePlatform
(
operatingSystem:
'macos'
);
testUsingContext
(
'uses existing emulator'
,
()
async
{
setOs
();
withMockDevice
();
when
(
mockDevice
.
name
).
thenReturn
(
'mock-simulator'
);
when
(
mockDevice
.
isLocalEmulator
).
thenReturn
(
true
);
...
...
@@ -248,10 +243,10 @@ void main() {
expect
(
device
.
name
,
'mock-simulator'
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
Platform:
()
=>
macOsPlatform
(),
});
testUsingContext
(
'uses existing Android device if and there are no simulators'
,
()
async
{
setOs
();
mockDevice
=
new
MockAndroidDevice
();
when
(
mockDevice
.
name
).
thenReturn
(
'mock-android-device'
);
when
(
mockDevice
.
isLocalEmulator
).
thenReturn
(
false
);
...
...
@@ -261,10 +256,10 @@ void main() {
expect
(
device
.
name
,
'mock-android-device'
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
Platform:
()
=>
macOsPlatform
(),
});
testUsingContext
(
'launches emulator'
,
()
async
{
setOs
();
when
(
SimControl
.
instance
.
boot
()).
thenReturn
(
true
);
Device
emulator
=
new
MockDevice
();
when
(
emulator
.
name
).
thenReturn
(
'new-simulator'
);
...
...
@@ -275,26 +270,23 @@ void main() {
expect
(
device
.
name
,
'new-simulator'
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
Platform:
()
=>
macOsPlatform
(),
});
});
void
findTargetDeviceOnLinuxOrWindows
({
bool
isWindows:
false
,
bool
isLinux:
false
})
{
assert
(
isWindows
!=
isLinux
);
void
setOs
()
{
when
(
os
.
isMacOS
).
thenReturn
(
false
);
when
(
os
.
isLinux
).
thenReturn
(
isLinux
);
when
(
os
.
isWindows
).
thenReturn
(
isWindows
);
}
void
findTargetDeviceOnOperatingSystem
(
String
operatingSystem
)
{
assert
(
operatingSystem
==
'windows'
||
operatingSystem
==
'linux'
);
Platform
platform
()
=>
new
FakePlatform
(
operatingSystem:
operatingSystem
);
testUsingContext
(
'returns null if no devices found'
,
()
async
{
setOs
();
expect
(
await
findTargetDevice
(),
isNull
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
Platform:
()
=>
platform
(),
});
testUsingContext
(
'uses existing Android device'
,
()
async
{
setOs
();
mockDevice
=
new
MockAndroidDevice
();
when
(
mockDevice
.
name
).
thenReturn
(
'mock-android-device'
);
withMockDevice
(
mockDevice
);
...
...
@@ -303,15 +295,16 @@ void main() {
expect
(
device
.
name
,
'mock-android-device'
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
Platform:
()
=>
platform
(),
});
}
group
(
'findTargetDevice on Linux'
,
()
{
findTargetDeviceOn
LinuxOrWindows
(
isLinux:
true
);
findTargetDeviceOn
OperatingSystem
(
'linux'
);
});
group
(
'findTargetDevice on Windows'
,
()
{
findTargetDeviceOn
LinuxOrWindows
(
isWindows:
true
);
findTargetDeviceOn
OperatingSystem
(
'windows'
);
});
});
}
...
...
packages/flutter_tools/test/src/context.dart
View file @
0d2c9670
...
...
@@ -42,7 +42,7 @@ void testUsingContext(String description, dynamic testMethod(), {
// Initialize the test context with some default mocks.
// Seed these context entries first since others depend on them
testContext
.
putIfAbsent
(
Platform
,
()
=>
const
Local
Platform
());
testContext
.
putIfAbsent
(
Platform
,
()
=>
new
_Fake
Platform
());
testContext
.
putIfAbsent
(
FileSystem
,
()
=>
const
LocalFileSystem
());
testContext
.
putIfAbsent
(
ProcessManager
,
()
=>
const
LocalProcessManager
());
testContext
.
putIfAbsent
(
Logger
,
()
=>
new
BufferLogger
());
...
...
@@ -55,11 +55,7 @@ void testUsingContext(String description, dynamic testMethod(), {
testContext
.
putIfAbsent
(
HotRunnerConfig
,
()
=>
new
HotRunnerConfig
());
testContext
.
putIfAbsent
(
Cache
,
()
=>
new
Cache
());
testContext
.
putIfAbsent
(
Artifacts
,
()
=>
new
CachedArtifacts
());
testContext
.
putIfAbsent
(
OperatingSystemUtils
,
()
{
MockOperatingSystemUtils
os
=
new
MockOperatingSystemUtils
();
when
(
os
.
isWindows
).
thenReturn
(
false
);
return
os
;
});
testContext
.
putIfAbsent
(
OperatingSystemUtils
,
()
=>
new
MockOperatingSystemUtils
());
testContext
.
putIfAbsent
(
Xcode
,
()
=>
new
Xcode
());
testContext
.
putIfAbsent
(
IOSSimulatorUtils
,
()
{
MockIOSSimulatorUtils
mock
=
new
MockIOSSimulatorUtils
();
...
...
@@ -144,6 +140,13 @@ class MockSimControl extends Mock implements SimControl {
}
}
class
_FakePlatform
extends
FakePlatform
{
_FakePlatform
()
:
super
.
fromPlatform
(
const
LocalPlatform
());
@override
bool
get
isWindows
=>
false
;
}
class
MockOperatingSystemUtils
extends
Mock
implements
OperatingSystemUtils
{}
class
MockIOSSimulatorUtils
extends
Mock
implements
IOSSimulatorUtils
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment