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
75da995f
Unverified
Commit
75da995f
authored
Mar 15, 2021
by
Jenn Magder
Committed by
GitHub
Mar 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MockOperatingSystemUtils -> FakeOperatingSystemUtils (#77988)
parent
2e17a8e6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
35 deletions
+26
-35
ios_device_port_forwarder_test.dart
...est/general.shard/ios/ios_device_port_forwarder_test.dart
+6
-12
plugins_test.dart
packages/flutter_tools/test/general.shard/plugins_test.dart
+11
-8
chrome_test.dart
...ges/flutter_tools/test/general.shard/web/chrome_test.dart
+9
-15
No files found.
packages/flutter_tools/test/general.shard/ios/ios_device_port_forwarder_test.dart
View file @
75da995f
...
...
@@ -5,9 +5,7 @@
// @dart = 2.8
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/ios/devices.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
...
...
@@ -22,36 +20,32 @@ void main() {
// and 65535; this test verifies we are killing iproxy processes when
// we timeout on a port
testWithoutContext
(
'IOSDevicePortForwarder.forward will kill iproxy processes before invoking a second'
,
()
async
{
const
int
devicePort
=
456
;
final
FakeProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'iproxy'
,
'
49154
:456'
,
'--udid'
,
'1234'
],
command:
<
String
>[
'iproxy'
,
'
12345
:456'
,
'--udid'
,
'1234'
],
// iproxy does not exit with 0 when it cannot forward.
exitCode:
0
,
stdout:
null
,
// no stdout indicates failure.
environment:
kDyLdLibEntry
,
),
const
FakeCommand
(
command:
<
String
>[
'iproxy'
,
'
49155
:456'
,
'--udid'
,
'1234'
],
command:
<
String
>[
'iproxy'
,
'
12346
:456'
,
'--udid'
,
'1234'
],
exitCode:
0
,
stdout:
'not empty'
,
environment:
kDyLdLibEntry
,
),
]);
final
MockOperatingSystemUtils
operatingSystemUtils
=
MockOperatingSystemUtils
();
when
(
operatingSystemUtils
.
findFreePort
()).
thenAnswer
((
Invocation
invocation
)
=>
Future
<
int
>.
value
(
49154
));
final
FakeOperatingSystemUtils
operatingSystemUtils
=
FakeOperatingSystemUtils
();
final
IOSDevicePortForwarder
portForwarder
=
IOSDevicePortForwarder
.
test
(
processManager:
processManager
,
logger:
BufferLogger
.
test
(),
operatingSystemUtils:
operatingSystemUtils
,
);
final
int
hostPort
=
await
portForwarder
.
forward
(
devicePort
);
final
int
hostPort
=
await
portForwarder
.
forward
(
456
);
// First port tried (
49154
) should fail, then succeed on the next
expect
(
hostPort
,
49154
+
1
);
// First port tried (
12345
) should fail, then succeed on the next
expect
(
hostPort
,
12345
+
1
);
expect
(
processManager
,
hasNoRemainingExpectations
);
});
}
class
MockOperatingSystemUtils
extends
Mock
implements
OperatingSystemUtils
{}
packages/flutter_tools/test/general.shard/plugins_test.dart
View file @
75da995f
...
...
@@ -27,7 +27,7 @@ import 'package:package_config/package_config.dart';
import
'package:yaml/yaml.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
import
'../src/context.dart'
hide
FakeOperatingSystemUtils
;
import
'../src/fakes.dart'
;
import
'../src/pubspec_schema.dart'
;
import
'../src/testbed.dart'
;
...
...
@@ -2159,8 +2159,7 @@ void main() {
testWithoutContext
(
'Symlink failures give developer mode instructions on recent versions of Windows'
,
()
async
{
final
Platform
platform
=
FakePlatform
(
operatingSystem:
'windows'
);
final
MockOperatingSystemUtils
os
=
MockOperatingSystemUtils
();
when
(
os
.
name
).
thenReturn
(
'Microsoft Windows [Version 10.0.14972.1]'
);
final
FakeOperatingSystemUtils
os
=
FakeOperatingSystemUtils
(
'Microsoft Windows [Version 10.0.14972.1]'
);
const
FileSystemException
e
=
FileSystemException
(
''
,
''
,
OSError
(
''
,
1314
));
...
...
@@ -2170,8 +2169,7 @@ void main() {
testWithoutContext
(
'Symlink failures instruct developers to run as administrator on older versions of Windows'
,
()
async
{
final
Platform
platform
=
FakePlatform
(
operatingSystem:
'windows'
);
final
MockOperatingSystemUtils
os
=
MockOperatingSystemUtils
();
when
(
os
.
name
).
thenReturn
(
'Microsoft Windows [Version 10.0.14393]'
);
final
FakeOperatingSystemUtils
os
=
FakeOperatingSystemUtils
(
'Microsoft Windows [Version 10.0.14393]'
);
const
FileSystemException
e
=
FileSystemException
(
''
,
''
,
OSError
(
''
,
1314
));
...
...
@@ -2181,8 +2179,7 @@ void main() {
testWithoutContext
(
'Symlink failures only give instructions for specific errors'
,
()
async
{
final
Platform
platform
=
FakePlatform
(
operatingSystem:
'windows'
);
final
MockOperatingSystemUtils
os
=
MockOperatingSystemUtils
();
when
(
os
.
name
).
thenReturn
(
'Microsoft Windows [Version 10.0.14393]'
);
final
FakeOperatingSystemUtils
os
=
FakeOperatingSystemUtils
(
'Microsoft Windows [Version 10.0.14393]'
);
const
FileSystemException
e
=
FileSystemException
(
''
,
''
,
OSError
(
''
,
999
));
...
...
@@ -2200,7 +2197,13 @@ class MockXcodeProjectInterpreter extends Mock implements XcodeProjectInterprete
class
MockWebProject
extends
Mock
implements
WebProject
{}
class
MockWindowsProject
extends
Mock
implements
WindowsProject
{}
class
MockLinuxProject
extends
Mock
implements
LinuxProject
{}
class
MockOperatingSystemUtils
extends
Mock
implements
OperatingSystemUtils
{}
class
FakeOperatingSystemUtils
extends
Fake
implements
OperatingSystemUtils
{
FakeOperatingSystemUtils
(
this
.
name
);
@override
final
String
name
;
}
class
FakeSystemClock
extends
Fake
implements
SystemClock
{
DateTime
currentTime
;
...
...
packages/flutter_tools/test/general.shard/web/chrome_test.dart
View file @
75da995f
...
...
@@ -12,7 +12,7 @@ import 'package:flutter_tools/src/base/logger.dart';
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/web/chrome.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
...
...
@@ -39,11 +39,7 @@ void main() {
setUp
(()
{
exceptionHandler
=
FileExceptionHandler
();
operatingSystemUtils
=
MockOperatingSystemUtils
();
when
(
operatingSystemUtils
.
findFreePort
())
.
thenAnswer
((
Invocation
invocation
)
async
{
return
1234
;
});
operatingSystemUtils
=
FakeOperatingSystemUtils
();
platform
=
FakePlatform
(
operatingSystem:
'macos'
,
environment:
<
String
,
String
>{
kChromeEnvironment:
'example_chrome'
,
});
...
...
@@ -119,7 +115,7 @@ void main() {
command:
<
String
>[
'example_chrome'
,
'--user-data-dir=/.tmp_rand0/flutter_tools_chrome_device.rand0'
,
'--remote-debugging-port=1234'
,
'--remote-debugging-port=1234
5
'
,
...
kChromeArgs
,
'example_url'
,
],
...
...
@@ -171,7 +167,7 @@ void main() {
command:
<
String
>[
'example_chrome'
,
'--user-data-dir=/.tmp_rand0/flutter_tools_chrome_device.rand0'
,
'--remote-debugging-port=1234'
,
'--remote-debugging-port=1234
5
'
,
...
kChromeArgs
,
'example_url'
,
],
...
...
@@ -220,7 +216,7 @@ void main() {
command:
<
String
>[
'example_chrome'
,
'--user-data-dir=/.tmp_rand0/flutter_tools_chrome_device.rand0'
,
'--remote-debugging-port=1234'
,
'--remote-debugging-port=1234
5
'
,
...
kChromeArgs
,
'--headless'
,
'--disable-gpu'
,
...
...
@@ -260,7 +256,7 @@ void main() {
command:
const
<
String
>[
'example_chrome'
,
'--user-data-dir=/.tmp_rand0/flutter_tools_chrome_device.rand0'
,
'--remote-debugging-port=1234'
,
'--remote-debugging-port=1234
5
'
,
...
kChromeArgs
,
'example_url'
,
],
...
...
@@ -294,7 +290,7 @@ void main() {
const
List
<
String
>
args
=
<
String
>[
'example_chrome'
,
'--user-data-dir=/.tmp_rand0/flutter_tools_chrome_device.rand0'
,
'--remote-debugging-port=1234'
,
'--remote-debugging-port=1234
5
'
,
...
kChromeArgs
,
'--headless'
,
'--disable-gpu'
,
...
...
@@ -334,7 +330,7 @@ void main() {
command:
<
String
>[
'example_chrome'
,
'--user-data-dir=/.tmp_rand0/flutter_tools_chrome_device.rand0'
,
'--remote-debugging-port=1234'
,
'--remote-debugging-port=1234
5
'
,
...
kChromeArgs
,
'--headless'
,
'--disable-gpu'
,
...
...
@@ -356,14 +352,12 @@ void main() {
});
}
class
MockOperatingSystemUtils
extends
Mock
implements
OperatingSystemUtils
{}
Future
<
Chromium
>
_testLaunchChrome
(
String
userDataDir
,
FakeProcessManager
processManager
,
ChromiumLauncher
chromeLauncher
)
{
processManager
.
addCommand
(
FakeCommand
(
command:
<
String
>[
'example_chrome'
,
'--user-data-dir=
$userDataDir
'
,
'--remote-debugging-port=1234'
,
'--remote-debugging-port=1234
5
'
,
...
kChromeArgs
,
'example_url'
,
],
...
...
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