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
9805df89
Unverified
Commit
9805df89
authored
May 15, 2021
by
Jonah Williams
Committed by
GitHub
May 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove more mocks (#82592)
parent
a34713fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
68 deletions
+87
-68
cache_test.dart
packages/flutter_tools/test/general.shard/cache_test.dart
+82
-67
fakes.dart
packages/flutter_tools/test/src/fakes.dart
+5
-1
No files found.
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
9805df89
...
@@ -22,6 +22,7 @@ import 'package:mockito/mockito.dart';
...
@@ -22,6 +22,7 @@ import 'package:mockito/mockito.dart';
import
'../src/common.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
import
'../src/context.dart'
;
import
'../src/fakes.dart'
;
const
FakeCommand
unameCommandForX64
=
FakeCommand
(
const
FakeCommand
unameCommandForX64
=
FakeCommand
(
command:
<
String
>[
command:
<
String
>[
...
@@ -126,7 +127,7 @@ void main() {
...
@@ -126,7 +127,7 @@ void main() {
throw
const
FileSystemException
(
'stamp write failed'
);
throw
const
FileSystemException
(
'stamp write failed'
);
});
});
final
FakeSimpleArtifact
artifact
=
FakeSimpleArtifact
(
mockCache
);
final
FakeSimpleArtifact
artifact
=
FakeSimpleArtifact
(
mockCache
);
await
artifact
.
update
(
MockArtifactUpdater
(),
logger
,
fileSystem
,
Mock
OperatingSystemUtils
());
await
artifact
.
update
(
FakeArtifactUpdater
(),
logger
,
fileSystem
,
Fake
OperatingSystemUtils
());
expect
(
logger
.
errorText
,
contains
(
'stamp write failed'
));
expect
(
logger
.
errorText
,
contains
(
'stamp write failed'
));
});
});
...
@@ -142,7 +143,7 @@ void main() {
...
@@ -142,7 +143,7 @@ void main() {
when
(
mockCache
.
getArtifactDirectory
(
any
)).
thenReturn
(
artifactDir
);
when
(
mockCache
.
getArtifactDirectory
(
any
)).
thenReturn
(
artifactDir
);
when
(
mockCache
.
getDownloadDir
()).
thenReturn
(
downloadDir
);
when
(
mockCache
.
getDownloadDir
()).
thenReturn
(
downloadDir
);
final
FakeSimpleArtifact
artifact
=
FakeSimpleArtifact
(
mockCache
);
final
FakeSimpleArtifact
artifact
=
FakeSimpleArtifact
(
mockCache
);
await
artifact
.
update
(
MockArtifactUpdater
(),
logger
,
fileSystem
,
Mock
OperatingSystemUtils
());
await
artifact
.
update
(
FakeArtifactUpdater
(),
logger
,
fileSystem
,
Fake
OperatingSystemUtils
());
expect
(
logger
.
errorText
,
contains
(
'No known version for the artifact name "fake"'
));
expect
(
logger
.
errorText
,
contains
(
'No known version for the artifact name "fake"'
));
});
});
...
@@ -276,8 +277,7 @@ void main() {
...
@@ -276,8 +277,7 @@ void main() {
final
CachedArtifact
artifact2
=
MockCachedArtifact
();
final
CachedArtifact
artifact2
=
MockCachedArtifact
();
when
(
artifact1
.
isUpToDate
(
any
)).
thenAnswer
((
Invocation
_
)
=>
Future
<
bool
>.
value
(
false
));
when
(
artifact1
.
isUpToDate
(
any
)).
thenAnswer
((
Invocation
_
)
=>
Future
<
bool
>.
value
(
false
));
when
(
artifact2
.
isUpToDate
(
any
)).
thenAnswer
((
Invocation
_
)
=>
Future
<
bool
>.
value
(
false
));
when
(
artifact2
.
isUpToDate
(
any
)).
thenAnswer
((
Invocation
_
)
=>
Future
<
bool
>.
value
(
false
));
final
MockInternetAddress
address
=
MockInternetAddress
();
final
InternetAddress
address
=
(
await
InternetAddress
.
lookup
(
'storage.googleapis.com'
)).
first
;
when
(
address
.
host
).
thenReturn
(
'storage.googleapis.com'
);
when
(
artifact1
.
update
(
any
,
any
,
any
,
any
)).
thenThrow
(
SocketException
(
when
(
artifact1
.
update
(
any
,
any
,
any
,
any
)).
thenThrow
(
SocketException
(
'Connection reset by peer'
,
'Connection reset by peer'
,
address:
address
,
address:
address
,
...
@@ -320,7 +320,7 @@ void main() {
...
@@ -320,7 +320,7 @@ void main() {
});
});
testWithoutContext
(
'EngineCachedArtifact makes binary dirs readable and executable by all'
,
()
async
{
testWithoutContext
(
'EngineCachedArtifact makes binary dirs readable and executable by all'
,
()
async
{
final
OperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
FakeOperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MockCache
cache
=
MockCache
();
final
MockCache
cache
=
MockCache
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Directory
artifactDir
=
fileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_cache_test_artifact.'
);
final
Directory
artifactDir
=
fileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_cache_test_artifact.'
);
...
@@ -338,7 +338,7 @@ void main() {
...
@@ -338,7 +338,7 @@ void main() {
],
],
requiredArtifacts:
DevelopmentArtifact
.
universal
,
requiredArtifacts:
DevelopmentArtifact
.
universal
,
);
);
await
artifact
.
updateInner
(
Mock
ArtifactUpdater
(),
fileSystem
,
operatingSystemUtils
);
await
artifact
.
updateInner
(
Fake
ArtifactUpdater
(),
fileSystem
,
operatingSystemUtils
);
final
Directory
dir
=
fileSystem
.
systemTempDirectory
final
Directory
dir
=
fileSystem
.
systemTempDirectory
.
listSync
(
recursive:
true
)
.
listSync
(
recursive:
true
)
.
whereType
<
Directory
>()
.
whereType
<
Directory
>()
...
@@ -346,11 +346,11 @@ void main() {
...
@@ -346,11 +346,11 @@ void main() {
expect
(
dir
,
isNotNull
);
expect
(
dir
,
isNotNull
);
expect
(
dir
.
path
,
artifactDir
.
childDirectory
(
'bin_dir'
).
path
);
expect
(
dir
.
path
,
artifactDir
.
childDirectory
(
'bin_dir'
).
path
);
verify
(
operatingSystemUtils
.
chmod
(
argThat
(
hasPath
(
dir
.
path
)),
'a+r,a+x'
)
);
expect
(
operatingSystemUtils
.
chmods
,
<
List
<
String
>>[<
String
>[
'/.tmp_rand0/flutter_cache_test_artifact.rand0/bin_dir'
,
'a+r,a+x'
]]
);
});
});
testWithoutContext
(
'EngineCachedArtifact removes unzipped FlutterMacOS.framework before replacing'
,
()
async
{
testWithoutContext
(
'EngineCachedArtifact removes unzipped FlutterMacOS.framework before replacing'
,
()
async
{
final
OperatingSystemUtils
operatingSystemUtils
=
Mock
OperatingSystemUtils
();
final
OperatingSystemUtils
operatingSystemUtils
=
Fake
OperatingSystemUtils
();
final
MockCache
cache
=
MockCache
();
final
MockCache
cache
=
MockCache
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Directory
artifactDir
=
fileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_cache_test_artifact.'
);
final
Directory
artifactDir
=
fileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_cache_test_artifact.'
);
...
@@ -371,7 +371,7 @@ void main() {
...
@@ -371,7 +371,7 @@ void main() {
],
],
requiredArtifacts:
DevelopmentArtifact
.
universal
,
requiredArtifacts:
DevelopmentArtifact
.
universal
,
);
);
await
artifact
.
updateInner
(
Mock
ArtifactUpdater
(),
fileSystem
,
operatingSystemUtils
);
await
artifact
.
updateInner
(
Fake
ArtifactUpdater
(),
fileSystem
,
operatingSystemUtils
);
expect
(
unzippedFramework
,
exists
);
expect
(
unzippedFramework
,
exists
);
expect
(
staleFile
,
isNot
(
exists
));
expect
(
staleFile
,
isNot
(
exists
));
});
});
...
@@ -438,19 +438,18 @@ void main() {
...
@@ -438,19 +438,18 @@ void main() {
fileSystem:
fileSystem
,
fileSystem:
fileSystem
,
processManager:
FakeProcessManager
.
any
(),
processManager:
FakeProcessManager
.
any
(),
);
);
final
MockVersionedPackageResolver
mockPackageResolver
=
Mock
VersionedPackageResolver
();
final
FakeVersionedPackageResolver
packageResolver
=
Fake
VersionedPackageResolver
();
final
FlutterRunnerDebugSymbols
flutterRunnerDebugSymbols
=
FlutterRunnerDebugSymbols
(
final
FlutterRunnerDebugSymbols
flutterRunnerDebugSymbols
=
FlutterRunnerDebugSymbols
(
cache
,
cache
,
packageResolver:
mockP
ackageResolver
,
packageResolver:
p
ackageResolver
,
platform:
FakePlatform
(
operatingSystem:
'linux'
),
platform:
FakePlatform
(
operatingSystem:
'linux'
),
);
);
when
(
mockPackageResolver
.
resolveUrl
(
any
,
any
)).
thenReturn
(
''
);
await
flutterRunnerDebugSymbols
.
updateInner
(
MockArtifactUpdater
(),
fileSystem
,
Mock
OperatingSystemUtils
());
await
flutterRunnerDebugSymbols
.
updateInner
(
FakeArtifactUpdater
(),
fileSystem
,
Fake
OperatingSystemUtils
());
verifyInOrder
(<
void
>[
expect
(
packageResolver
.
resolved
,
<
List
<
String
>
>[
mockPackageResolver
.
resolveUrl
(
'fuchsia-debug-symbols-x64'
,
any
)
,
<
String
>[
'fuchsia-debug-symbols-x64'
,
null
]
,
mockPackageResolver
.
resolveUrl
(
'fuchsia-debug-symbols-arm64'
,
any
)
,
<
String
>[
'fuchsia-debug-symbols-arm64'
,
null
]
,
]);
]);
});
});
...
@@ -659,7 +658,7 @@ void main() {
...
@@ -659,7 +658,7 @@ void main() {
logger:
logger
,
logger:
logger
,
fileSystem:
fileSystem
,
fileSystem:
fileSystem
,
platform:
FakePlatform
(),
platform:
FakePlatform
(),
osUtils:
Mock
OperatingSystemUtils
(),
osUtils:
Fake
OperatingSystemUtils
(),
rootOverride:
fileSystem
.
currentDirectory
,
rootOverride:
fileSystem
.
currentDirectory
,
);
);
final
File
toolStampFile
=
fileSystem
.
file
(
'bin/cache/flutter_tools.stamp'
);
final
File
toolStampFile
=
fileSystem
.
file
(
'bin/cache/flutter_tools.stamp'
);
...
@@ -687,7 +686,7 @@ void main() {
...
@@ -687,7 +686,7 @@ void main() {
logger:
logger
,
logger:
logger
,
fileSystem:
fileSystem
,
fileSystem:
fileSystem
,
platform:
FakePlatform
(),
platform:
FakePlatform
(),
osUtils:
Mock
OperatingSystemUtils
(),
osUtils:
Fake
OperatingSystemUtils
(),
rootOverride:
fileSystem
.
currentDirectory
,
rootOverride:
fileSystem
.
currentDirectory
,
);
);
final
File
toolStampFile
=
fileSystem
.
file
(
'bin/cache/flutter_tools.stamp'
);
final
File
toolStampFile
=
fileSystem
.
file
(
'bin/cache/flutter_tools.stamp'
);
...
@@ -714,7 +713,7 @@ void main() {
...
@@ -714,7 +713,7 @@ void main() {
logger:
logger
,
logger:
logger
,
fileSystem:
fileSystem
,
fileSystem:
fileSystem
,
platform:
FakePlatform
(),
platform:
FakePlatform
(),
osUtils:
Mock
OperatingSystemUtils
(),
osUtils:
Fake
OperatingSystemUtils
(),
rootOverride:
fileSystem
.
currentDirectory
,
rootOverride:
fileSystem
.
currentDirectory
,
);
);
...
@@ -725,46 +724,40 @@ void main() {
...
@@ -725,46 +724,40 @@ void main() {
testWithoutContext
(
'FlutterWebSdk deletes previous directory contents'
,
()
{
testWithoutContext
(
'FlutterWebSdk deletes previous directory contents'
,
()
{
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Directory
webStuff
=
fileSystem
.
directory
(
'web-stuff'
);
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
(),
fileSystem:
fileSystem
);
final
MockCache
cache
=
MockCache
();
final
Directory
webCacheDirectory
=
cache
.
getWebSdkDirectory
();
final
MockArtifactUpdater
artifactUpdater
=
Mock
ArtifactUpdater
();
final
FakeArtifactUpdater
artifactUpdater
=
Fake
ArtifactUpdater
();
final
FlutterWebSdk
webSdk
=
FlutterWebSdk
(
cache
,
platform:
FakePlatform
(
operatingSystem:
'linux'
));
final
FlutterWebSdk
webSdk
=
FlutterWebSdk
(
cache
,
platform:
FakePlatform
(
operatingSystem:
'linux'
));
when
(
cache
.
getWebSdkDirectory
()).
thenReturn
(
webStuff
);
artifactUpdater
.
onDownloadZipArchive
=
(
String
message
,
Uri
uri
,
Directory
location
)
{
when
(
artifactUpdater
.
downloadZipArchive
(
'Downloading Web SDK...'
,
any
,
any
))
location
.
createSync
(
recursive:
true
);
.
thenAnswer
((
Invocation
invocation
)
async
{
location
.
childFile
(
'foo'
).
createSync
();
final
Directory
location
=
invocation
.
positionalArguments
[
2
]
as
Directory
;
};
location
.
createSync
(
recursive:
true
);
webCacheDirectory
.
childFile
(
'bar'
).
createSync
(
recursive:
true
);
location
.
childFile
(
'foo'
).
createSync
();
});
webStuff
.
childFile
(
'bar'
).
createSync
(
recursive:
true
);
webSdk
.
updateInner
(
artifactUpdater
,
fileSystem
,
Mock
OperatingSystemUtils
());
webSdk
.
updateInner
(
artifactUpdater
,
fileSystem
,
Fake
OperatingSystemUtils
());
expect
(
web
Stuff
.
childFile
(
'foo'
),
exists
);
expect
(
web
CacheDirectory
.
childFile
(
'foo'
),
exists
);
expect
(
web
Stuff
.
childFile
(
'bar'
),
isNot
(
exists
));
expect
(
web
CacheDirectory
.
childFile
(
'bar'
),
isNot
(
exists
));
});
});
testWithoutContext
(
'FlutterWebSdk uses tryToDelete to handle directory edge cases'
,
()
async
{
testWithoutContext
(
'FlutterWebSdk uses tryToDelete to handle directory edge cases'
,
()
async
{
final
FileExceptionHandler
handler
=
FileExceptionHandler
();
final
FileExceptionHandler
handler
=
FileExceptionHandler
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
(
opHandle:
handler
.
opHandle
);
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
(
opHandle:
handler
.
opHandle
);
final
Directory
webStuff
=
fileSystem
.
directory
(
'web-stuff'
);
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
(),
fileSystem:
fileSystem
);
final
MockCache
cache
=
MockCache
();
final
Directory
webCacheDirectory
=
cache
.
getWebSdkDirectory
();
final
MockArtifactUpdater
artifactUpdater
=
Mock
ArtifactUpdater
();
final
FakeArtifactUpdater
artifactUpdater
=
Fake
ArtifactUpdater
();
final
FlutterWebSdk
webSdk
=
FlutterWebSdk
(
cache
,
platform:
FakePlatform
(
operatingSystem:
'linux'
));
final
FlutterWebSdk
webSdk
=
FlutterWebSdk
(
cache
,
platform:
FakePlatform
(
operatingSystem:
'linux'
));
when
(
cache
.
getWebSdkDirectory
()).
thenReturn
(
webStuff
);
artifactUpdater
.
onDownloadZipArchive
=
(
String
message
,
Uri
uri
,
Directory
location
)
{
when
(
artifactUpdater
.
downloadZipArchive
(
'Downloading Web SDK...'
,
any
,
any
))
location
.
createSync
(
recursive:
true
);
.
thenAnswer
((
Invocation
invocation
)
async
{
location
.
childFile
(
'foo'
).
createSync
();
final
Directory
location
=
invocation
.
positionalArguments
[
2
]
as
Directory
;
};
location
.
createSync
(
recursive:
true
);
webCacheDirectory
.
childFile
(
'bar'
).
createSync
(
recursive:
true
);
location
.
childFile
(
'foo'
).
createSync
();
handler
.
addError
(
webCacheDirectory
,
FileSystemOp
.
delete
,
const
FileSystemException
(
''
,
''
,
OSError
(
''
,
2
)));
});
webStuff
.
childFile
(
'bar'
).
createSync
(
recursive:
true
);
handler
.
addError
(
webStuff
,
FileSystemOp
.
delete
,
const
FileSystemException
(
''
,
''
,
OSError
(
''
,
2
)));
await
expectLater
(()
=>
webSdk
.
updateInner
(
artifactUpdater
,
fileSystem
,
Mock
OperatingSystemUtils
()),
throwsToolExit
(
await
expectLater
(()
=>
webSdk
.
updateInner
(
artifactUpdater
,
fileSystem
,
Fake
OperatingSystemUtils
()),
throwsToolExit
(
message:
RegExp
(
'The Flutter tool tried to delete the file or directory
web-stuff
but was unable to'
),
message:
RegExp
(
'The Flutter tool tried to delete the file or directory
cache/bin/cache/flutter_web_sdk
but was unable to'
),
));
));
});
});
...
@@ -776,7 +769,7 @@ void main() {
...
@@ -776,7 +769,7 @@ void main() {
fileSystem:
fileSystem
,
fileSystem:
fileSystem
,
logger:
logger
,
logger:
logger
,
platform:
FakePlatform
(),
platform:
FakePlatform
(),
osUtils:
Mock
OperatingSystemUtils
()
osUtils:
Fake
OperatingSystemUtils
()
);
);
final
File
file
=
fileSystem
.
file
(
'stamp'
);
final
File
file
=
fileSystem
.
file
(
'stamp'
);
cache
.
stampFile
=
file
;
cache
.
stampFile
=
file
;
...
@@ -797,10 +790,10 @@ void main() {
...
@@ -797,10 +790,10 @@ void main() {
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Logger
logger
=
BufferLogger
.
test
();
final
Logger
logger
=
BufferLogger
.
test
();
final
FakeCache
cache
=
FakeCache
(
final
FakeCache
cache
=
FakeCache
(
fileSystem:
fileSystem
,
fileSystem:
fileSystem
,
logger:
logger
,
logger:
logger
,
platform:
FakePlatform
(),
platform:
FakePlatform
(),
osUtils:
Mock
OperatingSystemUtils
()
osUtils:
Fake
OperatingSystemUtils
()
);
);
final
File
file
=
fileSystem
.
file
(
'stamp'
)..
writeAsStringSync
(
'ABC '
);
final
File
file
=
fileSystem
.
file
(
'stamp'
)..
writeAsStringSync
(
'ABC '
);
...
@@ -816,7 +809,7 @@ void main() {
...
@@ -816,7 +809,7 @@ void main() {
final
PubDependencies
pubDependencies
=
PubDependencies
(
final
PubDependencies
pubDependencies
=
PubDependencies
(
flutterRoot:
()
=>
''
,
flutterRoot:
()
=>
''
,
logger:
logger
,
logger:
logger
,
pub:
()
=>
Mock
Pub
(),
pub:
()
=>
Fake
Pub
(),
);
);
expect
(
await
pubDependencies
.
isUpToDate
(
fileSystem
),
false
);
// no package config
expect
(
await
pubDependencies
.
isUpToDate
(
fileSystem
),
false
);
// no package config
...
@@ -854,19 +847,16 @@ void main() {
...
@@ -854,19 +847,16 @@ void main() {
testWithoutContext
(
'PubDependencies updates via pub get'
,
()
async
{
testWithoutContext
(
'PubDependencies updates via pub get'
,
()
async
{
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
MockPub
pub
=
Mock
Pub
();
final
FakePub
pub
=
Fake
Pub
();
final
PubDependencies
pubDependencies
=
PubDependencies
(
final
PubDependencies
pubDependencies
=
PubDependencies
(
flutterRoot:
()
=>
''
,
flutterRoot:
()
=>
''
,
logger:
logger
,
logger:
logger
,
pub:
()
=>
pub
,
pub:
()
=>
pub
,
);
);
await
pubDependencies
.
update
(
MockArtifactUpdater
(),
logger
,
fileSystem
,
Mock
OperatingSystemUtils
());
await
pubDependencies
.
update
(
FakeArtifactUpdater
(),
logger
,
fileSystem
,
Fake
OperatingSystemUtils
());
verify
(
pub
.
get
(
expect
(
pub
.
calledGet
,
1
);
context:
PubContext
.
pubGet
,
directory:
'packages/flutter_tools'
,
)).
called
(
1
);
});
});
group
(
'AndroidMavenArtifacts'
,
()
{
group
(
'AndroidMavenArtifacts'
,
()
{
...
@@ -897,7 +887,7 @@ void main() {
...
@@ -897,7 +887,7 @@ void main() {
gradleWrapperDir
.
childFile
(
'gradlew'
).
writeAsStringSync
(
'irrelevant'
);
gradleWrapperDir
.
childFile
(
'gradlew'
).
writeAsStringSync
(
'irrelevant'
);
gradleWrapperDir
.
childFile
(
'gradlew.bat'
).
writeAsStringSync
(
'irrelevant'
);
gradleWrapperDir
.
childFile
(
'gradlew.bat'
).
writeAsStringSync
(
'irrelevant'
);
await
mavenArtifacts
.
update
(
MockArtifactUpdater
(),
BufferLogger
.
test
(),
memoryFileSystem
,
Mock
OperatingSystemUtils
());
await
mavenArtifacts
.
update
(
FakeArtifactUpdater
(),
BufferLogger
.
test
(),
memoryFileSystem
,
Fake
OperatingSystemUtils
());
expect
(
await
mavenArtifacts
.
isUpToDate
(
memoryFileSystem
),
isFalse
);
expect
(
await
mavenArtifacts
.
isUpToDate
(
memoryFileSystem
),
isFalse
);
expect
(
fakeAndroidSdk
.
reinitialized
,
true
);
expect
(
fakeAndroidSdk
.
reinitialized
,
true
);
...
@@ -922,7 +912,7 @@ void main() {
...
@@ -922,7 +912,7 @@ void main() {
final
AndroidMavenArtifacts
mavenArtifacts
=
AndroidMavenArtifacts
(
cache
,
platform:
FakePlatform
(
operatingSystem:
'linux'
));
final
AndroidMavenArtifacts
mavenArtifacts
=
AndroidMavenArtifacts
(
cache
,
platform:
FakePlatform
(
operatingSystem:
'linux'
));
expect
(
await
mavenArtifacts
.
isUpToDate
(
memoryFileSystem
),
isFalse
);
expect
(
await
mavenArtifacts
.
isUpToDate
(
memoryFileSystem
),
isFalse
);
await
mavenArtifacts
.
update
(
MockArtifactUpdater
(),
BufferLogger
.
test
(),
memoryFileSystem
,
Mock
OperatingSystemUtils
());
await
mavenArtifacts
.
update
(
FakeArtifactUpdater
(),
BufferLogger
.
test
(),
memoryFileSystem
,
Fake
OperatingSystemUtils
());
expect
(
await
mavenArtifacts
.
isUpToDate
(
memoryFileSystem
),
isFalse
);
expect
(
await
mavenArtifacts
.
isUpToDate
(
memoryFileSystem
),
isFalse
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
@@ -982,14 +972,28 @@ class FakeDownloadedArtifact extends CachedArtifact {
...
@@ -982,14 +972,28 @@ class FakeDownloadedArtifact extends CachedArtifact {
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
)
async
{
}
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
)
async
{
}
}
}
class
MockArtifactUpdater
extends
Mock
implements
ArtifactUpdater
{}
class
MockCachedArtifact
extends
Mock
implements
CachedArtifact
{}
class
MockCachedArtifact
extends
Mock
implements
CachedArtifact
{}
class
MockIosUsbArtifacts
extends
Mock
implements
IosUsbArtifacts
{}
class
MockIosUsbArtifacts
extends
Mock
implements
IosUsbArtifacts
{}
class
MockInternetAddress
extends
Mock
implements
InternetAddress
{}
class
MockCache
extends
Mock
implements
Cache
{}
class
MockCache
extends
Mock
implements
Cache
{}
class
MockOperatingSystemUtils
extends
Mock
implements
OperatingSystemUtils
{}
class
MockVersionedPackageResolver
extends
Mock
implements
VersionedPackageResolver
{}
class
FakeVersionedPackageResolver
extends
Fake
implements
VersionedPackageResolver
{
class
MockPub
extends
Mock
implements
Pub
{}
final
List
<
List
<
String
>>
resolved
=
<
List
<
String
>>[];
@override
String
resolveUrl
(
String
packageName
,
String
version
)
{
resolved
.
add
(<
String
>[
packageName
,
version
]);
return
''
;
}
}
class
FakePub
extends
Fake
implements
Pub
{
int
calledGet
=
0
;
@override
Future
<
void
>
get
({
PubContext
context
,
String
directory
,
bool
skipIfAbsent
=
false
,
bool
upgrade
=
false
,
bool
offline
=
false
,
bool
generateSyntheticPackage
=
false
,
String
flutterRootOverride
,
bool
checkUpToDate
=
false
})
async
{
calledGet
+=
1
;
}
}
class
FakeCache
extends
Cache
{
class
FakeCache
extends
Cache
{
FakeCache
({
FakeCache
({
...
@@ -1022,8 +1026,19 @@ class FakeAndroidSdk extends Fake implements AndroidSdk {
...
@@ -1022,8 +1026,19 @@ class FakeAndroidSdk extends Fake implements AndroidSdk {
}
}
class
FakeArtifactUpdater
extends
Fake
implements
ArtifactUpdater
{
class
FakeArtifactUpdater
extends
Fake
implements
ArtifactUpdater
{
void
Function
(
String
,
Uri
,
Directory
)
onDownloadZipArchive
;
void
Function
(
String
,
Uri
,
Directory
)
onDownloadZipTarball
;
@override
@override
Future
<
void
>
downloadZippedTarball
(
String
message
,
Uri
url
,
Directory
location
)
async
{
Future
<
void
>
downloadZippedTarball
(
String
message
,
Uri
url
,
Directory
location
)
async
{
return
;
onDownloadZipTarball
?.
call
(
message
,
url
,
location
);
}
@override
Future
<
void
>
downloadZipArchive
(
String
message
,
Uri
url
,
Directory
location
)
async
{
onDownloadZipArchive
?.
call
(
message
,
url
,
location
);
}
}
@override
void
removeDownloadedFiles
()
{
}
}
}
packages/flutter_tools/test/src/fakes.dart
View file @
9805df89
...
@@ -498,6 +498,8 @@ class FakeStatusLogger extends DelegatingLogger {
...
@@ -498,6 +498,8 @@ class FakeStatusLogger extends DelegatingLogger {
class
FakeOperatingSystemUtils
extends
Fake
implements
OperatingSystemUtils
{
class
FakeOperatingSystemUtils
extends
Fake
implements
OperatingSystemUtils
{
FakeOperatingSystemUtils
({
this
.
hostPlatform
=
HostPlatform
.
linux_x64
});
FakeOperatingSystemUtils
({
this
.
hostPlatform
=
HostPlatform
.
linux_x64
});
final
List
<
List
<
String
>>
chmods
=
<
List
<
String
>>[];
@override
@override
void
makeExecutable
(
File
file
)
{
}
void
makeExecutable
(
File
file
)
{
}
...
@@ -505,7 +507,9 @@ class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
...
@@ -505,7 +507,9 @@ class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
HostPlatform
hostPlatform
=
HostPlatform
.
linux_x64
;
HostPlatform
hostPlatform
=
HostPlatform
.
linux_x64
;
@override
@override
void
chmod
(
FileSystemEntity
entity
,
String
mode
)
{
}
void
chmod
(
FileSystemEntity
entity
,
String
mode
)
{
chmods
.
add
(<
String
>[
entity
.
path
,
mode
]);
}
@override
@override
File
?
which
(
String
execName
)
=>
null
;
File
?
which
(
String
execName
)
=>
null
;
...
...
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