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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c1cb159338beb8967f7503b11f5a681521b40fd
4
- data.tar.gz: 37d155a06363fe901d234027b6407b3a18eda291
3
+ metadata.gz: 240336d6be66f93dcf5fb8f86d0b22c02b8cf430
4
+ data.tar.gz: c3474a9d370b0d30621dadb856aed9aea93db090
5
5
  SHA512:
6
- metadata.gz: ccee926d0e221f8499e2fd7ea0b7a966fc8fd5386927f7ba08125495b7e0ff3e464e2222882f7dde62fe4ee468c6d558804eb4d2505d23e1369000d6b915d0c2
7
- data.tar.gz: fc7df18a95b939451ecea39cffaf7805f8403b0e0807b0425cc50381edafd2e90fc88b48ed15952d12fad4da759038219e8228b68b225970396cd84bfeededeb
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
 
@@ -13,7 +13,8 @@
13
13
  languages([
14
14
  "en-US",
15
15
  "de-DE",
16
- "it-IT"
16
+ "it-IT",
17
+ ["pt", "pt_BR"] # Portuguese with Brazilian locale
17
18
  ])
18
19
 
19
20
  # Arguments to pass to the app on launch. See https://github.com/fastlane/snapshot#launch-arguments
@@ -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
- locale = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String
40
- deviceLanguage = locale.substringToIndex(locale.startIndex.advancedBy(2, limit:locale.endIndex))
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 [[1.0]]
108
+ // SnapshotHelperVersion [1.1]
data/lib/snapshot.rb CHANGED
@@ -12,6 +12,7 @@ require 'snapshot/collector'
12
12
  require 'snapshot/options'
13
13
  require 'snapshot/update'
14
14
  require 'snapshot/fixes/simulator_zoom_fix'
15
+ require 'snapshot/fixes/hardware_keyboard_fix'
15
16
 
16
17
  require 'fastlane_core'
17
18
 
@@ -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
- command = "defaults write '#{config_path}' '#{key}' '1.0'"
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
 
@@ -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
- UI.header("#{device_type} - #{language}")
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
- if content.include?("start.pressForDuration(0, thenDragToCoordinate: finish)")
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")
@@ -1,4 +1,4 @@
1
1
  module Snapshot
2
- VERSION = "1.8.0"
2
+ VERSION = "1.9.0"
3
3
  DESCRIPTION = "Automate taking localized screenshots of your iOS app on every device"
4
4
  end
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.8.0
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-19 00:00:00.000000000 Z
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.0
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