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
Hide 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
...
@@ -9,186 +9,147 @@ import 'dart:convert';
...
@@ -9,186 +9,147 @@ import 'dart:convert';
import
'package:file/file.dart'
;
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/utils.dart'
;
import
'package:flutter_tools/src/base/utils.dart'
;
import
'package:flutter_tools/src/globals_null_migrated.dart'
as
globals
;
import
'package:flutter_tools/src/ios/plist_parser.dart'
;
import
'package:flutter_tools/src/ios/plist_parser.dart'
;
import
'package:flutter_tools/src/macos/application_package.dart'
;
import
'package:flutter_tools/src/macos/application_package.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'../../src/common.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/context.dart'
;
void
main
(
)
{
void
main
(
)
{
group
(
'PrebuiltMacOSApp'
,
()
{
group
(
'PrebuiltMacOSApp'
,
()
{
MockOperatingSystemUtils
os
;
FakeOperatingSystemUtils
os
;
FileSystem
fileSystem
;
BufferLogger
logger
;
final
Map
<
Type
,
Generator
>
overrides
=
<
Type
,
Generator
>{
final
Map
<
Type
,
Generator
>
overrides
=
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
.
test
()
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
PlistParser:
()
=>
FakePlistUtils
(),
PlistParser:
()
=>
FakePlistUtils
(
fileSystem
),
Platform:
_kNoColorTerminalPlatform
,
OperatingSystemUtils:
()
=>
os
,
OperatingSystemUtils:
()
=>
os
,
Logger:
()
=>
logger
,
};
};
setUp
(()
{
setUp
(()
{
os
=
MockOperatingSystemUtils
();
fileSystem
=
MemoryFileSystem
.
test
();
os
=
FakeOperatingSystemUtils
();
logger
=
BufferLogger
.
test
();
});
});
testUsingContext
(
'Error on non-existing file'
,
()
{
testUsingContext
(
'Error on non-existing file'
,
()
{
final
PrebuiltMacOSApp
macosApp
=
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
fileSystem
.
file
(
'not_existing.app'
))
as
PrebuiltMacOSApp
;
MacOSApp
.
fromPrebuiltApp
(
globals
.
fs
.
file
(
'not_existing.app'
))
as
PrebuiltMacOSApp
;
expect
(
macosApp
,
isNull
);
expect
(
macosApp
,
isNull
);
expect
(
expect
(
logger
.
errorText
,
contains
(
'File "not_existing.app" does not exist.'
));
testLogger
.
errorText
,
'File "not_existing.app" does not exist.
\n
'
,
);
},
overrides:
overrides
);
},
overrides:
overrides
);
testUsingContext
(
'Error on non-app-bundle folder'
,
()
{
testUsingContext
(
'Error on non-app-bundle folder'
,
()
{
globals
.
fs
.
directory
(
'regular_folder'
).
createSync
();
fileSystem
.
directory
(
'regular_folder'
).
createSync
();
final
PrebuiltMacOSApp
macosApp
=
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
fileSystem
.
file
(
'regular_folder'
))
as
PrebuiltMacOSApp
;
MacOSApp
.
fromPrebuiltApp
(
globals
.
fs
.
file
(
'regular_folder'
))
as
PrebuiltMacOSApp
;
expect
(
macosApp
,
isNull
);
expect
(
macosApp
,
isNull
);
expect
(
testLogger
.
errorText
,
expect
(
logger
.
errorText
,
contains
(
'Folder "regular_folder" is not an app bundle.'
));
'Folder "regular_folder" is not an app bundle.
\n
'
);
},
overrides:
overrides
);
},
overrides:
overrides
);
testUsingContext
(
'Error on no info.plist'
,
()
{
testUsingContext
(
'Error on no info.plist'
,
()
{
globals
.
fs
.
directory
(
'bundle.app'
).
createSync
();
fileSystem
.
directory
(
'bundle.app'
).
createSync
();
final
PrebuiltMacOSApp
macosApp
=
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
fileSystem
.
file
(
'bundle.app'
))
as
PrebuiltMacOSApp
;
MacOSApp
.
fromPrebuiltApp
(
globals
.
fs
.
file
(
'bundle.app'
))
as
PrebuiltMacOSApp
;
expect
(
macosApp
,
isNull
);
expect
(
macosApp
,
isNull
);
expect
(
expect
(
logger
.
errorText
,
contains
(
'Invalid prebuilt macOS app. Does not contain Info.plist.'
));
testLogger
.
errorText
,
'Invalid prebuilt macOS app. Does not contain Info.plist.
\n
'
,
);
},
overrides:
overrides
);
},
overrides:
overrides
);
testUsingContext
(
'Error on info.plist missing bundle identifier'
,
()
{
testUsingContext
(
'Error on info.plist missing bundle identifier'
,
()
{
final
String
contentsDirectory
=
final
String
contentsDirectory
=
fileSystem
.
path
.
join
(
'bundle.app'
,
'Contents'
);
globals
.
fs
.
path
.
join
(
'bundle.app'
,
'Contents'
);
fileSystem
.
directory
(
contentsDirectory
).
createSync
(
recursive:
true
);
globals
.
fs
.
directory
(
contentsDirectory
).
createSync
(
recursive:
true
);
fileSystem
globals
.
fs
.
file
(
fileSystem
.
path
.
join
(
'bundle.app'
,
'Contents'
,
'Info.plist'
))
.
file
(
globals
.
fs
.
path
.
join
(
'bundle.app'
,
'Contents'
,
'Info.plist'
))
.
writeAsStringSync
(
badPlistData
);
.
writeAsStringSync
(
badPlistData
);
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
fileSystem
.
file
(
'bundle.app'
))
as
PrebuiltMacOSApp
;
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
globals
.
fs
.
file
(
'bundle.app'
))
as
PrebuiltMacOSApp
;
expect
(
macosApp
,
isNull
);
expect
(
macosApp
,
isNull
);
expect
(
expect
(
logger
.
errorText
,
contains
(
'Invalid prebuilt macOS app. Info.plist does not contain bundle identifier'
));
testLogger
.
errorText
,
contains
(
'Invalid prebuilt macOS app. Info.plist does not contain bundle identifier
\n
'
),
);
},
overrides:
overrides
);
},
overrides:
overrides
);
testUsingContext
(
'Error on info.plist missing executable'
,
()
{
testUsingContext
(
'Error on info.plist missing executable'
,
()
{
final
String
contentsDirectory
=
final
String
contentsDirectory
=
fileSystem
.
path
.
join
(
'bundle.app'
,
'Contents'
);
globals
.
fs
.
path
.
join
(
'bundle.app'
,
'Contents'
);
fileSystem
.
directory
(
contentsDirectory
).
createSync
(
recursive:
true
);
globals
.
fs
.
directory
(
contentsDirectory
).
createSync
(
recursive:
true
);
fileSystem
globals
.
fs
.
file
(
fileSystem
.
path
.
join
(
'bundle.app'
,
'Contents'
,
'Info.plist'
))
.
file
(
globals
.
fs
.
path
.
join
(
'bundle.app'
,
'Contents'
,
'Info.plist'
))
.
writeAsStringSync
(
badPlistDataNoExecutable
);
.
writeAsStringSync
(
badPlistDataNoExecutable
);
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
fileSystem
.
file
(
'bundle.app'
))
as
PrebuiltMacOSApp
;
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
globals
.
fs
.
file
(
'bundle.app'
))
as
PrebuiltMacOSApp
;
expect
(
macosApp
,
isNull
);
expect
(
macosApp
,
isNull
);
expect
(
expect
(
logger
.
errorText
,
contains
(
'Invalid prebuilt macOS app. Info.plist does not contain bundle executable'
));
testLogger
.
errorText
,
contains
(
'Invalid prebuilt macOS app. Info.plist does not contain bundle executable
\n
'
),
);
},
overrides:
overrides
);
},
overrides:
overrides
);
testUsingContext
(
'Success with app bundle'
,
()
{
testUsingContext
(
'Success with app bundle'
,
()
{
final
String
appDirectory
=
final
String
appDirectory
=
fileSystem
.
path
.
join
(
'bundle.app'
,
'Contents'
,
'MacOS'
);
globals
.
fs
.
path
.
join
(
'bundle.app'
,
'Contents'
,
'MacOS'
);
fileSystem
.
directory
(
appDirectory
).
createSync
(
recursive:
true
);
globals
.
fs
.
directory
(
appDirectory
).
createSync
(
recursive:
true
);
fileSystem
globals
.
fs
.
file
(
fileSystem
.
path
.
join
(
'bundle.app'
,
'Contents'
,
'Info.plist'
))
.
file
(
globals
.
fs
.
path
.
join
(
'bundle.app'
,
'Contents'
,
'Info.plist'
))
.
writeAsStringSync
(
plistData
);
.
writeAsStringSync
(
plistData
);
fileSystem
globals
.
fs
.
file
(
fileSystem
.
path
.
join
(
appDirectory
,
executableName
))
.
file
(
globals
.
fs
.
path
.
join
(
appDirectory
,
executableName
))
.
createSync
();
.
createSync
();
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
fileSystem
.
file
(
'bundle.app'
))
as
PrebuiltMacOSApp
;
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
globals
.
fs
.
file
(
'bundle.app'
))
expect
(
logger
.
errorText
,
isEmpty
);
as
PrebuiltMacOSApp
;
expect
(
testLogger
.
errorText
,
isEmpty
);
expect
(
macosApp
.
bundleDir
.
path
,
'bundle.app'
);
expect
(
macosApp
.
bundleDir
.
path
,
'bundle.app'
);
expect
(
macosApp
.
id
,
'fooBundleId'
);
expect
(
macosApp
.
id
,
'fooBundleId'
);
expect
(
macosApp
.
bundleName
,
'bundle.app'
);
expect
(
macosApp
.
bundleName
,
'bundle.app'
);
},
overrides:
overrides
);
},
overrides:
overrides
);
testUsingContext
(
'Bad zipped app, no payload dir'
,
()
{
testUsingContext
(
'Bad zipped app, no payload dir'
,
()
{
globals
.
fs
.
file
(
'app.zip'
).
createSync
();
fileSystem
.
file
(
'app.zip'
).
createSync
();
when
(
os
.
unzip
(
globals
.
fs
.
file
(
'app.zip'
),
any
))
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
fileSystem
.
file
(
'app.zip'
))
as
PrebuiltMacOSApp
;
.
thenAnswer
((
Invocation
_
)
{});
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
globals
.
fs
.
file
(
'app.zip'
))
as
PrebuiltMacOSApp
;
expect
(
macosApp
,
isNull
);
expect
(
macosApp
,
isNull
);
expect
(
expect
(
logger
.
errorText
,
contains
(
'Archive "app.zip" does not contain a single app bundle.'
));
testLogger
.
errorText
,
'Archive "app.zip" does not contain a single app bundle.
\n
'
,
);
},
overrides:
overrides
);
},
overrides:
overrides
);
testUsingContext
(
'Bad zipped app, two app bundles'
,
()
{
testUsingContext
(
'Bad zipped app, two app bundles'
,
()
{
globals
.
fs
.
file
(
'app.zip'
).
createSync
();
fileSystem
.
file
(
'app.zip'
).
createSync
();
when
(
os
.
unzip
(
any
,
any
)).
thenAnswer
((
Invocation
invocation
)
{
os
.
unzipOverride
=
(
File
zipFile
,
Directory
targetDirectory
)
{
final
File
zipFile
=
invocation
.
positionalArguments
[
0
]
as
File
;
if
(
zipFile
.
path
!=
'app.zip'
)
{
if
(
zipFile
.
path
!=
'app.zip'
)
{
return
;
return
;
}
}
final
Directory
targetDirectory
=
final
String
bundlePath1
=
fileSystem
.
path
.
join
(
targetDirectory
.
path
,
'bundle1.app'
);
invocation
.
positionalArguments
[
1
]
as
Directory
;
final
String
bundlePath2
=
fileSystem
.
path
.
join
(
targetDirectory
.
path
,
'bundle2.app'
);
final
String
bundlePath1
=
fileSystem
.
directory
(
bundlePath1
).
createSync
(
recursive:
true
);
globals
.
fs
.
path
.
join
(
targetDirectory
.
path
,
'bundle1.app'
);
fileSystem
.
directory
(
bundlePath2
).
createSync
(
recursive:
true
);
final
String
bundlePath2
=
};
globals
.
fs
.
path
.
join
(
targetDirectory
.
path
,
'bundle2.app'
);
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
fileSystem
.
file
(
'app.zip'
))
as
PrebuiltMacOSApp
;
globals
.
fs
.
directory
(
bundlePath1
).
createSync
(
recursive:
true
);
globals
.
fs
.
directory
(
bundlePath2
).
createSync
(
recursive:
true
);
});
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
globals
.
fs
.
file
(
'app.zip'
))
as
PrebuiltMacOSApp
;
expect
(
macosApp
,
isNull
);
expect
(
macosApp
,
isNull
);
expect
(
testLogger
.
errorText
,
expect
(
logger
.
errorText
,
contains
(
'Archive "app.zip" does not contain a single app bundle.'
));
'Archive "app.zip" does not contain a single app bundle.
\n
'
);
},
overrides:
overrides
);
},
overrides:
overrides
);
testUsingContext
(
'Success with zipped app'
,
()
{
testUsingContext
(
'Success with zipped app'
,
()
{
globals
.
fs
.
file
(
'app.zip'
).
createSync
();
fileSystem
.
file
(
'app.zip'
).
createSync
();
when
(
os
.
unzip
(
any
,
any
)).
thenAnswer
((
Invocation
invocation
)
{
os
.
unzipOverride
=
(
File
zipFile
,
Directory
targetDirectory
)
{
final
File
zipFile
=
invocation
.
positionalArguments
[
0
]
as
File
;
if
(
zipFile
.
path
!=
'app.zip'
)
{
if
(
zipFile
.
path
!=
'app.zip'
)
{
return
;
return
;
}
}
final
Directory
targetDirectory
=
final
Directory
bundleAppContentsDir
=
fileSystem
.
directory
(
fileSystem
.
path
.
join
(
targetDirectory
.
path
,
'bundle.app'
,
'Contents'
));
invocation
.
positionalArguments
[
1
]
as
Directory
;
final
Directory
bundleAppContentsDir
=
globals
.
fs
.
directory
(
globals
.
fs
.
path
.
join
(
targetDirectory
.
path
,
'bundle.app'
,
'Contents'
));
bundleAppContentsDir
.
createSync
(
recursive:
true
);
bundleAppContentsDir
.
createSync
(
recursive:
true
);
globals
.
fs
fileSystem
.
file
(
globals
.
fs
.
path
.
join
(
bundleAppContentsDir
.
path
,
'Info.plist'
))
.
file
(
fileSystem
.
path
.
join
(
bundleAppContentsDir
.
path
,
'Info.plist'
))
.
writeAsStringSync
(
plistData
);
.
writeAsStringSync
(
plistData
);
globals
.
fs
fileSystem
.
directory
(
globals
.
fs
.
path
.
join
(
bundleAppContentsDir
.
path
,
'MacOS'
))
.
directory
(
fileSystem
.
path
.
join
(
bundleAppContentsDir
.
path
,
'MacOS'
))
.
createSync
();
.
createSync
();
globals
.
fs
fileSystem
.
file
(
globals
.
fs
.
path
.
file
(
fileSystem
.
path
.
join
(
bundleAppContentsDir
.
path
,
'MacOS'
,
executableName
))
.
join
(
bundleAppContentsDir
.
path
,
'MacOS'
,
executableName
))
.
createSync
();
.
createSync
();
});
};
final
PrebuiltMacOSApp
macosApp
=
final
PrebuiltMacOSApp
macosApp
=
MacOSApp
.
fromPrebuiltApp
(
fileSystem
.
file
(
'app.zip'
))
as
PrebuiltMacOSApp
;
MacOSApp
.
fromPrebuiltApp
(
globals
.
fs
.
file
(
'app.zip'
))
as
PrebuiltMacOSApp
;
expect
(
logger
.
errorText
,
isEmpty
);
expect
(
testLogger
.
errorText
,
isEmpty
);
expect
(
macosApp
.
bundleDir
.
path
,
endsWith
(
'bundle.app'
));
expect
(
macosApp
.
bundleDir
.
path
,
endsWith
(
'bundle.app'
));
expect
(
macosApp
.
id
,
'fooBundleId'
);
expect
(
macosApp
.
id
,
'fooBundleId'
);
expect
(
macosApp
.
bundleName
,
endsWith
(
'bundle.app'
));
expect
(
macosApp
.
bundleName
,
endsWith
(
'bundle.app'
));
...
@@ -196,17 +157,25 @@ void main() {
...
@@ -196,17 +157,25 @@ void main() {
});
});
}
}
class
MockOperatingSystemUtils
extends
Mock
implements
OperatingSystemUtils
{}
class
FakeOperatingSystemUtils
extends
Fake
implements
OperatingSystemUtils
{
FakeOperatingSystemUtils
();
void
Function
(
File
,
Directory
)
unzipOverride
;
FakePlatform
_kNoColorTerminalPlatform
(
)
=>
FakePlatform
(
stdoutSupportsAnsi:
false
);
@override
final
Map
<
Type
,
Generator
>
noColorTerminalOverride
=
<
Type
,
Generator
>{
void
unzip
(
File
file
,
Directory
targetDirectory
)
{
Platform:
_kNoColorTerminalPlatform
,
unzipOverride
?.
call
(
file
,
targetDirectory
);
};
}
}
class
FakePlistUtils
extends
Fake
implements
PlistParser
{
class
FakePlistUtils
extends
Fake
implements
PlistParser
{
FakePlistUtils
(
this
.
fileSystem
);
final
FileSystem
fileSystem
;
@override
@override
Map
<
String
,
dynamic
>
parseFile
(
String
plistFilePath
)
{
Map
<
String
,
dynamic
>
parseFile
(
String
plistFilePath
)
{
final
File
file
=
globals
.
fs
.
file
(
plistFilePath
);
final
File
file
=
fileSystem
.
file
(
plistFilePath
);
if
(!
file
.
existsSync
())
{
if
(!
file
.
existsSync
())
{
return
<
String
,
dynamic
>{};
return
<
String
,
dynamic
>{};
}
}
...
...
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';
...
@@ -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_device.dart'
;
import
'package:flutter_tools/src/macos/macos_workflow.dart'
;
import
'package:flutter_tools/src/macos/macos_workflow.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'../../src/common.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/context.dart'
;
...
@@ -39,14 +39,14 @@ void main() {
...
@@ -39,14 +39,14 @@ void main() {
fileSystem:
MemoryFileSystem
.
test
(),
fileSystem:
MemoryFileSystem
.
test
(),
operatingSystemUtils:
FakeOperatingSystemUtils
(),
operatingSystemUtils:
FakeOperatingSystemUtils
(),
);
);
final
MockMacOSApp
mockMacOSApp
=
Mock
MacOSApp
();
final
FakeMacOSApp
package
=
Fake
MacOSApp
();
expect
(
await
device
.
targetPlatform
,
TargetPlatform
.
darwin
);
expect
(
await
device
.
targetPlatform
,
TargetPlatform
.
darwin
);
expect
(
device
.
name
,
'macOS'
);
expect
(
device
.
name
,
'macOS'
);
expect
(
await
device
.
installApp
(
mockMacOSApp
),
true
);
expect
(
await
device
.
installApp
(
package
),
true
);
expect
(
await
device
.
uninstallApp
(
mockMacOSApp
),
true
);
expect
(
await
device
.
uninstallApp
(
package
),
true
);
expect
(
await
device
.
isLatestBuildInstalled
(
mockMacOSApp
),
true
);
expect
(
await
device
.
isLatestBuildInstalled
(
package
),
true
);
expect
(
await
device
.
isAppInstalled
(
mockMacOSApp
),
true
);
expect
(
await
device
.
isAppInstalled
(
package
),
true
);
expect
(
device
.
category
,
Category
.
desktop
);
expect
(
device
.
category
,
Category
.
desktop
);
expect
(
device
.
supportsRuntimeMode
(
BuildMode
.
debug
),
true
);
expect
(
device
.
supportsRuntimeMode
(
BuildMode
.
debug
),
true
);
...
@@ -61,7 +61,7 @@ void main() {
...
@@ -61,7 +61,7 @@ void main() {
fileSystem:
MemoryFileSystem
.
test
(),
fileSystem:
MemoryFileSystem
.
test
(),
processManager:
FakeProcessManager
.
list
(<
FakeCommand
>[
processManager:
FakeProcessManager
.
list
(<
FakeCommand
>[
FakeCommand
(
FakeCommand
(
command:
const
<
String
>[
'
Example.app
'
],
command:
const
<
String
>[
'
release/executable
'
],
stdout:
'Hello World'
,
stdout:
'Hello World'
,
stderr:
'Goodnight, Moon'
,
stderr:
'Goodnight, Moon'
,
completer:
completer
,
completer:
completer
,
...
@@ -70,18 +70,17 @@ void main() {
...
@@ -70,18 +70,17 @@ void main() {
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
operatingSystemUtils:
FakeOperatingSystemUtils
(),
operatingSystemUtils:
FakeOperatingSystemUtils
(),
);
);
final
MockMacOSApp
mockMacOSApp
=
MockMacOSApp
();
final
FakeMacOSApp
package
=
FakeMacOSApp
();
when
(
mockMacOSApp
.
executable
(
BuildMode
.
release
)).
thenReturn
(
'Example.app'
);
final
LaunchResult
result
=
await
device
.
startApp
(
final
LaunchResult
result
=
await
device
.
startApp
(
mockMacOSApp
,
package
,
debuggingOptions:
DebuggingOptions
.
disabled
(
BuildInfo
.
release
),
debuggingOptions:
DebuggingOptions
.
disabled
(
BuildInfo
.
release
),
prebuiltApplication:
true
,
prebuiltApplication:
true
,
);
);
expect
(
result
.
started
,
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'
));
expect
(
logReader
.
logLines
,
emits
(
'Hello WorldGoodnight, Moon'
));
completer
.
complete
();
completer
.
complete
();
...
@@ -213,7 +212,7 @@ void main() {
...
@@ -213,7 +212,7 @@ void main() {
});
});
testUsingContext
(
'executablePathForDevice uses the correct package executable'
,
()
async
{
testUsingContext
(
'executablePathForDevice uses the correct package executable'
,
()
async
{
final
MockMacOSApp
mockApp
=
Mock
MacOSApp
();
final
FakeMacOSApp
package
=
Fake
MacOSApp
();
final
MacOSDevice
device
=
MacOSDevice
(
final
MacOSDevice
device
=
MacOSDevice
(
fileSystem:
MemoryFileSystem
.
test
(),
fileSystem:
MemoryFileSystem
.
test
(),
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
...
@@ -223,13 +222,10 @@ void main() {
...
@@ -223,13 +222,10 @@ void main() {
const
String
debugPath
=
'debug/executable'
;
const
String
debugPath
=
'debug/executable'
;
const
String
profilePath
=
'profile/executable'
;
const
String
profilePath
=
'profile/executable'
;
const
String
releasePath
=
'release/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
(
package
,
BuildMode
.
debug
),
debugPath
);
expect
(
device
.
executablePathForDevice
(
mockApp
,
BuildMode
.
profile
),
profilePath
);
expect
(
device
.
executablePathForDevice
(
package
,
BuildMode
.
profile
),
profilePath
);
expect
(
device
.
executablePathForDevice
(
mockApp
,
BuildMode
.
release
),
releasePath
);
expect
(
device
.
executablePathForDevice
(
package
,
BuildMode
.
release
),
releasePath
);
});
});
}
}
...
@@ -241,4 +237,18 @@ FlutterProject setUpFlutterProject(Directory directory) {
...
@@ -241,4 +237,18 @@ FlutterProject setUpFlutterProject(Directory directory) {
return
flutterProjectFactory
.
fromDirectory
(
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 @@
...
@@ -7,14 +7,12 @@
import
'package:file/file.dart'
;
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/logger.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/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/macos/migrations/remove_macos_framework_link_and_embedding_migration.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'../../src/common.dart'
;
import
'../../src/common.dart'
;
...
@@ -22,31 +20,22 @@ void main() {
...
@@ -22,31 +20,22 @@ void main() {
TestUsage
testUsage
;
TestUsage
testUsage
;
MemoryFileSystem
memoryFileSystem
;
MemoryFileSystem
memoryFileSystem
;
BufferLogger
testLogger
;
BufferLogger
testLogger
;
MockMacOSProject
mockM
acOSProject
;
FakeMacOSProject
m
acOSProject
;
File
xcodeProjectInfoFile
;
File
xcodeProjectInfoFile
;
setUp
(()
{
setUp
(()
{
testUsage
=
TestUsage
();
testUsage
=
TestUsage
();
memoryFileSystem
=
MemoryFileSystem
.
test
();
memoryFileSystem
=
MemoryFileSystem
.
test
();
xcodeProjectInfoFile
=
memoryFileSystem
.
file
(
'project.pbxproj'
);
xcodeProjectInfoFile
=
memoryFileSystem
.
file
(
'project.pbxproj'
);
testLogger
=
BufferLogger
.
test
();
testLogger
=
BufferLogger
(
macOSProject
=
FakeMacOSProject
();
terminal:
AnsiTerminal
(
macOSProject
.
xcodeProjectInfoFile
=
xcodeProjectInfoFile
;
stdio:
null
,
platform:
const
LocalPlatform
(),
),
outputPreferences:
OutputPreferences
.
test
(),
);
mockMacOSProject
=
MockMacOSProject
();
when
(
mockMacOSProject
.
xcodeProjectInfoFile
)
.
thenReturn
(
xcodeProjectInfoFile
);
});
});
testWithoutContext
(
'skipped if files are missing'
,
()
{
testWithoutContext
(
'skipped if files are missing'
,
()
{
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
m
ockM
acOSProject
,
macOSProject
,
testLogger
,
testLogger
,
testUsage
,
testUsage
,
);
);
...
@@ -70,7 +59,7 @@ void main() {
...
@@ -70,7 +59,7 @@ void main() {
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
m
ockM
acOSProject
,
macOSProject
,
testLogger
,
testLogger
,
testUsage
,
testUsage
,
);
);
...
@@ -91,7 +80,7 @@ shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.
...
@@ -91,7 +80,7 @@ shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
m
ockM
acOSProject
,
macOSProject
,
testLogger
,
testLogger
,
testUsage
,
testUsage
,
);
);
...
@@ -114,7 +103,7 @@ keep this 2
...
@@ -114,7 +103,7 @@ keep this 2
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
m
ockM
acOSProject
,
macOSProject
,
testLogger
,
testLogger
,
testUsage
,
testUsage
,
);
);
...
@@ -137,7 +126,7 @@ keep this 2
...
@@ -137,7 +126,7 @@ keep this 2
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
m
ockM
acOSProject
,
macOSProject
,
testLogger
,
testLogger
,
testUsage
,
testUsage
,
);
);
...
@@ -157,7 +146,7 @@ keep this 2
...
@@ -157,7 +146,7 @@ keep this 2
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
final
RemoveMacOSFrameworkLinkAndEmbeddingMigration
macosProjectMigration
=
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
RemoveMacOSFrameworkLinkAndEmbeddingMigration
(
m
ockM
acOSProject
,
macOSProject
,
testLogger
,
testLogger
,
testUsage
,
testUsage
,
);
);
...
@@ -169,7 +158,10 @@ keep this 2
...
@@ -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
{
class
FakeMacOSMigrator
extends
ProjectMigrator
{
FakeMacOSMigrator
({
@required
this
.
succeeds
})
:
super
(
null
);
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