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
8b144544
Unverified
Commit
8b144544
authored
Mar 15, 2021
by
Jenn Magder
Committed by
GitHub
Mar 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove MockFlutterVersion from mocks (#78089)
parent
c94648f9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
68 deletions
+62
-68
downgrade_test.dart
...er_tools/test/commands.shard/hermetic/downgrade_test.dart
+15
-17
upgrade_test.dart
...ter_tools/test/commands.shard/permeable/upgrade_test.dart
+47
-49
mocks.dart
packages/flutter_tools/test/src/mocks.dart
+0
-2
No files found.
packages/flutter_tools/test/commands.shard/hermetic/downgrade_test.dart
View file @
8b144544
...
@@ -12,12 +12,11 @@ import 'package:flutter_tools/src/base/terminal.dart';
...
@@ -12,12 +12,11 @@ import 'package:flutter_tools/src/base/terminal.dart';
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/downgrade.dart'
;
import
'package:flutter_tools/src/commands/downgrade.dart'
;
import
'package:flutter_tools/src/persistent_tool_state.dart'
;
import
'package:flutter_tools/src/persistent_tool_state.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../../src/common.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/context.dart'
;
import
'../../src/
mock
s.dart'
;
import
'../../src/
fake
s.dart'
;
void
main
(
)
{
void
main
(
)
{
FileSystem
fileSystem
;
FileSystem
fileSystem
;
...
@@ -25,7 +24,6 @@ void main() {
...
@@ -25,7 +24,6 @@ void main() {
AnsiTerminal
terminal
;
AnsiTerminal
terminal
;
ProcessManager
processManager
;
ProcessManager
processManager
;
MockStdio
mockStdio
;
MockStdio
mockStdio
;
FlutterVersion
flutterVersion
;
setUpAll
(()
{
setUpAll
(()
{
Cache
.
disableLocking
();
Cache
.
disableLocking
();
...
@@ -36,7 +34,6 @@ void main() {
...
@@ -36,7 +34,6 @@ void main() {
});
});
setUp
(()
{
setUp
(()
{
flutterVersion
=
MockFlutterVersion
();
mockStdio
=
MockStdio
();
mockStdio
=
MockStdio
();
processManager
=
FakeProcessManager
.
any
();
processManager
=
FakeProcessManager
.
any
();
terminal
=
MockTerminal
();
terminal
=
MockTerminal
();
...
@@ -45,6 +42,7 @@ void main() {
...
@@ -45,6 +42,7 @@ void main() {
});
});
testUsingContext
(
'Downgrade exits on unknown channel'
,
()
async
{
testUsingContext
(
'Downgrade exits on unknown channel'
,
()
async
{
final
FakeFlutterVersion
fakeFlutterVersion
=
FakeFlutterVersion
(
channel:
'unknown'
);
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
.
writeAsStringSync
(
'{"last-active-master-version":"invalid"}'
);
.
writeAsStringSync
(
'{"last-active-master-version":"invalid"}'
);
final
DowngradeCommand
command
=
DowngradeCommand
(
final
DowngradeCommand
command
=
DowngradeCommand
(
...
@@ -52,7 +50,7 @@ void main() {
...
@@ -52,7 +50,7 @@ void main() {
processManager:
processManager
,
processManager:
processManager
,
terminal:
terminal
,
terminal:
terminal
,
stdio:
mockStdio
,
stdio:
mockStdio
,
flutterVersion:
flutterVersion
,
flutterVersion:
f
akeF
lutterVersion
,
logger:
bufferLogger
,
logger:
bufferLogger
,
);
);
...
@@ -61,7 +59,7 @@ void main() {
...
@@ -61,7 +59,7 @@ void main() {
});
});
testUsingContext
(
'Downgrade exits on no recorded version'
,
()
async
{
testUsingContext
(
'Downgrade exits on no recorded version'
,
()
async
{
when
(
flutterVersion
.
channel
).
thenReturn
(
'dev'
);
final
FakeFlutterVersion
fakeFlutterVersion
=
FakeFlutterVersion
(
channel:
'dev'
);
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
.
writeAsStringSync
(
'{"last-active-master-version":"abcd"}'
);
.
writeAsStringSync
(
'{"last-active-master-version":"abcd"}'
);
final
DowngradeCommand
command
=
DowngradeCommand
(
final
DowngradeCommand
command
=
DowngradeCommand
(
...
@@ -77,7 +75,7 @@ void main() {
...
@@ -77,7 +75,7 @@ void main() {
]),
]),
terminal:
terminal
,
terminal:
terminal
,
stdio:
mockStdio
,
stdio:
mockStdio
,
flutterVersion:
flutterVersion
,
flutterVersion:
f
akeF
lutterVersion
,
logger:
bufferLogger
,
logger:
bufferLogger
,
);
);
...
@@ -90,7 +88,7 @@ void main() {
...
@@ -90,7 +88,7 @@ void main() {
});
});
testUsingContext
(
'Downgrade exits on unknown recorded version'
,
()
async
{
testUsingContext
(
'Downgrade exits on unknown recorded version'
,
()
async
{
when
(
flutterVersion
.
channel
).
thenReturn
(
'master'
);
final
FakeFlutterVersion
fakeFlutterVersion
=
FakeFlutterVersion
(
channel:
'master'
);
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
.
writeAsStringSync
(
'{"last-active-master-version":"invalid"}'
);
.
writeAsStringSync
(
'{"last-active-master-version":"invalid"}'
);
final
DowngradeCommand
command
=
DowngradeCommand
(
final
DowngradeCommand
command
=
DowngradeCommand
(
...
@@ -105,7 +103,7 @@ void main() {
...
@@ -105,7 +103,7 @@ void main() {
]),
]),
terminal:
terminal
,
terminal:
terminal
,
stdio:
mockStdio
,
stdio:
mockStdio
,
flutterVersion:
flutterVersion
,
flutterVersion:
f
akeF
lutterVersion
,
logger:
bufferLogger
,
logger:
bufferLogger
,
);
);
...
@@ -114,7 +112,7 @@ void main() {
...
@@ -114,7 +112,7 @@ void main() {
});
});
testUsingContext
(
'Downgrade prompts for user input when terminal is attached - y'
,
()
async
{
testUsingContext
(
'Downgrade prompts for user input when terminal is attached - y'
,
()
async
{
when
(
flutterVersion
.
channel
).
thenReturn
(
'master'
);
final
FakeFlutterVersion
fakeFlutterVersion
=
FakeFlutterVersion
(
channel:
'master'
);
when
(
mockStdio
.
hasTerminal
).
thenReturn
(
true
);
when
(
mockStdio
.
hasTerminal
).
thenReturn
(
true
);
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
.
writeAsStringSync
(
'{"last-active-master-version":"g6b00b5e88"}'
);
.
writeAsStringSync
(
'{"last-active-master-version":"g6b00b5e88"}'
);
...
@@ -123,7 +121,7 @@ void main() {
...
@@ -123,7 +121,7 @@ void main() {
processManager:
processManager
,
processManager:
processManager
,
terminal:
terminal
,
terminal:
terminal
,
stdio:
mockStdio
,
stdio:
mockStdio
,
flutterVersion:
flutterVersion
,
flutterVersion:
f
akeF
lutterVersion
,
logger:
bufferLogger
,
logger:
bufferLogger
,
);
);
...
@@ -144,7 +142,7 @@ void main() {
...
@@ -144,7 +142,7 @@ void main() {
});
});
testUsingContext
(
'Downgrade prompts for user input when terminal is attached - n'
,
()
async
{
testUsingContext
(
'Downgrade prompts for user input when terminal is attached - n'
,
()
async
{
when
(
flutterVersion
.
channel
).
thenReturn
(
'master'
);
final
FakeFlutterVersion
fakeFlutterVersion
=
FakeFlutterVersion
(
channel:
'master'
);
when
(
mockStdio
.
hasTerminal
).
thenReturn
(
true
);
when
(
mockStdio
.
hasTerminal
).
thenReturn
(
true
);
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
.
writeAsStringSync
(
'{"last-active-master-version":"g6b00b5e88"}'
);
.
writeAsStringSync
(
'{"last-active-master-version":"g6b00b5e88"}'
);
...
@@ -153,7 +151,7 @@ void main() {
...
@@ -153,7 +151,7 @@ void main() {
processManager:
processManager
,
processManager:
processManager
,
terminal:
terminal
,
terminal:
terminal
,
stdio:
mockStdio
,
stdio:
mockStdio
,
flutterVersion:
flutterVersion
,
flutterVersion:
f
akeF
lutterVersion
,
logger:
bufferLogger
,
logger:
bufferLogger
,
);
);
...
@@ -174,7 +172,7 @@ void main() {
...
@@ -174,7 +172,7 @@ void main() {
});
});
testUsingContext
(
'Downgrade does not prompt when there is no terminal'
,
()
async
{
testUsingContext
(
'Downgrade does not prompt when there is no terminal'
,
()
async
{
when
(
flutterVersion
.
channel
).
thenReturn
(
'master'
);
final
FakeFlutterVersion
fakeFlutterVersion
=
FakeFlutterVersion
(
channel:
'master'
);
when
(
mockStdio
.
hasTerminal
).
thenReturn
(
false
);
when
(
mockStdio
.
hasTerminal
).
thenReturn
(
false
);
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
.
writeAsStringSync
(
'{"last-active-master-version":"g6b00b5e88"}'
);
.
writeAsStringSync
(
'{"last-active-master-version":"g6b00b5e88"}'
);
...
@@ -186,7 +184,7 @@ void main() {
...
@@ -186,7 +184,7 @@ void main() {
processManager:
processManager
,
processManager:
processManager
,
terminal:
terminal
,
terminal:
terminal
,
stdio:
mockStdio
,
stdio:
mockStdio
,
flutterVersion:
flutterVersion
,
flutterVersion:
f
akeF
lutterVersion
,
logger:
bufferLogger
,
logger:
bufferLogger
,
);
);
...
@@ -201,7 +199,7 @@ void main() {
...
@@ -201,7 +199,7 @@ void main() {
});
});
testUsingContext
(
'Downgrade performs correct git commands'
,
()
async
{
testUsingContext
(
'Downgrade performs correct git commands'
,
()
async
{
when
(
flutterVersion
.
channel
).
thenReturn
(
'master'
);
final
FakeFlutterVersion
fakeFlutterVersion
=
FakeFlutterVersion
(
channel:
'master'
);
when
(
mockStdio
.
hasTerminal
).
thenReturn
(
false
);
when
(
mockStdio
.
hasTerminal
).
thenReturn
(
false
);
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
fileSystem
.
currentDirectory
.
childFile
(
'.flutter_tool_state'
)
.
writeAsStringSync
(
'{"last-active-master-version":"g6b00b5e88"}'
);
.
writeAsStringSync
(
'{"last-active-master-version":"g6b00b5e88"}'
);
...
@@ -230,7 +228,7 @@ void main() {
...
@@ -230,7 +228,7 @@ void main() {
]),
]),
terminal:
terminal
,
terminal:
terminal
,
stdio:
mockStdio
,
stdio:
mockStdio
,
flutterVersion:
flutterVersion
,
flutterVersion:
f
akeF
lutterVersion
,
logger:
bufferLogger
,
logger:
bufferLogger
,
);
);
...
...
packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
View file @
8b144544
...
@@ -14,13 +14,12 @@ import 'package:flutter_tools/src/globals.dart' as globals;
...
@@ -14,13 +14,12 @@ import 'package:flutter_tools/src/globals.dart' as globals;
import
'package:flutter_tools/src/persistent_tool_state.dart'
;
import
'package:flutter_tools/src/persistent_tool_state.dart'
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'package:process/process.dart'
;
import
'../../src/common.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/context.dart'
;
import
'../../src/fake_process_manager.dart'
;
import
'../../src/fake_process_manager.dart'
;
import
'../../src/
mock
s.dart'
;
import
'../../src/
fake
s.dart'
;
void
main
(
)
{
void
main
(
)
{
group
(
'UpgradeCommandRunner'
,
()
{
group
(
'UpgradeCommandRunner'
,
()
{
...
@@ -28,7 +27,6 @@ void main() {
...
@@ -28,7 +27,6 @@ void main() {
UpgradeCommandRunner
realCommandRunner
;
UpgradeCommandRunner
realCommandRunner
;
FakeProcessManager
processManager
;
FakeProcessManager
processManager
;
FakePlatform
fakePlatform
;
FakePlatform
fakePlatform
;
final
MockFlutterVersion
flutterVersion
=
MockFlutterVersion
();
const
GitTagVersion
gitTagVersion
=
GitTagVersion
(
const
GitTagVersion
gitTagVersion
=
GitTagVersion
(
x:
1
,
x:
1
,
y:
2
,
y:
2
,
...
@@ -37,7 +35,6 @@ void main() {
...
@@ -37,7 +35,6 @@ void main() {
commits:
5
,
commits:
5
,
hash:
'asd'
,
hash:
'asd'
,
);
);
when
(
flutterVersion
.
channel
).
thenReturn
(
'dev'
);
setUp
(()
{
setUp
(()
{
fakeCommandRunner
=
FakeUpgradeCommandRunner
();
fakeCommandRunner
=
FakeUpgradeCommandRunner
();
...
@@ -51,9 +48,9 @@ void main() {
...
@@ -51,9 +48,9 @@ void main() {
});
});
testUsingContext
(
'throws on unknown tag, official branch, noforce'
,
()
async
{
testUsingContext
(
'throws on unknown tag, official branch, noforce'
,
()
async
{
final
FakeFlutterVersion
flutterVersion
=
FakeFlutterVersion
(
channel:
'dev'
);
const
String
upstreamRevision
=
''
;
const
String
upstreamRevision
=
''
;
final
MockFlutterVersion
latestVersion
=
MockFlutterVersion
();
final
FakeFlutterVersion
latestVersion
=
FakeFlutterVersion
(
frameworkRevision:
upstreamRevision
);
when
(
latestVersion
.
frameworkRevision
).
thenReturn
(
upstreamRevision
);
fakeCommandRunner
.
remoteVersion
=
latestVersion
;
fakeCommandRunner
.
remoteVersion
=
latestVersion
;
final
Future
<
FlutterCommandResult
>
result
=
fakeCommandRunner
.
runCommand
(
final
Future
<
FlutterCommandResult
>
result
=
fakeCommandRunner
.
runCommand
(
...
@@ -65,15 +62,15 @@ void main() {
...
@@ -65,15 +62,15 @@ void main() {
verifyOnly:
false
,
verifyOnly:
false
,
);
);
expect
(
result
,
throwsToolExit
());
expect
(
result
,
throwsToolExit
());
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
Platform:
()
=>
fakePlatform
,
});
});
testUsingContext
(
'throws tool exit with uncommitted changes'
,
()
async
{
testUsingContext
(
'throws tool exit with uncommitted changes'
,
()
async
{
final
FakeFlutterVersion
flutterVersion
=
FakeFlutterVersion
(
channel:
'dev'
);
const
String
upstreamRevision
=
''
;
const
String
upstreamRevision
=
''
;
final
MockFlutterVersion
latestVersion
=
MockFlutterVersion
();
final
FakeFlutterVersion
latestVersion
=
FakeFlutterVersion
(
frameworkRevision:
upstreamRevision
);
when
(
latestVersion
.
frameworkRevision
).
thenReturn
(
upstreamRevision
);
fakeCommandRunner
.
remoteVersion
=
latestVersion
;
fakeCommandRunner
.
remoteVersion
=
latestVersion
;
fakeCommandRunner
.
willHaveUncommittedChanges
=
true
;
fakeCommandRunner
.
willHaveUncommittedChanges
=
true
;
...
@@ -86,16 +83,15 @@ void main() {
...
@@ -86,16 +83,15 @@ void main() {
verifyOnly:
false
,
verifyOnly:
false
,
);
);
expect
(
result
,
throwsToolExit
());
expect
(
result
,
throwsToolExit
());
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
Platform:
()
=>
fakePlatform
,
});
});
testUsingContext
(
"Doesn't continue on known tag, dev branch, no force, already up-to-date"
,
()
async
{
testUsingContext
(
"Doesn't continue on known tag, dev branch, no force, already up-to-date"
,
()
async
{
const
String
revision
=
'abc123'
;
const
String
revision
=
'abc123'
;
final
MockFlutterVersion
latestVersion
=
MockFlutterVersion
();
final
FakeFlutterVersion
latestVersion
=
FakeFlutterVersion
(
frameworkRevision:
revision
);
when
(
flutterVersion
.
frameworkRevision
).
thenReturn
(
revision
);
final
FakeFlutterVersion
flutterVersion
=
FakeFlutterVersion
(
channel:
'dev'
,
frameworkRevision:
revision
);
when
(
latestVersion
.
frameworkRevision
).
thenReturn
(
revision
);
fakeCommandRunner
.
alreadyUpToDate
=
true
;
fakeCommandRunner
.
alreadyUpToDate
=
true
;
fakeCommandRunner
.
remoteVersion
=
latestVersion
;
fakeCommandRunner
.
remoteVersion
=
latestVersion
;
...
@@ -109,7 +105,7 @@ void main() {
...
@@ -109,7 +105,7 @@ void main() {
);
);
expect
(
await
result
,
FlutterCommandResult
.
success
());
expect
(
await
result
,
FlutterCommandResult
.
success
());
expect
(
testLogger
.
statusText
,
contains
(
'Flutter is already up to date'
));
expect
(
testLogger
.
statusText
,
contains
(
'Flutter is already up to date'
));
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
Platform:
()
=>
fakePlatform
,
...
@@ -121,15 +117,18 @@ void main() {
...
@@ -121,15 +117,18 @@ void main() {
const
String
version
=
'1.2.3'
;
const
String
version
=
'1.2.3'
;
const
String
upstreamVersion
=
'4.5.6'
;
const
String
upstreamVersion
=
'4.5.6'
;
when
(
flutterVersion
.
frameworkRevision
).
thenReturn
(
revision
);
final
FakeFlutterVersion
flutterVersion
=
FakeFlutterVersion
(
when
(
flutterVersion
.
frameworkRevisionShort
).
thenReturn
(
revision
);
channel:
'dev'
,
when
(
flutterVersion
.
frameworkVersion
).
thenReturn
(
version
);
frameworkRevision:
revision
,
frameworkRevisionShort:
revision
,
final
MockFlutterVersion
latestVersion
=
MockFlutterVersion
();
frameworkVersion:
version
,
);
when
(
latestVersion
.
frameworkRevision
).
thenReturn
(
upstreamRevision
);
final
FakeFlutterVersion
latestVersion
=
FakeFlutterVersion
(
when
(
latestVersion
.
frameworkRevisionShort
).
thenReturn
(
upstreamRevision
);
frameworkRevision:
upstreamRevision
,
when
(
latestVersion
.
frameworkVersion
).
thenReturn
(
upstreamVersion
);
frameworkRevisionShort:
upstreamRevision
,
frameworkVersion:
upstreamVersion
,
);
fakeCommandRunner
.
alreadyUpToDate
=
false
;
fakeCommandRunner
.
alreadyUpToDate
=
false
;
fakeCommandRunner
.
remoteVersion
=
latestVersion
;
fakeCommandRunner
.
remoteVersion
=
latestVersion
;
...
@@ -146,7 +145,7 @@ void main() {
...
@@ -146,7 +145,7 @@ void main() {
expect
(
testLogger
.
statusText
,
contains
(
'A new version of Flutter is available'
));
expect
(
testLogger
.
statusText
,
contains
(
'A new version of Flutter is available'
));
expect
(
testLogger
.
statusText
,
contains
(
'The latest version: 4.5.6 (revision def456)'
));
expect
(
testLogger
.
statusText
,
contains
(
'The latest version: 4.5.6 (revision def456)'
));
expect
(
testLogger
.
statusText
,
contains
(
'Your current version: 1.2.3 (revision abc123)'
));
expect
(
testLogger
.
statusText
,
contains
(
'Your current version: 1.2.3 (revision abc123)'
));
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
Platform:
()
=>
fakePlatform
,
...
@@ -178,7 +177,7 @@ void main() {
...
@@ -178,7 +177,7 @@ void main() {
expect
(
updateVersion
.
frameworkVersion
,
version
);
expect
(
updateVersion
.
frameworkVersion
,
version
);
expect
(
updateVersion
.
frameworkRevision
,
revision
);
expect
(
updateVersion
.
frameworkRevision
,
revision
);
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
Platform:
()
=>
fakePlatform
,
...
@@ -203,7 +202,7 @@ void main() {
...
@@ -203,7 +202,7 @@ void main() {
()
async
=>
realCommandRunner
.
fetchLatestVersion
(),
()
async
=>
realCommandRunner
.
fetchLatestVersion
(),
throwsToolExit
(
message:
'You are not currently on a release branch.'
),
throwsToolExit
(
message:
'You are not currently on a release branch.'
),
);
);
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
Platform:
()
=>
fakePlatform
,
...
@@ -230,7 +229,7 @@ void main() {
...
@@ -230,7 +229,7 @@ void main() {
message:
'Unable to upgrade Flutter: no origin repository configured.'
,
message:
'Unable to upgrade Flutter: no origin repository configured.'
,
),
),
);
);
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
Platform:
()
=>
fakePlatform
,
...
@@ -254,7 +253,7 @@ void main() {
...
@@ -254,7 +253,7 @@ void main() {
()
async
=>
realCommandRunner
.
attemptReset
(
revision
),
()
async
=>
realCommandRunner
.
attemptReset
(
revision
),
throwsToolExit
(
message:
errorMessage
),
throwsToolExit
(
message:
errorMessage
),
);
);
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
Platform:
()
=>
fakePlatform
,
...
@@ -273,7 +272,7 @@ void main() {
...
@@ -273,7 +272,7 @@ void main() {
),
),
);
);
await
realCommandRunner
.
flutterUpgradeContinue
();
await
realCommandRunner
.
flutterUpgradeContinue
();
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
Platform:
()
=>
fakePlatform
,
...
@@ -285,13 +284,15 @@ void main() {
...
@@ -285,13 +284,15 @@ void main() {
const
String
version
=
'1.2.3'
;
const
String
version
=
'1.2.3'
;
const
String
upstreamVersion
=
'4.5.6'
;
const
String
upstreamVersion
=
'4.5.6'
;
when
(
flutterVersion
.
frameworkRevision
).
thenReturn
(
revision
);
final
FakeFlutterVersion
flutterVersion
=
FakeFlutterVersion
(
when
(
flutterVersion
.
frameworkVersion
).
thenReturn
(
version
);
channel:
'dev'
,
frameworkRevision:
revision
,
final
MockFlutterVersion
latestVersion
=
MockFlutterVersion
();
frameworkVersion:
version
,
);
when
(
latestVersion
.
frameworkRevision
).
thenReturn
(
upstreamRevision
);
final
FakeFlutterVersion
latestVersion
=
FakeFlutterVersion
(
when
(
latestVersion
.
frameworkVersion
).
thenReturn
(
upstreamVersion
);
frameworkRevision:
upstreamRevision
,
frameworkVersion:
upstreamVersion
,
);
fakeCommandRunner
.
alreadyUpToDate
=
false
;
fakeCommandRunner
.
alreadyUpToDate
=
false
;
fakeCommandRunner
.
remoteVersion
=
latestVersion
;
fakeCommandRunner
.
remoteVersion
=
latestVersion
;
...
@@ -325,7 +326,7 @@ void main() {
...
@@ -325,7 +326,7 @@ void main() {
),
),
);
);
await
realCommandRunner
.
precacheArtifacts
();
await
realCommandRunner
.
precacheArtifacts
();
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
Platform:
()
=>
fakePlatform
,
...
@@ -344,8 +345,8 @@ void main() {
...
@@ -344,8 +345,8 @@ void main() {
});
});
testUsingContext
(
'does not throw on unknown tag, official branch, force'
,
()
async
{
testUsingContext
(
'does not throw on unknown tag, official branch, force'
,
()
async
{
f
inal
MockFlutterVersion
latestVersion
=
MockFlutterVersion
(
);
f
akeCommandRunner
.
remoteVersion
=
FakeFlutterVersion
(
frameworkRevision:
null
);
f
akeCommandRunner
.
remoteVersion
=
latestVersion
;
f
inal
FakeFlutterVersion
flutterVersion
=
FakeFlutterVersion
(
channel:
'dev'
)
;
final
Future
<
FlutterCommandResult
>
result
=
fakeCommandRunner
.
runCommand
(
final
Future
<
FlutterCommandResult
>
result
=
fakeCommandRunner
.
runCommand
(
force:
true
,
force:
true
,
...
@@ -356,15 +357,15 @@ void main() {
...
@@ -356,15 +357,15 @@ void main() {
verifyOnly:
false
,
verifyOnly:
false
,
);
);
expect
(
await
result
,
FlutterCommandResult
.
success
());
expect
(
await
result
,
FlutterCommandResult
.
success
());
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
Platform:
()
=>
fakePlatform
,
});
});
testUsingContext
(
'does not throw tool exit with uncommitted changes and force'
,
()
async
{
testUsingContext
(
'does not throw tool exit with uncommitted changes and force'
,
()
async
{
final
MockFlutterVersion
latestVersion
=
MockFlutterVersion
(
);
final
FakeFlutterVersion
flutterVersion
=
FakeFlutterVersion
(
channel:
'dev'
);
fakeCommandRunner
.
remoteVersion
=
latestVersion
;
fakeCommandRunner
.
remoteVersion
=
FakeFlutterVersion
(
frameworkRevision:
null
)
;
fakeCommandRunner
.
willHaveUncommittedChanges
=
true
;
fakeCommandRunner
.
willHaveUncommittedChanges
=
true
;
final
Future
<
FlutterCommandResult
>
result
=
fakeCommandRunner
.
runCommand
(
final
Future
<
FlutterCommandResult
>
result
=
fakeCommandRunner
.
runCommand
(
...
@@ -376,15 +377,15 @@ void main() {
...
@@ -376,15 +377,15 @@ void main() {
verifyOnly:
false
,
verifyOnly:
false
,
);
);
expect
(
await
result
,
FlutterCommandResult
.
success
());
expect
(
await
result
,
FlutterCommandResult
.
success
());
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
Platform:
()
=>
fakePlatform
,
});
});
testUsingContext
(
"Doesn't throw on known tag, dev branch, no force"
,
()
async
{
testUsingContext
(
"Doesn't throw on known tag, dev branch, no force"
,
()
async
{
final
MockFlutterVersion
latestVersion
=
MockFlutterVersion
(
);
final
FakeFlutterVersion
flutterVersion
=
FakeFlutterVersion
(
channel:
'dev'
);
fakeCommandRunner
.
remoteVersion
=
latestVersion
;
fakeCommandRunner
.
remoteVersion
=
FakeFlutterVersion
(
frameworkRevision:
null
)
;
final
Future
<
FlutterCommandResult
>
result
=
fakeCommandRunner
.
runCommand
(
final
Future
<
FlutterCommandResult
>
result
=
fakeCommandRunner
.
runCommand
(
force:
false
,
force:
false
,
...
@@ -395,7 +396,7 @@ void main() {
...
@@ -395,7 +396,7 @@ void main() {
verifyOnly:
false
,
verifyOnly:
false
,
);
);
expect
(
await
result
,
FlutterCommandResult
.
success
());
expect
(
await
result
,
FlutterCommandResult
.
success
());
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
Platform:
()
=>
fakePlatform
,
...
@@ -406,8 +407,6 @@ void main() {
...
@@ -406,8 +407,6 @@ void main() {
Directory
tempDir
;
Directory
tempDir
;
File
flutterToolState
;
File
flutterToolState
;
FlutterVersion
mockFlutterVersion
;
setUp
(()
{
setUp
(()
{
Cache
.
disableLocking
();
Cache
.
disableLocking
();
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
...
@@ -426,7 +425,6 @@ void main() {
...
@@ -426,7 +425,6 @@ void main() {
]);
]);
tempDir
=
globals
.
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_upgrade_test.'
);
tempDir
=
globals
.
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_upgrade_test.'
);
flutterToolState
=
tempDir
.
childFile
(
'.flutter_tool_state'
);
flutterToolState
=
tempDir
.
childFile
(
'.flutter_tool_state'
);
mockFlutterVersion
=
MockFlutterVersion
();
});
});
tearDown
(()
{
tearDown
(()
{
...
@@ -452,7 +450,7 @@ void main() {
...
@@ -452,7 +450,7 @@ void main() {
containsPair
(
'redisplay-welcome-message'
,
true
),
containsPair
(
'redisplay-welcome-message'
,
true
),
);
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FlutterVersion:
()
=>
mockFlutterVersion
,
FlutterVersion:
()
=>
FakeFlutterVersion
()
,
ProcessManager:
()
=>
fakeProcessManager
,
ProcessManager:
()
=>
fakeProcessManager
,
PersistentToolState:
()
=>
PersistentToolState
.
test
(
PersistentToolState:
()
=>
PersistentToolState
.
test
(
directory:
tempDir
,
directory:
tempDir
,
...
...
packages/flutter_tools/test/src/mocks.dart
View file @
8b144544
...
@@ -15,7 +15,6 @@ import 'package:flutter_tools/src/build_info.dart';
...
@@ -15,7 +15,6 @@ import 'package:flutter_tools/src/build_info.dart';
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/ios/devices.dart'
;
import
'package:flutter_tools/src/ios/devices.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'package:process/process.dart'
;
...
@@ -235,4 +234,3 @@ class MockStdIn extends Mock implements IOSink {
...
@@ -235,4 +234,3 @@ class MockStdIn extends Mock implements IOSink {
}
}
class
MockStream
extends
Mock
implements
Stream
<
List
<
int
>>
{}
class
MockStream
extends
Mock
implements
Stream
<
List
<
int
>>
{}
class
MockFlutterVersion
extends
Mock
implements
FlutterVersion
{}
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