snapshot 0.2.1.beta1 → 0.2.1
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 +3 -6
- data/lib/assets/SnapshotHelper.js +43 -0
- data/lib/assets/snapshot.js +13 -0
- data/lib/snapshot/runner.rb +30 -11
- data/lib/snapshot/snapfile_creator.rb +6 -5
- data/lib/snapshot/snapshot_config.rb +1 -1
- data/lib/snapshot/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9587bca312d28377307565bc943291fed8b44f5
|
4
|
+
data.tar.gz: 624c2a496b4c50820964d2626b20a61a413a4535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8ccb3fcc29be45f88c5ce7c9d8d2b61d8fa8c483c60226a2477c5991be56503d3e68b2d24fdd5d943ed41cf2413f992e7dca7b7e37164f42151b811f007691c
|
7
|
+
data.tar.gz: ef10c5745da09e21ccff13dfb420e8a31761949e314e379acd7147518563faffaf1355c256804e2b16ae887877c3bdadc43738a641500cd41c553564b57d725f
|
data/README.md
CHANGED
@@ -91,13 +91,10 @@ Here a few links to get started:
|
|
91
91
|
|
92
92
|
# Quick Start
|
93
93
|
|
94
|
-
|
95
|
-
|
94
|
+
- Run ```snapshot init``` in your project folder
|
96
95
|
- Profile your app (CMD + I), choose ```Automation``` and click the Record button on the bottom of the window.
|
97
|
-
- This will get you started.
|
98
|
-
-
|
99
|
-
- Add ```#import "SnapshotHelper.js"``` on the top of your newly created JS file.
|
100
|
-
- Now you can use ```captureLocalizedScreenshot('0-name')``` to take a snapshot.
|
96
|
+
- This will get you started. Copy the generated code into ```./snapshot.js```. Make sure, you leave the import statement on the top.
|
97
|
+
- To take a screenshot, use ```captureLocalizedScreenshot('0-name')```
|
101
98
|
|
102
99
|
You can take a look at the example project to play around with it.
|
103
100
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
function wait_for_loading_indicator_to_be_finished()
|
2
|
+
{
|
3
|
+
re = UIATarget.localTarget().frontMostApp().statusBar().elements()[2].rect()
|
4
|
+
while (re['size']['width'] == 10 && re['size']['height'] == 20) {
|
5
|
+
UIALogger.logMessage("Loading indicator is visible... waiting")
|
6
|
+
UIATarget.localTarget().delay(1)
|
7
|
+
re = UIATarget.localTarget().frontMostApp().statusBar().elements()[2].rect()
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
function captureLocalizedScreenshot(name) {
|
12
|
+
wait_for_loading_indicator_to_be_finished();
|
13
|
+
|
14
|
+
var target = UIATarget.localTarget();
|
15
|
+
var model = target.model();
|
16
|
+
var rect = target.rect();
|
17
|
+
|
18
|
+
if (model.match(/iPhone/))
|
19
|
+
{
|
20
|
+
if (rect.size.height > 667) {
|
21
|
+
model = "iPhone6Plus";
|
22
|
+
} else if (rect.size.height == 667) {
|
23
|
+
model = "iPhone6";
|
24
|
+
} else if (rect.size.height == 568){
|
25
|
+
model = "iPhone5";
|
26
|
+
} else {
|
27
|
+
model = "iPhone4";
|
28
|
+
}
|
29
|
+
}
|
30
|
+
else
|
31
|
+
{
|
32
|
+
model = "iOS-iPad";
|
33
|
+
}
|
34
|
+
|
35
|
+
var orientation = "portrait";
|
36
|
+
if (rect.size.height < rect.size.width) orientation = "landscape";
|
37
|
+
|
38
|
+
var result = target.host().performTaskWithPathArgumentsTimeout("/usr/bin/printenv" , ["SNAPSHOT_LANGUAGE"], 5);
|
39
|
+
var language = result.stdout.substring(0, result.stdout.length - 1);
|
40
|
+
|
41
|
+
var parts = [language, model, orientation, name];
|
42
|
+
target.captureScreenWithName(parts.join("-"));
|
43
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#import "SnapshotHelper.js"
|
2
|
+
|
3
|
+
var target = UIATarget.localTarget();
|
4
|
+
var app = target.frontMostApp();
|
5
|
+
var window = app.mainWindow();
|
6
|
+
|
7
|
+
|
8
|
+
target.delay(3)
|
9
|
+
captureLocalizedScreenshot("0-LandingScreen")
|
10
|
+
|
11
|
+
target.frontMostApp().tabBar().buttons()[1].tap();
|
12
|
+
target.delay(1)
|
13
|
+
captureLocalizedScreenshot("1-SecondScreen")
|
data/lib/snapshot/runner.rb
CHANGED
@@ -14,11 +14,12 @@ module Snapshot
|
|
14
14
|
Builder.new.build_app
|
15
15
|
|
16
16
|
counter = 0
|
17
|
+
errors = []
|
17
18
|
SnapshotConfig.shared_instance.devices.each do |device|
|
18
19
|
SnapshotConfig.shared_instance.languages.each do |language|
|
19
20
|
|
20
21
|
begin
|
21
|
-
run_tests(device, language)
|
22
|
+
errors.concat(run_tests(device, language))
|
22
23
|
counter += copy_screenshots(language)
|
23
24
|
rescue Exception => ex
|
24
25
|
Helper.log.error(ex)
|
@@ -27,9 +28,18 @@ module Snapshot
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
|
-
Helper.log.info "Successfully finished generating #{counter} screenshots.".green
|
31
|
-
Helper.log.info "Check it out here: #{SnapshotConfig.shared_instance.screenshots_path}".green
|
32
31
|
ReportsGenerator.new.generate
|
32
|
+
|
33
|
+
if errors.count > 0
|
34
|
+
Helper.log.error "-----------------------------------------------------------"
|
35
|
+
Helper.log.error errors.join(' - ').red
|
36
|
+
Helper.log.error "-----------------------------------------------------------"
|
37
|
+
raise "Finished generating #{counter} screenshots with #{errors.count} errors.".red
|
38
|
+
else
|
39
|
+
Helper.log.info "Successfully finished generating #{counter} screenshots.".green
|
40
|
+
end
|
41
|
+
|
42
|
+
Helper.log.info "Check it out here: #{SnapshotConfig.shared_instance.screenshots_path}".green
|
33
43
|
end
|
34
44
|
|
35
45
|
def clean_old_traces
|
@@ -50,16 +60,23 @@ module Snapshot
|
|
50
60
|
retry_run = false
|
51
61
|
|
52
62
|
lines = []
|
63
|
+
errors = []
|
53
64
|
PTY.spawn(command) do |stdin, stdout, pid|
|
54
65
|
stdin.each do |line|
|
55
66
|
lines << line
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
67
|
+
begin
|
68
|
+
result = parse_test_line(line)
|
69
|
+
|
70
|
+
case result
|
71
|
+
when :retry
|
72
|
+
retry_run = true
|
73
|
+
when :screenshot
|
74
|
+
Helper.log.info "Successfully took screenshot 📱"
|
75
|
+
end
|
76
|
+
rescue Exception => ex
|
77
|
+
Helper.log.error lines.join('')
|
78
|
+
Helper.log.error ex.to_s.red
|
79
|
+
errors << ex.to_s
|
63
80
|
end
|
64
81
|
end
|
65
82
|
end
|
@@ -67,8 +84,10 @@ module Snapshot
|
|
67
84
|
if retry_run
|
68
85
|
Helper.log.error "Instruments tool failed again. Re-trying..."
|
69
86
|
sleep 2 # We need enough sleep... that's an instruments bug
|
70
|
-
run_tests(device, language)
|
87
|
+
errors = run_tests(device, language)
|
71
88
|
end
|
89
|
+
|
90
|
+
return errors
|
72
91
|
end
|
73
92
|
|
74
93
|
def parse_test_line(line)
|
@@ -2,14 +2,15 @@ module Snapshot
|
|
2
2
|
class SnapfileCreator
|
3
3
|
# This method will take care of creating a Snapfile
|
4
4
|
def self.create(path)
|
5
|
-
|
5
|
+
snapfile_path = [path, 'Snapfile'].join("/")
|
6
6
|
|
7
|
-
raise "Snapfile already exists at path '#{
|
7
|
+
raise "Snapfile already exists at path '#{snapfile_path}'. Run 'snapshot' to use Snapshot.".red if File.exists?(snapfile_path)
|
8
8
|
|
9
|
-
|
10
|
-
File.write(path,
|
9
|
+
File.write(snapfile_path, File.read("#{gem_path}/lib/assets/SnapfileTemplate"))
|
10
|
+
File.write([path, 'snapshot.js'].join('/'), File.read("#{gem_path}/lib/assets/snapshot.js"))
|
11
|
+
File.write([path, 'SnapshotHelper.js'].join('/'), File.read("#{gem_path}/lib/assets/SnapshotHelper.js"))
|
11
12
|
|
12
|
-
puts "Successfully created new Snapfile at '#{
|
13
|
+
puts "Successfully created new Snapfile at '#{snapfile_path}'".green
|
13
14
|
end
|
14
15
|
|
15
16
|
private
|
@@ -41,7 +41,7 @@ module Snapshot
|
|
41
41
|
if path and File.exists?path
|
42
42
|
self.snapshot_file = SnapshotFile.new(path, self)
|
43
43
|
else
|
44
|
-
Helper.log.error "Could not find './Snapfile'. It is recommended to create a file into the current directory. Using the defaults now."
|
44
|
+
Helper.log.error "Could not find './Snapfile'. It is recommended to create a file using 'snapshot init' into the current directory. Using the defaults now."
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
data/lib/snapshot/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Krause
|
@@ -176,6 +176,8 @@ files:
|
|
176
176
|
- README.md
|
177
177
|
- bin/snapshot
|
178
178
|
- lib/assets/SnapfileTemplate
|
179
|
+
- lib/assets/SnapshotHelper.js
|
180
|
+
- lib/assets/snapshot.js
|
179
181
|
- lib/snapshot.rb
|
180
182
|
- lib/snapshot/builder.rb
|
181
183
|
- lib/snapshot/dependency_checker.rb
|
@@ -204,9 +206,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
206
|
version: 2.0.0
|
205
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
208
|
requirements:
|
207
|
-
- - "
|
209
|
+
- - ">="
|
208
210
|
- !ruby/object:Gem::Version
|
209
|
-
version:
|
211
|
+
version: '0'
|
210
212
|
requirements: []
|
211
213
|
rubyforge_project:
|
212
214
|
rubygems_version: 2.2.2
|