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
d7b0f7db
Commit
d7b0f7db
authored
Feb 17, 2017
by
xster
Committed by
GitHub
Feb 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support iOS screenshot 1/2 (#8210)
* Support iOS screenshot 1/3 * Use path.join * use fs.path instead
parent
0736fac4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
20 deletions
+118
-20
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+17
-17
devices_test.dart
packages/flutter_tools/test/src/ios/devices_test.dart
+97
-0
simulators_test.dart
packages/flutter_tools/test/src/ios/simulators_test.dart
+4
-3
No files found.
packages/flutter_tools/lib/src/ios/devices.dart
View file @
d7b0f7db
...
...
@@ -44,6 +44,7 @@ class IOSDevice extends Device {
_iproxyPath
=
_checkForCommand
(
'iproxy'
);
_debuggerPath
=
_checkForCommand
(
'idevicedebug'
);
_loggerPath
=
_checkForCommand
(
'idevicesyslog'
);
_screenshotPath
=
_checkForCommand
(
'idevicescreenshot'
);
_pusherPath
=
_checkForCommand
(
'ios-deploy'
,
'To copy files to iOS devices, please install ios-deploy. '
...
...
@@ -70,6 +71,9 @@ class IOSDevice extends Device {
String
_loggerPath
;
String
get
loggerPath
=>
_loggerPath
;
String
_screenshotPath
;
String
get
screenshotPath
=>
_screenshotPath
;
String
_pusherPath
;
String
get
pusherPath
=>
_pusherPath
;
...
...
@@ -118,12 +122,10 @@ class IOSDevice extends Device {
return
runSync
(<
String
>[
informerPath
,
'-k'
,
infoKey
,
'-u'
,
deviceID
]).
trim
();
}
static
final
Map
<
String
,
String
>
_commandMap
=
<
String
,
String
>{};
static
String
_checkForCommand
(
String
command
,
[
String
macInstructions
=
_ideviceinstallerInstructions
])
{
return
_commandMap
.
putIfAbsent
(
command
,
()
{
try
{
command
=
runCheckedSync
(<
String
>[
'which'
,
command
]).
trim
();
}
catch
(
e
)
{
...
...
@@ -132,9 +134,9 @@ class IOSDevice extends Device {
}
else
{
printError
(
'Cannot control iOS devices or simulators.
$command
is not available on your platform.'
);
}
return
null
;
}
return
command
;
});
}
@override
...
...
@@ -364,14 +366,12 @@ class IOSDevice extends Device {
}
@override
bool
get
supportsScreenshot
=>
false
;
bool
get
supportsScreenshot
=>
screenshotPath
!=
null
&&
screenshotPath
.
isNotEmpty
;
@override
Future
<
Null
>
takeScreenshot
(
File
outputFile
)
{
// We could use idevicescreenshot here (installed along with the brew
// ideviceinstaller tools). It however requires a developer disk image on
// the device.
return
new
Future
<
Null
>.
error
(
'Taking screenshots is not supported on iOS devices. Consider using a simulator instead.'
);
runCheckedSync
(<
String
>[
screenshotPath
,
outputFile
.
path
]);
return
new
Future
<
Null
>.
value
();
}
}
...
...
packages/flutter_tools/test/src/ios/devices_test.dart
0 → 100644
View file @
d7b0f7db
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:io'
show
ProcessResult
;
import
'package:file/file.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/ios/devices.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'package:test/test.dart'
;
import
'../context.dart'
;
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockFile
extends
Mock
implements
File
{}
void
main
(
)
{
group
(
'test screenshot'
,
()
{
MockProcessManager
mockProcessManager
;
MockFile
mockOutputFile
;
IOSDevice
iosDeviceUnderTest
;
setUp
(()
{
mockProcessManager
=
new
MockProcessManager
();
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
.
runSync
(
any
,
environment:
null
,
workingDirectory:
null
)
).
thenReturn
(
new
ProcessResult
(
2
,
0
,
''
,
null
)
);
// Let `which idevicescreenshot` fail with exit code 1.
when
(
mockProcessManager
.
runSync
(
<
String
>[
'which'
,
'idevicescreenshot'
],
environment:
null
,
workingDirectory:
null
)
).
thenReturn
(
new
ProcessResult
(
1
,
1
,
''
,
null
)
);
iosDeviceUnderTest
=
new
IOSDevice
(
'1234'
);
iosDeviceUnderTest
.
takeScreenshot
(
mockOutputFile
);
verify
(
mockProcessManager
.
runSync
(
<
String
>[
'which'
,
'idevicescreenshot'
],
environment:
null
,
workingDirectory:
null
));
verifyNever
(
mockProcessManager
.
runSync
(
<
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
}
);
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
.
runSync
(
any
,
environment:
null
,
workingDirectory:
null
)
).
thenReturn
(
new
ProcessResult
(
4
,
0
,
''
,
null
)
);
// 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'
),
null
)
);
iosDeviceUnderTest
=
new
IOSDevice
(
'1234'
);
iosDeviceUnderTest
.
takeScreenshot
(
mockOutputFile
);
verify
(
mockProcessManager
.
runSync
(
<
String
>[
'which'
,
'idevicescreenshot'
],
environment:
null
,
workingDirectory:
null
));
verify
(
mockProcessManager
.
runSync
(
<
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
}
);
});
}
packages/flutter_tools/test/src/ios/simulators_test.dart
View file @
d7b0f7db
import
'dart:io'
show
ProcessResult
;
import
'package:file/file.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/ios/mac.dart'
;
import
'package:flutter_tools/src/ios/simulators.dart'
;
import
'package:mockito/mockito.dart'
;
...
...
@@ -122,7 +123,7 @@ void main() {
when
(
mockXcode
.
xcodeMinorVersion
).
thenReturn
(
1
);
expect
(
deviceUnderTest
.
supportsScreenshot
,
false
);
},
overrides:
<
Type
,
Generator
>{
Xcode:
()
=>
mockXcode
}
overrides:
<
Type
,
Generator
>{
Xcode:
()
=>
mockXcode
}
);
testUsingContext
(
...
...
@@ -132,7 +133,7 @@ void main() {
when
(
mockXcode
.
xcodeMinorVersion
).
thenReturn
(
2
);
expect
(
deviceUnderTest
.
supportsScreenshot
,
true
);
MockFile
mockFile
=
new
MockFile
();
when
(
mockFile
.
path
).
thenReturn
(
'/some/path/to/screenshot.png'
);
when
(
mockFile
.
path
).
thenReturn
(
fs
.
path
.
join
(
'some'
,
'path'
,
'to'
,
'screenshot.png'
)
);
deviceUnderTest
.
takeScreenshot
(
mockFile
);
verify
(
mockProcessManager
.
runSync
(
<
String
>[
...
...
@@ -141,7 +142,7 @@ void main() {
'io'
,
'booted'
,
'screenshot'
,
'/some/path/to/screenshot.png'
fs
.
path
.
join
(
'some'
,
'path'
,
'to'
,
'screenshot.png'
),
],
environment:
null
,
workingDirectory:
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