kracker 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/kracker.gemspec +1 -0
- data/lib/kracker/analysis.rb +8 -3
- data/lib/kracker/kracker.rb +9 -0
- data/lib/kracker/version.rb +1 -1
- data/lib/kracker/zooka/analyzer.rb +157 -0
- data/lib/kracker/zooka/error_pixel_transform.rb +32 -0
- data/lib/kracker/zooka/image.rb +70 -0
- data/lib/kracker/zooka/pixel.rb +50 -0
- data/lib/kracker/zooka/tolerance.rb +36 -0
- data/lib/kracker.rb +6 -0
- data/test/selenium/mapping_test.rb +23 -3
- data/test/selenium/zooka_test.rb +64 -0
- data/test/selenium_test_helper.rb +48 -1
- data/test/test_helper.rb +3 -1
- data/test/test_objects/test_objects.rb +1138 -0
- data/test/unit/analysis_test.rb +13 -0
- data/test/unit/analyzer_test.rb +153 -0
- metadata +26 -3
data/test/unit/analysis_test.rb
CHANGED
@@ -95,4 +95,17 @@ class AnalysisTest < Kracker::KrackerTestCase
|
|
95
95
|
assert analysis[:same], 'results of data analysis.same'
|
96
96
|
end
|
97
97
|
|
98
|
+
def test_huge_another_list_of_similarly_named_elements
|
99
|
+
master_data = travis_local_generated_master_2
|
100
|
+
current_data = travis_generated_current_2
|
101
|
+
|
102
|
+
analysis = analyze(master_data, current_data)
|
103
|
+
|
104
|
+
## real difference that was found on travis with the INPUT tags being different styles/sizes if not css-styled
|
105
|
+
assert_equal 0, analysis[:not_in_master].count, 'results of data analysis: not_in_master'
|
106
|
+
assert_equal 0, analysis[:not_in_current].count, 'results of data analysis: not_in_current'
|
107
|
+
assert_equal 1, analysis[:changed_element_pairs].count, 'changed element pairs'
|
108
|
+
refute analysis[:same], 'results of data analysis.same'
|
109
|
+
end
|
110
|
+
|
98
111
|
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class AnalyzerTest < Kracker::KrackerTestCase
|
4
|
+
require 'chunky_png'
|
5
|
+
|
6
|
+
def test_analyzer_initialization
|
7
|
+
prep_locations_for_test
|
8
|
+
filename_1 = make_zooka_filename('zooka_1')
|
9
|
+
filename_2 = make_zooka_filename('zooka_2')
|
10
|
+
img1 = ChunkyPNG::Image.new(10, 10, ChunkyPNG::Color::rgb(0, 0, 255))
|
11
|
+
img2 = img1.dup
|
12
|
+
img1.save(filename_1)
|
13
|
+
img2.save(filename_2)
|
14
|
+
|
15
|
+
analyzer = Kracker::Zooka::Analyzer.new
|
16
|
+
assert analyzer.is_a?(Kracker::Zooka::Analyzer)
|
17
|
+
assert_nil analyzer.image_1
|
18
|
+
assert_nil analyzer.image_2
|
19
|
+
analyzer.image_1 = img1
|
20
|
+
analyzer.image_2 = img2
|
21
|
+
assert analyzer.image_1.is_a?(ChunkyPNG::Image)
|
22
|
+
assert analyzer.image_2.is_a?(ChunkyPNG::Image)
|
23
|
+
|
24
|
+
analyzer = Kracker::Zooka::Analyzer.new({ :image_1 => img1, :image_2 => img2 })
|
25
|
+
assert analyzer.is_a?(Kracker::Zooka::Analyzer)
|
26
|
+
assert analyzer.image_1.is_a?(ChunkyPNG::Image)
|
27
|
+
assert analyzer.image_2.is_a?(ChunkyPNG::Image)
|
28
|
+
|
29
|
+
analyzer = Kracker::Zooka::Analyzer.new({ :filename_1 => filename_1, :filename_2 => filename_2 })
|
30
|
+
assert analyzer.is_a?(Kracker::Zooka::Analyzer)
|
31
|
+
assert analyzer.image_1.is_a?(ChunkyPNG::Image)
|
32
|
+
assert analyzer.image_2.is_a?(ChunkyPNG::Image)
|
33
|
+
|
34
|
+
analyzer = Kracker::Zooka::Analyzer.new({ :image_1 => img1, :filename_2 => filename_2 })
|
35
|
+
assert analyzer.is_a?(Kracker::Zooka::Analyzer)
|
36
|
+
assert analyzer.image_1.is_a?(ChunkyPNG::Image)
|
37
|
+
assert analyzer.image_2.is_a?(ChunkyPNG::Image)
|
38
|
+
|
39
|
+
remove_old_zooka_files
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_similar_color
|
43
|
+
analyzer = Kracker::Zooka::Analyzer.new
|
44
|
+
|
45
|
+
assert analyzer.send(:color_similar?, 1, 1, 'red')
|
46
|
+
assert analyzer.send(:color_similar?, 1, 16, 'red')
|
47
|
+
refute analyzer.send(:color_similar?, 1, 17, 'red')
|
48
|
+
|
49
|
+
refute analyzer.send(:color_similar?, 1, 2, 'no_color')
|
50
|
+
|
51
|
+
analyzer.tolerance.red = 2
|
52
|
+
assert analyzer.send(:color_similar?, 1, 1, 'red')
|
53
|
+
assert analyzer.send(:color_similar?, 1, 2, 'red')
|
54
|
+
refute analyzer.send(:color_similar?, 1, 3, 'red')
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_similar_brightness
|
58
|
+
analyzer = Kracker::Zooka::Analyzer.new
|
59
|
+
analyzer.tolerance.red = 2
|
60
|
+
|
61
|
+
pixel1 = Kracker::Zooka::Pixel.new(0)
|
62
|
+
pixel2 = Kracker::Zooka::Pixel.new(0)
|
63
|
+
|
64
|
+
assert analyzer.send(:brightness_similar?, pixel1, pixel2)
|
65
|
+
|
66
|
+
pixel1.alpha = 1
|
67
|
+
pixel1.red = 1
|
68
|
+
|
69
|
+
pixel2.alpha = 10
|
70
|
+
pixel2.red = 3
|
71
|
+
|
72
|
+
assert analyzer.send(:brightness_similar?, pixel1, pixel2)
|
73
|
+
refute analyzer.send(:color_similar?, pixel1.red, pixel2.red, 'red')
|
74
|
+
|
75
|
+
pixel2.red = 100
|
76
|
+
refute analyzer.send(:brightness_similar?, pixel1, pixel2)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_hue
|
80
|
+
hue_data = [
|
81
|
+
[ 9, 135, 209, 0.5616 ], #r:9 g:135 b:209 h:0.5616666666666666 - blue is greatest
|
82
|
+
[ 106, 186, 221, 0.5507 ], #r:106 g:186 b:221 h:0.5507246376811594 - blue is greatest
|
83
|
+
[ 106, 221, 186, 0.4492 ], #r:106 g:221 b:186 h:0.4492753623188406 - green is greatest
|
84
|
+
[ 225, 254, 100, 0.1980 ], #r:225 g:254 b:100 h:0.19805194805194806 - green is greatest
|
85
|
+
[ 21, 16, 13, 0.0625 ], #r:21 g:16 b:13 h:0.0625 - red is greatest
|
86
|
+
[ 17, 16, 11, 0.1388 ] #r:17 g:16 b:11 h:0.1388888888888889 - red is greatest
|
87
|
+
]
|
88
|
+
|
89
|
+
hue_data.each do |hue_data_set|
|
90
|
+
pixel1 = Kracker::Zooka::Pixel.new(ChunkyPNG::Color.rgba(hue_data_set[0], hue_data_set[1], hue_data_set[2], 128))
|
91
|
+
assert_in_delta hue_data_set[3], pixel1.hue, 0.0001, "hue calcuation for r: #{hue_data_set[0]}, g: #{hue_data_set[1]}, b: #{hue_data_set[2]}"
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_analyze
|
97
|
+
prep_locations_for_test
|
98
|
+
|
99
|
+
filename_1 = make_zooka_filename('zooka_1')
|
100
|
+
filename_2 = make_zooka_filename('zooka_2')
|
101
|
+
result_filename_standard = make_zooka_filename('results_standard')
|
102
|
+
result_file_ignore_colors = make_zooka_filename('result_ignore_colors')
|
103
|
+
result_file_ignore_anitaliasing = make_zooka_filename('result_ignore_antialiasing')
|
104
|
+
|
105
|
+
img1 = ChunkyPNG::Image.new(10, 10, ChunkyPNG::Color::rgb(0, 0, 255))
|
106
|
+
img2 = img1.dup
|
107
|
+
img2.width.times { |w| img2[w, w] = ChunkyPNG::Color::rgb(255 / (w+ 1), 0, 0) }
|
108
|
+
img2.width.times { |w| img2[w, img2.width - w - 1] = ChunkyPNG::Color::rgb(0, 255 / (w+ 1), 0) }
|
109
|
+
img1.save(filename_1)
|
110
|
+
img2.save(filename_2)
|
111
|
+
|
112
|
+
analyzer = Kracker::Zooka::Analyzer.new({ :image_1 => img1, :image_2 => img2 })
|
113
|
+
analyzer.analyze
|
114
|
+
result_image = analyzer.result
|
115
|
+
pixels = analyzer.noncompliant_pixels
|
116
|
+
|
117
|
+
result_image.save(result_filename_standard)
|
118
|
+
|
119
|
+
assert_equal 20, pixels.length
|
120
|
+
|
121
|
+
analyzer.ignore_colors = true
|
122
|
+
analyzer.analyze
|
123
|
+
pixels = analyzer.noncompliant_pixels
|
124
|
+
result_image = analyzer.result
|
125
|
+
result_image.save(result_file_ignore_colors)
|
126
|
+
|
127
|
+
assert_equal 8, pixels.length
|
128
|
+
|
129
|
+
analyzer.ignore_colors = false
|
130
|
+
analyzer.ignore_antialiasing = true
|
131
|
+
analyzer.analyze
|
132
|
+
pixels = analyzer.noncompliant_pixels
|
133
|
+
assert_equal 9, pixels.length
|
134
|
+
result_image = analyzer.result
|
135
|
+
result_image.save(result_file_ignore_anitaliasing)
|
136
|
+
assert result_image.is_a?(ChunkyPNG::Image)
|
137
|
+
|
138
|
+
remove_old_zooka_files
|
139
|
+
end
|
140
|
+
|
141
|
+
private
|
142
|
+
|
143
|
+
def make_zooka_filename(base_name)
|
144
|
+
Kracker.current_filename(base_name).gsub('yaml', 'png')
|
145
|
+
end
|
146
|
+
|
147
|
+
def remove_old_zooka_files
|
148
|
+
Dir[File.join(Kracker::current_file_location, '*.png')].each { |f| FileUtils.rm_rf f }
|
149
|
+
Dir[File.join(Kracker::master_file_location, '*.png')].each { |f| FileUtils.rm_rf f }
|
150
|
+
Dir[File.join(Kracker::diff_file_location, '*.png')].each { |f| FileUtils.rm_rf f }
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- geordie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: chunky_png
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: DOM Mapping
|
70
84
|
email:
|
71
85
|
- george.speake@gmail.com
|
@@ -107,6 +121,11 @@ files:
|
|
107
121
|
- lib/kracker/rails/engine.rb
|
108
122
|
- lib/kracker/svg.rb
|
109
123
|
- lib/kracker/version.rb
|
124
|
+
- lib/kracker/zooka/analyzer.rb
|
125
|
+
- lib/kracker/zooka/error_pixel_transform.rb
|
126
|
+
- lib/kracker/zooka/image.rb
|
127
|
+
- lib/kracker/zooka/pixel.rb
|
128
|
+
- lib/kracker/zooka/tolerance.rb
|
110
129
|
- test/page_objects.rb
|
111
130
|
- test/page_objects/kracker/about_page.rb
|
112
131
|
- test/page_objects/kracker/artifacts_page.rb
|
@@ -119,6 +138,7 @@ files:
|
|
119
138
|
- test/page_objects/navigation.rb
|
120
139
|
- test/selenium/mapping_test.rb
|
121
140
|
- test/selenium/viewer_test.rb
|
141
|
+
- test/selenium/zooka_test.rb
|
122
142
|
- test/selenium_test_helper.rb
|
123
143
|
- test/test_app/Gemfile
|
124
144
|
- test/test_app/app/assets/stylesheets/local_app.css
|
@@ -136,6 +156,7 @@ files:
|
|
136
156
|
- test/test_helpers/location_helpers.rb
|
137
157
|
- test/test_objects/test_objects.rb
|
138
158
|
- test/unit/analysis_test.rb
|
159
|
+
- test/unit/analyzer_test.rb
|
139
160
|
- test/unit/element_test.rb
|
140
161
|
- test/unit/kracker_test.rb
|
141
162
|
- test/unit/location_test.rb
|
@@ -160,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
181
|
version: '0'
|
161
182
|
requirements: []
|
162
183
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.
|
184
|
+
rubygems_version: 2.2.2
|
164
185
|
signing_key:
|
165
186
|
specification_version: 4
|
166
187
|
summary: Map the page DOM and get some stats on it compared to a known default map.
|
@@ -177,6 +198,7 @@ test_files:
|
|
177
198
|
- test/page_objects/navigation.rb
|
178
199
|
- test/selenium/mapping_test.rb
|
179
200
|
- test/selenium/viewer_test.rb
|
201
|
+
- test/selenium/zooka_test.rb
|
180
202
|
- test/selenium_test_helper.rb
|
181
203
|
- test/test_app/Gemfile
|
182
204
|
- test/test_app/app/assets/stylesheets/local_app.css
|
@@ -194,6 +216,7 @@ test_files:
|
|
194
216
|
- test/test_helpers/location_helpers.rb
|
195
217
|
- test/test_objects/test_objects.rb
|
196
218
|
- test/unit/analysis_test.rb
|
219
|
+
- test/unit/analyzer_test.rb
|
197
220
|
- test/unit/element_test.rb
|
198
221
|
- test/unit/kracker_test.rb
|
199
222
|
- test/unit/location_test.rb
|