appium_lib 16.3.1 → 16.3.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.
data/test/first_test.rb DELETED
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require 'minitest/autorun'
16
- require 'minitest/reporters'
17
- require 'minitest'
18
-
19
- begin
20
- Minitest::Reporters.use! [Minitest::Reporters::ProgressReporter.new]
21
- rescue Errno::ENOENT
22
- # Ignore since Minitest::Reporters::JUnitReporter.new fails in deleting files, sometimes
23
- end
24
-
25
- class SampleTest < Minitest::Test
26
- def test_test
27
- assert(true)
28
- end
29
- end
@@ -1,132 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'minitest/autorun'
4
- require 'appium_lib'
5
- require 'tmpdir'
6
-
7
- class RegressionTest < Minitest::Test
8
- def test_expand_single_required_file
9
- Dir.mktmpdir do |dir|
10
- path = File.join(dir, 'helper.rb')
11
- File.write(path, '')
12
-
13
- assert_equal [path], Appium.expand_required_files(dir, 'helper.rb')
14
- end
15
- end
16
-
17
- def test_expand_required_directory_and_skip_missing_files
18
- Dir.mktmpdir do |dir|
19
- nested = File.join(dir, 'helpers')
20
- Dir.mkdir(nested)
21
- path = File.join(nested, 'helper.rb')
22
- File.write(path, '')
23
- File.write(File.join(nested, 'notes.txt'), '')
24
-
25
- assert_equal [path], Appium.expand_required_files(dir, %w(helpers missing.rb))
26
- assert_empty Appium.expand_required_files(dir, 'missing.rb')
27
- end
28
- end
29
-
30
- def test_promote_preserves_inherited_method
31
- parent = Class.new do
32
- def back
33
- :inherited
34
- end
35
- end
36
- child = Class.new(parent)
37
- driver = Object.new
38
- def driver.back
39
- :driver
40
- end
41
-
42
- Appium.promote_appium_methods(child, driver)
43
-
44
- assert_equal :inherited, child.new.back
45
- end
46
-
47
- def test_promote_again_uses_new_driver
48
- target = Class.new
49
- first = Object.new
50
- def first.back
51
- :first
52
- end
53
- second = Object.new
54
- def second.back
55
- :second
56
- end
57
-
58
- Appium.promote_appium_methods(target, first)
59
- assert_equal :first, target.new.back
60
- Appium.promote_appium_methods(target, second)
61
- assert_equal :second, target.new.back
62
- end
63
-
64
- def test_singleton_promotion_forwards_keywords_and_block
65
- driver = Object.new
66
- def driver.log_event(vendor:, event:)
67
- yield [vendor, event]
68
- end
69
- target = Module.new
70
- Appium.promote_singleton_appium_methods([target], driver)
71
-
72
- result = target.log_event(vendor: 'test', event: 'event') { |values| values.join(':') }
73
-
74
- assert_equal 'test:event', result
75
- end
76
-
77
- def test_singleton_promotion_preserves_positional_hash
78
- driver = Object.new
79
- def driver.command(options)
80
- options
81
- end
82
- target = Module.new
83
- Appium.promote_singleton_appium_methods([target], driver)
84
-
85
- assert_equal({ value: 1 }, target.command({ value: 1 }))
86
- end
87
-
88
- class RecordingCore
89
- attr_reader :http_client
90
-
91
- def automation_name
92
- :uiautomator2
93
- end
94
-
95
- def start_driver(http_client_ops:, **)
96
- @http_client = http_client_ops[:http_client]
97
- nil
98
- end
99
-
100
- def appium_server_version
101
- {}
102
- end
103
- end
104
-
105
- def test_start_driver_passes_custom_http_client
106
- client = Object.new
107
- driver = build_driver
108
-
109
- driver.start_driver(http_client: client)
110
-
111
- assert_same client, driver.http_client
112
- end
113
-
114
- def test_start_driver_builds_default_http_client
115
- driver = build_driver
116
-
117
- driver.start_driver
118
-
119
- assert_instance_of Appium::Http::Default, driver.http_client
120
- end
121
-
122
- private
123
-
124
- def build_driver
125
- driver = Appium::Driver.allocate
126
- driver.instance_variable_set(:@core, RecordingCore.new)
127
- def driver.server_url
128
- 'http://127.0.0.1:4723'
129
- end
130
- driver
131
- end
132
- end