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
dbb1958c
Unverified
Commit
dbb1958c
authored
Jan 29, 2021
by
Jenn Magder
Committed by
GitHub
Jan 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add canRun override to FakeProcessManager (#74865)
parent
904d63fb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
31 deletions
+17
-31
doctor_test.dart
...utter_tools/test/commands.shard/hermetic/doctor_test.dart
+3
-5
android_device_discovery_test.dart
.../general.shard/android/android_device_discovery_test.dart
+5
-10
cache_test.dart
packages/flutter_tools/test/general.shard/cache_test.dart
+0
-4
web_validator_test.dart
...tter_tools/test/general.shard/web/web_validator_test.dart
+5
-11
fake_process_manager.dart
packages/flutter_tools/test/src/fake_process_manager.dart
+4
-1
No files found.
packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart
View file @
dbb1958c
...
...
@@ -55,10 +55,12 @@ final Platform macPlatform = FakePlatform(
void
main
(
)
{
MockFlutterVersion
mockFlutterVersion
;
BufferLogger
logger
;
FakeProcessManager
fakeProcessManager
;
setUp
(()
{
mockFlutterVersion
=
MockFlutterVersion
();
logger
=
BufferLogger
.
test
();
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[]);
});
testWithoutContext
(
'ValidationMessage equality and hashCode includes contextUrl'
,
()
{
...
...
@@ -597,7 +599,6 @@ void main() {
},
overrides:
noColorTerminalOverride
);
});
group
(
'grouped validator merging results'
,
()
{
final
PassingGroupedValidator
installed
=
PassingGroupedValidator
(
'Category'
);
final
PartialGroupedValidator
partial
=
PartialGroupedValidator
(
'Category'
);
...
...
@@ -650,14 +651,12 @@ void main() {
});
testUsingContext
(
'WebWorkflow is a part of validator workflows if enabled'
,
()
async
{
when
(
globals
.
processManager
.
canRun
(
any
)).
thenReturn
(
true
);
expect
(
DoctorValidatorsProvider
.
defaultInstance
.
workflows
,
contains
(
isA
<
WebWorkflow
>()));
},
overrides:
<
Type
,
Generator
>{
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
ProcessManager:
()
=>
MockProcessManager
()
,
ProcessManager:
()
=>
fakeProcessManager
,
});
testUsingContext
(
'Fetches tags to get the right version'
,
()
async
{
...
...
@@ -1046,7 +1045,6 @@ class VsCodeValidatorTestTargets extends VsCodeValidator {
static
final
String
missingExtensions
=
globals
.
fs
.
path
.
join
(
'test'
,
'data'
,
'vscode'
,
'notExtensions'
);
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockPlistParser
extends
Mock
implements
PlistParser
{}
class
MockDeviceManager
extends
Mock
implements
DeviceManager
{}
class
MockDevice
extends
Mock
implements
Device
{
...
...
packages/flutter_tools/test/general.shard/android/android_device_discovery_test.dart
View file @
dbb1958c
...
...
@@ -47,15 +47,16 @@ void main() {
});
testWithoutContext
(
'AndroidDevices returns empty device list and diagnostics when adb cannot be run'
,
()
async
{
final
FakeProcessManager
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[]);
fakeProcessManager
.
excludedExecutables
.
add
(
'adb'
);
final
AndroidDevices
androidDevices
=
AndroidDevices
(
androidSdk:
FakeAndroidSdk
(
null
),
androidSdk:
FakeAndroidSdk
(),
logger:
BufferLogger
.
test
(),
androidWorkflow:
AndroidWorkflow
(
androidSdk:
FakeAndroidSdk
(
'adb'
),
featureFlags:
TestFeatureFlags
(),
),
// Will throw an exception if anything other than canRun is invoked
processManager:
FakeProcessManger
(),
processManager:
fakeProcessManager
,
fileSystem:
MemoryFileSystem
.
test
(),
platform:
FakePlatform
(),
userMessages:
UserMessages
(),
...
...
@@ -63,6 +64,7 @@ void main() {
expect
(
await
androidDevices
.
pollingGetDevices
(),
isEmpty
);
expect
(
await
androidDevices
.
getDiagnostics
(),
isEmpty
);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
});
testWithoutContext
(
'AndroidDevices returns empty device list and diagnostics on null Android SDK'
,
()
async
{
...
...
@@ -239,10 +241,3 @@ class FakeAndroidSdk extends Fake implements AndroidSdk {
@override
final
String
adbPath
;
}
class
FakeProcessManger
extends
Fake
implements
ProcessManager
{
@override
bool
canRun
(
dynamic
executable
,
{
String
workingDirectory
})
{
return
false
;
}
}
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
dbb1958c
...
...
@@ -763,11 +763,7 @@ class FakeDownloadedArtifact extends CachedArtifact {
}
class
MockArtifactUpdater
extends
Mock
implements
ArtifactUpdater
{}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockFileSystem
extends
Mock
implements
FileSystem
{}
class
MockFile
extends
Mock
implements
File
{}
class
MockDirectory
extends
Mock
implements
Directory
{}
class
MockRandomAccessFile
extends
Mock
implements
RandomAccessFile
{}
class
MockCachedArtifact
extends
Mock
implements
CachedArtifact
{}
class
MockIosUsbArtifacts
extends
Mock
implements
IosUsbArtifacts
{}
class
MockInternetAddress
extends
Mock
implements
InternetAddress
{}
...
...
packages/flutter_tools/test/general.shard/web/web_validator_test.dart
View file @
dbb1958c
...
...
@@ -11,22 +11,20 @@ import 'package:flutter_tools/src/base/platform.dart';
import
'package:flutter_tools/src/doctor.dart'
;
import
'package:flutter_tools/src/web/chrome.dart'
;
import
'package:flutter_tools/src/web/web_validator.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'../../src/common.dart'
;
import
'../../src/fake_process_manager.dart'
;
void
main
(
)
{
Platform
platform
;
ProcessManager
p
rocessManager
;
FakeProcessManager
fakeP
rocessManager
;
ChromiumLauncher
chromeLauncher
;
FileSystem
fileSystem
;
ChromiumValidator
webValidator
;
setUp
(()
{
fileSystem
=
MemoryFileSystem
.
test
();
processManager
=
MockProcessManager
(
);
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[]
);
platform
=
FakePlatform
(
operatingSystem:
'macos'
,
environment:
<
String
,
String
>{},
...
...
@@ -34,7 +32,7 @@ void main() {
chromeLauncher
=
ChromiumLauncher
(
fileSystem:
fileSystem
,
platform:
platform
,
processManager:
p
rocessManager
,
processManager:
fakeP
rocessManager
,
operatingSystemUtils:
null
,
browserFinder:
findChromeExecutable
,
logger:
BufferLogger
.
test
(),
...
...
@@ -46,15 +44,13 @@ void main() {
});
testWithoutContext
(
'WebValidator can find executable on macOS'
,
()
async
{
when
(
processManager
.
canRun
(
kMacOSExecutable
)).
thenReturn
(
true
);
final
ValidationResult
result
=
await
webValidator
.
validate
();
expect
(
result
.
type
,
ValidationType
.
installed
);
});
testWithoutContext
(
'WebValidator Can notice missing macOS executable '
,
()
async
{
when
(
processManager
.
canRun
(
kMacOSExecutable
)).
thenReturn
(
fals
e
);
fakeProcessManager
.
excludedExecutables
.
add
(
kMacOSExecutabl
e
);
final
ValidationResult
result
=
await
webValidator
.
validate
();
...
...
@@ -62,7 +58,7 @@ void main() {
});
testWithoutContext
(
'WebValidator does not warn about CHROME_EXECUTABLE unless it cant find chrome '
,
()
async
{
when
(
processManager
.
canRun
(
kMacOSExecutable
)).
thenReturn
(
fals
e
);
fakeProcessManager
.
excludedExecutables
.
add
(
kMacOSExecutabl
e
);
final
ValidationResult
result
=
await
webValidator
.
validate
();
...
...
@@ -73,5 +69,3 @@ void main() {
expect
(
result
.
type
,
ValidationType
.
missing
);
});
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
packages/flutter_tools/test/src/fake_process_manager.dart
View file @
dbb1958c
...
...
@@ -301,8 +301,11 @@ abstract class FakeProcessManager implements ProcessManager {
);
}
/// Returns false if executable in [excludedExecutables].
@override
bool
canRun
(
dynamic
executable
,
{
String
workingDirectory
})
=>
true
;
bool
canRun
(
dynamic
executable
,
{
String
workingDirectory
})
=>
!
excludedExecutables
.
contains
(
executable
);
Set
<
String
>
excludedExecutables
=
<
String
>{};
@override
bool
killPid
(
int
pid
,
[
io
.
ProcessSignal
signal
=
io
.
ProcessSignal
.
sigterm
])
{
...
...
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