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
d6f5767e
Unverified
Commit
d6f5767e
authored
Mar 12, 2021
by
Jenn Magder
Committed by
GitHub
Mar 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove MockFlutterVersions (#77962)
parent
413c8a0b
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
173 deletions
+72
-173
build_ios_framework_test.dart
...est/commands.shard/hermetic/build_ios_framework_test.dart
+53
-43
create_test.dart
...tter_tools/test/commands.shard/permeable/create_test.dart
+8
-116
flutter_platform_test.dart
...utter_tools/test/general.shard/flutter_platform_test.dart
+6
-6
flutter_command_test.dart
...tools/test/general.shard/runner/flutter_command_test.dart
+0
-2
fakes.dart
packages/flutter_tools/test/src/fakes.dart
+5
-6
No files found.
packages/flutter_tools/test/commands.shard/hermetic/build_ios_framework_test.dart
View file @
d6f5767e
...
@@ -12,7 +12,6 @@ import 'package:flutter_tools/src/build_system/build_system.dart';
...
@@ -12,7 +12,6 @@ import 'package:flutter_tools/src/build_system/build_system.dart';
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/build_ios_framework.dart'
;
import
'package:flutter_tools/src/commands/build_ios_framework.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../../src/common.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/context.dart'
;
...
@@ -21,8 +20,6 @@ import '../../src/fakes.dart';
...
@@ -21,8 +20,6 @@ import '../../src/fakes.dart';
void
main
(
)
{
void
main
(
)
{
group
(
'build ios-framework'
,
()
{
group
(
'build ios-framework'
,
()
{
MemoryFileSystem
memoryFileSystem
;
MemoryFileSystem
memoryFileSystem
;
MockFlutterVersion
mockFlutterVersion
;
MockGitTagVersion
mockGitTagVersion
;
Directory
outputDirectory
;
Directory
outputDirectory
;
FakePlatform
fakePlatform
;
FakePlatform
fakePlatform
;
...
@@ -33,8 +30,6 @@ void main() {
...
@@ -33,8 +30,6 @@ void main() {
const
String
storageBaseUrl
=
'https://fake.googleapis.com'
;
const
String
storageBaseUrl
=
'https://fake.googleapis.com'
;
setUp
(()
{
setUp
(()
{
memoryFileSystem
=
MemoryFileSystem
.
test
();
memoryFileSystem
=
MemoryFileSystem
.
test
();
mockFlutterVersion
=
MockFlutterVersion
();
mockGitTagVersion
=
MockGitTagVersion
();
fakePlatform
=
FakePlatform
(
fakePlatform
=
FakePlatform
(
operatingSystem:
'macos'
,
operatingSystem:
'macos'
,
environment:
<
String
,
String
>{
environment:
<
String
,
String
>{
...
@@ -42,7 +37,6 @@ void main() {
...
@@ -42,7 +37,6 @@ void main() {
},
},
);
);
when
(
mockFlutterVersion
.
gitTagVersion
).
thenReturn
(
mockGitTagVersion
);
outputDirectory
=
memoryFileSystem
.
systemTempDirectory
outputDirectory
=
memoryFileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_build_ios_framework_test_output.'
)
.
createTempSync
(
'flutter_build_ios_framework_test_output.'
)
.
childDirectory
(
'Debug'
)
.
childDirectory
(
'Debug'
)
...
@@ -63,17 +57,16 @@ void main() {
...
@@ -63,17 +57,16 @@ void main() {
rootOverride
.
childDirectory
(
'bin'
).
childDirectory
(
'internal'
).
childFile
(
'engine.version'
)
rootOverride
.
childDirectory
(
'bin'
).
childDirectory
(
'internal'
).
childFile
(
'engine.version'
)
..
createSync
(
recursive:
true
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
engineRevision
);
..
writeAsStringSync
(
engineRevision
);
when
(
mockFlutterVersion
.
gitTagVersion
).
thenReturn
(
mockGitTagVersion
);
});
});
testUsingContext
(
'version unknown'
,
()
async
{
testUsingContext
(
'version unknown'
,
()
async
{
const
String
frameworkVersion
=
'0.0.0-unknown'
;
const
String
frameworkVersion
=
'0.0.0-unknown'
;
when
(
mockFlutterVersion
.
frameworkVersion
).
thenReturn
(
frameworkVersion
);
final
FakeFlutterVersion
fakeFlutterVersion
=
FakeFlutterVersion
(
frameworkVersion:
frameworkVersion
);
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
platform:
fakePlatform
,
platform:
fakePlatform
,
flutterVersion:
mock
FlutterVersion
,
flutterVersion:
fake
FlutterVersion
,
cache:
cache
,
cache:
cache
,
verboseHelp:
false
,
verboseHelp:
false
,
);
);
...
@@ -87,18 +80,22 @@ void main() {
...
@@ -87,18 +80,22 @@ void main() {
testUsingContext
(
'throws when not on a released version'
,
()
async
{
testUsingContext
(
'throws when not on a released version'
,
()
async
{
const
String
frameworkVersion
=
'v1.13.10+hotfix-pre.2'
;
const
String
frameworkVersion
=
'v1.13.10+hotfix-pre.2'
;
when
(
mockFlutterVersion
.
frameworkVersion
).
thenReturn
(
frameworkVersion
);
const
GitTagVersion
gitTagVersion
=
GitTagVersion
(
x:
1
,
when
(
mockGitTagVersion
.
x
).
thenReturn
(
1
);
y:
13
,
when
(
mockGitTagVersion
.
y
).
thenReturn
(
13
);
z:
10
,
when
(
mockGitTagVersion
.
z
).
thenReturn
(
10
);
hotfix:
13
,
when
(
mockGitTagVersion
.
hotfix
).
thenReturn
(
13
);
commits:
2
,
when
(
mockGitTagVersion
.
commits
).
thenReturn
(
2
);
);
final
FakeFlutterVersion
fakeFlutterVersion
=
FakeFlutterVersion
(
gitTagVersion:
gitTagVersion
,
frameworkVersion:
frameworkVersion
,
);
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
platform:
fakePlatform
,
platform:
fakePlatform
,
flutterVersion:
mock
FlutterVersion
,
flutterVersion:
fake
FlutterVersion
,
cache:
cache
,
cache:
cache
,
verboseHelp:
false
,
verboseHelp:
false
,
);
);
...
@@ -111,16 +108,20 @@ void main() {
...
@@ -111,16 +108,20 @@ void main() {
});
});
testUsingContext
(
'throws when license not found'
,
()
async
{
testUsingContext
(
'throws when license not found'
,
()
async
{
when
(
mockGitTagVersion
.
x
).
thenReturn
(
1
);
final
FakeFlutterVersion
fakeFlutterVersion
=
FakeFlutterVersion
(
when
(
mockGitTagVersion
.
y
).
thenReturn
(
13
);
gitTagVersion:
const
GitTagVersion
(
when
(
mockGitTagVersion
.
z
).
thenReturn
(
10
);
x:
1
,
when
(
mockGitTagVersion
.
hotfix
).
thenReturn
(
13
);
y:
13
,
when
(
mockGitTagVersion
.
commits
).
thenReturn
(
0
);
z:
10
,
hotfix:
13
,
commits:
0
,
),
);
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
platform:
fakePlatform
,
platform:
fakePlatform
,
flutterVersion:
mock
FlutterVersion
,
flutterVersion:
fake
FlutterVersion
,
cache:
cache
,
cache:
cache
,
verboseHelp:
false
,
verboseHelp:
false
,
);
);
...
@@ -137,28 +138,29 @@ void main() {
...
@@ -137,28 +138,29 @@ void main() {
const
String
licenseText
=
'This is the license!'
;
const
String
licenseText
=
'This is the license!'
;
setUp
(()
{
setUp
(()
{
when
(
mockGitTagVersion
.
x
).
thenReturn
(
1
);
when
(
mockGitTagVersion
.
y
).
thenReturn
(
13
);
when
(
mockGitTagVersion
.
z
).
thenReturn
(
11
);
when
(
mockGitTagVersion
.
hotfix
).
thenReturn
(
13
);
when
(
mockFlutterVersion
.
frameworkVersion
).
thenReturn
(
frameworkVersion
);
cache
.
getLicenseFile
()
cache
.
getLicenseFile
()
..
createSync
(
recursive:
true
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
licenseText
);
..
writeAsStringSync
(
licenseText
);
});
});
group
(
'on master channel'
,
()
{
group
(
'on master channel'
,
()
{
setUp
(()
{
when
(
mockGitTagVersion
.
commits
).
thenReturn
(
100
);
});
testUsingContext
(
'created when forced'
,
()
async
{
testUsingContext
(
'created when forced'
,
()
async
{
const
GitTagVersion
gitTagVersion
=
GitTagVersion
(
x:
1
,
y:
13
,
z:
11
,
hotfix:
13
,
commits:
100
,
);
final
FakeFlutterVersion
fakeFlutterVersion
=
FakeFlutterVersion
(
gitTagVersion:
gitTagVersion
,
frameworkVersion:
frameworkVersion
,
);
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
platform:
fakePlatform
,
platform:
fakePlatform
,
flutterVersion:
mock
FlutterVersion
,
flutterVersion:
fake
FlutterVersion
,
cache:
cache
,
cache:
cache
,
verboseHelp:
false
,
verboseHelp:
false
,
);
);
...
@@ -173,15 +175,26 @@ void main() {
...
@@ -173,15 +175,26 @@ void main() {
});
});
group
(
'not on master channel'
,
()
{
group
(
'not on master channel'
,
()
{
FakeFlutterVersion
fakeFlutterVersion
;
setUp
(()
{
setUp
(()
{
when
(
mockGitTagVersion
.
commits
).
thenReturn
(
0
);
const
GitTagVersion
gitTagVersion
=
GitTagVersion
(
x:
1
,
y:
13
,
z:
11
,
hotfix:
13
,
commits:
0
,
);
fakeFlutterVersion
=
FakeFlutterVersion
(
gitTagVersion:
gitTagVersion
,
frameworkVersion:
frameworkVersion
,
);
});
});
testUsingContext
(
'contains license and version'
,
()
async
{
testUsingContext
(
'contains license and version'
,
()
async
{
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
platform:
fakePlatform
,
platform:
fakePlatform
,
flutterVersion:
mock
FlutterVersion
,
flutterVersion:
fake
FlutterVersion
,
cache:
cache
,
cache:
cache
,
verboseHelp:
false
,
verboseHelp:
false
,
);
);
...
@@ -201,7 +214,7 @@ void main() {
...
@@ -201,7 +214,7 @@ void main() {
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
platform:
fakePlatform
,
platform:
fakePlatform
,
flutterVersion:
mock
FlutterVersion
,
flutterVersion:
fake
FlutterVersion
,
cache:
cache
,
cache:
cache
,
verboseHelp:
false
,
verboseHelp:
false
,
);
);
...
@@ -219,7 +232,7 @@ void main() {
...
@@ -219,7 +232,7 @@ void main() {
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
platform:
fakePlatform
,
platform:
fakePlatform
,
flutterVersion:
mock
FlutterVersion
,
flutterVersion:
fake
FlutterVersion
,
cache:
cache
,
cache:
cache
,
verboseHelp:
false
,
verboseHelp:
false
,
);
);
...
@@ -237,7 +250,7 @@ void main() {
...
@@ -237,7 +250,7 @@ void main() {
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
final
BuildIOSFrameworkCommand
command
=
BuildIOSFrameworkCommand
(
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
buildSystem:
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
platform:
fakePlatform
,
platform:
fakePlatform
,
flutterVersion:
mock
FlutterVersion
,
flutterVersion:
fake
FlutterVersion
,
cache:
cache
,
cache:
cache
,
verboseHelp:
false
,
verboseHelp:
false
,
);
);
...
@@ -255,6 +268,3 @@ void main() {
...
@@ -255,6 +268,3 @@ void main() {
});
});
});
});
}
}
class
MockFlutterVersion
extends
Mock
implements
FlutterVersion
{}
class
MockGitTagVersion
extends
Mock
implements
GitTagVersion
{}
packages/flutter_tools/test/commands.shard/permeable/create_test.dart
View file @
d6f5767e
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/flutter_platform_test.dart
View file @
d6f5767e
...
@@ -10,7 +10,7 @@ import 'package:flutter_tools/src/base/io.dart';
...
@@ -10,7 +10,7 @@ import 'package:flutter_tools/src/base/io.dart';
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/test/flutter_platform.dart'
;
import
'package:flutter_tools/src/test/flutter_platform.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'package:test_core/backend.dart'
;
// ignore: deprecated_member_use
import
'package:test_core/backend.dart'
;
// ignore: deprecated_member_use
import
'../src/common.dart'
;
import
'../src/common.dart'
;
...
@@ -38,9 +38,9 @@ void main() {
...
@@ -38,9 +38,9 @@ void main() {
),
),
enableObservatory:
false
,
enableObservatory:
false
,
);
);
flutterPlatform
.
loadChannel
(
'test1.dart'
,
Mock
SuitePlatform
());
flutterPlatform
.
loadChannel
(
'test1.dart'
,
Fake
SuitePlatform
());
expect
(()
=>
flutterPlatform
.
loadChannel
(
'test2.dart'
,
Mock
SuitePlatform
()),
throwsToolExit
());
expect
(()
=>
flutterPlatform
.
loadChannel
(
'test2.dart'
,
Fake
SuitePlatform
()),
throwsToolExit
());
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
...
@@ -54,9 +54,9 @@ void main() {
...
@@ -54,9 +54,9 @@ void main() {
precompiledDillPath:
'example.dill'
,
precompiledDillPath:
'example.dill'
,
enableObservatory:
false
,
enableObservatory:
false
,
);
);
flutterPlatform
.
loadChannel
(
'test1.dart'
,
Mock
SuitePlatform
());
flutterPlatform
.
loadChannel
(
'test1.dart'
,
Fake
SuitePlatform
());
expect
(()
=>
flutterPlatform
.
loadChannel
(
'test2.dart'
,
Mock
SuitePlatform
()),
throwsToolExit
());
expect
(()
=>
flutterPlatform
.
loadChannel
(
'test2.dart'
,
Fake
SuitePlatform
()),
throwsToolExit
());
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
...
@@ -122,7 +122,7 @@ void main() {
...
@@ -122,7 +122,7 @@ void main() {
});
});
}
}
class
MockSuitePlatform
extends
Mock
implements
SuitePlatform
{}
class
FakeSuitePlatform
extends
Fake
implements
SuitePlatform
{}
// A FlutterPlatform with enough fields set to load and start a test.
// A FlutterPlatform with enough fields set to load and start a test.
class
TestFlutterPlatform
extends
FlutterPlatform
{
class
TestFlutterPlatform
extends
FlutterPlatform
{
...
...
packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
View file @
d6f5767e
...
@@ -19,7 +19,6 @@ import 'package:flutter_tools/src/cache.dart';
...
@@ -19,7 +19,6 @@ import 'package:flutter_tools/src/cache.dart';
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:flutter_tools/src/reporting/reporting.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/globals.dart'
as
globals
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:mockito/mockito.dart'
;
import
'package:mockito/mockito.dart'
;
...
@@ -624,7 +623,6 @@ class FakeReportingNullSafetyCommand extends FlutterCommand {
...
@@ -624,7 +623,6 @@ class FakeReportingNullSafetyCommand extends FlutterCommand {
}
}
}
}
class
MockVersion
extends
Mock
implements
FlutterVersion
{}
class
MockProcessInfo
extends
Mock
implements
ProcessInfo
{}
class
MockProcessInfo
extends
Mock
implements
ProcessInfo
{}
class
MockIoProcessSignal
extends
Mock
implements
io
.
ProcessSignal
{}
class
MockIoProcessSignal
extends
Mock
implements
io
.
ProcessSignal
{}
...
...
packages/flutter_tools/test/src/fakes.dart
View file @
d6f5767e
...
@@ -458,7 +458,8 @@ class FakeFlutterVersion implements FlutterVersion {
...
@@ -458,7 +458,8 @@ class FakeFlutterVersion implements FlutterVersion {
this
.
frameworkRevision
=
'11111111111111111111'
,
this
.
frameworkRevision
=
'11111111111111111111'
,
this
.
frameworkRevisionShort
=
'11111'
,
this
.
frameworkRevisionShort
=
'11111'
,
this
.
frameworkAge
=
'0 hours ago'
,
this
.
frameworkAge
=
'0 hours ago'
,
this
.
frameworkCommitDate
=
'12/01/01'
this
.
frameworkCommitDate
=
'12/01/01'
,
this
.
gitTagVersion
=
const
GitTagVersion
.
unknown
(),
});
});
bool
get
didFetchTagsAndUpdate
=>
_didFetchTagsAndUpdate
;
bool
get
didFetchTagsAndUpdate
=>
_didFetchTagsAndUpdate
;
...
@@ -500,6 +501,9 @@ class FakeFlutterVersion implements FlutterVersion {
...
@@ -500,6 +501,9 @@ class FakeFlutterVersion implements FlutterVersion {
@override
@override
String
get
frameworkDate
=>
frameworkCommitDate
;
String
get
frameworkDate
=>
frameworkCommitDate
;
@override
final
GitTagVersion
gitTagVersion
;
@override
@override
void
fetchTagsAndUpdate
()
{
void
fetchTagsAndUpdate
()
{
_didFetchTagsAndUpdate
=
true
;
_didFetchTagsAndUpdate
=
true
;
...
@@ -515,11 +519,6 @@ class FakeFlutterVersion implements FlutterVersion {
...
@@ -515,11 +519,6 @@ class FakeFlutterVersion implements FlutterVersion {
throw
UnimplementedError
();
throw
UnimplementedError
();
}
}
@override
GitTagVersion
get
gitTagVersion
{
throw
UnimplementedError
();
}
@override
@override
Future
<
void
>
ensureVersionFile
()
async
{
}
Future
<
void
>
ensureVersionFile
()
async
{
}
...
...
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