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
99e343a2
Commit
99e343a2
authored
Jun 15, 2017
by
Chris Bracken
Committed by
GitHub
Jun 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-title, format iOS device tests (#10733)
parent
1bc54e06
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
68 deletions
+61
-68
devices_test.dart
packages/flutter_tools/test/ios/devices_test.dart
+61
-68
No files found.
packages/flutter_tools/test/ios/devices_test.dart
View file @
99e343a2
...
...
@@ -22,7 +22,7 @@ void main() {
final
FakePlatform
osx
=
new
FakePlatform
.
fromPlatform
(
const
LocalPlatform
());
osx
.
operatingSystem
=
'macos'
;
group
(
'
test
screenshot'
,
()
{
group
(
'screenshot'
,
()
{
MockProcessManager
mockProcessManager
;
MockFile
mockOutputFile
;
IOSDevice
iosDeviceUnderTest
;
...
...
@@ -32,75 +32,68 @@ void main() {
mockOutputFile
=
new
MockFile
();
});
testUsingContext
(
'screenshot without ideviceinstaller error'
,
()
async
{
when
(
mockOutputFile
.
path
).
thenReturn
(
fs
.
path
.
join
(
'some'
,
'test'
,
'path'
,
'image.png'
));
// Let everything else return exit code 0 so process.dart doesn't crash.
// The matcher order is important.
when
(
mockProcessManager
.
run
(
any
,
environment:
null
,
workingDirectory:
null
)
).
thenReturn
(
new
Future
<
ProcessResult
>.
value
(
new
ProcessResult
(
2
,
0
,
''
,
''
))
);
// Let `which idevicescreenshot` fail with exit code 1.
when
(
mockProcessManager
.
runSync
(
<
String
>[
'which'
,
'idevicescreenshot'
],
environment:
null
,
workingDirectory:
null
)
).
thenReturn
(
new
ProcessResult
(
1
,
1
,
''
,
''
)
);
testUsingContext
(
'error if idevicescreenshot is not installed'
,
()
async
{
when
(
mockOutputFile
.
path
).
thenReturn
(
fs
.
path
.
join
(
'some'
,
'test'
,
'path'
,
'image.png'
));
// Let everything else return exit code 0 so process.dart doesn't crash.
// The matcher order is important.
when
(
mockProcessManager
.
run
(
any
,
environment:
null
,
workingDirectory:
null
)
).
thenReturn
(
new
Future
<
ProcessResult
>.
value
(
new
ProcessResult
(
2
,
0
,
''
,
''
))
);
// Let `which idevicescreenshot` fail with exit code 1.
when
(
mockProcessManager
.
runSync
(
<
String
>[
'which'
,
'idevicescreenshot'
],
environment:
null
,
workingDirectory:
null
)
).
thenReturn
(
new
ProcessResult
(
1
,
1
,
''
,
''
)
);
iosDeviceUnderTest
=
new
IOSDevice
(
'1234'
);
await
iosDeviceUnderTest
.
takeScreenshot
(
mockOutputFile
);
verify
(
mockProcessManager
.
runSync
(
<
String
>[
'which'
,
'idevicescreenshot'
],
environment:
null
,
workingDirectory:
null
));
verifyNever
(
mockProcessManager
.
run
(
<
String
>[
'idevicescreenshot'
,
fs
.
path
.
join
(
'some'
,
'test'
,
'path'
,
'image.png'
)],
environment:
null
,
workingDirectory:
null
));
expect
(
testLogger
.
errorText
,
contains
(
'brew install ideviceinstaller'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Platform:
()
=>
osx
,
}
);
iosDeviceUnderTest
=
new
IOSDevice
(
'1234'
);
await
iosDeviceUnderTest
.
takeScreenshot
(
mockOutputFile
);
verify
(
mockProcessManager
.
runSync
(
<
String
>[
'which'
,
'idevicescreenshot'
],
environment:
null
,
workingDirectory:
null
));
verifyNever
(
mockProcessManager
.
run
(
<
String
>[
'idevicescreenshot'
,
fs
.
path
.
join
(
'some'
,
'test'
,
'path'
,
'image.png'
)],
environment:
null
,
workingDirectory:
null
));
expect
(
testLogger
.
errorText
,
contains
(
'brew install ideviceinstaller'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Platform:
()
=>
osx
,
});
testUsingContext
(
'screenshot with ideviceinstaller gets command'
,
()
async
{
when
(
mockOutputFile
.
path
).
thenReturn
(
fs
.
path
.
join
(
'some'
,
'test'
,
'path'
,
'image.png'
));
// Let everything else return exit code 0.
// The matcher order is important.
when
(
mockProcessManager
.
run
(
any
,
environment:
null
,
workingDirectory:
null
)
).
thenReturn
(
new
Future
<
ProcessResult
>.
value
(
new
ProcessResult
(
4
,
0
,
''
,
''
))
);
// Let there be idevicescreenshot in the PATH.
when
(
mockProcessManager
.
runSync
(
<
String
>[
'which'
,
'idevicescreenshot'
],
environment:
null
,
workingDirectory:
null
)
).
thenReturn
(
new
ProcessResult
(
3
,
0
,
fs
.
path
.
join
(
'some'
,
'path'
,
'to'
,
'iscreenshot'
),
''
)
);
testUsingContext
(
'idevicescreenshot captures and returns screenshot'
,
()
async
{
when
(
mockOutputFile
.
path
).
thenReturn
(
fs
.
path
.
join
(
'some'
,
'test'
,
'path'
,
'image.png'
));
// Let everything else return exit code 0.
// The matcher order is important.
when
(
mockProcessManager
.
run
(
any
,
environment:
null
,
workingDirectory:
null
)
).
thenReturn
(
new
Future
<
ProcessResult
>.
value
(
new
ProcessResult
(
4
,
0
,
''
,
''
))
);
// Let there be idevicescreenshot in the PATH.
when
(
mockProcessManager
.
runSync
(
<
String
>[
'which'
,
'idevicescreenshot'
],
environment:
null
,
workingDirectory:
null
)
).
thenReturn
(
new
ProcessResult
(
3
,
0
,
fs
.
path
.
join
(
'some'
,
'path'
,
'to'
,
'iscreenshot'
),
''
)
);
iosDeviceUnderTest
=
new
IOSDevice
(
'1234'
);
await
iosDeviceUnderTest
.
takeScreenshot
(
mockOutputFile
);
verify
(
mockProcessManager
.
runSync
(
<
String
>[
'which'
,
'idevicescreenshot'
],
environment:
null
,
workingDirectory:
null
));
verify
(
mockProcessManager
.
run
(
<
String
>[
fs
.
path
.
join
(
'some'
,
'path'
,
'to'
,
'iscreenshot'
),
fs
.
path
.
join
(
'some'
,
'test'
,
'path'
,
'image.png'
)
],
environment:
null
,
workingDirectory:
null
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
}
);
iosDeviceUnderTest
=
new
IOSDevice
(
'1234'
);
await
iosDeviceUnderTest
.
takeScreenshot
(
mockOutputFile
);
verify
(
mockProcessManager
.
runSync
(
<
String
>[
'which'
,
'idevicescreenshot'
],
environment:
null
,
workingDirectory:
null
));
verify
(
mockProcessManager
.
run
(
<
String
>[
fs
.
path
.
join
(
'some'
,
'path'
,
'to'
,
'iscreenshot'
),
fs
.
path
.
join
(
'some'
,
'test'
,
'path'
,
'image.png'
)
],
environment:
null
,
workingDirectory:
null
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
});
});
}
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