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
6e5f9ed9
Unverified
Commit
6e5f9ed9
authored
Oct 05, 2020
by
Jenn Magder
Committed by
GitHub
Oct 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace MockProcessManager with FakeProcessManager (#67019)
parent
b42cf8a7
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
222 additions
and
275 deletions
+222
-275
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+0
-2
build_windows_test.dart
...ools/test/commands.shard/hermetic/build_windows_test.dart
+0
-3
upgrade_test.dart
...ter_tools/test/commands.shard/permeable/upgrade_test.dart
+201
-230
application_package_test.dart
...er_tools/test/general.shard/application_package_test.dart
+21
-40
No files found.
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
6e5f9ed9
...
...
@@ -827,8 +827,6 @@ class TestHotRunnerFactory extends HotRunnerFactory {
}
class
MockDartDevelopmentService
extends
Mock
implements
DartDevelopmentService
{}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockProcess
extends
Mock
implements
Process
{}
class
MockHttpClientRequest
extends
Mock
implements
HttpClientRequest
{}
class
MockHttpClientResponse
extends
Mock
implements
HttpClientResponse
{}
class
MockHttpHeaders
extends
Mock
implements
HttpHeaders
{}
packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart
View file @
6e5f9ed9
...
...
@@ -5,7 +5,6 @@
import
'package:file/memory.dart'
;
import
'package:file_testing/file_testing.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/build_windows.dart'
;
...
...
@@ -420,7 +419,5 @@ C:\foo\windows\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identifier
});
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockProcess
extends
Mock
implements
Process
{}
class
MockVisualStudio
extends
Mock
implements
VisualStudio
{}
class
MockUsage
extends
Mock
implements
Usage
{}
packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
View file @
6e5f9ed9
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/application_package_test.dart
View file @
6e5f9ed9
...
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import
'dart:convert'
;
import
'dart:io'
show
ProcessResult
;
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
...
...
@@ -30,44 +29,35 @@ final Map<Type, Generator> noColorTerminalOverride = <Type, Generator>{
Platform:
_kNoColorTerminalPlatform
,
};
class
MockitoProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockitoAndroidSdk
extends
Mock
implements
AndroidSdk
{}
class
MockitoAndroidSdkVersion
extends
Mock
implements
AndroidSdkVersion
{}
void
main
(
)
{
group
(
'Apk with partial Android SDK works'
,
()
{
AndroidSdk
sdk
;
ProcessManager
mock
ProcessManager
;
FakeProcessManager
fake
ProcessManager
;
MemoryFileSystem
fs
;
Cache
cache
;
File
gradle
;
final
Map
<
Type
,
Generator
>
overrides
=
<
Type
,
Generator
>{
AndroidSdk:
()
=>
sdk
,
ProcessManager:
()
=>
mock
ProcessManager
,
ProcessManager:
()
=>
fake
ProcessManager
,
FileSystem:
()
=>
fs
,
Cache:
()
=>
cache
,
};
setUp
(()
async
{
sdk
=
MockitoAndroidSdk
();
mockProcessManager
=
MockitoProcessManager
(
);
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[]
);
fs
=
MemoryFileSystem
.
test
();
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
processManager:
FakeProcessManager
.
any
()
,
);
Cache
.
flutterRoot
=
'../..'
;
when
(
sdk
.
licensesAvailable
).
thenReturn
(
true
);
when
(
mockProcessManager
.
canRun
(
any
)).
thenReturn
(
true
);
when
(
mockProcessManager
.
run
(
any
,
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
)).
thenAnswer
((
_
)
async
=>
ProcessResult
(
1
,
0
,
'stdout'
,
'stderr'
));
when
(
mockProcessManager
.
runSync
(
any
)).
thenReturn
(
ProcessResult
(
1
,
0
,
'stdout'
,
'stderr'
));
final
FlutterProject
project
=
FlutterProject
.
current
();
g
radle
=
g
lobals
.
fs
.
file
(
project
.
android
.
hostAppGradleRoot
.
childFile
(
globals
.
fs
.
file
(
project
.
android
.
hostAppGradleRoot
.
childFile
(
globals
.
platform
.
isWindows
?
'gradlew.bat'
:
'gradlew'
,
).
path
).
.
createSync
(
recursive:
true
);
).
path
).
createSync
(
recursive:
true
);
});
testUsingContext
(
'Licenses not available, platform and buildtools available, apk exists'
,
()
async
{
...
...
@@ -78,18 +68,19 @@ void main() {
when
(
sdk
.
latestVersion
).
thenReturn
(
sdkVersion
);
when
(
sdk
.
platformToolsAvailable
).
thenReturn
(
true
);
when
(
sdk
.
licensesAvailable
).
thenReturn
(
false
);
when
(
mockProcessManager
.
runSync
(
argThat
(
equals
(<
String
>[
fakeProcessManager
.
addCommand
(
FakeCommand
(
command:
<
String
>[
aaptPath
,
'dump'
,
'xmltree'
,
apkFile
.
path
,
apkFile
.
path
,
'AndroidManifest.xml'
,
])),
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
),
).
thenReturn
(
ProcessResult
(
0
,
0
,
_aaptDataWithDefaultEnabledAndMainLauncherActivity
,
''
));
],
stdout:
_aaptDataWithDefaultEnabledAndMainLauncherActivity
)
);
final
ApplicationPackage
applicationPackage
=
await
ApplicationPackageFactory
.
instance
.
getPackageForPlatform
(
TargetPlatform
.
android_arm
,
...
...
@@ -97,6 +88,7 @@ void main() {
applicationBinary:
apkFile
,
);
expect
(
applicationPackage
.
name
,
'app.apk'
);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
overrides
);
testUsingContext
(
'Licenses available, build tools not, apk exists'
,
()
async
{
...
...
@@ -117,18 +109,14 @@ void main() {
gradleWrapperDir
.
childFile
(
'gradlew'
).
writeAsStringSync
(
'irrelevant'
);
gradleWrapperDir
.
childFile
(
'gradlew.bat'
).
writeAsStringSync
(
'irrelevant'
);
fakeProcessManager
.
addCommand
(
FakeCommand
(
command:
<
String
>[
gradle
.
path
,
'dependencies'
]));
await
ApplicationPackageFactory
.
instance
.
getPackageForPlatform
(
TargetPlatform
.
android_arm
,
buildInfo:
null
,
applicationBinary:
globals
.
fs
.
file
(
'app.apk'
),
);
verify
(
mockProcessManager
.
run
(
argThat
(
equals
(<
String
>[
gradle
.
path
,
'dependencies'
])),
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
),
).
called
(
1
);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
overrides
);
testUsingContext
(
'Licenses available, build tools available, does not call gradle dependencies'
,
()
async
{
...
...
@@ -139,22 +127,15 @@ void main() {
TargetPlatform
.
android_arm
,
buildInfo:
null
,
);
verifyNever
(
mockProcessManager
.
run
(
argThat
(
equals
(<
String
>[
gradle
.
path
,
'dependencies'
])),
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
),
);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
overrides
);
testUsingContext
(
'returns null when failed to extract manifest'
,
()
async
{
final
AndroidSdkVersion
sdkVersion
=
MockitoAndroidSdkVersion
();
when
(
sdk
.
latestVersion
).
thenReturn
(
sdkVersion
);
when
(
mockProcessManager
.
runSync
(
argThat
(
contains
(
'logcat'
))))
.
thenReturn
(
ProcessResult
(
0
,
1
,
''
,
''
));
expect
(
AndroidApk
.
fromApk
(
null
),
isNull
);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
overrides
);
});
...
...
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