percy-appium-app 0.0.1 → 0.0.2
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/percy/environment.rb +15 -13
- data/percy/exceptions/exceptions.rb +0 -2
- data/percy/lib/app_percy.rb +36 -34
- data/percy/lib/cache.rb +42 -41
- data/percy/lib/cli_wrapper.rb +94 -92
- data/percy/lib/ignore_region.rb +4 -3
- data/percy/lib/percy_automate.rb +44 -42
- data/percy/lib/percy_options.rb +30 -28
- data/percy/lib/region.rb +15 -13
- data/percy/lib/tile.rb +24 -22
- data/percy/metadata/android_metadata.rb +60 -58
- data/percy/metadata/driver_metadata.rb +29 -27
- data/percy/metadata/ios_metadata.rb +64 -62
- data/percy/metadata/metadata.rb +80 -78
- data/percy/metadata/metadata_resolver.rb +14 -12
- data/percy/{screenshot.rb → percy-appium-app.rb} +3 -3
- data/percy/providers/app_automate.rb +131 -129
- data/percy/providers/generic_provider.rb +166 -164
- data/percy/providers/provider_resolver.rb +9 -7
- data/percy/version.rb +1 -1
- data/percy-appium-app.gemspec +1 -0
- data/specs/android_metadata.rb +2 -4
- data/specs/app_automate.rb +10 -13
- data/specs/app_percy.rb +20 -22
- data/specs/cache.rb +16 -16
- data/specs/cli_wrapper.rb +6 -8
- data/specs/driver_metadata.rb +2 -4
- data/specs/generic_providers.rb +9 -12
- data/specs/ignore_regions.rb +10 -12
- data/specs/ios_metadata.rb +2 -2
- data/specs/metadata.rb +2 -5
- data/specs/metadata_resolver.rb +6 -6
- data/specs/mocks/mock_methods.rb +0 -2
- data/specs/percy_options.rb +16 -16
- data/specs/screenshot.rb +7 -10
- data/specs/tile.rb +2 -2
- metadata +17 -3
@@ -9,197 +9,199 @@ require_relative '../lib/cli_wrapper'
|
|
9
9
|
require_relative '../lib/tile'
|
10
10
|
require_relative '../common/common'
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
module Percy
|
13
|
+
class GenericProvider
|
14
|
+
attr_accessor :driver, :metadata, :debug_url
|
15
|
+
|
16
|
+
def initialize(driver, metadata)
|
17
|
+
@driver = driver
|
18
|
+
@metadata = metadata
|
19
|
+
@debug_url = ''
|
20
|
+
end
|
14
21
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@debug_url = ''
|
19
|
-
end
|
22
|
+
def self.supports(_remote_url)
|
23
|
+
true
|
24
|
+
end
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
|
26
|
+
def screenshot(name, **kwargs)
|
27
|
+
tiles = _get_tiles(**kwargs)
|
28
|
+
tag = _get_tag(**kwargs)
|
29
|
+
ignore_regions = {
|
30
|
+
'ignoreElementsData' => _find_regions(
|
31
|
+
xpaths: kwargs.fetch(:ignore_regions_xpaths, []),
|
32
|
+
accessibility_ids: kwargs.fetch(:ignore_region_accessibility_ids, []),
|
33
|
+
appium_elements: kwargs.fetch(:ignore_region_appium_elements, []),
|
34
|
+
custom_locations: kwargs.fetch(:custom_ignore_regions, [])
|
35
|
+
)
|
36
|
+
}
|
37
|
+
consider_regions = {
|
38
|
+
'considerElementsData' => _find_regions(
|
39
|
+
xpaths: kwargs.fetch(:consider_regions_xpaths, []),
|
40
|
+
accessibility_ids: kwargs.fetch(:consider_region_accessibility_ids, []),
|
41
|
+
appium_elements: kwargs.fetch(:consider_region_appium_elements, []),
|
42
|
+
custom_locations: kwargs.fetch(:custom_consider_regions, [])
|
43
|
+
)
|
44
|
+
}
|
45
|
+
|
46
|
+
_post_screenshots(name, tag, tiles, get_debug_url, ignore_regions, consider_regions)
|
47
|
+
end
|
24
48
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
'
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
)
|
43
|
-
}
|
44
|
-
|
45
|
-
_post_screenshots(name, tag, tiles, get_debug_url, ignore_regions, consider_regions)
|
46
|
-
end
|
49
|
+
def _get_tag(**kwargs)
|
50
|
+
name = kwargs[:device_name] || metadata.device_name
|
51
|
+
os_name = metadata.os_name
|
52
|
+
os_version = metadata.os_version
|
53
|
+
width = metadata.device_screen_size['width'] || 1
|
54
|
+
height = metadata.device_screen_size['height'] || 1
|
55
|
+
orientation = metadata.get_orientation(**kwargs).downcase
|
56
|
+
|
57
|
+
{
|
58
|
+
'name' => name,
|
59
|
+
'os_name' => os_name,
|
60
|
+
'os_version' => os_version,
|
61
|
+
'width' => width,
|
62
|
+
'height' => height,
|
63
|
+
'orientation' => orientation
|
64
|
+
}
|
65
|
+
end
|
47
66
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
height = metadata.device_screen_size['height'] || 1
|
54
|
-
orientation = metadata.get_orientation(**kwargs).downcase
|
55
|
-
|
56
|
-
{
|
57
|
-
'name' => name,
|
58
|
-
'os_name' => os_name,
|
59
|
-
'os_version' => os_version,
|
60
|
-
'width' => width,
|
61
|
-
'height' => height,
|
62
|
-
'orientation' => orientation
|
63
|
-
}
|
64
|
-
end
|
67
|
+
def _get_tiles(**kwargs)
|
68
|
+
fullpage_ss = kwargs[:fullpage] || false
|
69
|
+
if fullpage_ss
|
70
|
+
log('Full page screenshot is only supported on App Automate. Falling back to single page screenshot.')
|
71
|
+
end
|
65
72
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
73
|
+
png_bytes = driver.screenshot_as(:png)
|
74
|
+
directory = _get_dir
|
75
|
+
path = _write_screenshot(png_bytes, directory)
|
76
|
+
|
77
|
+
fullscreen = kwargs[:full_screen] || false
|
78
|
+
status_bar_height = kwargs[:status_bar_height] || metadata.status_bar_height
|
79
|
+
nav_bar_height = kwargs[:nav_bar_height] || metadata.navigation_bar_height
|
80
|
+
header_height = 0
|
81
|
+
footer_height = 0
|
82
|
+
[
|
83
|
+
Percy::Tile.new(status_bar_height, nav_bar_height, header_height, footer_height, filepath: path, fullscreen: fullscreen)
|
84
|
+
]
|
70
85
|
end
|
71
86
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
footer_height = 0
|
81
|
-
[
|
82
|
-
Tile.new(status_bar_height, nav_bar_height, header_height, footer_height, filepath: path, fullscreen: fullscreen)
|
83
|
-
]
|
84
|
-
end
|
87
|
+
def _find_regions(xpaths:, accessibility_ids:, appium_elements:, custom_locations:)
|
88
|
+
elements_array = []
|
89
|
+
get_regions_by_xpath(elements_array, xpaths)
|
90
|
+
get_regions_by_ids(elements_array, accessibility_ids)
|
91
|
+
get_regions_by_elements(elements_array, appium_elements)
|
92
|
+
get_regions_by_location(elements_array, custom_locations)
|
93
|
+
elements_array
|
94
|
+
end
|
85
95
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
get_regions_by_ids(elements_array, accessibility_ids)
|
90
|
-
get_regions_by_elements(elements_array, appium_elements)
|
91
|
-
get_regions_by_location(elements_array, custom_locations)
|
92
|
-
elements_array
|
93
|
-
end
|
96
|
+
def _post_screenshots(name, tag, tiles, debug_url, ignored_regions, considered_regions)
|
97
|
+
Percy::CLIWrapper.new.post_screenshots(name, tag, tiles, debug_url, ignored_regions, considered_regions)
|
98
|
+
end
|
94
99
|
|
95
|
-
|
96
|
-
|
97
|
-
|
100
|
+
def _write_screenshot(png_bytes, directory)
|
101
|
+
filepath = _get_path(directory)
|
102
|
+
File.open(filepath, 'wb') { |f| f.write(png_bytes) }
|
103
|
+
filepath
|
104
|
+
end
|
98
105
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
106
|
+
def get_region_object(selector, element)
|
107
|
+
scale_factor = metadata.scale_factor
|
108
|
+
location = hashed(element.location)
|
109
|
+
size = hashed(element.size)
|
110
|
+
coordinates = {
|
111
|
+
'top' => location['y'] * scale_factor,
|
112
|
+
'bottom' => (location['y'] + size['height']) * scale_factor,
|
113
|
+
'left' => location['x'] * scale_factor,
|
114
|
+
'right' => (location['x'] + size['width']) * scale_factor
|
115
|
+
}
|
116
|
+
{ 'selector' => selector, 'coOrdinates' => coordinates }
|
117
|
+
end
|
104
118
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
119
|
+
def get_regions_by_xpath(elements_array, xpaths)
|
120
|
+
xpaths.each do |xpath|
|
121
|
+
element = driver.find_element(Appium::Core::Base::SearchContext::FINDERS[:xpath], xpath)
|
122
|
+
selector = "xpath: #{xpath}"
|
123
|
+
if element
|
124
|
+
region = get_region_object(selector, element)
|
125
|
+
elements_array << region
|
126
|
+
end
|
127
|
+
rescue Appium::Core::Error::NoSuchElementError => e
|
128
|
+
log("Appium Element with xpath: #{xpath} not found. Ignoring this xpath.")
|
129
|
+
log(e, on_debug: true)
|
130
|
+
end
|
131
|
+
end
|
117
132
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
if element
|
133
|
+
def get_regions_by_ids(elements_array, ids)
|
134
|
+
ids.each do |id|
|
135
|
+
element = driver.find_element(Appium::Core::Base::SearchContext::FINDERS[:accessibility_id], id)
|
136
|
+
selector = "id: #{id}"
|
123
137
|
region = get_region_object(selector, element)
|
124
138
|
elements_array << region
|
139
|
+
rescue Appium::Core::Error::NoSuchElementError => e
|
140
|
+
log("Appium Element with id: #{id} not found. Ignoring this id.")
|
141
|
+
log(e, on_debug: true)
|
125
142
|
end
|
126
|
-
rescue Appium::Core::Error::NoSuchElementError => e
|
127
|
-
log("Appium Element with xpath: #{xpath} not found. Ignoring this xpath.")
|
128
|
-
log(e, on_debug: true)
|
129
143
|
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def get_regions_by_ids(elements_array, ids)
|
133
|
-
ids.each do |id|
|
134
|
-
element = driver.find_element(Appium::Core::Base::SearchContext::FINDERS[:accessibility_id], id)
|
135
|
-
selector = "id: #{id}"
|
136
|
-
region = get_region_object(selector, element)
|
137
|
-
elements_array << region
|
138
|
-
rescue Appium::Core::Error::NoSuchElementError => e
|
139
|
-
log("Appium Element with id: #{id} not found. Ignoring this id.")
|
140
|
-
log(e, on_debug: true)
|
141
|
-
end
|
142
|
-
end
|
143
144
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
145
|
+
def get_regions_by_elements(elements_array, elements)
|
146
|
+
elements.each_with_index do |element, index|
|
147
|
+
class_name = element.attribute('class')
|
148
|
+
selector = "element: #{index} #{class_name}"
|
149
|
+
region = get_region_object(selector, element)
|
150
|
+
elements_array << region
|
151
|
+
rescue Appium::Core::Error::NoSuchElementError => e
|
152
|
+
log("Correct Element not passed at index #{index}")
|
153
|
+
log(e, on_debug: true)
|
154
|
+
end
|
153
155
|
end
|
154
|
-
end
|
155
156
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
157
|
+
def get_regions_by_location(elements_array, custom_locations)
|
158
|
+
custom_locations.each_with_index do |custom_location, index|
|
159
|
+
screen_width = metadata.device_screen_size['width']
|
160
|
+
screen_height = metadata.device_screen_size['height']
|
161
|
+
if custom_location.valid?(screen_height, screen_width)
|
162
|
+
region = {
|
163
|
+
selector: "custom ignore region: #{index}",
|
164
|
+
coOrdinates: {
|
165
|
+
top: custom_location.top,
|
166
|
+
bottom: custom_location.bottom,
|
167
|
+
left: custom_location.left,
|
168
|
+
right: custom_location.right
|
169
|
+
}
|
168
170
|
}
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
171
|
+
elements_array << region
|
172
|
+
else
|
173
|
+
log("Values passed in custom ignored region at index: #{index} are not valid")
|
174
|
+
end
|
173
175
|
end
|
174
176
|
end
|
175
|
-
end
|
176
177
|
|
177
|
-
|
178
|
-
|
179
|
-
|
178
|
+
def log(message, on_debug: false)
|
179
|
+
puts message if on_debug
|
180
|
+
end
|
180
181
|
|
181
|
-
|
182
|
-
|
183
|
-
|
182
|
+
def get_debug_url
|
183
|
+
debug_url
|
184
|
+
end
|
184
185
|
|
185
|
-
|
186
|
-
|
187
|
-
|
186
|
+
def get_device_name
|
187
|
+
''
|
188
|
+
end
|
188
189
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
190
|
+
def _get_dir
|
191
|
+
dir_path = ENV['PERCY_TMP_DIR'] || nil
|
192
|
+
if dir_path
|
193
|
+
Pathname.new(dir_path).mkpath
|
194
|
+
return dir_path
|
195
|
+
end
|
196
|
+
Dir.mktmpdir
|
194
197
|
end
|
195
|
-
Dir.mktmpdir
|
196
|
-
end
|
197
198
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
199
|
+
def _get_path(directory)
|
200
|
+
suffix = '.png'
|
201
|
+
prefix = 'percy-appium-'
|
202
|
+
file = Tempfile.new([prefix, suffix], directory)
|
203
|
+
file.close
|
204
|
+
file.path
|
205
|
+
end
|
204
206
|
end
|
205
207
|
end
|
@@ -5,13 +5,15 @@ require_relative '../metadata/metadata_resolver'
|
|
5
5
|
require_relative 'app_automate'
|
6
6
|
require_relative 'generic_provider'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
module Percy
|
9
|
+
class ProviderResolver
|
10
|
+
def self.resolve(driver)
|
11
|
+
metadata = Percy::MetadataResolver.resolve(driver)
|
12
|
+
providers = [Percy::AppAutomate, Percy::GenericProvider]
|
13
|
+
providers.each do |provider|
|
14
|
+
return provider.new(driver, metadata) if provider.supports(metadata.remote_url)
|
15
|
+
end
|
16
|
+
raise UnknownProvider
|
14
17
|
end
|
15
|
-
raise UnknownProvider
|
16
18
|
end
|
17
19
|
end
|
data/percy/version.rb
CHANGED
data/percy-appium-app.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.require_paths = ['percy']
|
27
27
|
|
28
28
|
spec.add_runtime_dependency 'appium_lib', '~> 12.0'
|
29
|
+
spec.add_runtime_dependency 'dotenv', '~> 2.8'
|
29
30
|
|
30
31
|
spec.add_development_dependency 'bundler', '~> 2.4'
|
31
32
|
spec.add_development_dependency 'minitest', '~> 5.20'
|
data/specs/android_metadata.rb
CHANGED
@@ -1,19 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Metrics/MethodLength
|
4
|
-
|
5
3
|
require 'minitest/autorun'
|
6
4
|
require 'minitest/mock'
|
7
5
|
require 'appium_lib'
|
8
6
|
require_relative 'mocks/mock_methods'
|
9
7
|
require_relative '../percy/metadata/android_metadata'
|
10
8
|
|
11
|
-
# Test suite for the AndroidMetadata class
|
9
|
+
# Test suite for the Percy::AndroidMetadata class
|
12
10
|
class TestAndroidMetadata < Minitest::Test
|
13
11
|
def setup
|
14
12
|
@mock_webdriver = Minitest::Mock.new
|
15
13
|
@mock_webdriver.expect(:capabilities, get_android_capabilities)
|
16
|
-
@android_metadata = AndroidMetadata.new(@mock_webdriver)
|
14
|
+
@android_metadata = Percy::AndroidMetadata.new(@mock_webdriver)
|
17
15
|
end
|
18
16
|
|
19
17
|
def test_android_execute_script
|
data/specs/app_automate.rb
CHANGED
@@ -1,23 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Metrics/MethodLength
|
4
|
-
# rubocop:disable Metrics/AbcSize
|
5
|
-
|
6
3
|
require 'minitest/autorun'
|
7
4
|
require 'minitest/mock'
|
8
5
|
require_relative '../percy/providers/app_automate'
|
9
6
|
require_relative '../percy/metadata/android_metadata'
|
10
7
|
require_relative 'mocks/mock_methods'
|
11
8
|
|
12
|
-
# Test suite for the AppAutomate class
|
9
|
+
# Test suite for the Percy::AppAutomate class
|
13
10
|
class TestAppAutomate < Minitest::Test
|
14
11
|
COMPARISON_RESPONSE = { 'success' => true, 'link' => 'https://snapshots-url' }.freeze
|
15
12
|
|
16
13
|
def setup
|
17
14
|
@mock_webdriver = Minitest::Mock.new
|
18
15
|
@mock_webdriver.expect(:capabilities, get_android_capabilities)
|
19
|
-
@metadata = AndroidMetadata.new(@mock_webdriver)
|
20
|
-
@app_automate = AppAutomate.new(@mock_webdriver, @metadata)
|
16
|
+
@metadata = Percy::AndroidMetadata.new(@mock_webdriver)
|
17
|
+
@app_automate = Percy::AppAutomate.new(@mock_webdriver, @metadata)
|
21
18
|
end
|
22
19
|
|
23
20
|
def test_app_automate_get_debug_url
|
@@ -28,18 +25,18 @@ class TestAppAutomate < Minitest::Test
|
|
28
25
|
end
|
29
26
|
|
30
27
|
def test_app_automate_supports_with_correct_url
|
31
|
-
app_automate_session = AppAutomate.supports('https://hub-cloud.browserstack.com/wd/hub')
|
28
|
+
app_automate_session = Percy::AppAutomate.supports('https://hub-cloud.browserstack.com/wd/hub')
|
32
29
|
assert_equal true, app_automate_session
|
33
30
|
end
|
34
31
|
|
35
32
|
def test_app_automate_supports_with_incorrect_url
|
36
|
-
app_automate_session = AppAutomate.supports('https://hub-cloud.generic.com/wd/hub')
|
33
|
+
app_automate_session = Percy::AppAutomate.supports('https://hub-cloud.generic.com/wd/hub')
|
37
34
|
assert_equal false, app_automate_session
|
38
35
|
end
|
39
36
|
|
40
37
|
def test_app_automate_supports_with_AA_DOMAIN
|
41
38
|
ENV['AA_DOMAIN'] = 'bsstag'
|
42
|
-
app_automate_session = AppAutomate.supports('bsstag.com')
|
39
|
+
app_automate_session = Percy::AppAutomate.supports('bsstag.com')
|
43
40
|
assert_equal true, app_automate_session
|
44
41
|
ENV['AA_DOMAIN'] = nil
|
45
42
|
end
|
@@ -80,23 +77,23 @@ class TestAppAutomate < Minitest::Test
|
|
80
77
|
end
|
81
78
|
|
82
79
|
def test_get_tiles
|
83
|
-
# Mocking Metadata's session_id method
|
80
|
+
# Mocking Percy::Metadata's session_id method
|
84
81
|
metadata_mock = Minitest::Mock.new
|
85
82
|
metadata_mock.expect(:session_id, 'session_id_123')
|
86
83
|
|
87
|
-
# Mocking AndroidMetadata's methods
|
84
|
+
# Mocking Percy::AndroidMetadata's methods
|
88
85
|
android_metadata_mock = Minitest::Mock.new
|
89
86
|
android_metadata_mock.expect(:device_screen_size, { 'width' => 1080, 'height' => 1920 })
|
90
87
|
android_metadata_mock.expect(:navigation_bar_height, 150)
|
91
88
|
android_metadata_mock.expect(:status_bar_height, 100)
|
92
89
|
|
93
|
-
Metadata.class_eval do
|
90
|
+
Percy::Metadata.class_eval do
|
94
91
|
define_method(:session_id) do
|
95
92
|
metadata_mock.session_id
|
96
93
|
end
|
97
94
|
end
|
98
95
|
|
99
|
-
AndroidMetadata.class_eval do
|
96
|
+
Percy::AndroidMetadata.class_eval do
|
100
97
|
define_method(:device_screen_size) do
|
101
98
|
android_metadata_mock.device_screen_size
|
102
99
|
end
|
data/specs/app_percy.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Metrics/MethodLength
|
4
|
-
|
5
3
|
require 'minitest/autorun'
|
6
4
|
# require 'webmock/minitest'
|
7
5
|
require_relative '../percy/lib/app_percy'
|
@@ -12,7 +10,7 @@ require_relative '../percy/providers/generic_provider'
|
|
12
10
|
require_relative '../percy/lib/cli_wrapper'
|
13
11
|
require_relative 'mocks/mock_methods'
|
14
12
|
|
15
|
-
# Test suite for the AppPercy class
|
13
|
+
# Test suite for the Percy::AppPercy class
|
16
14
|
class TestAppPercy < Minitest::Test
|
17
15
|
COMPARISON_RESPONSE = { 'link' => 'https://snapshot_url', 'success' => true }.freeze
|
18
16
|
|
@@ -38,10 +36,10 @@ class TestAppPercy < Minitest::Test
|
|
38
36
|
|
39
37
|
ENV['PERCY_DISABLE_REMOTE_UPLOADS'] = 'true'
|
40
38
|
|
41
|
-
app_percy = AppPercy.new(@mock_android_webdriver)
|
39
|
+
app_percy = Percy::AppPercy.new(@mock_android_webdriver)
|
42
40
|
|
43
|
-
assert_instance_of(AndroidMetadata, app_percy.metadata)
|
44
|
-
assert_instance_of(AppAutomate, app_percy.provider)
|
41
|
+
assert_instance_of(Percy::AndroidMetadata, app_percy.metadata)
|
42
|
+
assert_instance_of(Percy::AppAutomate, app_percy.provider)
|
45
43
|
end
|
46
44
|
|
47
45
|
def test_android_on_non_app_automate
|
@@ -57,9 +55,9 @@ class TestAppPercy < Minitest::Test
|
|
57
55
|
5.times do
|
58
56
|
@mock_android_webdriver.expect(:capabilities, get_android_capabilities)
|
59
57
|
end
|
60
|
-
app_percy = AppPercy.new(@mock_android_webdriver)
|
61
|
-
assert_instance_of(AndroidMetadata, app_percy.metadata)
|
62
|
-
assert_instance_of(GenericProvider, app_percy.provider)
|
58
|
+
app_percy = Percy::AppPercy.new(@mock_android_webdriver)
|
59
|
+
assert_instance_of(Percy::AndroidMetadata, app_percy.metadata)
|
60
|
+
assert_instance_of(Percy::GenericProvider, app_percy.provider)
|
63
61
|
end
|
64
62
|
|
65
63
|
def test_ios_on_app_automate
|
@@ -68,9 +66,9 @@ class TestAppPercy < Minitest::Test
|
|
68
66
|
5.times do
|
69
67
|
@mock_ios_webdriver.expect(:capabilities, get_ios_capabilities)
|
70
68
|
end
|
71
|
-
app_percy = AppPercy.new(@mock_ios_webdriver)
|
72
|
-
assert_instance_of(IOSMetadata, app_percy.metadata)
|
73
|
-
assert_instance_of(AppAutomate, app_percy.provider)
|
69
|
+
app_percy = Percy::AppPercy.new(@mock_ios_webdriver)
|
70
|
+
assert_instance_of(Percy::IOSMetadata, app_percy.metadata)
|
71
|
+
assert_instance_of(Percy::AppAutomate, app_percy.provider)
|
74
72
|
end
|
75
73
|
|
76
74
|
def test_ios_on_non_app_automate
|
@@ -84,16 +82,16 @@ class TestAppPercy < Minitest::Test
|
|
84
82
|
3.times do
|
85
83
|
@mock_ios_webdriver.expect(:capabilities, get_ios_capabilities)
|
86
84
|
end
|
87
|
-
app_percy = AppPercy.new(@mock_ios_webdriver)
|
88
|
-
assert_instance_of(IOSMetadata, app_percy.metadata)
|
89
|
-
assert_instance_of(GenericProvider, app_percy.provider)
|
85
|
+
app_percy = Percy::AppPercy.new(@mock_ios_webdriver)
|
86
|
+
assert_instance_of(Percy::IOSMetadata, app_percy.metadata)
|
87
|
+
assert_instance_of(Percy::GenericProvider, app_percy.provider)
|
90
88
|
end
|
91
89
|
|
92
90
|
def test_screenshot_with_percy_options_disabled
|
93
91
|
disable_percy_options(@mock_android_webdriver, num = 5)
|
94
92
|
make_mock_driver_appium(@mock_android_webdriver)
|
95
93
|
mock_driver_remote_url(@mock_android_webdriver, 'some-other-url', num = 2)
|
96
|
-
app_percy = AppPercy.new(@mock_android_webdriver)
|
94
|
+
app_percy = Percy::AppPercy.new(@mock_android_webdriver)
|
97
95
|
assert_nil app_percy.screenshot('screenshot 1')
|
98
96
|
end
|
99
97
|
|
@@ -101,7 +99,7 @@ class TestAppPercy < Minitest::Test
|
|
101
99
|
disable_percy_options(@mock_android_webdriver, num = 5)
|
102
100
|
make_mock_driver_appium(@mock_android_webdriver)
|
103
101
|
mock_driver_remote_url(@mock_android_webdriver, 'some-other-url', num = 2)
|
104
|
-
app_percy = AppPercy.new(@mock_android_webdriver)
|
102
|
+
app_percy = Percy::AppPercy.new(@mock_android_webdriver)
|
105
103
|
assert_nil app_percy.screenshot('screenshot 1')
|
106
104
|
end
|
107
105
|
|
@@ -112,7 +110,7 @@ class TestAppPercy < Minitest::Test
|
|
112
110
|
})
|
113
111
|
|
114
112
|
assert_raises(Exception) do
|
115
|
-
AppPercy.screenshot(@mock_android_webdriver, 'screenshot')
|
113
|
+
Percy::AppPercy.screenshot(@mock_android_webdriver, 'screenshot')
|
116
114
|
end
|
117
115
|
end
|
118
116
|
|
@@ -125,16 +123,16 @@ class TestAppPercy < Minitest::Test
|
|
125
123
|
@mock_android_webdriver.expect(:capabilities, caps)
|
126
124
|
end
|
127
125
|
|
128
|
-
GenericProvider.stub(:supports, false) do
|
126
|
+
Percy::GenericProvider.stub(:supports, false) do
|
129
127
|
assert_raises(UnknownProvider) do
|
130
|
-
_provider = AppPercy.new(@mock_android_webdriver).provider
|
128
|
+
_provider = Percy::AppPercy.new(@mock_android_webdriver).provider
|
131
129
|
end
|
132
130
|
end
|
133
131
|
end
|
134
132
|
|
135
133
|
def test_invalid_driver
|
136
134
|
assert_raises(DriverNotSupported) do
|
137
|
-
AppPercy.new(Object.new)
|
135
|
+
Percy::AppPercy.new(Object.new)
|
138
136
|
end
|
139
137
|
end
|
140
138
|
|
@@ -169,7 +167,7 @@ class TestAppPercy < Minitest::Test
|
|
169
167
|
})
|
170
168
|
|
171
169
|
assert_raises(Exception) do
|
172
|
-
AppPercy.screenshot(mock_webdriver, 'screenshot')
|
170
|
+
Percy::AppPercy.screenshot(mock_webdriver, 'screenshot')
|
173
171
|
end
|
174
172
|
end
|
175
173
|
end
|