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
7c27db3d
Unverified
Commit
7c27db3d
authored
Apr 28, 2021
by
Jonah Williams
Committed by
GitHub
Apr 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove mocks and globals from macOS tests (#81401)
parent
cbf885b7
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
140 additions
and
169 deletions
+140
-169
application_package_test.dart
...ls/test/general.shard/macos/application_package_test.dart
+96
-127
macos_device_test.dart
...ter_tools/test/general.shard/macos/macos_device_test.dart
+29
-19
macos_project_migration_test.dart
...est/general.shard/macos/macos_project_migration_test.dart
+15
-23
No files found.
packages/flutter_tools/test/general.shard/macos/application_package_test.dart
View file @
7c27db3d
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/macos/macos_device_test.dart
View file @
7c27db3d
...
...
@@ -17,7 +17,7 @@ import 'package:flutter_tools/src/macos/application_package.dart';
import
'package:flutter_tools/src/macos/macos_device.dart'
;
import
'package:flutter_tools/src/macos/macos_workflow.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
...
...
@@ -39,14 +39,14 @@ void main() {
fileSystem:
MemoryFileSystem
.
test
(),
operatingSystemUtils:
FakeOperatingSystemUtils
(),
);
final
MockMacOSApp
mockMacOSApp
=
Mock
MacOSApp
();
final
FakeMacOSApp
package
=
Fake
MacOSApp
();
expect
(
await
device
.
targetPlatform
,
TargetPlatform
.
darwin
);
expect
(
device
.
name
,
'macOS'
);
expect
(
await
device
.
installApp
(
mockMacOSApp
),
true
);
expect
(
await
device
.
uninstallApp
(
mockMacOSApp
),
true
);
expect
(
await
device
.
isLatestBuildInstalled
(
mockMacOSApp
),
true
);
expect
(
await
device
.
isAppInstalled
(
mockMacOSApp
),
true
);
expect
(
await
device
.
installApp
(
package
),
true
);
expect
(
await
device
.
uninstallApp
(
package
),
true
);
expect
(
await
device
.
isLatestBuildInstalled
(
package
),
true
);
expect
(
await
device
.
isAppInstalled
(
package
),
true
);
expect
(
device
.
category
,
Category
.
desktop
);
expect
(
device
.
supportsRuntimeMode
(
BuildMode
.
debug
),
true
);
...
...
@@ -61,7 +61,7 @@ void main() {
fileSystem:
MemoryFileSystem
.
test
(),
processManager:
FakeProcessManager
.
list
(<
FakeCommand
>[
FakeCommand
(
command:
const
<
String
>[
'
Example.app
'
],
command:
const
<
String
>[
'
release/executable
'
],
stdout:
'Hello World'
,
stderr:
'Goodnight, Moon'
,
completer:
completer
,
...
...
@@ -70,18 +70,17 @@ void main() {
logger:
BufferLogger
.
test
(),
operatingSystemUtils:
FakeOperatingSystemUtils
(),
);
final
MockMacOSApp
mockMacOSApp
=
MockMacOSApp
();
when
(
mockMacOSApp
.
executable
(
BuildMode
.
release
)).
thenReturn
(
'Example.app'
);
final
FakeMacOSApp
package
=
FakeMacOSApp
();
final
LaunchResult
result
=
await
device
.
startApp
(
mockMacOSApp
,
package
,
debuggingOptions:
DebuggingOptions
.
disabled
(
BuildInfo
.
release
),
prebuiltApplication:
true
,
);
expect
(
result
.
started
,
true
);
final
DeviceLogReader
logReader
=
device
.
getLogReader
(
app:
mockMacOSApp
);
final
DeviceLogReader
logReader
=
device
.
getLogReader
(
app:
package
);
expect
(
logReader
.
logLines
,
emits
(
'Hello WorldGoodnight, Moon'
));
completer
.
complete
();
...
...
@@ -213,7 +212,7 @@ void main() {
});
testUsingContext
(
'executablePathForDevice uses the correct package executable'
,
()
async
{
final
MockMacOSApp
mockApp
=
Mock
MacOSApp
();
final
FakeMacOSApp
package
=
Fake
MacOSApp
();
final
MacOSDevice
device
=
MacOSDevice
(
fileSystem:
MemoryFileSystem
.
test
(),
logger:
BufferLogger
.
test
(),
...
...
@@ -223,13 +222,10 @@ void main() {
const
String
debugPath
=
'debug/executable'
;
const
String
profilePath
=
'profile/executable'
;
const
String
releasePath
=
'release/executable'
;
when
(
mockApp
.
executable
(
BuildMode
.
debug
)).
thenReturn
(
debugPath
);
when
(
mockApp
.
executable
(
BuildMode
.
profile
)).
thenReturn
(
profilePath
);
when
(
mockApp
.
executable
(
BuildMode
.
release
)).
thenReturn
(
releasePath
);
expect
(
device
.
executablePathForDevice
(
mockApp
,
BuildMode
.
debug
),
debugPath
);
expect
(
device
.
executablePathForDevice
(
mockApp
,
BuildMode
.
profile
),
profilePath
);
expect
(
device
.
executablePathForDevice
(
mockApp
,
BuildMode
.
release
),
releasePath
);
expect
(
device
.
executablePathForDevice
(
package
,
BuildMode
.
debug
),
debugPath
);
expect
(
device
.
executablePathForDevice
(
package
,
BuildMode
.
profile
),
profilePath
);
expect
(
device
.
executablePathForDevice
(
package
,
BuildMode
.
release
),
releasePath
);
});
}
...
...
@@ -241,4 +237,18 @@ FlutterProject setUpFlutterProject(Directory directory) {
return
flutterProjectFactory
.
fromDirectory
(
directory
);
}
class
MockMacOSApp
extends
Mock
implements
MacOSApp
{}
class
FakeMacOSApp
extends
Fake
implements
MacOSApp
{
@override
String
executable
(
BuildMode
buildMode
)
{
switch
(
buildMode
)
{
case
BuildMode
.
debug
:
return
'debug/executable'
;
case
BuildMode
.
profile
:
return
'profile/executable'
;
case
BuildMode
.
release
:
return
'release/executable'
;
default
:
throw
StateError
(
''
);
}
}
}
packages/flutter_tools/test/general.shard/macos/macos_project_migration_test.dart
View file @
7c27db3d
...
...
@@ -7,14 +7,12 @@
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/project_migrator.dart'
;
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/macos/migrations/remove_macos_framework_link_and_embedding_migration.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:meta/meta.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'../../src/common.dart'
;
...
...
@@ -22,31 +20,22 @@ void main() {
TestUsage
testUsage
;
MemoryFileSystem
memoryFileSystem
;
BufferLogger
testLogger
;
MockMacOSProject
mockM
acOSProject
;
FakeMacOSProject
m
acOSProject
;
File
xcodeProjectInfoFile
;
setUp
(()
{
testUsage
=
TestUsage
();
memoryFileSystem
=
MemoryFileSystem
.
test
();
xcodeProjectInfoFile
=
memoryFileSystem
.
file
(
'project.pbxproj'
);
testLogger
=
BufferLogger
(
terminal:
AnsiTerminal
(
stdio:
null
,
platform:
const
LocalPlatform
(),
),
outputPreferences:
OutputPreferences
.
test
(),
);
mockMacOSProject
=
MockMacOSProject
();
when
(
mockMacOSProject
.
xcodeProjectInfoFile
)
.
thenReturn
(
xcodeProjectInfoFile
);
testLogger
=
BufferLogger
.
test
();
macOSProject
=
FakeMacOSProject
();
macOSProject
.
xcodeProjectInfoFile
=
xcodeProjectInfoFile
;
});
testWithoutContext
(
'skipped if files are missing'
,
()
{
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
m
ockM
acOSProject
,
macOSProject
,
testLogger
,
testUsage
,
);
...
...
@@ -70,7 +59,7 @@ void main() {
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
m
ockM
acOSProject
,
macOSProject
,
testLogger
,
testUsage
,
);
...
...
@@ -91,7 +80,7 @@ shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
m
ockM
acOSProject
,
macOSProject
,
testLogger
,
testUsage
,
);
...
...
@@ -114,7 +103,7 @@ keep this 2
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
m
ockM
acOSProject
,
macOSProject
,
testLogger
,
testUsage
,
);
...
...
@@ -137,7 +126,7 @@ keep this 2
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
m
ockM
acOSProject
,
macOSProject
,
testLogger
,
testUsage
,
);
...
...
@@ -157,7 +146,7 @@ keep this 2
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
m
ockM
acOSProject
,
macOSProject
,
testLogger
,
testUsage
,
);
...
...
@@ -169,7 +158,10 @@ keep this 2
});
}
class
MockMacOSProject
extends
Mock
implements
MacOSProject
{}
class
FakeMacOSProject
extends
Fake
implements
MacOSProject
{
@override
File
xcodeProjectInfoFile
;
}
class
FakeMacOSMigrator
extends
ProjectMigrator
{
FakeMacOSMigrator
({
@required
this
.
succeeds
})
:
super
(
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