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
8283ce87
Commit
8283ce87
authored
Mar 03, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the stop command tests
parent
932b09c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
33 deletions
+26
-33
daemon.dart
packages/flutter_tools/lib/src/commands/daemon.dart
+10
-10
daemon_test.dart
packages/flutter_tools/test/daemon_test.dart
+3
-10
context.dart
packages/flutter_tools/test/src/context.dart
+5
-2
stop_test.dart
packages/flutter_tools/test/stop_test.dart
+8
-11
No files found.
packages/flutter_tools/lib/src/commands/daemon.dart
View file @
8283ce87
...
...
@@ -236,17 +236,17 @@ class AppDomain extends Domain {
}
Future
<
dynamic
>
start
(
Map
<
String
,
dynamic
>
args
)
async
{
if
(
args
[
'deviceId'
]
is
!
String
)
throw
"
A 'deviceId'
is required"
;
if
(
args
==
null
||
args
[
'deviceId'
]
is
!
String
)
throw
"
deviceId
is required"
;
Device
device
=
await
_getDevice
(
args
[
'deviceId'
]);
if
(
device
==
null
)
throw
"
A 'projectDirectory' is require
d"
;
throw
"
device '
${args['deviceId']}
' not foun
d"
;
if
(
args
[
'projectDirectory'
]
is
!
String
)
throw
"
A 'projectDirectory'
is required"
;
throw
"
projectDirectory
is required"
;
String
projectDirectory
=
args
[
'projectDirectory'
];
if
(!
FileSystemEntity
.
isDirectorySync
(
projectDirectory
))
throw
"
The
'
$projectDirectory
' does not exist"
;
throw
"'
$projectDirectory
' does not exist"
;
// We change the current working directory for the duration of the `start` command.
// TODO(devoncarew): Make flutter_tools work better with commands run from any directory.
...
...
@@ -280,17 +280,17 @@ class AppDomain extends Domain {
}
Future
<
bool
>
stop
(
dynamic
args
)
async
{
if
(
args
[
'deviceId'
]
is
!
String
)
throw
"
A 'deviceId'
is required"
;
if
(
args
==
null
||
args
[
'deviceId'
]
is
!
String
)
throw
"
deviceId
is required"
;
Device
device
=
await
_getDevice
(
args
[
'deviceId'
]);
if
(
device
==
null
)
throw
"
A 'projectDirectory' is require
d"
;
throw
"
device '
${args['deviceId']}
' not foun
d"
;
if
(
args
[
'projectDirectory'
]
is
!
String
)
throw
"
A 'projectDirectory'
is required"
;
throw
"
projectDirectory
is required"
;
String
projectDirectory
=
args
[
'projectDirectory'
];
if
(!
FileSystemEntity
.
isDirectorySync
(
projectDirectory
))
throw
"
The
'
$projectDirectory
' does not exist"
;
throw
"'
$projectDirectory
' does not exist"
;
Directory
cwd
=
Directory
.
current
;
Directory
.
current
=
new
Directory
(
projectDirectory
);
...
...
packages/flutter_tools/test/daemon_test.dart
View file @
8283ce87
...
...
@@ -12,7 +12,6 @@ import 'package:flutter_tools/src/device.dart';
import
'package:flutter_tools/src/doctor.dart'
;
import
'package:flutter_tools/src/globals.dart'
;
import
'package:flutter_tools/src/ios/mac.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:test/test.dart'
;
import
'src/context.dart'
;
...
...
@@ -97,7 +96,7 @@ defineTests() {
});
});
_testUsingContext
(
'daemon.stop
All
'
,
()
async
{
_testUsingContext
(
'daemon.stop'
,
()
async
{
DaemonCommand
command
=
new
DaemonCommand
();
applyMocksToCommand
(
command
);
...
...
@@ -110,16 +109,10 @@ defineTests() {
notifyingLogger:
notifyingLogger
);
MockDeviceStore
mockDevices
=
command
.
devices
;
when
(
mockDevices
.
android
.
stopApp
(
any
)).
thenReturn
(
true
);
when
(
mockDevices
.
iOS
.
stopApp
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
iOSSimulator
.
stopApp
(
any
)).
thenReturn
(
false
);
commands
.
add
({
'id'
:
0
,
'method'
:
'app.stopAll'
});
commands
.
add
(<
String
,
dynamic
>{
'id'
:
0
,
'method'
:
'app.stop'
});
Map
response
=
await
responses
.
stream
.
where
(
_notEvent
).
first
;
expect
(
response
[
'id'
],
0
);
expect
(
response
[
'
result'
],
true
);
expect
(
response
[
'
error'
],
contains
(
'deviceId is required'
)
);
});
_testUsingContext
(
'device.getDevices'
,
()
async
{
...
...
packages/flutter_tools/test/src/context.dart
View file @
8283ce87
...
...
@@ -45,8 +45,11 @@ void testUsingContext(String description, dynamic testMethod(), {
if
(!
overrides
.
containsKey
(
SimControl
))
testContext
[
SimControl
]
=
new
MockSimControl
();
if
(!
overrides
.
containsKey
(
OperatingSystemUtils
))
testContext
[
OperatingSystemUtils
]
=
new
MockOperatingSystemUtils
();
if
(!
overrides
.
containsKey
(
OperatingSystemUtils
))
{
MockOperatingSystemUtils
os
=
new
MockOperatingSystemUtils
();
when
(
os
.
isWindows
).
thenReturn
(
false
);
testContext
[
OperatingSystemUtils
]
=
os
;
}
if
(!
overrides
.
containsKey
(
IOSSimulatorUtils
))
{
MockIOSSimulatorUtils
mock
=
new
MockIOSSimulatorUtils
();
...
...
packages/flutter_tools/test/stop_test.dart
View file @
8283ce87
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:flutter_tools/src/commands/stop.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:test/test.dart'
;
...
...
@@ -17,12 +19,9 @@ defineTests() {
testUsingContext
(
'returns 0 when Android is connected and ready to be stopped'
,
()
{
StopCommand
command
=
new
StopCommand
();
applyMocksToCommand
(
command
);
MockDeviceStore
mockDevices
=
command
.
devices
;
when
(
mockDevices
.
android
.
stopApp
(
any
)).
thenReturn
(
true
);
when
(
mockDevices
.
iOS
.
stopApp
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
iOSSimulator
.
stopApp
(
any
)).
thenReturn
(
false
);
MockAndroidDevice
device
=
new
MockAndroidDevice
();
when
(
device
.
stopApp
(
any
)).
thenReturn
(
new
Future
.
value
(
true
));
testDeviceManager
.
addDevice
(
device
);
return
createTestCommandRunner
(
command
).
run
([
'stop'
]).
then
((
int
code
)
{
expect
(
code
,
equals
(
0
));
});
...
...
@@ -31,11 +30,9 @@ defineTests() {
testUsingContext
(
'returns 0 when iOS is connected and ready to be stopped'
,
()
{
StopCommand
command
=
new
StopCommand
();
applyMocksToCommand
(
command
);
MockDeviceStore
mockDevices
=
command
.
devices
;
when
(
mockDevices
.
android
.
stopApp
(
any
)).
thenReturn
(
false
);
when
(
mockDevices
.
iOS
.
stopApp
(
any
)).
thenReturn
(
true
);
when
(
mockDevices
.
iOSSimulator
.
stopApp
(
any
)).
thenReturn
(
false
);
MockIOSDevice
device
=
new
MockIOSDevice
();
when
(
device
.
stopApp
(
any
)).
thenReturn
(
new
Future
.
value
(
true
));
testDeviceManager
.
addDevice
(
device
);
return
createTestCommandRunner
(
command
).
run
([
'stop'
]).
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