Skip to content

Commit 48a53f2

Browse files
authored
Add test wda attachment (#207)
* add todo * add skip for open notifications in espresso driver * add wda attachment test * revert auto udid
1 parent 2d8a8f3 commit 48a53f2

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

test/functional/android/android/device_test.rb

+2
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ def test_long_press_keycode
310310
end
311311

312312
def test_open_notifications
313+
skip unless @@core.automation_name == :espresso
314+
313315
# test & comments from https://github.com/appium/appium/blob/master/test/functional/android/apidemos/notifications-specs.js#L19
314316
# get to the notification page
315317
@@core.wait { scroll_to('App').click }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 'test_helper'
16+
require 'base64'
17+
18+
# $ rake test:func:ios TEST=test/functional/ios/ios/device_wda_attachment_test.rb
19+
class AppiumLibCoreTest
20+
module Ios
21+
class DeviceWDAAttachmentTest < AppiumLibCoreTest::Function::TestCase
22+
def setup
23+
# will add test ad an attachment
24+
ios_caps = Caps.ios.dup
25+
ios_caps[:caps][:useNewWDA] = true
26+
@core = ::Appium::Core.for(ios_caps)
27+
@driver = @core.start_driver
28+
end
29+
30+
def teardown
31+
save_reports(@driver)
32+
end
33+
34+
def test_localhost_wda_agent_url
35+
status = JSON.parse(Net::HTTP.get('localhost', '/status', @core.caps[:wdaLocalPort]))['value']
36+
37+
# Run with webDriverAgentUrl
38+
current_host = status['ios']['ip']
39+
current_port = @core.caps[:wdaLocalPort]
40+
41+
new_ios_caps = Caps.ios.dup
42+
new_ios_caps[:caps][:useNewWDA] = false
43+
new_ios_caps[:caps][:webDriverAgentUrl] = "http://#{current_host}:#{current_port}"
44+
new_ios_caps[:caps].delete :wdaLocalPort
45+
new_ios_caps[:caps].delete :derivedDataPath
46+
new_ios_caps[:caps].delete :bootstrapPath
47+
new_ios_caps[:caps].delete :useXctestrunFile
48+
49+
new_core = ::Appium::Core.for(new_ios_caps)
50+
@driver = new_core.start_driver
51+
# Make sure if the driver works
52+
assert @driver.remote_status
53+
54+
@driver.quit
55+
# WDA should not stop by `quit` if `webDriverAgentUrl` exists
56+
assert_equal status, JSON.parse(Net::HTTP.get(current_host, '/status', current_port))['value']
57+
58+
# Create the original driver again
59+
@driver = @core.start_driver
60+
status = JSON.parse(Net::HTTP.get('localhost', '/status', @core.caps[:wdaLocalPort]))['value']
61+
current_host = status['ios']['ip']
62+
current_port = @core.caps[:wdaLocalPort]
63+
64+
@driver.quit
65+
66+
# WDA should stop
67+
assert_raises Errno::ECONNREFUSED do
68+
JSON.parse(Net::HTTP.get(current_host, '/status', current_port))['value']
69+
end
70+
end
71+
end
72+
end
73+
end

0 commit comments

Comments
 (0)