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
73b6702d
Unverified
Commit
73b6702d
authored
Mar 19, 2020
by
Jonah Williams
Committed by
GitHub
Mar 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] refactor iOS tests for Device.startApp into new file (#52854)
parent
2a93afa7
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
473 additions
and
454 deletions
+473
-454
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+1
-1
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+5
-4
drive_test.dart
...lutter_tools/test/commands.shard/hermetic/drive_test.dart
+3
-2
run_test.dart
.../flutter_tools/test/commands.shard/hermetic/run_test.dart
+3
-2
devices_test.dart
...es/flutter_tools/test/general.shard/ios/devices_test.dart
+3
-367
ios_device_start_prebuilt_test.dart
...est/general.shard/ios/ios_device_start_prebuilt_test.dart
+402
-0
protocol_discovery_test.dart
...ter_tools/test/general.shard/protocol_discovery_test.dart
+8
-8
fake_process_manager.dart
packages/flutter_tools/test/src/fake_process_manager.dart
+6
-36
fakes.dart
packages/flutter_tools/test/src/fakes.dart
+42
-0
mocks.dart
packages/flutter_tools/test/src/mocks.dart
+0
-34
No files found.
packages/flutter_tools/lib/src/ios/devices.dart
View file @
73b6702d
...
...
@@ -383,7 +383,7 @@ class IOSDevice extends Device {
@override
DevicePortForwarder
get
portForwarder
=>
_portForwarder
??=
IOSDevicePortForwarder
(
processManager:
globals
.
processManager
,
logger:
globals
.
logger
,
logger:
_
logger
,
dyLdLibEntry:
globals
.
cache
.
dyLdLibEntry
,
id:
id
,
iproxyPath:
_iproxyPath
,
...
...
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
73b6702d
...
...
@@ -30,6 +30,7 @@ import 'package:flutter_tools/src/globals.dart' as globals;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/fakes.dart'
;
import
'../../src/mocks.dart'
;
...
...
@@ -54,7 +55,7 @@ void main() {
const
int
devicePort
=
499
;
const
int
hostPort
=
42
;
Mock
DeviceLogReader
mockLogReader
;
Fake
DeviceLogReader
mockLogReader
;
MockPortForwarder
portForwarder
;
MockAndroidDevice
device
;
MockProcessManager
mockProcessManager
;
...
...
@@ -63,7 +64,7 @@ void main() {
setUp
(()
{
mockProcessManager
=
MockProcessManager
();
mockLogReader
=
Mock
DeviceLogReader
();
mockLogReader
=
Fake
DeviceLogReader
();
portForwarder
=
MockPortForwarder
();
device
=
MockAndroidDevice
();
vmServiceDoneCompleter
=
Completer
<
void
>();
...
...
@@ -374,7 +375,7 @@ void main() {
testUsingContext
(
'selects specified target'
,
()
async
{
const
int
devicePort
=
499
;
const
int
hostPort
=
42
;
final
MockDeviceLogReader
mockLogReader
=
Mock
DeviceLogReader
();
final
FakeDeviceLogReader
mockLogReader
=
Fake
DeviceLogReader
();
final
MockPortForwarder
portForwarder
=
MockPortForwarder
();
final
MockAndroidDevice
device
=
MockAndroidDevice
();
final
MockHotRunner
mockHotRunner
=
MockHotRunner
();
...
...
@@ -434,7 +435,7 @@ void main() {
testUsingContext
(
'fallbacks to protocol observatory if MDNS failed on iOS'
,
()
async
{
const
int
devicePort
=
499
;
const
int
hostPort
=
42
;
final
MockDeviceLogReader
mockLogReader
=
Mock
DeviceLogReader
();
final
FakeDeviceLogReader
mockLogReader
=
Fake
DeviceLogReader
();
final
MockPortForwarder
portForwarder
=
MockPortForwarder
();
final
MockIOSDevice
device
=
MockIOSDevice
();
final
MockHotRunner
mockHotRunner
=
MockHotRunner
();
...
...
packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart
View file @
73b6702d
...
...
@@ -21,6 +21,7 @@ import 'package:webdriver/sync_io.dart' as sync_io;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/fakes.dart'
;
import
'../../src/mocks.dart'
;
void
main
(
)
{
...
...
@@ -351,7 +352,7 @@ void main() {
final
Device
mockDevice
=
MockDevice
();
testDeviceManager
.
addDevice
(
mockDevice
);
final
MockDeviceLogReader
mockDeviceLogReader
=
Mock
DeviceLogReader
();
final
FakeDeviceLogReader
mockDeviceLogReader
=
Fake
DeviceLogReader
();
when
(
mockDevice
.
getLogReader
()).
thenReturn
(
mockDeviceLogReader
);
final
MockLaunchResult
mockLaunchResult
=
MockLaunchResult
();
when
(
mockLaunchResult
.
started
).
thenReturn
(
true
);
...
...
@@ -481,7 +482,7 @@ void main() {
final
Device
mockDevice
=
MockDevice
();
testDeviceManager
.
addDevice
(
mockDevice
);
final
MockDeviceLogReader
mockDeviceLogReader
=
Mock
DeviceLogReader
();
final
FakeDeviceLogReader
mockDeviceLogReader
=
Fake
DeviceLogReader
();
when
(
mockDevice
.
getLogReader
()).
thenReturn
(
mockDeviceLogReader
);
final
MockLaunchResult
mockLaunchResult
=
MockLaunchResult
();
when
(
mockLaunchResult
.
started
).
thenReturn
(
true
);
...
...
packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
View file @
73b6702d
...
...
@@ -32,6 +32,7 @@ import 'package:mockito/mockito.dart';
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/fakes.dart'
;
import
'../../src/mocks.dart'
;
import
'../../src/testbed.dart'
;
...
...
@@ -279,7 +280,7 @@ void main() {
applyMocksToCommand
(
command
);
final
MockDevice
mockDevice
=
MockDevice
(
TargetPlatform
.
ios
);
when
(
mockDevice
.
isLocalEmulator
).
thenAnswer
((
Invocation
invocation
)
=>
Future
<
bool
>.
value
(
false
));
when
(
mockDevice
.
getLogReader
(
app:
anyNamed
(
'app'
))).
thenReturn
(
Mock
DeviceLogReader
());
when
(
mockDevice
.
getLogReader
(
app:
anyNamed
(
'app'
))).
thenReturn
(
Fake
DeviceLogReader
());
when
(
mockDevice
.
supportsFastStart
).
thenReturn
(
true
);
when
(
mockDevice
.
sdkNameAndVersion
).
thenAnswer
((
Invocation
invocation
)
=>
Future
<
String
>.
value
(
'iOS 13'
));
// App fails to start because we're only interested in usage
...
...
@@ -633,7 +634,7 @@ class FakeDevice extends Fake implements Device {
@override
DeviceLogReader
getLogReader
({
ApplicationPackage
app
})
{
return
Mock
DeviceLogReader
();
return
Fake
DeviceLogReader
();
}
@override
...
...
packages/flutter_tools/test/general.shard/ios/devices_test.dart
View file @
73b6702d
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart
0 → 100644
View file @
73b6702d
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/protocol_discovery_test.dart
View file @
73b6702d
...
...
@@ -10,11 +10,11 @@ import 'package:quiver/testing/async.dart';
import
'../src/common.dart'
;
import
'../src/context.dart'
;
import
'../src/
mock
s.dart'
;
import
'../src/
fake
s.dart'
;
void
main
(
)
{
group
(
'service_protocol discovery'
,
()
{
Mock
DeviceLogReader
logReader
;
Fake
DeviceLogReader
logReader
;
ProtocolDiscovery
discoverer
;
/// Performs test set-up functionality that must be performed as part of
...
...
@@ -37,7 +37,7 @@ void main() {
int
devicePort
,
Duration
throttleDuration
=
const
Duration
(
milliseconds:
200
),
})
{
logReader
=
Mock
DeviceLogReader
();
logReader
=
Fake
DeviceLogReader
();
discoverer
=
ProtocolDiscovery
.
observatory
(
logReader
,
ipv6:
false
,
...
...
@@ -261,7 +261,7 @@ void main() {
group
(
'port forwarding'
,
()
{
testUsingContext
(
'default port'
,
()
async
{
final
MockDeviceLogReader
logReader
=
Mock
DeviceLogReader
();
final
FakeDeviceLogReader
logReader
=
Fake
DeviceLogReader
();
final
ProtocolDiscovery
discoverer
=
ProtocolDiscovery
.
observatory
(
logReader
,
portForwarder:
MockPortForwarder
(
99
),
...
...
@@ -282,7 +282,7 @@ void main() {
});
testUsingContext
(
'specified port'
,
()
async
{
final
MockDeviceLogReader
logReader
=
Mock
DeviceLogReader
();
final
FakeDeviceLogReader
logReader
=
Fake
DeviceLogReader
();
final
ProtocolDiscovery
discoverer
=
ProtocolDiscovery
.
observatory
(
logReader
,
portForwarder:
MockPortForwarder
(
99
),
...
...
@@ -303,7 +303,7 @@ void main() {
});
testUsingContext
(
'specified port zero'
,
()
async
{
final
MockDeviceLogReader
logReader
=
Mock
DeviceLogReader
();
final
FakeDeviceLogReader
logReader
=
Fake
DeviceLogReader
();
final
ProtocolDiscovery
discoverer
=
ProtocolDiscovery
.
observatory
(
logReader
,
portForwarder:
MockPortForwarder
(
99
),
...
...
@@ -324,7 +324,7 @@ void main() {
});
testUsingContext
(
'ipv6'
,
()
async
{
final
MockDeviceLogReader
logReader
=
Mock
DeviceLogReader
();
final
FakeDeviceLogReader
logReader
=
Fake
DeviceLogReader
();
final
ProtocolDiscovery
discoverer
=
ProtocolDiscovery
.
observatory
(
logReader
,
portForwarder:
MockPortForwarder
(
99
),
...
...
@@ -345,7 +345,7 @@ void main() {
});
testUsingContext
(
'ipv6 with Ascii Escape code'
,
()
async
{
final
MockDeviceLogReader
logReader
=
Mock
DeviceLogReader
();
final
FakeDeviceLogReader
logReader
=
Fake
DeviceLogReader
();
final
ProtocolDiscovery
discoverer
=
ProtocolDiscovery
.
observatory
(
logReader
,
portForwarder:
MockPortForwarder
(
99
),
...
...
packages/flutter_tools/test/src/fake_process_manager.dart
View file @
73b6702d
...
...
@@ -82,39 +82,14 @@ class FakeCommand {
/// resolves.
final
Completer
<
void
>
completer
;
static
bool
_listEquals
<
T
>(
List
<
T
>
a
,
List
<
T
>
b
)
{
if
(
a
==
null
)
{
return
b
==
null
;
}
if
(
b
==
null
||
a
.
length
!=
b
.
length
)
{
return
false
;
}
for
(
int
index
=
0
;
index
<
a
.
length
;
index
+=
1
)
{
if
(
a
[
index
]
!=
b
[
index
])
{
return
false
;
}
}
return
true
;
}
bool
_matches
(
List
<
String
>
command
,
String
workingDirectory
,
Map
<
String
,
String
>
environment
)
{
if
(!
_listEquals
(
command
,
this
.
command
))
{
return
false
;
}
if
(
this
.
workingDirectory
!=
null
&&
workingDirectory
!=
this
.
workingDirectory
)
{
return
false
;
void
_matches
(
List
<
String
>
command
,
String
workingDirectory
,
Map
<
String
,
String
>
environment
)
{
expect
(
command
,
equals
(
this
.
command
));
if
(
this
.
workingDirectory
!=
null
)
{
expect
(
this
.
workingDirectory
,
workingDirectory
);
}
if
(
this
.
environment
!=
null
)
{
if
(
environment
==
null
)
{
return
false
;
}
for
(
final
String
key
in
environment
.
keys
)
{
if
(
environment
[
key
]
!=
this
.
environment
[
key
])
{
return
false
;
}
}
expect
(
this
.
environment
,
environment
);
}
return
true
;
}
}
...
...
@@ -322,12 +297,7 @@ class _SequenceProcessManager extends FakeProcessManager {
reason:
'ProcessManager was told to execute
$command
(in
$workingDirectory
) '
'but the FakeProcessManager.list expected no more processes.'
);
expect
(
_commands
.
first
.
_matches
(
command
,
workingDirectory
,
environment
),
isTrue
,
reason:
'ProcessManager was told to execute
$command
'
'(in
$workingDirectory
, with environment
$environment
) '
'but the next process that was expected was
${_commands.first.command}
'
'(in
${_commands.first.workingDirectory}
, with environment
${_commands.first.environment}
)}.'
);
_commands
.
first
.
_matches
(
command
,
workingDirectory
,
environment
);
return
_commands
.
removeAt
(
0
);
}
...
...
packages/flutter_tools/test/src/fakes.dart
0 → 100644
View file @
73b6702d
// Copyright 2014 The Flutter Authors. All rights reserved.
// 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/device.dart'
;
/// A fake implementation of the [DeviceLogReader].
class
FakeDeviceLogReader
extends
DeviceLogReader
{
@override
String
get
name
=>
'FakeLogReader'
;
StreamController
<
String
>
_cachedLinesController
;
final
List
<
String
>
_lineQueue
=
<
String
>[];
StreamController
<
String
>
get
_linesController
{
_cachedLinesController
??=
StreamController
<
String
>
.
broadcast
(
onListen:
()
{
_lineQueue
.
forEach
(
_linesController
.
add
);
_lineQueue
.
clear
();
});
return
_cachedLinesController
;
}
@override
Stream
<
String
>
get
logLines
=>
_linesController
.
stream
;
void
addLine
(
String
line
)
{
if
(
_linesController
.
hasListener
)
{
_linesController
.
add
(
line
);
}
else
{
_lineQueue
.
add
(
line
);
}
}
@override
Future
<
void
>
dispose
()
async
{
_lineQueue
.
clear
();
await
_linesController
.
close
();
}
}
packages/flutter_tools/test/src/mocks.dart
View file @
73b6702d
...
...
@@ -612,40 +612,6 @@ class MockIOSSimulator extends Mock implements IOSSimulator {
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
=>
true
;
}
class
MockDeviceLogReader
extends
DeviceLogReader
{
@override
String
get
name
=>
'MockLogReader'
;
StreamController
<
String
>
_cachedLinesController
;
final
List
<
String
>
_lineQueue
=
<
String
>[];
StreamController
<
String
>
get
_linesController
{
_cachedLinesController
??=
StreamController
<
String
>
.
broadcast
(
onListen:
()
{
_lineQueue
.
forEach
(
_linesController
.
add
);
_lineQueue
.
clear
();
});
return
_cachedLinesController
;
}
@override
Stream
<
String
>
get
logLines
=>
_linesController
.
stream
;
void
addLine
(
String
line
)
{
if
(
_linesController
.
hasListener
)
{
_linesController
.
add
(
line
);
}
else
{
_lineQueue
.
add
(
line
);
}
}
@override
Future
<
void
>
dispose
()
async
{
_lineQueue
.
clear
();
await
_linesController
.
close
();
}
}
void
applyMocksToCommand
(
FlutterCommand
command
)
{
command
.
applicationPackages
=
MockApplicationPackageStore
();
}
...
...
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