percy-appium-app 0.0.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.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +55 -0
  3. data/.github/dependabot.yml +14 -0
  4. data/.github/release-drafter.yml +28 -0
  5. data/.github/workflows/Semgrep.yml +48 -0
  6. data/.github/workflows/changelog.yml +11 -0
  7. data/.github/workflows/release.yml +22 -0
  8. data/.github/workflows/stale.yml +30 -0
  9. data/.github/workflows/test.yml +40 -0
  10. data/Gemfile +13 -0
  11. data/LICENSE +21 -0
  12. data/Makefile +3 -0
  13. data/README.md +1 -0
  14. data/Rakefile +1 -0
  15. data/percy/common/common.rb +19 -0
  16. data/percy/configs/devices.json +232 -0
  17. data/percy/environment.rb +25 -0
  18. data/percy/exceptions/exceptions.rb +13 -0
  19. data/percy/lib/app_percy.rb +55 -0
  20. data/percy/lib/cache.rb +53 -0
  21. data/percy/lib/cli_wrapper.rb +132 -0
  22. data/percy/lib/ignore_region.rb +8 -0
  23. data/percy/lib/percy_automate.rb +59 -0
  24. data/percy/lib/percy_options.rb +37 -0
  25. data/percy/lib/region.rb +22 -0
  26. data/percy/lib/tile.rb +28 -0
  27. data/percy/metadata/android_metadata.rb +79 -0
  28. data/percy/metadata/driver_metadata.rb +40 -0
  29. data/percy/metadata/ios_metadata.rb +83 -0
  30. data/percy/metadata/metadata.rb +108 -0
  31. data/percy/metadata/metadata_resolver.rb +21 -0
  32. data/percy/providers/app_automate.rb +159 -0
  33. data/percy/providers/generic_provider.rb +205 -0
  34. data/percy/providers/provider_resolver.rb +17 -0
  35. data/percy/screenshot.rb +23 -0
  36. data/percy/version.rb +5 -0
  37. data/percy-appium-app.gemspec +37 -0
  38. data/specs/android_metadata.rb +79 -0
  39. data/specs/app_automate.rb +124 -0
  40. data/specs/app_percy.rb +175 -0
  41. data/specs/cache.rb +56 -0
  42. data/specs/cli_wrapper.rb +135 -0
  43. data/specs/driver_metadata.rb +71 -0
  44. data/specs/generic_providers.rb +370 -0
  45. data/specs/ignore_regions.rb +51 -0
  46. data/specs/ios_metadata.rb +88 -0
  47. data/specs/metadata.rb +105 -0
  48. data/specs/metadata_resolver.rb +41 -0
  49. data/specs/mocks/mock_methods.rb +147 -0
  50. data/specs/percy_options.rb +114 -0
  51. data/specs/screenshot.rb +342 -0
  52. data/specs/tile.rb +33 -0
  53. metadata +194 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ba54dc346521591705be68354e98b25018a98a1af988b9d05c7b3e6d6120b92f
4
+ data.tar.gz: 5fe4abc08f138a09c1f5c95f327f9bebb8c9d4f7899cd0ffbe233d2d95cb5e86
5
+ SHA512:
6
+ metadata.gz: 5434a1ce14329a48bf5411050de8c466ec40e77f3545fa159d566d077d28d88ce027a7ed87ea3a3cf0cc6a851350376a7218d93e6250de93cc165e5ba6179196
7
+ data.tar.gz: 2a8f9febe81d0490ed25d4f8bca3a2b24851a62d5c51ea33527629e72e810de9a4e0e94593f88727ffe42c25237c43aab785529d1e7bb4d24b5fd81488fedd8e
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us fix the issue
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+ ---
8
+
9
+ <!--
10
+ ## Have you read the "Debugging SDKs" doc yet?
11
+
12
+ There are common setup gotchas that happen with Percy's SDKs, it would be worth reading
13
+ the debugging document, which might already answer your question:
14
+ https://docs.percy.io/docs/debugging-sdk
15
+
16
+ ## Reach out to Percy support instead?
17
+
18
+ If you’re having issues that _aren’t SDK bugs_, it would be best for you to
19
+ reach out to support instead: support@percy.io or
20
+ https://www.browserstack.com/contact#technical-support
21
+ -->
22
+
23
+ ## The problem
24
+
25
+ Briefly describe the issue you are experiencing (or the feature you want to see
26
+ added to Percy). Tell us what you were trying to do and what happened
27
+ instead. Remember, this is _not_ a place to ask questions. For that, go to
28
+ https://github.com/percy/cli/discussions/new
29
+
30
+ ## Environment
31
+
32
+ - Node version:
33
+ - `@percy/cli` version:
34
+ - Version of Percy SDK you’re using:
35
+ - If needed, a build or snapshot ID:
36
+ - OS version:
37
+ - Type of shell command-line [interface]:
38
+
39
+ ## Details
40
+
41
+ If necessary, describe the problem you have been experiencing in more detail.
42
+
43
+ ## Debug logs
44
+
45
+ If you are reporting a bug, _always_ include logs! [Give the "Debugging SDKs"
46
+ document a quick read for how to gather logs](https://docs.percy.io/docs/debugging-sdks#debugging-sdks)
47
+
48
+ Please do not trim or edit these logs, often times there are hints in the full
49
+ logs that help debug what is going on.
50
+
51
+ ## Code to reproduce issue
52
+
53
+ Given the nature of testing/environment bugs, it’s best to try and isolate the
54
+ issue in a reproducible repo. This will make it much easier for us to diagnose
55
+ and fix.
@@ -0,0 +1,14 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: npm
4
+ directory: /
5
+ schedule:
6
+ interval: weekly
7
+ commit-message:
8
+ prefix: ⬆️
9
+ - package-ecosystem: bundler
10
+ directory: /
11
+ schedule:
12
+ interval: weekly
13
+ commit-message:
14
+ prefix: ⬆️
@@ -0,0 +1,28 @@
1
+ name-template: 'v$RESOLVED_VERSION'
2
+ tag-template: 'v$RESOLVED_VERSION'
3
+ categories:
4
+ - title: '💥 Breaking Changes'
5
+ labels:
6
+ - 💥 breaking
7
+ - title: '✨ Enhancements'
8
+ labels:
9
+ - ✨ enhancement
10
+ - title: '🐛 Bug Fixes'
11
+ labels:
12
+ - 🐛 bug
13
+ - title: '🏗 Maintenance'
14
+ labels:
15
+ - 🧹 maintenance
16
+ - title: '⬆️⬇️ Dependency Updates'
17
+ labels:
18
+ - ⬆️⬇️ dependencies
19
+ change-title-escapes: '\<*_&#@'
20
+ version-resolver:
21
+ major:
22
+ labels:
23
+ - 💥 breaking
24
+ minor:
25
+ labels:
26
+ - ✨ enhancement
27
+ default: patch
28
+ template: '$CHANGES'
@@ -0,0 +1,48 @@
1
+ # Name of this GitHub Actions workflow.
2
+ name: Semgrep
3
+
4
+ on:
5
+ # Scan changed files in PRs (diff-aware scanning):
6
+ # The branches below must be a subset of the branches above
7
+ pull_request:
8
+ branches: ["master", "main"]
9
+ push:
10
+ branches: ["master", "main"]
11
+ schedule:
12
+ - cron: '0 6 * * *'
13
+
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ semgrep:
20
+ # User definable name of this GitHub Actions job.
21
+ permissions:
22
+ contents: read # for actions/checkout to fetch code
23
+ security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
24
+ name: semgrep/ci
25
+ # If you are self-hosting, change the following `runs-on` value:
26
+ runs-on: ubuntu-latest
27
+
28
+ container:
29
+ # A Docker image with Semgrep installed. Do not change this.
30
+ image: returntocorp/semgrep
31
+
32
+ # Skip any PR created by dependabot to avoid permission issues:
33
+ if: (github.actor != 'dependabot[bot]')
34
+
35
+ steps:
36
+ # Fetch project source with GitHub Actions Checkout.
37
+ - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
38
+ # Run the "semgrep ci" command on the command line of the docker image.
39
+ - run: semgrep ci --sarif --output=semgrep.sarif
40
+ env:
41
+ # Add the rules that Semgrep uses by setting the SEMGREP_RULES environment variable.
42
+ SEMGREP_RULES: p/default # more at semgrep.dev/explore
43
+
44
+ - name: Upload SARIF file for GitHub Advanced Security Dashboard
45
+ uses: github/codeql-action/upload-sarif@6c089f53dd51dc3fc7e599c3cb5356453a52ca9e # v2.20.0
46
+ with:
47
+ sarif_file: semgrep.sarif
48
+ if: always()
@@ -0,0 +1,11 @@
1
+ name: Changelog
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ jobs:
6
+ update_draft:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: release-drafter/release-drafter@v5
10
+ env:
11
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,22 @@
1
+ name: Release
2
+ on:
3
+ release:
4
+ types: [published]
5
+ jobs:
6
+ publish:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - uses: ruby/setup-ruby@v1
11
+ with:
12
+ ruby-version: 2.6
13
+ bundler-cache: true
14
+ - uses: actions/cache@v2
15
+ with:
16
+ path: "./vendor/bundle"
17
+ key: v1/${{ runner.os }}/ruby-2.6/${{ hashFiles('**/Gemfile.lock') }}
18
+ restore-keys: v1/${{ runner.os }}/ruby-2.6/
19
+ - uses: cadwallion/publish-rubygems-action@master
20
+ env:
21
+ RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
22
+ RELEASE_COMMAND: make release
@@ -0,0 +1,30 @@
1
+ name: 'Close stale issues and PRs'
2
+ on:
3
+ schedule:
4
+ - cron: '0 19 * * 2'
5
+
6
+ jobs:
7
+ stale:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/stale@v4
11
+ with:
12
+ stale-issue-message: >-
13
+ This issue is stale because it has been open for more than 14 days with no activity.
14
+ Remove stale label or comment or this will be closed in 14 days.
15
+ stale-pr-message: >-
16
+ This PR is stale because it has been open for more than 14 days with no activity.
17
+ Remove stale label or comment or this will be closed in 14 days.
18
+ close-issue-message: >-
19
+ This issue was closed because it has been stalled for 28 days with no activity.
20
+ close-pr-message: >-
21
+ This PR was closed because it has been stalled for 28 days with no activity.
22
+ days-before-issue-stale: 14
23
+ days-before-pr-stale: 14
24
+ # close 14 days _after_ initial warning
25
+ days-before-issue-close: 14
26
+ days-before-pr-close: 14
27
+ exempt-pr-labels: '❄️ on ice'
28
+ exempt-issue-labels: '🐛 bug,❄️ on ice,✨ enhancement'
29
+ exempt-all-assignees: true
30
+ stale-pr-label: '🍞 stale'
@@ -0,0 +1,40 @@
1
+ name: Test
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ workflow_dispatch:
6
+ inputs:
7
+ branch:
8
+ required: false
9
+ type: string
10
+ default: master
11
+ jobs:
12
+ test:
13
+ name: Test
14
+ strategy:
15
+ matrix:
16
+ os: [ubuntu-latest]
17
+ ruby: ['2.6', '2.7', '3.0']
18
+ runs-on: ${{ matrix.os }}
19
+ steps:
20
+ - uses: actions-ecosystem/action-regex-match@v2
21
+ id: regex-match
22
+ if: ${{ github.event_name == 'workflow_dispatch' }}
23
+ with:
24
+ text: ${{ github.event.inputs.branch }}
25
+ regex: '^[a-zA-Z0-9_/\-]+$'
26
+ - name: Break on invalid branch name
27
+ run: exit 1
28
+ if: ${{ github.event_name == 'workflow_dispatch' && steps.regex-match.outputs && steps.regex-match.outputs.match == '' }}
29
+ - uses: actions/checkout@v2
30
+ - uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{matrix.ruby}}
33
+ bundler-cache: true
34
+ - uses: actions/cache@v2
35
+ with:
36
+ path: "./vendor/bundle"
37
+ key: v1/${{ runner.os }}/ruby-${{ matrix.ruby }}/${{ hashFiles('**/Gemfile.lock') }}
38
+ restore-keys: v1/${{ runner.os }}/ruby-${{ matrix.ruby }}/
39
+ - run: bundle install
40
+ - run: for file in specs/*.rb; do ruby $file; done
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'appium_console'
6
+ gem 'appium_lib'
7
+ gem 'dotenv'
8
+ gem 'minitest'
9
+ gem 'rubocop', require: false
10
+ gem 'tempfile'
11
+ gem 'webmock', '~> 3.18', '>= 3.18.1'
12
+ gem 'webrick', '~> 1.3', '>= 1.3.1'
13
+ gem 'rake', '~> 13.0'
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Percy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,3 @@
1
+ release:
2
+ rake build
3
+ gem push pkg/percy-appium-app-*
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # percy-appium-ruby
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dotenv/load'
4
+
5
+ PERCY_LOGLEVEL = ENV['PERCY_LOGLEVEL']
6
+ PERCY_DEBUG = PERCY_LOGLEVEL == 'debug'
7
+ LABEL = "[\e[35m#{PERCY_DEBUG ? 'percy:ruby' : 'percy'}\e[39m]"
8
+
9
+ def log(message, on_debug: nil)
10
+ return unless on_debug.nil? || (on_debug.is_a?(TrueClass) && PERCY_DEBUG)
11
+
12
+ puts "#{LABEL} #{message}"
13
+ end
14
+
15
+ def hashed(object)
16
+ return object.as_json unless object.is_a?(Hash)
17
+
18
+ object
19
+ end
@@ -0,0 +1,232 @@
1
+ {
2
+ "iphone 12 pro max": {
3
+ "scale_factor": "3",
4
+ "status_bar": "47"
5
+ },
6
+ "iphone 12 pro": {
7
+ "scale_factor": "3",
8
+ "status_bar": "47"
9
+ },
10
+ "iphone 12 mini": {
11
+ "scale_factor": "3",
12
+ "status_bar": "50"
13
+ },
14
+ "iphone 12": {
15
+ "scale_factor": "3",
16
+ "status_bar": "47"
17
+ },
18
+ "iphone 11 pro max": {
19
+ "scale_factor": "3",
20
+ "status_bar": "44"
21
+ },
22
+ "iphone 11 pro": {
23
+ "scale_factor": "3",
24
+ "status_bar": "44"
25
+ },
26
+ "iphone 11": {
27
+ "scale_factor": "2",
28
+ "status_bar": "48"
29
+ },
30
+ "iphone xs": {
31
+ "scale_factor": "3",
32
+ "status_bar": "44"
33
+ },
34
+ "iphone xs max": {
35
+ "scale_factor": "3",
36
+ "status_bar": "44"
37
+ },
38
+ "iphone xr": {
39
+ "scale_factor": "2",
40
+ "status_bar": "48"
41
+ },
42
+ "iphone x": {
43
+ "scale_factor": "3",
44
+ "status_bar": "44"
45
+ },
46
+ "iphone 8": {
47
+ "scale_factor": "2",
48
+ "status_bar": "20"
49
+ },
50
+ "iphone 8 plus": {
51
+ "scale_factor": "3",
52
+ "status_bar": "20"
53
+ },
54
+ "iphone 7": {
55
+ "scale_factor": "2",
56
+ "status_bar": "20"
57
+ },
58
+ "iphone 6s": {
59
+ "scale_factor": "2",
60
+ "status_bar": "20"
61
+ },
62
+ "iphone 6 plus": {
63
+ "scale_factor": "3",
64
+ "status_bar": "20"
65
+ },
66
+ "iphone 6s plus": {
67
+ "scale_factor": "3",
68
+ "status_bar": "20"
69
+ },
70
+ "iphone 6": {
71
+ "scale_factor": "2",
72
+ "status_bar": "20"
73
+ },
74
+ "iphone se 2022": {
75
+ "scale_factor": "2",
76
+ "status_bar": "20"
77
+ },
78
+ "iphone se 2020": {
79
+ "scale_factor": "2",
80
+ "status_bar": "20"
81
+ },
82
+ "iphone se": {
83
+ "scale_factor": "2",
84
+ "status_bar": "20"
85
+ },
86
+ "ipad air 4": {
87
+ "scale_factor": "2",
88
+ "status_bar": "24"
89
+ },
90
+ "ipad 9th": {
91
+ "scale_factor": "2",
92
+ "status_bar": "20"
93
+ },
94
+ "ipad 10th": {
95
+ "scale_factor": "2",
96
+ "status_bar": "24"
97
+ },
98
+ "ipad air 5": {
99
+ "scale_factor": "2",
100
+ "status_bar": "24"
101
+ },
102
+ "ipad pro 12.9 2022": {
103
+ "scale_factor": "2",
104
+ "status_bar": "24"
105
+ },
106
+ "ipad pro 12.9 2021": {
107
+ "scale_factor": "2",
108
+ "status_bar": "24"
109
+ },
110
+ "ipad pro 12.9 2020": {
111
+ "scale_factor": "2",
112
+ "status_bar": "24"
113
+ },
114
+ "ipad pro 11 2021": {
115
+ "scale_factor": "2",
116
+ "status_bar": "24"
117
+ },
118
+ "ipad pro 11 2022": {
119
+ "scale_factor": "2",
120
+ "status_bar": "24"
121
+ },
122
+ "ipad 8th": {
123
+ "scale_factor": "2",
124
+ "status_bar": "20"
125
+ },
126
+ "ipad pro 12.9 2018": {
127
+ "scale_factor": "2",
128
+ "status_bar": "24"
129
+ },
130
+ "ipad mini 2021": {
131
+ "scale_factor": "2",
132
+ "status_bar": "24"
133
+ },
134
+ "ipad pro 11 2020": {
135
+ "scale_factor": "2",
136
+ "status_bar": "24"
137
+ },
138
+ "ipad mini 2019": {
139
+ "scale_factor": "2",
140
+ "status_bar": "20"
141
+ },
142
+ "ipad air 2019": {
143
+ "scale_factor": "2",
144
+ "status_bar": "20"
145
+ },
146
+ "ipad 7th": {
147
+ "scale_factor": "2",
148
+ "status_bar": "20"
149
+ },
150
+ "ipad pro 11 2018": {
151
+ "scale_factor": "2",
152
+ "status_bar": "24"
153
+ },
154
+ "ipad pro 9.7 2016": {
155
+ "scale_factor": "2",
156
+ "status_bar": "20"
157
+ },
158
+ "ipad pro 12.9": {
159
+ "scale_factor": "2",
160
+ "status_bar": "20"
161
+ },
162
+ "ipad mini 4": {
163
+ "scale_factor": "2",
164
+ "status_bar": "20"
165
+ },
166
+ "ipad 6th": {
167
+ "scale_factor": "2",
168
+ "status_bar": "20"
169
+ },
170
+ "ipad 5th": {
171
+ "scale_factor": "2",
172
+ "status_bar": "20"
173
+ },
174
+ "google pixel 6 pro": {
175
+ "12": {
176
+ "status_bar": "143",
177
+ "nav_bar": "56"
178
+ },
179
+ "13": {
180
+ "status_bar": "130",
181
+ "nav_bar": "84"
182
+ }
183
+ },
184
+ "samsung galaxy s22 plus": {
185
+ "12": {
186
+ "status_bar": "74",
187
+ "nav_bar": "135"
188
+ }
189
+ },
190
+ "samsung galaxy s21": {
191
+ "12": {
192
+ "status_bar": "80",
193
+ "nav_bar": "144"
194
+ }
195
+ },
196
+ "samsung galaxy s22 ultra": {
197
+ "12": {
198
+ "status_bar": "75",
199
+ "nav_bar": "135"
200
+ }
201
+ },
202
+ "samsung galaxy s22": {
203
+ "12": {
204
+ "status_bar": "81",
205
+ "nav_bar": "144"
206
+ }
207
+ },
208
+ "samsung galaxy tab s8": {
209
+ "12": {
210
+ "status_bar": "51",
211
+ "nav_bar": "102"
212
+ }
213
+ },
214
+ "google pixel 5": {
215
+ "12": {
216
+ "status_bar": "145",
217
+ "nav_bar": "44"
218
+ }
219
+ },
220
+ "google pixel 6": {
221
+ "12": {
222
+ "status_bar": "124",
223
+ "nav_bar": "42"
224
+ }
225
+ },
226
+ "google pixel 7": {
227
+ "13": {
228
+ "status_bar": "118",
229
+ "nav_bar": "63"
230
+ }
231
+ }
232
+ }
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'appium_lib'
4
+ require 'appium_lib/version'
5
+ require_relative 'version'
6
+
7
+ class Environment
8
+ @percy_build_id = nil
9
+ @percy_build_url = nil
10
+ @session_type = nil
11
+
12
+ class << self
13
+ attr_accessor :percy_build_id, :percy_build_url, :session_type
14
+
15
+ def get_client_info(flag = false)
16
+ sdk_version = SDK_VERSION
17
+ flag ? "percy-appium-app-ruby/#{sdk_version}" : "percy-appium-app/#{sdk_version}"
18
+ end
19
+
20
+ def get_env_info
21
+ appium_version = Appium::VERSION # This assumes the 'appium_lib' gem provides a VERSION constant.
22
+ ["appium/#{appium_version}", "ruby/#{RUBY_VERSION}"]
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class BaseException < StandardError; end
4
+
5
+ class UnsupportedDevice < BaseException; end
6
+
7
+ class UnknownProvider < BaseException; end
8
+
9
+ class PlatformNotSupported < BaseException; end
10
+
11
+ class DriverNotSupported < BaseException; end
12
+
13
+ class CLIException < StandardError; end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'appium_lib'
4
+ require_relative '../exceptions/exceptions'
5
+ require_relative 'percy_options'
6
+ require_relative '../providers/provider_resolver'
7
+ require_relative '../metadata/metadata_resolver'
8
+
9
+ class AppPercy
10
+ attr_accessor :metadata, :provider
11
+
12
+ def initialize(driver)
13
+ raise DriverNotSupported unless driver.is_a?(Appium::Core::Base::Driver)
14
+
15
+ @driver = driver
16
+ @metadata = MetadataResolver.resolve(@driver)
17
+ @provider = ProviderResolver.resolve(@driver)
18
+ @percy_options = PercyOptions.new(@metadata.capabilities)
19
+ end
20
+
21
+ def screenshot(name, **kwargs)
22
+ return nil unless @percy_options.enabled
23
+
24
+ raise TypeError, 'Argument name should be a String' unless name.is_a?(String)
25
+
26
+ device_name = kwargs[:device_name]
27
+ raise TypeError, 'Argument device_name should be a String' if device_name && !device_name.is_a?(String)
28
+
29
+ fullscreen = kwargs[:full_screen]
30
+ if fullscreen && !fullscreen.is_a?(TrueClass) && !fullscreen.is_a?(FalseClass)
31
+ raise TypeError,
32
+ 'Argument fullscreen should be a Boolean'
33
+ end
34
+
35
+ status_bar_height = kwargs[:status_bar_height]
36
+ if status_bar_height && !status_bar_height.is_a?(Integer)
37
+ raise TypeError,
38
+ 'Argument status_bar_height should be an Integer'
39
+ end
40
+
41
+ nav_bar_height = kwargs[:nav_bar_height]
42
+ raise TypeError, 'Argument nav_bar_height should be an Integer' if nav_bar_height && !nav_bar_height.is_a?(Integer)
43
+
44
+ orientation = kwargs[:orientation]
45
+ if orientation && !orientation.is_a?(String)
46
+ raise TypeError,
47
+ 'Argument orientation should be a String and portrait/landscape'
48
+ end
49
+
50
+ @provider.screenshot(name, **kwargs)
51
+ nil
52
+ end
53
+
54
+ attr_reader :percy_options
55
+ end