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
6b191841
Unverified
Commit
6b191841
authored
Apr 25, 2019
by
Jonah Williams
Committed by
GitHub
Apr 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow filtering devices to only those supported by current project (#31446)
parent
5ec33654
Changes
24
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
278 additions
and
8 deletions
+278
-8
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+5
-0
attach.dart
packages/flutter_tools/lib/src/commands/attach.dart
+1
-0
daemon.dart
packages/flutter_tools/lib/src/commands/daemon.dart
+3
-0
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+3
-0
device.dart
packages/flutter_tools/lib/src/device.dart
+4
-0
fuchsia_device.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+4
-0
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+6
-0
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+6
-0
linux_device.dart
packages/flutter_tools/lib/src/linux/linux_device.dart
+5
-0
macos_device.dart
packages/flutter_tools/lib/src/macos/macos_device.dart
+5
-0
project.dart
packages/flutter_tools/lib/src/project.dart
+15
-6
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+1
-1
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+7
-0
flutter_tester.dart
packages/flutter_tools/lib/src/tester/flutter_tester.dart
+4
-0
web_device.dart
packages/flutter_tools/lib/src/web/web_device.dart
+5
-0
windows_device.dart
packages/flutter_tools/lib/src/windows/windows_device.dart
+5
-0
android_device_test.dart
packages/flutter_tools/test/android/android_device_test.dart
+39
-0
fuchsa_device_test.dart
packages/flutter_tools/test/fuchsia/fuchsa_device_test.dart
+1
-0
devices_test.dart
packages/flutter_tools/test/ios/devices_test.dart
+40
-0
simulators_test.dart
packages/flutter_tools/test/ios/simulators_test.dart
+40
-0
linux_device_test.dart
packages/flutter_tools/test/linux/linux_device_test.dart
+23
-0
macos_device_test.dart
packages/flutter_tools/test/macos/macos_device_test.dart
+23
-0
mocks.dart
packages/flutter_tools/test/src/mocks.dart
+9
-0
windows_device_test.dart
packages/flutter_tools/test/windows/windows_device_test.dart
+24
-1
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
6b191841
...
...
@@ -535,6 +535,11 @@ class AndroidDevice extends Device {
await
runCheckedAsync
(
adbCommandForDevice
(<
String
>[
'pull'
,
remotePath
,
outputFile
.
path
]));
await
runCheckedAsync
(
adbCommandForDevice
(<
String
>[
'shell'
,
'rm'
,
remotePath
]));
}
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
{
return
flutterProject
.
android
.
existsSync
();
}
}
Map
<
String
,
String
>
parseAdbDeviceProperties
(
String
str
)
{
...
...
packages/flutter_tools/lib/src/commands/attach.dart
View file @
6b191841
...
...
@@ -243,6 +243,7 @@ class AttachCommand extends FlutterCommand {
final
bool
useHot
=
getBuildInfo
().
isDebug
;
final
FlutterDevice
flutterDevice
=
await
FlutterDevice
.
create
(
device
,
flutterProject:
flutterProject
,
trackWidgetCreation:
argResults
[
'track-widget-creation'
],
dillOutputPath:
argResults
[
'output-dill'
],
fileSystemRoots:
argResults
[
'filesystem-root'
],
...
...
packages/flutter_tools/lib/src/commands/daemon.dart
View file @
6b191841
...
...
@@ -19,6 +19,7 @@ import '../convert.dart';
import
'../device.dart'
;
import
'../emulator.dart'
;
import
'../globals.dart'
;
import
'../project.dart'
;
import
'../resident_runner.dart'
;
import
'../run_cold.dart'
;
import
'../run_hot.dart'
;
...
...
@@ -344,9 +345,11 @@ class AppDomain extends Domain {
// We change the current working directory for the duration of the `start` command.
final
Directory
cwd
=
fs
.
currentDirectory
;
fs
.
currentDirectory
=
fs
.
directory
(
projectDirectory
);
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
final
FlutterDevice
flutterDevice
=
await
FlutterDevice
.
create
(
device
,
flutterProject:
flutterProject
,
trackWidgetCreation:
trackWidgetCreation
,
dillOutputPath:
dillOutputPath
,
viewFilter:
isolateFilter
,
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
6b191841
...
...
@@ -13,6 +13,7 @@ import '../cache.dart';
import
'../device.dart'
;
import
'../globals.dart'
;
import
'../ios/mac.dart'
;
import
'../project.dart'
;
import
'../resident_runner.dart'
;
import
'../run_cold.dart'
;
import
'../run_hot.dart'
;
...
...
@@ -364,9 +365,11 @@ class RunCommand extends RunCommandBase {
expFlags
=
argResults
[
FlutterOptions
.
kEnableExperiment
];
}
final
List
<
FlutterDevice
>
flutterDevices
=
<
FlutterDevice
>[];
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
for
(
Device
device
in
devices
)
{
final
FlutterDevice
flutterDevice
=
await
FlutterDevice
.
create
(
device
,
flutterProject:
flutterProject
,
trackWidgetCreation:
argResults
[
'track-widget-creation'
],
dillOutputPath:
argResults
[
'output-dill'
],
fileSystemRoots:
argResults
[
'filesystem-root'
],
...
...
packages/flutter_tools/lib/src/device.dart
View file @
6b191841
...
...
@@ -19,6 +19,7 @@ import 'ios/devices.dart';
import
'ios/simulators.dart'
;
import
'linux/linux_device.dart'
;
import
'macos/macos_device.dart'
;
import
'project.dart'
;
import
'tester/flutter_tester.dart'
;
import
'web/web_device.dart'
;
import
'windows/windows_device.dart'
;
...
...
@@ -235,6 +236,9 @@ abstract class Device {
}
}
/// Whether the device is supported for the current project directory.
bool
isSupportedForProject
(
FlutterProject
flutterProject
);
/// Check if a version of the given app is already installed
Future
<
bool
>
isAppInstalled
(
ApplicationPackage
app
);
...
...
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
View file @
6b191841
...
...
@@ -17,6 +17,7 @@ import '../base/time.dart';
import
'../build_info.dart'
;
import
'../device.dart'
;
import
'../globals.dart'
;
import
'../project.dart'
;
import
'../vmservice.dart'
;
import
'fuchsia_sdk.dart'
;
...
...
@@ -302,6 +303,9 @@ class FuchsiaDevice extends Device {
}
FuchsiaIsolateDiscoveryProtocol
getIsolateDiscoveryProtocol
(
String
isolateName
)
=>
FuchsiaIsolateDiscoveryProtocol
(
this
,
isolateName
);
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
=>
true
;
}
class
FuchsiaIsolateDiscoveryProtocol
{
...
...
packages/flutter_tools/lib/src/ios/devices.dart
View file @
6b191841
...
...
@@ -17,6 +17,7 @@ import '../build_info.dart';
import
'../convert.dart'
;
import
'../device.dart'
;
import
'../globals.dart'
;
import
'../project.dart'
;
import
'../protocol_discovery.dart'
;
import
'code_signing.dart'
;
import
'ios_workflow.dart'
;
...
...
@@ -401,6 +402,11 @@ class IOSDevice extends Device {
Future
<
void
>
takeScreenshot
(
File
outputFile
)
async
{
await
iMobileDevice
.
takeScreenshot
(
outputFile
);
}
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
{
return
flutterProject
.
ios
.
existsSync
();
}
}
/// Decodes a vis-encoded syslog string to a UTF-8 representation.
...
...
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
6b191841
...
...
@@ -19,6 +19,7 @@ import '../bundle.dart' as bundle;
import
'../convert.dart'
;
import
'../device.dart'
;
import
'../globals.dart'
;
import
'../project.dart'
;
import
'../protocol_discovery.dart'
;
import
'ios_workflow.dart'
;
import
'mac.dart'
;
...
...
@@ -473,6 +474,11 @@ class IOSSimulator extends Device {
Future
<
void
>
takeScreenshot
(
File
outputFile
)
{
return
SimControl
.
instance
.
takeScreenshot
(
id
,
outputFile
.
path
);
}
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
{
return
flutterProject
.
ios
.
existsSync
();
}
}
/// Launches the device log reader process on the host.
...
...
packages/flutter_tools/lib/src/linux/linux_device.dart
View file @
6b191841
...
...
@@ -108,6 +108,11 @@ class LinuxDevice extends Device {
@override
Future
<
bool
>
uninstallApp
(
ApplicationPackage
app
)
async
=>
true
;
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
{
return
flutterProject
.
linux
.
existsSync
();
}
// Track the last built mode from startApp.
BuildMode
_lastBuiltMode
;
}
...
...
packages/flutter_tools/lib/src/macos/macos_device.dart
View file @
6b191841
...
...
@@ -117,6 +117,11 @@ class MacOSDevice extends Device {
// to uninstall the application.
@override
Future
<
bool
>
uninstallApp
(
ApplicationPackage
app
)
async
=>
true
;
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
{
return
flutterProject
.
macos
.
existsSync
();
}
}
class
MacOSDevices
extends
PollingDeviceDiscovery
{
...
...
packages/flutter_tools/lib/src/project.dart
View file @
6b191841
...
...
@@ -208,8 +208,6 @@ class IosProject {
Directory get _ephemeralDirectory => parent.directory.childDirectory('
.
ios
');
Directory get _editableDirectory => parent.directory.childDirectory('
ios
');
bool existsSync() => parent.isModule || _editableDirectory.existsSync();
/// This parent folder of `Runner.xcodeproj`.
Directory get hostAppRoot {
if (!isModule || _editableDirectory.existsSync())
...
...
@@ -264,6 +262,11 @@ class IosProject {
/// Xcode workspace shared workspace settings file for the host app.
File get xcodeWorkspaceSharedSettings => xcodeWorkspaceSharedData.childFile('
WorkspaceSettings
.
xcsettings
');
/// Whether the current flutter project has an iOS subproject.
bool existsSync() {
return parent.isModule || _editableDirectory.existsSync();
}
/// The product bundle identifier of the host app, or null if not set or if
/// iOS tooling needed to read it is not installed.
String get productBundleIdentifier {
...
...
@@ -391,8 +394,6 @@ class AndroidProject {
return
_ephemeralDirectory
;
}
bool
existsSync
()
=>
parent
.
isModule
||
_flutterLibGradleRoot
.
existsSync
();
/// The Gradle root directory of the Android wrapping of Flutter and plugins.
/// This is the same as [hostAppGradleRoot] except when the project is
/// a Flutter module with an editable host app.
...
...
@@ -420,6 +421,11 @@ class AndroidProject {
return
fs
.
directory
(
fs
.
path
.
join
(
hostAppGradleRoot
.
path
,
'app'
,
'build'
,
'outputs'
,
'bundle'
));
}
/// Whether the current flutter project has an Android sub-project.
bool
existsSync
()
{
return
parent
.
isModule
||
_editableHostAppDirectory
.
existsSync
();
}
bool
get
isUsingGradle
{
return
hostAppGradleRoot
.
childFile
(
'build.gradle'
).
existsSync
();
}
...
...
@@ -498,7 +504,10 @@ class WebProject {
final
FlutterProject
parent
;
bool
existsSync
()
=>
parent
.
directory
.
childDirectory
(
'web'
).
existsSync
();
/// Whether this flutter project has a web sub-project.
bool
existsSync
()
{
return
parent
.
directory
.
childDirectory
(
'web'
).
existsSync
();
}
Future
<
void
>
ensureReadyForPlatformSpecificTooling
()
async
{
/// Generate index.html in build/web. Eventually we could support
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
6b191841
...
...
@@ -52,6 +52,7 @@ class FlutterDevice {
/// Create a [FlutterDevice] with optional code generation enabled.
static
Future
<
FlutterDevice
>
create
(
Device
device
,
{
@required
FlutterProject
flutterProject
,
@required
bool
trackWidgetCreation
,
String
dillOutputPath
,
List
<
String
>
fileSystemRoots
,
...
...
@@ -64,7 +65,6 @@ class FlutterDevice {
@required
BuildMode
buildMode
,
})
async
{
ResidentCompiler
generator
;
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
if
(
flutterProject
.
hasBuilders
)
{
generator
=
await
CodeGeneratingResidentCompiler
.
create
(
flutterProject:
flutterProject
,
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
6b191841
...
...
@@ -527,6 +527,13 @@ abstract class FlutterCommand extends Command<void> {
}
devices
=
devices
.
where
((
Device
device
)
=>
device
.
isSupported
()).
toList
();
// If the user has not specified all devices and has multiple connected
// then filter then list by those supported in the current project. If
// this ends up with a single device we can proceed as normal.
if
(
devices
.
length
>
1
&&
!
deviceManager
.
hasSpecifiedAllDevices
&&
!
deviceManager
.
hasSpecifiedDeviceId
)
{
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
devices
.
removeWhere
((
Device
device
)
=>
!
device
.
isSupportedForProject
(
flutterProject
));
}
if
(
devices
.
isEmpty
)
{
printStatus
(
userMessages
.
flutterNoSupportedDevices
);
...
...
packages/flutter_tools/lib/src/tester/flutter_tester.dart
View file @
6b191841
...
...
@@ -18,6 +18,7 @@ import '../convert.dart';
import
'../dart/package_map.dart'
;
import
'../device.dart'
;
import
'../globals.dart'
;
import
'../project.dart'
;
import
'../protocol_discovery.dart'
;
import
'../version.dart'
;
...
...
@@ -192,6 +193,9 @@ class FlutterTesterDevice extends Device {
@override
Future
<
bool
>
uninstallApp
(
ApplicationPackage
app
)
async
=>
true
;
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
=>
true
;
}
class
FlutterTesterDevices
extends
PollingDeviceDiscovery
{
...
...
packages/flutter_tools/lib/src/web/web_device.dart
View file @
6b191841
...
...
@@ -166,6 +166,11 @@ class WebDevice extends Device {
await
request
.
response
.
addStream
(
file
.
openRead
());
await
request
.
response
.
close
();
}
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
{
return
flutterProject
.
web
.
existsSync
();
}
}
class
WebDevices
extends
PollingDeviceDiscovery
{
...
...
packages/flutter_tools/lib/src/windows/windows_device.dart
View file @
6b191841
...
...
@@ -114,6 +114,11 @@ class WindowsDevice extends Device {
// to uninstall the application.
@override
Future
<
bool
>
uninstallApp
(
ApplicationPackage
app
)
async
=>
true
;
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
{
return
flutterProject
.
windows
.
existsSync
();
}
}
class
WindowsDevices
extends
PollingDeviceDiscovery
{
...
...
packages/flutter_tools/test/android/android_device_test.dart
View file @
6b191841
...
...
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/android/android_sdk.dart';
import
'package:flutter_tools/src/base/config.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
...
...
@@ -157,6 +158,44 @@ Use the 'android' tool to install them:
ProcessManager:
()
=>
mockProcessManager
,
});
});
testUsingContext
(
'isSupportedForProject is true on module project'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
)
..
createSync
()
..
writeAsStringSync
(
r''
'
name: example
flutter:
module: {}
'''
);
fs
.
file
(
'.packages'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
AndroidDevice
(
'test'
).
isSupportedForProject
(
flutterProject
),
true
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
testUsingContext
(
'isSupportedForProject is true with editable host app'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
fs
.
directory
(
'android'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
AndroidDevice
(
'test'
).
isSupportedForProject
(
flutterProject
),
true
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
testUsingContext
(
'isSupportedForProject is false with no host app and no module'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
AndroidDevice
(
'test'
).
isSupportedForProject
(
flutterProject
),
false
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
...
...
packages/flutter_tools/test/fuchsia/fuchsa_device_test.dart
View file @
6b191841
...
...
@@ -53,6 +53,7 @@ void main() {
expect
(
device
.
supportsHotReload
,
true
);
expect
(
device
.
supportsHotRestart
,
false
);
expect
(
device
.
supportsStopApp
,
false
);
expect
(
device
.
isSupportedForProject
(
null
),
true
);
expect
(
await
device
.
stopApp
(
null
),
false
);
});
});
...
...
packages/flutter_tools/test/ios/devices_test.dart
View file @
6b191841
...
...
@@ -5,12 +5,14 @@
import
'dart:async'
;
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/application_package.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/ios/devices.dart'
;
import
'package:flutter_tools/src/ios/mac.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:platform/platform.dart'
;
import
'package:process/process.dart'
;
...
...
@@ -183,4 +185,42 @@ f577a7903cc54959be2e34bc4f7f80b7009efcf4
IMobileDevice:
()
=>
mockIMobileDevice
,
});
});
testUsingContext
(
'IOSDevice.isSupportedForProject is true on module project'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
)
..
createSync
()
..
writeAsStringSync
(
r''
'
name: example
flutter:
module: {}
'''
);
fs
.
file
(
'.packages'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
IOSDevice
(
'test'
).
isSupportedForProject
(
flutterProject
),
true
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
testUsingContext
(
'IOSDevice.isSupportedForProject is true with editable host app'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
fs
.
directory
(
'ios'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
IOSDevice
(
'test'
).
isSupportedForProject
(
flutterProject
),
true
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
testUsingContext
(
'IOSDevice.isSupportedForProject is false with no host app and no module'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
IOSDevice
(
'test'
).
isSupportedForProject
(
flutterProject
),
false
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
}
packages/flutter_tools/test/ios/simulators_test.dart
View file @
6b191841
...
...
@@ -6,11 +6,13 @@ import 'dart:async';
import
'dart:io'
show
ProcessResult
,
Process
;
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/application_package.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/ios/mac.dart'
;
import
'package:flutter_tools/src/ios/simulators.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:platform/platform.dart'
;
import
'package:process/process.dart'
;
...
...
@@ -414,4 +416,42 @@ void main() {
SimControl:
()
=>
simControl
,
});
});
testUsingContext
(
'IOSDevice.isSupportedForProject is true on module project'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
)
..
createSync
()
..
writeAsStringSync
(
r''
'
name: example
flutter:
module: {}
'''
);
fs
.
file
(
'.packages'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
IOSSimulator
(
'test'
).
isSupportedForProject
(
flutterProject
),
true
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
testUsingContext
(
'IOSDevice.isSupportedForProject is true with editable host app'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
fs
.
directory
(
'ios'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
IOSSimulator
(
'test'
).
isSupportedForProject
(
flutterProject
),
true
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
testUsingContext
(
'IOSDevice.isSupportedForProject is false with no host app and no module'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
IOSSimulator
(
'test'
).
isSupportedForProject
(
flutterProject
),
false
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
}
packages/flutter_tools/test/linux/linux_device_test.dart
View file @
6b191841
...
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
...
...
@@ -9,6 +10,7 @@ import 'package:flutter_tools/src/build_info.dart';
import
'package:flutter_tools/src/linux/application_package.dart'
;
import
'package:flutter_tools/src/linux/linux_device.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
...
...
@@ -59,6 +61,27 @@ void main() {
Platform:
()
=>
notLinux
,
});
});
testUsingContext
(
'LinuxDevice.isSupportedForProject is true with editable host app'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
fs
.
directory
(
'linux'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
LinuxDevice
().
isSupportedForProject
(
flutterProject
),
true
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
testUsingContext
(
'LinuxDevice.isSupportedForProject is false with no host app'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
LinuxDevice
().
isSupportedForProject
(
flutterProject
),
false
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
}
class
MockPlatform
extends
Mock
implements
Platform
{}
...
...
packages/flutter_tools/test/macos/macos_device_test.dart
View file @
6b191841
...
...
@@ -4,7 +4,9 @@
import
'dart:convert'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/context.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
...
...
@@ -106,6 +108,27 @@ tester 17193 0.0 0.2 4791128 37820 ?? S 2:27PM 0:00.09 /Applica
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
notMac
,
});
testUsingContext
(
'isSupportedForProject is true with editable host app'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
fs
.
directory
(
'macos'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
MacOSDevice
().
isSupportedForProject
(
flutterProject
),
true
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
testUsingContext
(
'isSupportedForProject is false with no host app'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
MacOSDevice
().
isSupportedForProject
(
flutterProject
),
false
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
});
}
...
...
packages/flutter_tools/test/src/mocks.dart
View file @
6b191841
...
...
@@ -379,6 +379,9 @@ class MockAndroidDevice extends Mock implements AndroidDevice {
@override
bool
isSupported
()
=>
true
;
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
=>
true
;
}
class
MockIOSDevice
extends
Mock
implements
IOSDevice
{
...
...
@@ -387,6 +390,9 @@ class MockIOSDevice extends Mock implements IOSDevice {
@override
bool
isSupported
()
=>
true
;
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
=>
true
;
}
class
MockIOSSimulator
extends
Mock
implements
IOSSimulator
{
...
...
@@ -395,6 +401,9 @@ class MockIOSSimulator extends Mock implements IOSSimulator {
@override
bool
isSupported
()
=>
true
;
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
=>
true
;
}
class
MockDeviceLogReader
extends
DeviceLogReader
{
...
...
packages/flutter_tools/test/windows/windows_device_test.dart
View file @
6b191841
...
...
@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/windows/application_package.dart'
;
import
'package:flutter_tools/src/windows/windows_device.dart'
;
import
'package:flutter_tools/src/device.dart'
;
...
...
@@ -58,6 +60,27 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
notWindows
,
});
testUsingContext
(
'isSupportedForProject is true with editable host app'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
fs
.
directory
(
'windows'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
WindowsDevice
().
isSupportedForProject
(
flutterProject
),
true
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
testUsingContext
(
'isSupportedForProject is false with no host app'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
WindowsDevice
().
isSupportedForProject
(
flutterProject
),
false
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
});
}
...
...
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