Skip to content

Commit 44a0fff

Browse files
authored
add siri func test for mobile command (#167)
* add siri func test for mobile command * tweak siri test * fix rubocop
1 parent b821556 commit 44a0fff

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

test/functional/ios/ios/mobile_commands_test.rb

+35-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
# $ rake test:func:ios TEST=test/functional/ios/ios/mobile_commands_test.rb
44
class AppiumLibCoreTest
5-
class DriverTest < AppiumLibCoreTest::Function::TestCase
5+
class MobileCommandsTest < AppiumLibCoreTest::Function::TestCase
6+
def setup
7+
@core = ::Appium::Core.for(Caps.ios)
8+
end
9+
610
def teardown
711
save_reports(@driver)
812
end
@@ -33,5 +37,35 @@ def test_permission
3337
el = @driver.find_element(:accessibility_id, 'Never')
3438
assert_equal 'Never', el.value
3539
end
40+
41+
# @since Appium 1.10.0
42+
def test_siri
43+
@driver = @core.start_driver
44+
assert @driver.app_state('com.example.apple-samplecode.UICatalog') == :running_in_foreground
45+
siri_state = @driver.app_state('com.apple.SiriViewService')
46+
assert [:running_in_background_suspended, :not_running].include? siri_state
47+
48+
@driver.execute_script 'mobile: activateSiri', { text: 'hello, siri' }
49+
50+
e = @driver.find_element :accessibility_id, 'hello, siri'
51+
assert_equal 'hello, siri', e.text
52+
53+
assert_equal :running_in_foreground, @driver.app_state('com.example.apple-samplecode.UICatalog')
54+
assert @driver.app_state('com.apple.SiriViewService') == :running_in_background
55+
56+
@driver.activate_app 'com.example.apple-samplecode.UICatalog'
57+
sleep 1 # wait a bit for switching siri service with the test target app
58+
assert_equal :running_in_background_suspended, @driver.app_state('com.apple.SiriViewService')
59+
end
60+
61+
def test_source
62+
@driver = @core.start_driver
63+
64+
json = @driver.execute_script 'mobile: source', { format: :json }
65+
xml = @driver.execute_script 'mobile: source', { format: :xml }
66+
67+
assert !json.empty?
68+
assert !xml.empty?
69+
end
3670
end
3771
end

0 commit comments

Comments
 (0)