Skip to content

Commit 591a9bd

Browse files
authored
add unit tests for w3c case (#43)
1 parent c5412bd commit 591a9bd

7 files changed

+726
-4
lines changed

test/test_helper.rb

+61-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module Caps
5959
platformName: :android,
6060
automationName: 'uiautomator2',
6161
app: 'test/functional/app/api.apk',
62-
platformVersion: '6.0',
62+
platformVersion: '7.1.1',
6363
deviceName: 'Android Emulator',
6464
appPackage: 'io.appium.android.apis',
6565
appActivity: 'io.appium.android.apis.ApiDemos',
@@ -138,6 +138,39 @@ def android_mock_create_session
138138
driver
139139
end
140140

141+
def android_mock_create_session_w3c
142+
response = {
143+
value: {
144+
sessionId: '1234567890',
145+
capabilities: {
146+
platformName: :android,
147+
automationName: 'uiautomator2',
148+
app: 'test/functional/app/api.apk',
149+
platformVersion: '7.1.1',
150+
deviceName: 'Android Emulator',
151+
appPackage: 'io.appium.android.apis',
152+
appActivity: 'io.appium.android.apis.ApiDemos',
153+
some_capability: 'some_capability',
154+
unicodeKeyboard: true,
155+
resetKeyboard: true
156+
}
157+
}
158+
}.to_json
159+
160+
stub_request(:post, 'http://127.0.0.1:4723/wd/hub/session')
161+
.to_return(headers: HEADER, status: 200, body: response)
162+
163+
stub_request(:post, "#{SESSION}/timeouts")
164+
.with(body: { implicit: 30_000 }.to_json)
165+
.to_return(headers: HEADER, status: 200, body: { value: nil }.to_json)
166+
167+
driver = @core.start_driver
168+
169+
assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)
170+
assert_requested(:post, "#{SESSION}/timeouts", body: { implicit: 30_000 }.to_json, times: 1)
171+
driver
172+
end
173+
141174
def ios_mock_create_session
142175
response = {
143176
status: 0, # To make bridge.dialect == :oss
@@ -165,5 +198,32 @@ def ios_mock_create_session
165198
assert_requested(:post, "#{SESSION}/timeouts/implicit_wait", times: 1)
166199
driver
167200
end
201+
202+
def ios_mock_create_session_w3c
203+
response = {
204+
value: {
205+
sessionId: '1234567890',
206+
capabilities: {
207+
device: 'iphone',
208+
browserName: 'UICatalog',
209+
sdkVersion: '10.3.1',
210+
CFBundleIdentifier: 'com.example.apple-samplecode.UICatalog'
211+
}
212+
}
213+
}.to_json
214+
215+
stub_request(:post, 'http://127.0.0.1:4723/wd/hub/session')
216+
.to_return(headers: HEADER, status: 200, body: response)
217+
218+
stub_request(:post, "#{SESSION}/timeouts")
219+
.with(body: { implicit: 30_000 }.to_json)
220+
.to_return(headers: HEADER, status: 200, body: { value: nil }.to_json)
221+
222+
driver = @core.start_driver
223+
224+
assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)
225+
assert_requested(:post, "#{SESSION}/timeouts", body: { implicit: 30_000 }.to_json, times: 1)
226+
driver
227+
end
168228
end
169229
end

test/unit/android/device_test.rb

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def setup
1515

1616
def parameterized_method_defined_check(array)
1717
array.each { |v| assert ::Appium::Core::Base::Bridge::MJSONWP.method_defined?(v) }
18-
array.each { |v| assert ::Appium::Core::Base::Bridge::W3C.method_defined?(v) }
1918
end
2019

2120
def test_no_arg_definitions

0 commit comments

Comments
 (0)