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
886eb3e6
Unverified
Commit
886eb3e6
authored
May 11, 2021
by
Jonah Williams
Committed by
GitHub
May 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove mocks from ios_device, project, flutter_command test (#82195)
parent
191c75d4
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
139 deletions
+115
-139
ios_device_logger_test.dart
..._tools/test/general.shard/ios/ios_device_logger_test.dart
+24
-12
project_test.dart
packages/flutter_tools/test/general.shard/project_test.dart
+53
-71
flutter_command_test.dart
...tools/test/general.shard/runner/flutter_command_test.dart
+38
-56
No files found.
packages/flutter_tools/test/general.shard/ios/ios_device_logger_test.dart
View file @
886eb3e6
...
...
@@ -15,7 +15,7 @@ import 'package:flutter_tools/src/ios/devices.dart';
import
'package:flutter_tools/src/ios/ios_deploy.dart'
;
import
'package:flutter_tools/src/ios/mac.dart'
;
import
'package:flutter_tools/src/vmservice.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'package:vm_service/vm_service.dart'
;
import
'../../src/common.dart'
;
...
...
@@ -226,13 +226,13 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
);
logReader
.
connectedVMService
=
vmService
;
final
MockIOSDeployDebugger
iosDeployDebugger
=
Mock
IOSDeployDebugger
();
when
(
iosDeployDebugger
.
debuggerAttached
).
thenReturn
(
true
)
;
final
FakeIOSDeployDebugger
iosDeployDebugger
=
Fake
IOSDeployDebugger
();
iosDeployDebugger
.
debuggerAttached
=
true
;
final
Stream
<
String
>
debuggingLogs
=
Stream
<
String
>.
fromIterable
(<
String
>[
'Message from debugger'
]);
when
(
iosDeployDebugger
.
logLines
).
thenAnswer
((
Invocation
invocation
)
=>
debuggingLogs
)
;
iosDeployDebugger
.
logLines
=
debuggingLogs
;
logReader
.
debuggerStream
=
iosDeployDebugger
;
// Wait for stream listeners to fire.
...
...
@@ -260,8 +260,8 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
),
useSyslog:
false
,
);
final
MockIOSDeployDebugger
iosDeployDebugger
=
Mock
IOSDeployDebugger
();
when
(
iosDeployDebugger
.
logLines
).
thenAnswer
((
Invocation
invocation
)
=>
debuggingLogs
)
;
final
FakeIOSDeployDebugger
iosDeployDebugger
=
Fake
IOSDeployDebugger
();
iosDeployDebugger
.
logLines
=
debuggingLogs
;
logReader
.
debuggerStream
=
iosDeployDebugger
;
final
Future
<
List
<
String
>>
logLines
=
logReader
.
logLines
.
toList
();
...
...
@@ -285,8 +285,8 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
useSyslog:
false
,
);
final
Completer
<
void
>
streamComplete
=
Completer
<
void
>();
final
MockIOSDeployDebugger
iosDeployDebugger
=
Mock
IOSDeployDebugger
();
when
(
iosDeployDebugger
.
logLines
).
thenAnswer
((
Invocation
invocation
)
=>
debuggingLogs
)
;
final
FakeIOSDeployDebugger
iosDeployDebugger
=
Fake
IOSDeployDebugger
();
iosDeployDebugger
.
logLines
=
debuggingLogs
;
logReader
.
logLines
.
listen
(
null
,
onError:
(
Object
error
)
=>
streamComplete
.
complete
());
logReader
.
debuggerStream
=
iosDeployDebugger
;
...
...
@@ -303,14 +303,26 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
),
useSyslog:
false
,
);
final
MockIOSDeployDebugger
iosDeployDebugger
=
MockIOSDeployDebugger
();
when
(
iosDeployDebugger
.
logLines
).
thenAnswer
((
Invocation
invocation
)
=>
const
Stream
<
String
>.
empty
());
final
FakeIOSDeployDebugger
iosDeployDebugger
=
FakeIOSDeployDebugger
();
logReader
.
debuggerStream
=
iosDeployDebugger
;
logReader
.
dispose
();
verify
(
iosDeployDebugger
.
detach
()
);
expect
(
iosDeployDebugger
.
detached
,
true
);
});
});
}
class
MockIOSDeployDebugger
extends
Mock
implements
IOSDeployDebugger
{}
class
FakeIOSDeployDebugger
extends
Fake
implements
IOSDeployDebugger
{
bool
detached
=
false
;
@override
bool
debuggerAttached
=
false
;
@override
Stream
<
String
>
logLines
=
const
Stream
<
String
>.
empty
();
@override
void
detach
()
{
detached
=
true
;
}
}
packages/flutter_tools/test/general.shard/project_test.dart
View file @
886eb3e6
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
View file @
886eb3e6
...
...
@@ -21,7 +21,7 @@ import 'package:flutter_tools/src/dart/pub.dart';
import
'package:flutter_tools/src/globals_null_migrated.dart'
as
globals
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
...
...
@@ -30,19 +30,18 @@ import 'utils.dart';
void
main
(
)
{
group
(
'Flutter Command'
,
()
{
Mock
Cache
cache
;
Fake
Cache
cache
;
TestUsage
usage
;
FakeClock
clock
;
MockProcessInfo
mockP
rocessInfo
;
FakeProcessInfo
p
rocessInfo
;
setUp
(()
{
Cache
.
disableLocking
();
cache
=
Mock
Cache
();
cache
=
Fake
Cache
();
usage
=
TestUsage
();
clock
=
FakeClock
();
mockProcessInfo
=
MockProcessInfo
();
when
(
mockProcessInfo
.
maxRss
).
thenReturn
(
10
);
processInfo
=
FakeProcessInfo
();
processInfo
.
maxRss
=
10
;
});
tearDown
(()
{
...
...
@@ -58,7 +57,8 @@ void main() {
testUsingContext
(
'honors shouldUpdateCache false'
,
()
async
{
final
DummyFlutterCommand
flutterCommand
=
DummyFlutterCommand
(
shouldUpdateCache:
false
);
await
flutterCommand
.
run
();
verifyNever
(
cache
.
updateAll
(
any
));
expect
(
cache
.
artifacts
,
isEmpty
);
expect
(
flutterCommand
.
deprecated
,
isFalse
);
expect
(
flutterCommand
.
hidden
,
isFalse
);
},
...
...
@@ -71,7 +71,7 @@ void main() {
await
flutterCommand
.
run
();
// First call for universal, second for the rest
expect
(
verify
(
cache
.
updateAll
(
captureAny
)).
captured
,
cache
.
artifacts
,
<
Set
<
DevelopmentArtifact
>>[
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
},
<
DevelopmentArtifact
>{},
...
...
@@ -143,7 +143,7 @@ void main() {
void
testUsingCommandContext
(
String
testName
,
dynamic
Function
()
testBody
)
{
testUsingContext
(
testName
,
testBody
,
overrides:
<
Type
,
Generator
>{
ProcessInfo:
()
=>
mockP
rocessInfo
,
ProcessInfo:
()
=>
p
rocessInfo
,
SystemClock:
()
=>
clock
,
Usage:
()
=>
usage
,
});
...
...
@@ -201,40 +201,6 @@ void main() {
]);
});
testUsingCommandContext
(
'reports command that results in failure'
,
()
async
{
// Crash if called a third time which is unexpected.
clock
.
times
=
<
int
>[
1000
,
2000
];
final
DummyFlutterCommand
flutterCommand
=
DummyFlutterCommand
(
commandFunction:
()
async
{
return
const
FlutterCommandResult
(
ExitStatus
.
fail
);
}
);
try
{
await
flutterCommand
.
run
();
}
on
ToolExit
{
verify
(
usage
.
sendCommand
(
'dummy'
,
parameters:
anyNamed
(
'parameters'
),
));
verify
(
usage
.
sendEvent
(
'tool-command-result'
,
'dummy'
,
label:
'fail'
,
parameters:
anyNamed
(
'parameters'
),
));
expect
(
verify
(
usage
.
sendEvent
(
'tool-command-max-rss'
,
'dummy'
,
label:
'fail'
,
value:
captureAnyNamed
(
'value'
),
)).
captured
[
0
],
10
,
);
}
});
testUsingCommandContext
(
'reports command that results in error'
,
()
async
{
// Crash if called a third time which is unexpected.
clock
.
times
=
<
int
>[
1000
,
2000
];
...
...
@@ -315,15 +281,15 @@ void main() {
});
group
(
'signals tests'
,
()
{
Mock
IoProcessSignal
mockSignal
;
Fake
IoProcessSignal
mockSignal
;
ProcessSignal
signalUnderTest
;
StreamController
<
io
.
ProcessSignal
>
signalController
;
setUp
(()
{
mockSignal
=
Mock
IoProcessSignal
();
mockSignal
=
Fake
IoProcessSignal
();
signalUnderTest
=
ProcessSignal
(
mockSignal
);
signalController
=
StreamController
<
io
.
ProcessSignal
>();
when
(
mockSignal
.
watch
()).
thenAnswer
((
Invocation
invocation
)
=>
signalController
.
stream
)
;
mockSignal
.
stream
=
signalController
.
stream
;
});
testUsingContext
(
'reports command that is killed'
,
()
async
{
...
...
@@ -363,7 +329,7 @@ void main() {
),
]);
},
overrides:
<
Type
,
Generator
>{
ProcessInfo:
()
=>
mockP
rocessInfo
,
ProcessInfo:
()
=>
p
rocessInfo
,
Signals:
()
=>
FakeSignals
(
subForSigTerm:
signalUnderTest
,
exitSignals:
<
ProcessSignal
>[
signalUnderTest
],
...
...
@@ -397,11 +363,8 @@ void main() {
signalController
.
add
(
mockSignal
);
await
completer
.
future
;
await
globals
.
cache
.
lock
();
globals
.
cache
.
releaseLock
();
},
overrides:
<
Type
,
Generator
>{
ProcessInfo:
()
=>
mockP
rocessInfo
,
ProcessInfo:
()
=>
p
rocessInfo
,
Signals:
()
=>
FakeSignals
(
subForSigTerm:
signalUnderTest
,
exitSignals:
<
ProcessSignal
>[
signalUnderTest
],
...
...
@@ -671,8 +634,29 @@ class FakeDdsCommand extends FlutterCommand {
}
}
class
MockProcessInfo
extends
Mock
implements
ProcessInfo
{}
class
MockIoProcessSignal
extends
Mock
implements
io
.
ProcessSignal
{}
class
FakeProcessInfo
extends
Fake
implements
ProcessInfo
{
@override
int
maxRss
=
0
;
}
class
FakeIoProcessSignal
extends
Fake
implements
io
.
ProcessSignal
{
Stream
<
io
.
ProcessSignal
>
stream
;
@override
Stream
<
io
.
ProcessSignal
>
watch
()
=>
stream
;
}
class
FakeCache
extends
Fake
implements
Cache
{
List
<
Set
<
DevelopmentArtifact
>>
artifacts
=
<
Set
<
DevelopmentArtifact
>>[];
@override
Future
<
void
>
updateAll
(
Set
<
DevelopmentArtifact
>
requiredArtifacts
)
async
{
artifacts
.
add
(
requiredArtifacts
.
toSet
());
}
@override
void
releaseLock
()
{
}
}
class
FakeSignals
implements
Signals
{
FakeSignals
({
...
...
@@ -708,8 +692,6 @@ class FakeClock extends Fake implements SystemClock {
}
}
class
MockCache
extends
Mock
implements
Cache
{}
class
FakePub
extends
Fake
implements
Pub
{
@override
Future
<
void
>
get
({
...
...
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