snapshot 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/assets/SnapfileTemplate +2 -1
- data/lib/assets/SnapshotHelper.swift +19 -5
- data/lib/snapshot.rb +1 -0
- data/lib/snapshot/fixes/hardware_keyboard_fix.rb +16 -0
- data/lib/snapshot/fixes/simulator_zoom_fix.rb +2 -5
- data/lib/snapshot/runner.rb +19 -8
- data/lib/snapshot/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 240336d6be66f93dcf5fb8f86d0b22c02b8cf430
|
4
|
+
data.tar.gz: c3474a9d370b0d30621dadb856aed9aea93db090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c08cc643de417f35674cc2ebf621afb8df57454556b0f0346e8895b8743347a16b31df40a0448f3682eb9f7fc82d705213346f0f352b6bd7605f11ff92851446
|
7
|
+
data.tar.gz: a4c00fc15adb4707dad1bcca1e1f6cab5a5f63f8be2ff82286e1ad37cb7388fd0a0f5974c3756be77bc37c945ee160a7da2dc684a77c83d02dbf31e396e0d74c
|
data/README.md
CHANGED
@@ -245,7 +245,8 @@ devices([
|
|
245
245
|
languages([
|
246
246
|
"en-US",
|
247
247
|
"de-DE",
|
248
|
-
"es-ES"
|
248
|
+
"es-ES",
|
249
|
+
["pt", "pt_BR"] # Portuguese with Brazilian locale
|
249
250
|
])
|
250
251
|
|
251
252
|
launch_arguments("-username Felix")
|
@@ -362,6 +363,8 @@ If you want to add frames around the screenshots and even put a title on top, ch
|
|
362
363
|
ALL_LANGUAGES = ["da", "de-DE", "el", "en-AU", "en-CA", "en-GB", "en-US", "es-ES", "es-MX", "fi", "fr-CA", "fr-FR", "id", "it", "ja", "ko", "ms", "nl", "no", "pt-BR", "pt-PT", "ru", "sv", "th", "tr", "vi", "zh-Hans", "zh-Hant"]
|
363
364
|
```
|
364
365
|
|
366
|
+
To get more information about language and locale codes please read [Internationalization and Localization Guide](https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/LanguageandLocaleIDs/LanguageandLocaleIDs.html).
|
367
|
+
|
365
368
|
## Use a clean status bar
|
366
369
|
You can use [SimulatorStatusMagic](https://github.com/shinydevelopment/SimulatorStatusMagic) to clean up the status bar.
|
367
370
|
|
data/lib/assets/SnapfileTemplate
CHANGED
@@ -29,6 +29,7 @@ class Snapshot: NSObject {
|
|
29
29
|
|
30
30
|
class func setupSnapshot(app: XCUIApplication) {
|
31
31
|
setLanguage(app)
|
32
|
+
setLocale(app)
|
32
33
|
setLaunchArguments(app)
|
33
34
|
}
|
34
35
|
|
@@ -36,18 +37,31 @@ class Snapshot: NSObject {
|
|
36
37
|
let path = "/tmp/language.txt"
|
37
38
|
|
38
39
|
do {
|
39
|
-
|
40
|
-
|
41
|
-
app.launchArguments += ["-AppleLanguages", "(\(deviceLanguage))", "-AppleLocale", "\"\(locale)\"", "-ui_testing"]
|
40
|
+
deviceLanguage = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String
|
41
|
+
app.launchArguments += ["-AppleLanguages", "(\(deviceLanguage))"]
|
42
42
|
} catch {
|
43
43
|
print("Couldn't detect/set language...")
|
44
44
|
}
|
45
45
|
}
|
46
46
|
|
47
|
+
class func setLocale(app: XCUIApplication) {
|
48
|
+
let path = "tmp/locale.txt"
|
49
|
+
|
50
|
+
do {
|
51
|
+
locale = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String
|
52
|
+
} catch {
|
53
|
+
print("Couldn't detect/set locale...")
|
54
|
+
}
|
55
|
+
if locale.isEmpty {
|
56
|
+
locale = NSLocale(localeIdentifier: deviceLanguage).localeIdentifier
|
57
|
+
}
|
58
|
+
app.launchArguments += ["-AppleLocale", "\"\(locale)\""]
|
59
|
+
}
|
60
|
+
|
47
61
|
class func setLaunchArguments(app: XCUIApplication) {
|
48
62
|
let path = "/tmp/snapshot-launch_arguments.txt"
|
49
63
|
|
50
|
-
app.launchArguments += ["-FASTLANE_SNAPSHOT", "YES"]
|
64
|
+
app.launchArguments += ["-FASTLANE_SNAPSHOT", "YES", "-ui_testing"]
|
51
65
|
|
52
66
|
do {
|
53
67
|
let launchArguments = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String
|
@@ -91,4 +105,4 @@ extension XCUIElement {
|
|
91
105
|
|
92
106
|
// Please don't remove the lines below
|
93
107
|
// They are used to detect outdated configuration files
|
94
|
-
// SnapshotHelperVersion [
|
108
|
+
// SnapshotHelperVersion [1.1]
|
data/lib/snapshot.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Snapshot
|
2
|
+
module Fixes
|
3
|
+
# Having "Connect Hardware Keyboard" enabled causes issues with entering text in secure textfields
|
4
|
+
# Fixes https://github.com/fastlane/snapshot/issues/433
|
5
|
+
|
6
|
+
class HardwareKeyboardFix
|
7
|
+
def self.patch
|
8
|
+
Snapshot.kill_simulator # First we need to kill the simulator
|
9
|
+
|
10
|
+
UI.verbose "Patching simulator to work with secure text fields"
|
11
|
+
|
12
|
+
Helper.backticks("defaults write com.apple.iphonesimulator ConnectHardwareKeyboard 0", print: $verbose)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -7,8 +7,7 @@ module Snapshot
|
|
7
7
|
|
8
8
|
class SimulatorZoomFix
|
9
9
|
def self.patch
|
10
|
-
# First we need to kill the simulator
|
11
|
-
Snapshot.kill_simulator
|
10
|
+
Snapshot.kill_simulator # First we need to kill the simulator
|
12
11
|
|
13
12
|
UI.message "Patching '#{config_path}' to scale simulator to 100%"
|
14
13
|
|
@@ -16,9 +15,7 @@ module Snapshot
|
|
16
15
|
simulator_name = simulator.name.tr("\s", "-")
|
17
16
|
key = "SimulatorWindowLastScale-com.apple.CoreSimulator.SimDeviceType.#{simulator_name}"
|
18
17
|
|
19
|
-
|
20
|
-
puts command.yellow if $debug
|
21
|
-
`#{command}`
|
18
|
+
Helper.backticks("defaults write '#{config_path}' '#{key}' '1.0'", print: $verbose)
|
22
19
|
end
|
23
20
|
end
|
24
21
|
|
data/lib/snapshot/runner.rb
CHANGED
@@ -35,9 +35,14 @@ module Snapshot
|
|
35
35
|
Snapshot.config[:devices].each do |device|
|
36
36
|
launch_arguments_set.each do |launch_arguments|
|
37
37
|
Snapshot.config[:languages].each do |language|
|
38
|
+
locale = nil
|
39
|
+
if language.kind_of?(Array)
|
40
|
+
locale = language[1]
|
41
|
+
language = language[0]
|
42
|
+
end
|
38
43
|
results[device] ||= {}
|
39
44
|
|
40
|
-
results[device][language] = run_for_device_and_language(language, device, launch_arguments)
|
45
|
+
results[device][language] = run_for_device_and_language(language, locale, device, launch_arguments)
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
@@ -55,14 +60,14 @@ module Snapshot
|
|
55
60
|
|
56
61
|
# This is its own method so that it can re-try if the tests fail randomly
|
57
62
|
# @return true/false depending on if the tests succeded
|
58
|
-
def run_for_device_and_language(language, device, launch_arguments, retries = 0)
|
59
|
-
return launch(language, device, launch_arguments)
|
63
|
+
def run_for_device_and_language(language, locale, device, launch_arguments, retries = 0)
|
64
|
+
return launch(language, locale, device, launch_arguments)
|
60
65
|
rescue => ex
|
61
66
|
UI.error ex.to_s # show the reason for failure to the user, but still maybe retry
|
62
67
|
|
63
68
|
if retries < Snapshot.config[:number_of_retries]
|
64
69
|
UI.important "Tests failed, re-trying #{retries + 1} out of #{Snapshot.config[:number_of_retries] + 1} times"
|
65
|
-
run_for_device_and_language(language, device, launch_arguments, retries + 1)
|
70
|
+
run_for_device_and_language(language, locale, device, launch_arguments, retries + 1)
|
66
71
|
else
|
67
72
|
UI.error "Backtrace:\n\t#{ex.backtrace.join("\n\t")}" if $verbose
|
68
73
|
self.collected_errors << ex
|
@@ -104,16 +109,18 @@ module Snapshot
|
|
104
109
|
end
|
105
110
|
|
106
111
|
# Returns true if it succeded
|
107
|
-
def launch(language, device_type, launch_arguments)
|
112
|
+
def launch(language, locale, device_type, launch_arguments)
|
108
113
|
screenshots_path = TestCommandGenerator.derived_data_path
|
109
114
|
FileUtils.rm_rf(File.join(screenshots_path, "Logs"))
|
110
115
|
FileUtils.rm_rf(screenshots_path) if Snapshot.config[:clean]
|
111
116
|
FileUtils.mkdir_p(screenshots_path)
|
112
117
|
|
113
118
|
File.write("/tmp/language.txt", language)
|
119
|
+
File.write("/tmp/locale.txt", locale || "")
|
114
120
|
File.write("/tmp/snapshot-launch_arguments.txt", launch_arguments.last)
|
115
121
|
|
116
122
|
Fixes::SimulatorZoomFix.patch
|
123
|
+
Fixes::HardwareKeyboardFix.patch
|
117
124
|
|
118
125
|
Snapshot.kill_simulator # because of https://github.com/fastlane/snapshot/issues/337
|
119
126
|
`xcrun simctl shutdown booted &> /dev/null`
|
@@ -130,7 +137,11 @@ module Snapshot
|
|
130
137
|
|
131
138
|
command = TestCommandGenerator.generate(device_type: device_type)
|
132
139
|
|
133
|
-
|
140
|
+
if locale
|
141
|
+
UI.header("#{device_type} - #{language} (#{locale})")
|
142
|
+
else
|
143
|
+
UI.header("#{device_type} - #{language}")
|
144
|
+
end
|
134
145
|
|
135
146
|
prefix_hash = [
|
136
147
|
{
|
@@ -154,7 +165,7 @@ module Snapshot
|
|
154
165
|
|
155
166
|
self.number_of_retries_due_to_failing_simulator += 1
|
156
167
|
if self.number_of_retries_due_to_failing_simulator < 20
|
157
|
-
launch(language, device_type, launch_arguments)
|
168
|
+
launch(language, locale, device_type, launch_arguments)
|
158
169
|
else
|
159
170
|
# It's important to raise an error, as we don't want to collect the screenshots
|
160
171
|
UI.crash!("Too many errors... no more retries...")
|
@@ -215,7 +226,7 @@ module Snapshot
|
|
215
226
|
helper_files.each do |path|
|
216
227
|
content = File.read(path)
|
217
228
|
|
218
|
-
|
229
|
+
unless content.include?("SnapshotHelperVersion [1.1]")
|
219
230
|
UI.error "Your '#{path}' is outdated, please run `snapshot update`"
|
220
231
|
UI.error "to update your Helper file"
|
221
232
|
UI.user_error!("Please update your Snapshot Helper file")
|
data/lib/snapshot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Krause
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastimage
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- lib/snapshot/detect_values.rb
|
218
218
|
- lib/snapshot/error_handler.rb
|
219
219
|
- lib/snapshot/fixes/README.md
|
220
|
+
- lib/snapshot/fixes/hardware_keyboard_fix.rb
|
220
221
|
- lib/snapshot/fixes/simulator_zoom_fix.rb
|
221
222
|
- lib/snapshot/latest_ios_version.rb
|
222
223
|
- lib/snapshot/options.rb
|
@@ -250,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
251
|
version: '0'
|
251
252
|
requirements: []
|
252
253
|
rubyforge_project:
|
253
|
-
rubygems_version: 2.4.
|
254
|
+
rubygems_version: 2.4.6
|
254
255
|
signing_key:
|
255
256
|
specification_version: 4
|
256
257
|
summary: Automate taking localized screenshots of your iOS app on every device
|