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
022047f5
Commit
022047f5
authored
Feb 26, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove the isConnected() method from device
parent
240e499b
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
19 additions
and
82 deletions
+19
-82
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+4
-28
apk.dart
packages/flutter_tools/lib/src/commands/apk.dart
+1
-1
daemon.dart
packages/flutter_tools/lib/src/commands/daemon.dart
+1
-1
install.dart
packages/flutter_tools/lib/src/commands/install.dart
+1
-1
refresh.dart
packages/flutter_tools/lib/src/commands/refresh.dart
+1
-1
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+4
-3
stop.dart
packages/flutter_tools/lib/src/commands/stop.dart
+1
-1
trace.dart
packages/flutter_tools/lib/src/commands/trace.dart
+1
-1
device.dart
packages/flutter_tools/lib/src/device.dart
+0
-3
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+0
-6
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+0
-8
daemon_test.dart
packages/flutter_tools/test/daemon_test.dart
+0
-5
install_test.dart
packages/flutter_tools/test/install_test.dart
+0
-6
context.dart
packages/flutter_tools/test/src/context.dart
+5
-2
stop_test.dart
packages/flutter_tools/test/stop_test.dart
+0
-10
trace_test.dart
packages/flutter_tools/test/trace_test.dart
+0
-5
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
022047f5
...
...
@@ -41,19 +41,13 @@ class AndroidDevice extends Device {
String
id
,
{
this
.
productID
,
this
.
modelID
,
this
.
deviceCodeName
,
bool
connected
})
:
super
(
id
)
{
if
(
connected
!=
null
)
_connected
=
connected
;
}
this
.
deviceCodeName
})
:
super
(
id
);
final
String
productID
;
final
String
modelID
;
final
String
deviceCodeName
;
bool
_connected
;
bool
get
isLocalEmulator
=>
false
;
List
<
String
>
adbCommandForDevice
(
List
<
String
>
args
)
{
...
...
@@ -152,9 +146,6 @@ class AndroidDevice extends Device {
@override
bool
isAppInstalled
(
ApplicationPackage
app
)
{
if
(!
isConnected
())
return
false
;
if
(
runCheckedSync
(
adbCommandForDevice
(<
String
>[
'shell'
,
'pm'
,
'path'
,
app
.
id
]))
==
''
)
{
printTrace
(
'TODO(iansf): move this log to the caller.
${app.name}
is not on the device. Installing now...'
);
return
false
;
...
...
@@ -169,11 +160,6 @@ class AndroidDevice extends Device {
@override
bool
installApp
(
ApplicationPackage
app
)
{
if
(!
isConnected
())
{
printTrace
(
'Android device not connected. Not installing.'
);
return
false
;
}
if
(!
FileSystemEntity
.
isFileSync
(
app
.
localPath
))
{
printError
(
'"
${app.localPath}
" does not exist.'
);
return
false
;
...
...
@@ -390,14 +376,8 @@ class AndroidDevice extends Device {
return
null
;
}
bool
isConnected
()
=>
_connected
??
androidSdk
!=
null
;
bool
isSupported
()
=>
true
;
void
setConnected
(
bool
value
)
{
_connected
=
value
;
}
Future
<
bool
>
refreshSnapshot
(
AndroidApk
apk
,
String
snapshotPath
)
async
{
if
(!
FileSystemEntity
.
isFileSync
(
snapshotPath
))
{
printError
(
'Cannot find
$snapshotPath
'
);
...
...
@@ -462,13 +442,12 @@ List<AndroidDevice> getAdbDevices() {
deviceID
,
productID:
productID
,
modelID:
modelID
,
deviceCodeName:
deviceCodeName
,
connected:
true
deviceCodeName:
deviceCodeName
));
}
else
if
(
deviceRegex2
.
hasMatch
(
line
))
{
Match
match
=
deviceRegex2
.
firstMatch
(
line
);
String
deviceID
=
match
[
1
];
devices
.
add
(
new
AndroidDevice
(
deviceID
,
connected:
true
));
devices
.
add
(
new
AndroidDevice
(
deviceID
));
}
else
if
(
unauthorizedRegex
.
hasMatch
(
line
))
{
Match
match
=
unauthorizedRegex
.
firstMatch
(
line
);
String
deviceID
=
match
[
1
];
...
...
@@ -499,9 +478,6 @@ class _AdbLogReader extends DeviceLogReader {
String
get
name
=>
device
.
name
;
Future
<
int
>
logs
({
bool
clear:
false
,
bool
showPrefix:
false
})
async
{
if
(!
device
.
isConnected
())
return
2
;
if
(
clear
)
device
.
clearLogs
();
...
...
packages/flutter_tools/lib/src/commands/apk.dart
View file @
022047f5
...
...
@@ -430,7 +430,7 @@ Future<int> buildAll(
})
async
{
for
(
Device
device
in
devices
.
all
)
{
ApplicationPackage
package
=
applicationPackages
.
getPackageForPlatform
(
device
.
platform
);
if
(
package
==
null
||
!
device
.
isConnected
()
)
if
(
package
==
null
)
continue
;
// TODO(mpcomplete): Temporary hack. We only support the apk builder atm.
...
...
packages/flutter_tools/lib/src/commands/daemon.dart
View file @
022047f5
...
...
@@ -347,7 +347,7 @@ Map<String, dynamic> _deviceToMap(Device device) {
'id'
:
device
.
id
,
'name'
:
device
.
name
,
'platform'
:
_enumToString
(
device
.
platform
),
'available'
:
device
.
isConnected
()
'available'
:
true
};
}
...
...
packages/flutter_tools/lib/src/commands/install.dart
View file @
022047f5
...
...
@@ -30,7 +30,7 @@ Future<bool> installApp(
for
(
Device
device
in
devices
.
all
)
{
ApplicationPackage
package
=
applicationPackages
.
getPackageForPlatform
(
device
.
platform
);
if
(
package
==
null
||
!
device
.
isConnected
()
||
device
.
isAppInstalled
(
package
))
if
(
package
==
null
||
device
.
isAppInstalled
(
package
))
continue
;
if
(
device
.
installApp
(
package
))
installedSomewhere
=
true
;
...
...
packages/flutter_tools/lib/src/commands/refresh.dart
View file @
022047f5
...
...
@@ -36,7 +36,7 @@ class RefreshCommand extends FlutterCommand {
downloadApplicationPackagesAndConnectToDevices
(),
],
eagerError:
true
);
if
(
devices
.
android
==
null
||
!
devices
.
android
.
isConnected
()
)
{
if
(
devices
.
android
==
null
)
{
printError
(
'No device connected.'
);
return
1
;
}
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
022047f5
...
...
@@ -185,7 +185,7 @@ Future<int> startApp(
for
(
Device
device
in
devices
.
all
)
{
ApplicationPackage
package
=
applicationPackages
.
getPackageForPlatform
(
device
.
platform
);
if
(
package
==
null
||
!
device
.
isConnected
()
)
if
(
package
==
null
)
continue
;
if
(!
device
.
isSupported
())
{
...
...
@@ -230,13 +230,14 @@ Future<int> startApp(
}
if
(!
startedSomething
)
{
int
connected
=
devices
.
all
.
where
((
device
)
=>
device
.
isConnected
()).
length
;
String
message
=
'Unable to run application'
;
if
(
connected
==
0
)
{
if
(
devices
.
all
.
isEmpty
)
{
message
+=
' - no connected devices.'
;
}
else
if
(
unsupportedCount
!=
0
)
{
message
+=
' -
$unsupportedCount
unsupported
${pluralize('device', unsupportedCount)}
connected'
;
}
printError
(
message
);
}
...
...
packages/flutter_tools/lib/src/commands/stop.dart
View file @
022047f5
...
...
@@ -26,7 +26,7 @@ Future<bool> stopAll(DeviceStore devices, ApplicationPackageStore applicationPac
for
(
Device
device
in
devices
.
all
)
{
ApplicationPackage
package
=
applicationPackages
.
getPackageForPlatform
(
device
.
platform
);
if
(
package
==
null
||
!
device
.
isConnected
()
)
if
(
package
==
null
)
continue
;
if
(
await
device
.
stopApp
(
package
))
stoppedSomething
=
true
;
...
...
packages/flutter_tools/lib/src/commands/trace.dart
View file @
022047f5
...
...
@@ -33,7 +33,7 @@ class TraceCommand extends FlutterCommand {
Future
<
int
>
runInProject
()
async
{
await
downloadApplicationPackagesAndConnectToDevices
();
if
(
devices
.
android
==
null
||
!
devices
.
android
.
isConnected
()
)
{
if
(
devices
.
android
==
null
)
{
printError
(
'No device connected, so no trace was completed.'
);
return
1
;
}
...
...
packages/flutter_tools/lib/src/device.dart
View file @
022047f5
...
...
@@ -136,9 +136,6 @@ abstract class Device {
/// Install an app package on the current device
bool
installApp
(
ApplicationPackage
app
);
/// Check if the device is currently connected
bool
isConnected
();
/// Check if the device is supported by Flutter
bool
isSupported
();
...
...
packages/flutter_tools/lib/src/ios/devices.dart
View file @
022047f5
...
...
@@ -125,9 +125,6 @@ class IOSDevice extends Device {
return
false
;
}
@override
bool
isConnected
()
=>
_getAttachedDeviceIDs
().
contains
(
id
);
@override
bool
isSupported
()
=>
true
;
...
...
@@ -235,9 +232,6 @@ class _IOSDeviceLogReader extends DeviceLogReader {
// TODO(devoncarew): Support [clear].
Future
<
int
>
logs
({
bool
clear:
false
,
bool
showPrefix:
false
})
async
{
if
(!
device
.
isConnected
())
return
2
;
return
await
runCommandAndStreamOutput
(
<
String
>[
device
.
loggerPath
],
prefix:
showPrefix
?
'[
$name
] '
:
''
,
...
...
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
022047f5
...
...
@@ -229,9 +229,6 @@ class IOSSimulator extends Device {
@override
bool
installApp
(
ApplicationPackage
app
)
{
if
(!
isConnected
())
return
false
;
try
{
SimControl
.
instance
.
install
(
id
,
app
.
localPath
);
return
true
;
...
...
@@ -240,8 +237,6 @@ class IOSSimulator extends Device {
}
}
bool
isConnected
()
=>
Platform
.
isMacOS
;
@override
bool
isSupported
()
{
if
(!
Platform
.
isMacOS
)
{
...
...
@@ -419,9 +414,6 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
String
get
name
=>
device
.
name
;
Future
<
int
>
logs
({
bool
clear:
false
,
bool
showPrefix:
false
})
async
{
if
(!
device
.
isConnected
())
return
2
;
if
(
clear
)
device
.
clearLogs
();
...
...
packages/flutter_tools/test/daemon_test.dart
View file @
022047f5
...
...
@@ -112,13 +112,8 @@ defineTests() {
MockDeviceStore
mockDevices
=
command
.
devices
;
when
(
mockDevices
.
android
.
isConnected
()).
thenReturn
(
true
);
when
(
mockDevices
.
android
.
stopApp
(
any
)).
thenReturn
(
true
);
when
(
mockDevices
.
iOS
.
isConnected
()).
thenReturn
(
false
);
when
(
mockDevices
.
iOS
.
stopApp
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
iOSSimulator
.
isConnected
()).
thenReturn
(
false
);
when
(
mockDevices
.
iOSSimulator
.
stopApp
(
any
)).
thenReturn
(
false
);
commands
.
add
({
'id'
:
0
,
'method'
:
'app.stopAll'
});
...
...
packages/flutter_tools/test/install_test.dart
View file @
022047f5
...
...
@@ -19,15 +19,12 @@ defineTests() {
applyMocksToCommand
(
command
);
MockDeviceStore
mockDevices
=
command
.
devices
;
when
(
mockDevices
.
android
.
isConnected
()).
thenReturn
(
true
);
when
(
mockDevices
.
android
.
isAppInstalled
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
android
.
installApp
(
any
)).
thenReturn
(
true
);
when
(
mockDevices
.
iOS
.
isConnected
()).
thenReturn
(
false
);
when
(
mockDevices
.
iOS
.
isAppInstalled
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
iOS
.
installApp
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
iOSSimulator
.
isConnected
()).
thenReturn
(
false
);
when
(
mockDevices
.
iOSSimulator
.
isAppInstalled
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
iOSSimulator
.
installApp
(
any
)).
thenReturn
(
false
);
...
...
@@ -43,15 +40,12 @@ defineTests() {
applyMocksToCommand
(
command
);
MockDeviceStore
mockDevices
=
command
.
devices
;
when
(
mockDevices
.
android
.
isConnected
()).
thenReturn
(
false
);
when
(
mockDevices
.
android
.
isAppInstalled
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
android
.
installApp
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
iOS
.
isConnected
()).
thenReturn
(
true
);
when
(
mockDevices
.
iOS
.
isAppInstalled
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
iOS
.
installApp
(
any
)).
thenReturn
(
true
);
when
(
mockDevices
.
iOSSimulator
.
isConnected
()).
thenReturn
(
false
);
when
(
mockDevices
.
iOSSimulator
.
isAppInstalled
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
iOSSimulator
.
installApp
(
any
)).
thenReturn
(
false
);
...
...
packages/flutter_tools/test/src/context.dart
View file @
022047f5
...
...
@@ -48,8 +48,11 @@ void testUsingContext(String description, dynamic testMethod(), {
if
(!
overrides
.
containsKey
(
OperatingSystemUtils
))
testContext
[
OperatingSystemUtils
]
=
new
MockOperatingSystemUtils
();
if
(!
overrides
.
containsKey
(
IOSSimulatorUtils
))
testContext
[
IOSSimulatorUtils
]
=
new
MockIOSSimulatorUtils
();
if
(!
overrides
.
containsKey
(
IOSSimulatorUtils
))
{
MockIOSSimulatorUtils
mock
=
new
MockIOSSimulatorUtils
();
when
(
mock
.
getAttachedDevices
()).
thenReturn
(<
IOSSimulator
>[]);
testContext
[
IOSSimulatorUtils
]
=
mock
;
}
if
(
Platform
.
isMacOS
)
{
if
(!
overrides
.
containsKey
(
XCode
))
...
...
packages/flutter_tools/test/stop_test.dart
View file @
022047f5
...
...
@@ -19,13 +19,8 @@ defineTests() {
applyMocksToCommand
(
command
);
MockDeviceStore
mockDevices
=
command
.
devices
;
when
(
mockDevices
.
android
.
isConnected
()).
thenReturn
(
true
);
when
(
mockDevices
.
android
.
stopApp
(
any
)).
thenReturn
(
true
);
when
(
mockDevices
.
iOS
.
isConnected
()).
thenReturn
(
false
);
when
(
mockDevices
.
iOS
.
stopApp
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
iOSSimulator
.
isConnected
()).
thenReturn
(
false
);
when
(
mockDevices
.
iOSSimulator
.
stopApp
(
any
)).
thenReturn
(
false
);
return
createTestCommandRunner
(
command
).
run
([
'stop'
]).
then
((
int
code
)
{
...
...
@@ -38,13 +33,8 @@ defineTests() {
applyMocksToCommand
(
command
);
MockDeviceStore
mockDevices
=
command
.
devices
;
when
(
mockDevices
.
android
.
isConnected
()).
thenReturn
(
false
);
when
(
mockDevices
.
android
.
stopApp
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
iOS
.
isConnected
()).
thenReturn
(
true
);
when
(
mockDevices
.
iOS
.
stopApp
(
any
)).
thenReturn
(
true
);
when
(
mockDevices
.
iOSSimulator
.
isConnected
()).
thenReturn
(
false
);
when
(
mockDevices
.
iOSSimulator
.
stopApp
(
any
)).
thenReturn
(
false
);
return
createTestCommandRunner
(
command
).
run
([
'stop'
]).
then
((
int
code
)
{
...
...
packages/flutter_tools/test/trace_test.dart
View file @
022047f5
...
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import
'package:flutter_tools/src/commands/trace.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:test/test.dart'
;
import
'src/common.dart'
;
...
...
@@ -17,10 +16,6 @@ defineTests() {
testUsingContext
(
'returns 1 when no Android device is connected'
,
()
{
TraceCommand
command
=
new
TraceCommand
();
applyMocksToCommand
(
command
);
MockDeviceStore
mockDevices
=
command
.
devices
;
when
(
mockDevices
.
android
.
isConnected
()).
thenReturn
(
false
);
return
createTestCommandRunner
(
command
).
run
([
'trace'
]).
then
((
int
code
)
{
expect
(
code
,
equals
(
1
));
});
...
...
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