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