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
207efd4c
Unverified
Commit
207efd4c
authored
Mar 25, 2020
by
Jenn Magder
Committed by
GitHub
Mar 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert idevicescreenshot and upgradePbxProjWithFlutterAssets tests to testWithoutContext (#53208)
parent
52e4011a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
18 deletions
+20
-18
mac.dart
packages/flutter_tools/lib/src/ios/mac.dart
+4
-4
mac_test.dart
packages/flutter_tools/test/general.shard/ios/mac_test.dart
+16
-14
No files found.
packages/flutter_tools/lib/src/ios/mac.dart
View file @
207efd4c
...
...
@@ -66,7 +66,7 @@ class IMobileDevice {
/// Captures a screenshot to the specified outputFile.
Future
<
void
>
takeScreenshot
(
File
outputFile
)
{
return
processUtils
.
run
(
return
_
processUtils
.
run
(
<
String
>[
_idevicescreenshotPath
,
outputFile
.
path
,
...
...
@@ -87,7 +87,7 @@ Future<XcodeBuildResult> buildXcodeProject({
DarwinArch
activeArch
,
bool
codesign
=
true
,
})
async
{
if
(!
upgradePbxProjWithFlutterAssets
(
app
.
project
))
{
if
(!
upgradePbxProjWithFlutterAssets
(
app
.
project
,
globals
.
logger
))
{
return
XcodeBuildResult
(
success:
false
);
}
...
...
@@ -562,7 +562,7 @@ bool _checkXcodeVersion() {
}
// TODO(jmagman): Refactor to IOSMigrator.
bool
upgradePbxProjWithFlutterAssets
(
IosProject
project
)
{
bool
upgradePbxProjWithFlutterAssets
(
IosProject
project
,
Logger
logger
)
{
final
File
xcodeProjectFile
=
project
.
xcodeProjectInfoFile
;
assert
(
xcodeProjectFile
.
existsSync
());
final
List
<
String
>
lines
=
xcodeProjectFile
.
readAsLinesSync
();
...
...
@@ -575,7 +575,7 @@ bool upgradePbxProjWithFlutterAssets(IosProject project) {
final
Match
match
=
oldAssets
.
firstMatch
(
line
);
if
(
match
!=
null
)
{
if
(
printedStatuses
.
add
(
match
.
group
(
1
)))
{
globals
.
printStatus
(
'Removing obsolete reference to
${match.group(1)}
from
${project.hostAppBundleName}
'
);
logger
.
printStatus
(
'Removing obsolete reference to
${match.group(1)}
from
${project.hostAppBundleName}
'
);
}
}
else
{
buffer
.
writeln
(
line
);
...
...
packages/flutter_tools/test/general.shard/ios/mac_test.dart
View file @
207efd4c
...
...
@@ -36,15 +36,19 @@ class MockXcodeProjectInterpreter extends Mock implements XcodeProjectInterprete
class
MockIosProject
extends
Mock
implements
IosProject
{}
void
main
(
)
{
BufferLogger
logger
;
setUp
(()
{
logger
=
BufferLogger
.
test
();
});
group
(
'IMobileDevice'
,
()
{
final
String
libimobiledevicePath
=
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'artifacts'
,
'libimobiledevice'
);
final
String
idevicescreenshotPath
=
globals
.
fs
.
path
.
join
(
libimobiledevicePath
,
'idevicescreenshot'
);
MockArtifacts
mockArtifacts
;
MockCache
mockCache
;
Logger
logger
;
setUp
(()
{
logger
=
BufferLogger
.
test
();
mockCache
=
MockCache
();
mockArtifacts
=
MockArtifacts
();
when
(
mockArtifacts
.
getArtifactPath
(
Artifact
.
idevicescreenshot
,
platform:
anyNamed
(
'platform'
))).
thenReturn
(
idevicescreenshotPath
);
...
...
@@ -83,7 +87,7 @@ void main() {
expect
(()
async
=>
await
iMobileDevice
.
takeScreenshot
(
mockOutputFile
),
throwsA
(
anything
));
});
test
Using
Context
(
'idevicescreenshot captures and returns screenshot'
,
()
async
{
test
Without
Context
(
'idevicescreenshot captures and returns screenshot'
,
()
async
{
when
(
mockOutputFile
.
path
).
thenReturn
(
outputPath
);
when
(
mockProcessManager
.
run
(
any
,
environment:
anyNamed
(
'environment'
),
workingDirectory:
null
)).
thenAnswer
(
(
Invocation
invocation
)
=>
Future
<
ProcessResult
>.
value
(
ProcessResult
(
4
,
0
,
''
,
''
)));
...
...
@@ -100,8 +104,6 @@ void main() {
environment:
<
String
,
String
>{
'DYLD_LIBRARY_PATH'
:
libimobiledevicePath
},
workingDirectory:
null
,
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
});
});
});
...
...
@@ -389,7 +391,7 @@ Exited (sigterm)''',
'another line',
];
test
Using
Context('upgradePbxProjWithFlutterAssets', () async {
test
Without
Context('upgradePbxProjWithFlutterAssets', () async {
final MockIosProject project = MockIosProject();
final MockFile pbxprojFile = MockFile();
...
...
@@ -400,30 +402,30 @@ Exited (sigterm)''',
when(pbxprojFile.existsSync())
.thenAnswer((_) => true);
bool result = upgradePbxProjWithFlutterAssets(project);
bool result = upgradePbxProjWithFlutterAssets(project
, logger
);
expect(result, true);
expect(
testL
ogger.statusText,
l
ogger.statusText,
contains('Removing obsolete reference to flutter_assets'),
);
testL
ogger.clear();
l
ogger.clear();
when(pbxprojFile.readAsLinesSync())
.thenAnswer((_) => appFlxPbxProjLines);
result = upgradePbxProjWithFlutterAssets(project);
result = upgradePbxProjWithFlutterAssets(project
, logger
);
expect(result, true);
expect(
testL
ogger.statusText,
l
ogger.statusText,
contains('Removing obsolete reference to app.flx'),
);
testL
ogger.clear();
l
ogger.clear();
when(pbxprojFile.readAsLinesSync())
.thenAnswer((_) => cleanPbxProjLines);
result = upgradePbxProjWithFlutterAssets(project);
result = upgradePbxProjWithFlutterAssets(project
, logger
);
expect(result, true);
expect(
testL
ogger.statusText,
l
ogger.statusText,
isEmpty,
);
});
...
...
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