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
3f380ca5
Unverified
Commit
3f380ca5
authored
Jan 28, 2021
by
Jenn Magder
Committed by
GitHub
Jan 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap mockito import for test/fake (#74847)
parent
c05f623c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
42 deletions
+41
-42
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+26
-26
android_device_discovery_test.dart
.../general.shard/android/android_device_discovery_test.dart
+1
-1
android_device_test.dart
...tools/test/general.shard/android/android_device_test.dart
+8
-9
android_install_test.dart
...ools/test/general.shard/android/android_install_test.dart
+1
-1
desktop_device_test.dart
...flutter_tools/test/general.shard/desktop_device_test.dart
+1
-1
drive_service_test.dart
...er_tools/test/general.shard/drive/drive_service_test.dart
+1
-1
flutter_platform_test.dart
...utter_tools/test/general.shard/flutter_platform_test.dart
+3
-3
No files found.
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
3f380ca5
...
...
@@ -74,14 +74,14 @@ void main() {
const
int
devicePort
=
499
;
const
int
hostPort
=
42
;
FakeDeviceLogReader
mock
LogReader
;
FakeDeviceLogReader
fake
LogReader
;
MockPortForwarder
portForwarder
;
MockDartDevelopmentService
mockDds
;
MockAndroidDevice
device
;
MockHttpClient
httpClient
;
setUp
(()
{
mock
LogReader
=
FakeDeviceLogReader
();
fake
LogReader
=
FakeDeviceLogReader
();
portForwarder
=
MockPortForwarder
();
device
=
MockAndroidDevice
();
mockDds
=
MockDartDevelopmentService
();
...
...
@@ -114,16 +114,16 @@ void main() {
});
tearDown
(()
{
mock
LogReader
.
dispose
();
fake
LogReader
.
dispose
();
});
testUsingContext
(
'finds observatory port and forwards'
,
()
async
{
when
(
device
.
getLogReader
(
includePastLogs:
anyNamed
(
'includePastLogs'
)))
.
thenAnswer
((
_
)
{
// Now that the reader is used, start writing messages to it.
mock
LogReader
.
addLine
(
'Foo'
);
mock
LogReader
.
addLine
(
'Observatory listening on http://127.0.0.1:
$devicePort
'
);
return
mock
LogReader
;
fake
LogReader
.
addLine
(
'Foo'
);
fake
LogReader
.
addLine
(
'Observatory listening on http://127.0.0.1:
$devicePort
'
);
return
fake
LogReader
;
});
testDeviceManager
.
addDevice
(
device
);
final
Completer
<
void
>
completer
=
Completer
<
void
>();
...
...
@@ -138,7 +138,7 @@ void main() {
verify
(
portForwarder
.
forward
(
devicePort
,
hostPort:
anyNamed
(
'hostPort'
)),
).
called
(
1
);
await
mock
LogReader
.
dispose
();
await
fake
LogReader
.
dispose
();
await
expectLoggerInterruptEndsTask
(
task
,
logger
);
await
loggerSubscription
.
cancel
();
},
overrides:
<
Type
,
Generator
>{
...
...
@@ -151,10 +151,10 @@ void main() {
when
(
device
.
getLogReader
(
includePastLogs:
anyNamed
(
'includePastLogs'
)))
.
thenAnswer
((
_
)
{
// Now that the reader is used, start writing messages to it.
mock
LogReader
.
addLine
(
'Foo'
);
mock
LogReader
.
addLine
(
'Observatory listening on http:/:/127.0.0.1:
$devicePort
'
);
mock
LogReader
.
dispose
();
return
mock
LogReader
;
fake
LogReader
.
addLine
(
'Foo'
);
fake
LogReader
.
addLine
(
'Observatory listening on http:/:/127.0.0.1:
$devicePort
'
);
fake
LogReader
.
dispose
();
return
fake
LogReader
;
});
testDeviceManager
.
addDevice
(
device
);
expect
(
createTestCommandRunner
(
AttachCommand
()).
run
(<
String
>[
'attach'
]),
...
...
@@ -169,9 +169,9 @@ void main() {
when
(
device
.
getLogReader
(
includePastLogs:
anyNamed
(
'includePastLogs'
)))
.
thenAnswer
((
_
)
{
// Now that the reader is used, start writing messages to it.
mock
LogReader
.
addLine
(
'Foo'
);
mock
LogReader
.
addLine
(
'Observatory listening on http://127.0.0.1:
$devicePort
'
);
return
mock
LogReader
;
fake
LogReader
.
addLine
(
'Foo'
);
fake
LogReader
.
addLine
(
'Observatory listening on http://127.0.0.1:
$devicePort
'
);
return
fake
LogReader
;
});
testDeviceManager
.
addDevice
(
device
);
...
...
@@ -249,9 +249,9 @@ void main() {
when
(
device
.
getLogReader
(
includePastLogs:
anyNamed
(
'includePastLogs'
)))
.
thenAnswer
((
_
)
{
// Now that the reader is used, start writing messages to it.
mock
LogReader
.
addLine
(
'Foo'
);
mock
LogReader
.
addLine
(
'Observatory listening on http://127.0.0.1:
$devicePort
'
);
return
mock
LogReader
;
fake
LogReader
.
addLine
(
'Foo'
);
fake
LogReader
.
addLine
(
'Observatory listening on http://127.0.0.1:
$devicePort
'
);
return
fake
LogReader
;
});
testDeviceManager
.
addDevice
(
device
);
...
...
@@ -272,9 +272,9 @@ void main() {
when
(
device
.
getLogReader
(
includePastLogs:
anyNamed
(
'includePastLogs'
)))
.
thenAnswer
((
_
)
{
// Now that the reader is used, start writing messages to it.
mock
LogReader
.
addLine
(
'Foo'
);
mock
LogReader
.
addLine
(
'Observatory listening on http://127.0.0.1:
$devicePort
'
);
return
mock
LogReader
;
fake
LogReader
.
addLine
(
'Foo'
);
fake
LogReader
.
addLine
(
'Observatory listening on http://127.0.0.1:
$devicePort
'
);
return
fake
LogReader
;
});
testDeviceManager
.
addDevice
(
device
);
...
...
@@ -295,7 +295,7 @@ void main() {
testUsingContext
(
'selects specified target'
,
()
async
{
const
int
devicePort
=
499
;
const
int
hostPort
=
42
;
final
FakeDeviceLogReader
mock
LogReader
=
FakeDeviceLogReader
();
final
FakeDeviceLogReader
fake
LogReader
=
FakeDeviceLogReader
();
final
MockPortForwarder
portForwarder
=
MockPortForwarder
();
final
MockDartDevelopmentService
mockDds
=
MockDartDevelopmentService
();
final
MockAndroidDevice
device
=
MockAndroidDevice
();
...
...
@@ -332,10 +332,10 @@ void main() {
when
(
device
.
getLogReader
(
includePastLogs:
anyNamed
(
'includePastLogs'
)))
.
thenAnswer
((
_
)
{
// Now that the reader is used, start writing messages to it.
mock
LogReader
.
addLine
(
'Foo'
);
mock
LogReader
.
addLine
(
fake
LogReader
.
addLine
(
'Foo'
);
fake
LogReader
.
addLine
(
'Observatory listening on http://127.0.0.1:
$devicePort
'
);
return
mock
LogReader
;
return
fake
LogReader
;
});
final
File
foo
=
globals
.
fs
.
file
(
'lib/foo.dart'
)
..
createSync
();
...
...
@@ -377,7 +377,7 @@ void main() {
testUsingContext
(
'fallbacks to protocol observatory if MDNS failed on iOS'
,
()
async
{
const
int
devicePort
=
499
;
const
int
hostPort
=
42
;
final
FakeDeviceLogReader
mock
LogReader
=
FakeDeviceLogReader
();
final
FakeDeviceLogReader
fake
LogReader
=
FakeDeviceLogReader
();
final
MockPortForwarder
portForwarder
=
MockPortForwarder
();
final
MockDartDevelopmentService
mockDds
=
MockDartDevelopmentService
();
final
MockIOSDevice
device
=
MockIOSDevice
();
...
...
@@ -390,7 +390,7 @@ void main() {
final
Completer
<
void
>
noopCompleter
=
Completer
<
void
>();
when
(
mockDds
.
done
).
thenAnswer
((
_
)
=>
noopCompleter
.
future
);
when
(
device
.
getLogReader
(
includePastLogs:
anyNamed
(
'includePastLogs'
)))
.
thenAnswer
((
_
)
=>
mock
LogReader
);
.
thenAnswer
((
_
)
=>
fake
LogReader
);
when
(
portForwarder
.
forward
(
devicePort
,
hostPort:
anyNamed
(
'hostPort'
)))
.
thenAnswer
((
_
)
async
=>
hostPort
);
when
(
portForwarder
.
forwardedPorts
)
...
...
packages/flutter_tools/test/general.shard/android/android_device_discovery_test.dart
View file @
3f380ca5
...
...
@@ -12,7 +12,7 @@ import 'package:flutter_tools/src/base/logger.dart';
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/user_messages.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'../../src/common.dart'
;
import
'../../src/fake_process_manager.dart'
;
...
...
packages/flutter_tools/test/general.shard/android/android_device_test.dart
View file @
3f380ca5
...
...
@@ -241,7 +241,7 @@ flutter:
]),
id:
'emulator-5555'
,
androidConsoleSocketFactory:
(
String
host
,
int
port
)
async
=>
Mock
WorkingAndroidConsoleSocket
(
'dummyEmulatorId'
),
Fake
WorkingAndroidConsoleSocket
(
'dummyEmulatorId'
),
);
expect
(
await
device
.
emulatorId
,
equals
(
'dummyEmulatorId'
));
...
...
@@ -313,7 +313,7 @@ flutter:
)
]),
androidConsoleSocketFactory:
(
String
host
,
int
port
)
async
=>
Mock
UnresponsiveAndroidConsoleSocket
(),
Fake
UnresponsiveAndroidConsoleSocket
(),
);
expect
(
await
device
.
emulatorId
,
isNull
);
...
...
@@ -328,7 +328,7 @@ flutter:
)
]),
androidConsoleSocketFactory:
(
String
host
,
int
port
)
async
=>
Mock
DisconnectingAndroidConsoleSocket
()
Fake
DisconnectingAndroidConsoleSocket
()
);
expect
(
await
device
.
emulatorId
,
isNull
);
...
...
@@ -480,7 +480,6 @@ AndroidDevice setUpAndroidDevice({
}
class
MockAndroidSdk
extends
Mock
implements
AndroidSdk
{}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
const
String
kAdbShellGetprop
=
'''
[dalvik.vm.dex2oat-Xms]: [64m]
...
...
@@ -642,8 +641,8 @@ const String kAdbShellGetprop = '''
/// A mock Android Console that presents a connection banner and responds to
/// "avd name" requests with the supplied name.
class
Mock
WorkingAndroidConsoleSocket
extends
Fake
implements
Socket
{
Mock
WorkingAndroidConsoleSocket
(
this
.
avdName
)
{
class
Fake
WorkingAndroidConsoleSocket
extends
Fake
implements
Socket
{
Fake
WorkingAndroidConsoleSocket
(
this
.
avdName
)
{
_controller
.
add
(
'Android Console: Welcome!
\n
'
);
// Include OK in the same packet here. In the response to "avd name"
// it's sent alone to ensure both are handled.
...
...
@@ -674,7 +673,7 @@ class MockWorkingAndroidConsoleSocket extends Fake implements Socket {
}
/// An Android console socket that drops all input and returns no output.
class
Mock
UnresponsiveAndroidConsoleSocket
extends
Fake
implements
Socket
{
class
Fake
UnresponsiveAndroidConsoleSocket
extends
Fake
implements
Socket
{
final
StreamController
<
String
>
_controller
=
StreamController
<
String
>();
@override
...
...
@@ -688,8 +687,8 @@ class MockUnresponsiveAndroidConsoleSocket extends Fake implements Socket {
}
/// An Android console socket that drops all input and returns no output.
class
Mock
DisconnectingAndroidConsoleSocket
extends
Fake
implements
Socket
{
Mock
DisconnectingAndroidConsoleSocket
()
{
class
Fake
DisconnectingAndroidConsoleSocket
extends
Fake
implements
Socket
{
Fake
DisconnectingAndroidConsoleSocket
()
{
_controller
.
add
(
'Android Console: Welcome!
\n
'
);
// Include OK in the same packet here. In the response to "avd name"
// it's sent alone to ensure both are handled.
...
...
packages/flutter_tools/test/general.shard/android/android_install_test.dart
View file @
3f380ca5
...
...
@@ -11,7 +11,7 @@ import 'package:flutter_tools/src/application_package.dart';
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
...
...
packages/flutter_tools/test/general.shard/desktop_device_test.dart
View file @
3f380ca5
...
...
@@ -18,8 +18,8 @@ import 'package:flutter_tools/src/device.dart';
import
'package:flutter_tools/src/project.dart'
;
import
'package:meta/meta.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'package:test/fake.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
...
...
packages/flutter_tools/test/general.shard/drive/drive_service_test.dart
View file @
3f380ca5
...
...
@@ -15,9 +15,9 @@ import 'package:flutter_tools/src/convert.dart';
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/drive/drive_service.dart'
;
import
'package:flutter_tools/src/vmservice.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:package_config/package_config_types.dart'
;
import
'package:process/process.dart'
;
import
'package:test/fake.dart'
;
import
'package:vm_service/vm_service.dart'
as
vm_service
;
import
'../../src/common.dart'
;
...
...
packages/flutter_tools/test/general.shard/flutter_platform_test.dart
View file @
3f380ca5
...
...
@@ -64,17 +64,17 @@ void main() {
group
(
'Observatory and DDS setup'
,
()
{
Platform
fakePlatform
;
ProcessManager
mock
ProcessManager
;
ProcessManager
fake
ProcessManager
;
FlutterPlatform
flutterPlatform
;
final
Map
<
Type
,
Generator
>
contextOverrides
=
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
ProcessManager:
()
=>
mock
ProcessManager
,
ProcessManager:
()
=>
fake
ProcessManager
,
FileSystem:
()
=>
fileSystem
,
};
setUp
(()
{
fakePlatform
=
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{});
mock
ProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
fake
ProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'/'
,
...
...
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