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
d07ca929
Commit
d07ca929
authored
Sep 30, 2015
by
Ian Fischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic sky_tools list command, Android implementation, and test.
parent
b8085cd0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
131 additions
and
7 deletions
+131
-7
sky_tools.dart
packages/flutter_tools/bin/sky_tools.dart
+2
-0
device.dart
packages/flutter_tools/lib/src/device.dart
+50
-3
list.dart
packages/flutter_tools/lib/src/list.dart
+45
-0
trace.dart
packages/flutter_tools/lib/src/trace.dart
+1
-1
android_device_test.dart
packages/flutter_tools/test/android_device_test.dart
+3
-3
list_test.dart
packages/flutter_tools/test/list_test.dart
+30
-0
No files found.
packages/flutter_tools/bin/sky_tools.dart
View file @
d07ca929
...
...
@@ -13,6 +13,7 @@ import 'package:sky_tools/src/build.dart';
import
'package:sky_tools/src/cache.dart'
;
import
'package:sky_tools/src/init.dart'
;
import
'package:sky_tools/src/install.dart'
;
import
'package:sky_tools/src/list.dart'
;
import
'package:sky_tools/src/listen.dart'
;
import
'package:sky_tools/src/logs.dart'
;
import
'package:sky_tools/src/run_mojo.dart'
;
...
...
@@ -151,6 +152,7 @@ void main(List<String> args) {
..
addCommand
(
new
CacheCommand
())
..
addCommand
(
new
InitCommand
())
..
addCommand
(
new
InstallCommand
())
..
addCommand
(
new
ListCommand
())
..
addCommand
(
new
ListenCommand
())
..
addCommand
(
new
LogsCommand
())
..
addCommand
(
new
RunMojoCommand
())
...
...
packages/flutter_tools/lib/src/device.dart
View file @
d07ca929
...
...
@@ -60,13 +60,60 @@ class AndroidDevice extends _Device {
static
const
String
className
=
'AndroidDevice'
;
static
final
String
defaultDeviceID
=
'default'
;
String
productID
;
String
modelID
;
String
deviceCodeName
;
String
_adbPath
;
String
get
adbPath
=>
_adbPath
;
bool
_hasAdb
=
false
;
bool
_hasValidAndroid
=
false
;
factory
AndroidDevice
([
String
id
=
null
])
{
return
new
_Device
(
className
,
id
);
factory
AndroidDevice
(
{
String
id:
null
,
String
productID:
null
,
String
modelID:
null
,
String
deviceCodeName:
null
})
{
AndroidDevice
device
=
new
_Device
(
className
,
id
);
device
.
productID
=
productID
;
device
.
modelID
=
modelID
;
device
.
deviceCodeName
=
deviceCodeName
;
return
device
;
}
/// mockAndroid argument is only to facilitate testing with mocks, so that
/// we don't have to rely on the test setup having adb available to it.
static
List
<
AndroidDevice
>
getAttachedDevices
([
AndroidDevice
mockAndroid
])
{
List
<
AndroidDevice
>
devices
=
[];
String
adbPath
=
_getAdbPath
();
if
(
mockAndroid
!=
null
)
{
adbPath
=
mockAndroid
.
adbPath
;
}
List
<
String
>
output
=
runSync
([
adbPath
,
'devices'
,
'-l'
]).
trim
().
split
(
'
\n
'
);
RegExp
deviceInfo
=
new
RegExp
(
r'^(\S+)\s+device\s+\S+\s+product:(\S+)\s+model:(\S+)\s+device:(\S+)$'
);
// Skip first line, which is always 'List of devices attached'.
for
(
String
line
in
output
.
skip
(
1
))
{
Match
match
=
deviceInfo
.
firstMatch
(
line
);
if
(
match
!=
null
)
{
String
deviceID
=
match
[
1
];
String
productID
=
match
[
2
];
String
modelID
=
match
[
3
];
String
deviceCodeName
=
match
[
4
];
devices
.
add
(
new
AndroidDevice
(
id:
deviceID
,
productID:
productID
,
modelID:
modelID
,
deviceCodeName:
deviceCodeName
));
}
else
{
_logging
.
warning
(
'Unexpected failure parsing device information '
'from adb output:
\n
$line
\n
'
'Please report a bug at http://flutter.io/'
);
}
}
return
devices
;
}
AndroidDevice
.
_
(
id
)
:
super
.
_
(
id
)
{
...
...
@@ -83,7 +130,7 @@ class AndroidDevice extends _Device {
}
}
String
_getAdbPath
()
{
static
String
_getAdbPath
()
{
if
(
Platform
.
environment
.
containsKey
(
'ANDROID_HOME'
))
{
String
androidHomeDir
=
Platform
.
environment
[
'ANDROID_HOME'
];
String
adbPath1
=
...
...
packages/flutter_tools/lib/src/list.dart
0 → 100644
View file @
d07ca929
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library
sky_tools
.
list
;
import
'dart:async'
;
import
'package:args/command_runner.dart'
;
import
'package:logging/logging.dart'
;
import
'package:sky_tools/src/device.dart'
;
final
Logger
_logging
=
new
Logger
(
'sky_tools.list'
);
class
ListCommand
extends
Command
{
final
name
=
'list'
;
final
description
=
'List all connected devices.'
;
AndroidDevice
android
;
ListCommand
([
this
.
android
])
{
argParser
.
addFlag
(
'details'
,
abbr:
'd'
,
negatable:
false
,
help:
'Log additional details about attached devices.'
);
}
@override
Future
<
int
>
run
()
async
{
bool
details
=
argResults
[
'details'
];
if
(
details
)
{
print
(
'Android Devices:'
);
}
for
(
AndroidDevice
device
in
AndroidDevice
.
getAttachedDevices
(
android
))
{
if
(
details
)
{
print
(
'
${device.id}
\t
'
'
${device.modelID}
\t
'
'
${device.productID}
\t
'
'
${device.deviceCodeName}
'
);
}
else
{
print
(
device
.
id
);
}
}
return
0
;
}
}
packages/flutter_tools/lib/src/trace.dart
View file @
d07ca929
...
...
@@ -63,7 +63,7 @@ class TraceCommand extends Command {
if
(
tracePath
==
null
)
{
_logging
.
warning
(
'No trace file saved.'
);
}
else
{
_logging
.
warning
(
'Trace file saved to
$tracePath
'
);
print
(
'Trace file saved to
$tracePath
'
);
}
}
}
packages/flutter_tools/test/android_device_test.dart
View file @
d07ca929
...
...
@@ -18,14 +18,14 @@ defineTests() {
test
(
'stores the requested id'
,
()
{
String
deviceID
=
'1234'
;
AndroidDevice
android
=
new
AndroidDevice
(
deviceID
);
AndroidDevice
android
=
new
AndroidDevice
(
id:
deviceID
);
expect
(
android
.
id
,
equals
(
deviceID
));
});
test
(
'correctly creates only one of each requested device id'
,
()
{
String
deviceID
=
'1234'
;
AndroidDevice
a1
=
new
AndroidDevice
(
deviceID
);
AndroidDevice
a2
=
new
AndroidDevice
(
deviceID
);
AndroidDevice
a1
=
new
AndroidDevice
(
id:
deviceID
);
AndroidDevice
a2
=
new
AndroidDevice
(
id:
deviceID
);
expect
(
a1
,
equals
(
a2
));
});
});
...
...
packages/flutter_tools/test/list_test.dart
0 → 100644
View file @
d07ca929
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library
list_test
;
import
'package:args/command_runner.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:sky_tools/src/list.dart'
;
import
'package:test/test.dart'
;
import
'src/common.dart'
;
main
()
=>
defineTests
();
defineTests
()
{
group
(
'list'
,
()
{
test
(
'returns 0 when called'
,
()
{
MockAndroidDevice
android
=
new
MockAndroidDevice
();
// Avoid relying on adb being installed on the test system.
// Instead, cause the test to run the echo command.
when
(
android
.
adbPath
).
thenReturn
(
'echo'
);
ListCommand
command
=
new
ListCommand
(
android
);
CommandRunner
runner
=
new
CommandRunner
(
'test_flutter'
,
''
)
..
addCommand
(
command
);
runner
.
run
([
'list'
]).
then
((
int
code
)
=>
expect
(
code
,
equals
(
0
)));
});
});
}
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