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
23e41734
Unverified
Commit
23e41734
authored
Feb 18, 2021
by
Jenn Magder
Committed by
GitHub
Feb 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap Mocks to Fakes in config_test (#76274)
parent
86d6d17a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
47 deletions
+56
-47
build_linux_test.dart
..._tools/test/commands.shard/hermetic/build_linux_test.dart
+1
-1
config_test.dart
...utter_tools/test/commands.shard/hermetic/config_test.dart
+27
-18
artifact_updater_test.dart
...utter_tools/test/general.shard/artifact_updater_test.dart
+18
-18
signals_test.dart
...s/flutter_tools/test/general.shard/base/signals_test.dart
+1
-1
application_package_test.dart
...ls/test/general.shard/macos/application_package_test.dart
+2
-2
terminal_handler_test.dart
...utter_tools/test/general.shard/terminal_handler_test.dart
+2
-2
vmservice_test.dart
...ages/flutter_tools/test/general.shard/vmservice_test.dart
+5
-5
No files found.
packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart
View file @
23e41734
...
...
@@ -19,8 +19,8 @@ import 'package:flutter_tools/src/commands/build_linux.dart';
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/reporting/reporting.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/commands.shard/hermetic/config_test.dart
View file @
23e41734
...
...
@@ -17,15 +17,15 @@ import 'package:flutter_tools/src/commands/config.dart';
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
void
main
(
)
{
MockAndroidStudio
mock
AndroidStudio
;
MockAndroidSdk
mock
AndroidSdk
;
MockFlutterVersion
mock
FlutterVersion
;
FakeAndroidStudio
fake
AndroidStudio
;
FakeAndroidSdk
fake
AndroidSdk
;
FakeFlutterVersion
fake
FlutterVersion
;
TestUsage
testUsage
;
setUpAll
(()
{
...
...
@@ -33,9 +33,9 @@ void main() {
});
setUp
(()
{
mockAndroidStudio
=
Mock
AndroidStudio
();
mockAndroidSdk
=
Mock
AndroidSdk
();
mockFlutterVersion
=
Mock
FlutterVersion
();
fakeAndroidStudio
=
Fake
AndroidStudio
();
fakeAndroidSdk
=
Fake
AndroidSdk
();
fakeFlutterVersion
=
Fake
FlutterVersion
();
testUsage
=
TestUsage
();
});
...
...
@@ -61,8 +61,8 @@ void main() {
expect
(
jsonObject
[
'android-sdk'
],
isNotNull
);
verifyNoAnalytics
();
},
overrides:
<
Type
,
Generator
>{
AndroidStudio:
()
=>
mock
AndroidStudio
,
AndroidSdk:
()
=>
mock
AndroidSdk
,
AndroidStudio:
()
=>
fake
AndroidStudio
,
AndroidSdk:
()
=>
fake
AndroidSdk
,
Usage:
()
=>
testUsage
,
});
...
...
@@ -134,8 +134,8 @@ void main() {
expect
(
globals
.
config
.
getValue
(
'enable-macos-desktop'
),
false
);
verifyNoAnalytics
();
},
overrides:
<
Type
,
Generator
>{
AndroidStudio:
()
=>
mock
AndroidStudio
,
AndroidSdk:
()
=>
mock
AndroidSdk
,
AndroidStudio:
()
=>
fake
AndroidStudio
,
AndroidSdk:
()
=>
fake
AndroidSdk
,
Usage:
()
=>
testUsage
,
});
...
...
@@ -157,7 +157,7 @@ void main() {
});
testUsingContext
(
'displays which config settings are available on stable'
,
()
async
{
when
(
mockFlutterVersion
.
channel
).
thenReturn
(
'stable'
)
;
fakeFlutterVersion
.
channel
=
'stable'
;
final
ConfigCommand
configCommand
=
ConfigCommand
();
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
configCommand
);
...
...
@@ -191,9 +191,9 @@ void main() {
);
verifyNoAnalytics
();
},
overrides:
<
Type
,
Generator
>{
AndroidStudio:
()
=>
mock
AndroidStudio
,
AndroidSdk:
()
=>
mock
AndroidSdk
,
FlutterVersion:
()
=>
mock
FlutterVersion
,
AndroidStudio:
()
=>
fake
AndroidStudio
,
AndroidSdk:
()
=>
fake
AndroidSdk
,
FlutterVersion:
()
=>
fake
FlutterVersion
,
Usage:
()
=>
testUsage
,
});
...
...
@@ -265,14 +265,23 @@ void main() {
});
}
class
MockAndroidStudio
extends
Mock
implements
AndroidStudio
,
Comparable
<
AndroidStudio
>
{
class
FakeAndroidStudio
extends
Fake
implements
AndroidStudio
,
Comparable
<
AndroidStudio
>
{
@override
String
get
directory
=>
'path/to/android/stdio'
;
}
class
MockAndroidSdk
extends
Mock
implements
AndroidSdk
{
class
FakeAndroidSdk
extends
Fake
implements
AndroidSdk
{
@override
Directory
get
directory
=>
globals
.
fs
.
directory
(
'path/to/android/sdk'
);
}
class
MockFlutterVersion
extends
Mock
implements
FlutterVersion
{}
class
FakeFlutterVersion
extends
Fake
implements
FlutterVersion
{
@override
String
channel
;
@override
void
ensureVersionFile
()
{}
@override
Future
<
void
>
checkFlutterVersionFreshness
()
async
{}
}
packages/flutter_tools/test/general.shard/artifact_updater_test.dart
View file @
23e41734
...
...
@@ -15,7 +15,7 @@ import 'package:flutter_tools/src/base/os.dart';
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'../src/common.dart'
;
import
'../src/fake_http_client.dart'
;
...
...
@@ -25,7 +25,7 @@ final Platform testPlatform = FakePlatform(environment: const <String, String>{}
void
main
(
)
{
testWithoutContext
(
'ArtifactUpdater can download a zip archive'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ArtifactUpdater
artifactUpdater
=
ArtifactUpdater
(
...
...
@@ -48,7 +48,7 @@ void main() {
});
testWithoutContext
(
'ArtifactUpdater can download a zip archive and delete stale files'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ArtifactUpdater
artifactUpdater
=
ArtifactUpdater
(
...
...
@@ -78,7 +78,7 @@ void main() {
testWithoutContext
(
'ArtifactUpdater will not validate the md5 hash if the '
'x-goog-hash header is present but missing an md5 entry'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
...
...
@@ -109,7 +109,7 @@ void main() {
testWithoutContext
(
'ArtifactUpdater will validate the md5 hash if the '
'x-goog-hash header is present'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
...
...
@@ -144,7 +144,7 @@ void main() {
testWithoutContext
(
'ArtifactUpdater will validate the md5 hash if the '
'x-goog-hash header is present and throw if it does not match'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
...
...
@@ -184,7 +184,7 @@ void main() {
});
testWithoutContext
(
'ArtifactUpdater will restart the status ticker if it needs to retry the download'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Logger
logger
=
StdoutLogger
(
terminal:
Terminal
.
test
(
supportsColor:
true
),
...
...
@@ -214,7 +214,7 @@ void main() {
});
testWithoutContext
(
'ArtifactUpdater will re-attempt on a non-200 response'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
...
...
@@ -242,7 +242,7 @@ void main() {
});
testWithoutContext
(
'ArtifactUpdater will tool exit on an ArgumentError from http client with base url override'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ArtifactUpdater
artifactUpdater
=
ArtifactUpdater
(
...
...
@@ -272,7 +272,7 @@ void main() {
});
testWithoutContext
(
'ArtifactUpdater will rethrow on an ArgumentError from http client without base url override'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ArtifactUpdater
artifactUpdater
=
ArtifactUpdater
(
...
...
@@ -298,7 +298,7 @@ void main() {
});
testWithoutContext
(
'ArtifactUpdater will re-download a file if unzipping fails'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ArtifactUpdater
artifactUpdater
=
ArtifactUpdater
(
...
...
@@ -322,7 +322,7 @@ void main() {
});
testWithoutContext
(
'ArtifactUpdater will de-download a file if unzipping fails on windows'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
(
windows:
true
);
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
(
windows:
true
);
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ArtifactUpdater
artifactUpdater
=
ArtifactUpdater
(
...
...
@@ -346,7 +346,7 @@ void main() {
});
testWithoutContext
(
'ArtifactUpdater will bail with a tool exit if unzipping fails more than twice'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ArtifactUpdater
artifactUpdater
=
ArtifactUpdater
(
...
...
@@ -370,7 +370,7 @@ void main() {
});
testWithoutContext
(
'ArtifactUpdater will bail if unzipping fails more than twice on Windows'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
(
windows:
true
);
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
(
windows:
true
);
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ArtifactUpdater
artifactUpdater
=
ArtifactUpdater
(
...
...
@@ -394,7 +394,7 @@ void main() {
});
testWithoutContext
(
'ArtifactUpdater can download a tar archive'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ArtifactUpdater
artifactUpdater
=
ArtifactUpdater
(
...
...
@@ -416,7 +416,7 @@ void main() {
});
testWithoutContext
(
'ArtifactUpdater will delete downloaded files if they exist.'
,
()
async
{
final
MockOperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ArtifactUpdater
artifactUpdater
=
ArtifactUpdater
(
...
...
@@ -441,8 +441,8 @@ void main() {
});
}
class
MockOperatingSystemUtils
extends
Mock
implements
OperatingSystemUtils
{
Mock
OperatingSystemUtils
({
this
.
windows
=
false
});
class
FakeOperatingSystemUtils
extends
Fake
implements
OperatingSystemUtils
{
Fake
OperatingSystemUtils
({
this
.
windows
=
false
});
int
failures
=
0
;
final
bool
windows
;
...
...
packages/flutter_tools/test/general.shard/base/signals_test.dart
View file @
23e41734
...
...
@@ -9,7 +9,7 @@ import 'dart:io' as io;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/signals.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'../../src/common.dart'
;
...
...
packages/flutter_tools/test/general.shard/macos/application_package_test.dart
View file @
23e41734
...
...
@@ -26,7 +26,7 @@ void main() {
final
Map
<
Type
,
Generator
>
overrides
=
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
PlistParser:
()
=>
Mock
PlistUtils
(),
PlistParser:
()
=>
Fake
PlistUtils
(),
Platform:
_kNoColorTerminalPlatform
,
OperatingSystemUtils:
()
=>
os
,
};
...
...
@@ -204,7 +204,7 @@ final Map<Type, Generator> noColorTerminalOverride = <Type, Generator>{
Platform:
_kNoColorTerminalPlatform
,
};
class
MockPlistUtils
extends
Mock
implements
PlistParser
{
class
FakePlistUtils
extends
Fake
implements
PlistParser
{
@override
Map
<
String
,
dynamic
>
parseFile
(
String
plistFilePath
)
{
final
File
file
=
globals
.
fs
.
file
(
plistFilePath
);
...
...
packages/flutter_tools/test/general.shard/terminal_handler_test.dart
View file @
23e41734
...
...
@@ -362,9 +362,9 @@ class MockDevice extends Mock implements Device {
class
MockResidentRunner
extends
Mock
implements
ResidentRunner
{}
class
MockFlutterDevice
extends
Mock
implements
FlutterDevice
{}
class
MockResidentCompiler
extends
Mock
implements
ResidentCompiler
{}
class
FakeResidentCompiler
extends
Fake
implements
ResidentCompiler
{}
class
TestRunner
extends
Mock
implements
ResidentRunner
{
class
TestRunner
extends
Fake
implements
ResidentRunner
{
bool
hasHelpBeenPrinted
=
false
;
String
receivedCommand
;
...
...
packages/flutter_tools/test/general.shard/vmservice_test.dart
View file @
23e41734
...
...
@@ -115,7 +115,7 @@ void main() {
});
testUsingContext
(
'VmService registers flutterMemoryInfo service'
,
()
async
{
final
MockDevice
mockDevice
=
Mock
Device
();
final
FakeDevice
mockDevice
=
Fake
Device
();
final
MockVMService
mockVMService
=
MockVMService
();
setUpVmService
(
...
...
@@ -183,7 +183,7 @@ void main() {
verify
(
mockVMService
.
registerService
(
'flutterVersion'
,
'Flutter Tools'
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
FlutterVersion:
()
=>
Mock
FlutterVersion
(),
FlutterVersion:
()
=>
Fake
FlutterVersion
(),
});
testUsingContext
(
'VMService prints messages for connection failures'
,
()
{
...
...
@@ -467,11 +467,11 @@ void main() {
});
}
class
MockDevice
extends
Mock
implements
Device
{}
class
MockVMService
extends
Mock
implements
vm_service
.
VmService
{}
class
MockFlutterVersion
extends
Mock
implements
FlutterVersion
{
class
FakeDevice
extends
Fake
implements
Device
{}
class
FakeFlutterVersion
extends
Fake
implements
FlutterVersion
{
@override
Map
<
String
,
Object
>
toJson
()
=>
const
<
String
,
Object
>{
'
Mock
'
:
'Version'
};
Map
<
String
,
Object
>
toJson
()
=>
const
<
String
,
Object
>{
'
Fake
'
:
'Version'
};
}
/// A [WebSocketConnector] that always throws an [io.SocketException].
...
...
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