|
2 | 2 |
|
3 | 3 | # $ rake test:func:ios TEST=test/functional/ios/ios/mobile_commands_test.rb
|
4 | 4 | class AppiumLibCoreTest
|
5 |
| - class MobileCommandsTest < AppiumLibCoreTest::Function::TestCase |
6 |
| - def setup |
7 |
| - @core = ::Appium::Core.for(Caps.ios) |
8 |
| - end |
9 |
| - |
10 |
| - def teardown |
11 |
| - save_reports(@driver) |
12 |
| - end |
13 |
| - |
14 |
| - # @since Appium 1.10.0 |
15 |
| - # Requires simulator |
16 |
| - def test_permission |
17 |
| - caps = Caps.ios.dup |
18 |
| - caps[:caps][:permissions] = '{"com.example.apple-samplecode.UICatalog": { "calendar": "YES", "photos": "no" }}' |
19 |
| - core = ::Appium::Core.for(caps) |
20 |
| - @driver = core.start_driver |
21 |
| - |
22 |
| - assert @driver.execute_script('mobile: getPermission', |
23 |
| - { service: 'calendar', bundleId: 'com.example.apple-samplecode.UICatalog' }) == 'yes' |
24 |
| - assert @driver.execute_script('mobile: getPermission', |
25 |
| - { service: 'photos', bundleId: 'com.example.apple-samplecode.UICatalog' }) == 'no' |
26 |
| - |
27 |
| - @driver.activate_app('com.apple.Preferences') |
28 |
| - @driver.find_element(:accessibility_id, 'Privacy').click |
29 |
| - |
30 |
| - @driver.find_element(:accessibility_id, 'Calendars').click |
31 |
| - el = @driver.find_element(:accessibility_id, 'UICatalog') |
32 |
| - assert_equal '1', el.value |
33 |
| - |
34 |
| - @driver.back |
35 |
| - |
36 |
| - @driver.find_element(:accessibility_id, 'Photos').click |
37 |
| - el = @driver.find_element(:accessibility_id, 'Never') |
38 |
| - assert_equal 'Never', el.value |
39 |
| - 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? |
| 5 | + module Ios |
| 6 | + class MobileCommandsTest < AppiumLibCoreTest::Function::TestCase |
| 7 | + def setup |
| 8 | + @core = ::Appium::Core.for(Caps.ios) |
| 9 | + end |
| 10 | + |
| 11 | + def teardown |
| 12 | + save_reports(@driver) |
| 13 | + end |
| 14 | + |
| 15 | + # @since Appium 1.10.0 |
| 16 | + # Requires simulator |
| 17 | + def test_permission |
| 18 | + caps = Caps.ios.dup |
| 19 | + caps[:caps][:permissions] = '{"com.example.apple-samplecode.UICatalog": { "calendar": "YES", "photos": "no" }}' |
| 20 | + core = ::Appium::Core.for(caps) |
| 21 | + @driver = core.start_driver |
| 22 | + |
| 23 | + assert @driver.execute_script('mobile: getPermission', |
| 24 | + { service: 'calendar', bundleId: 'com.example.apple-samplecode.UICatalog' }) == 'yes' |
| 25 | + assert @driver.execute_script('mobile: getPermission', |
| 26 | + { service: 'photos', bundleId: 'com.example.apple-samplecode.UICatalog' }) == 'no' |
| 27 | + |
| 28 | + @driver.activate_app('com.apple.Preferences') |
| 29 | + @driver.find_element(:accessibility_id, 'Privacy').click |
| 30 | + |
| 31 | + @driver.find_element(:accessibility_id, 'Calendars').click |
| 32 | + el = @driver.find_element(:accessibility_id, 'UICatalog') |
| 33 | + assert_equal '1', el.value |
| 34 | + |
| 35 | + @driver.back |
| 36 | + |
| 37 | + @driver.find_element(:accessibility_id, 'Photos').click |
| 38 | + el = @driver.find_element(:accessibility_id, 'Never') |
| 39 | + assert_equal 'Never', el.value |
| 40 | + end |
| 41 | + |
| 42 | + # @since Appium 1.10.0 |
| 43 | + def test_siri |
| 44 | + @driver = @core.start_driver |
| 45 | + assert @driver.app_state('com.example.apple-samplecode.UICatalog') == :running_in_foreground |
| 46 | + siri_state = @driver.app_state('com.apple.SiriViewService') |
| 47 | + assert [:running_in_background_suspended, :not_running].include? siri_state |
| 48 | + |
| 49 | + @driver.execute_script 'mobile: activateSiri', { text: 'hello, siri' } |
| 50 | + |
| 51 | + e = @driver.find_element :accessibility_id, 'hello, siri' |
| 52 | + assert_equal 'hello, siri', e.text |
| 53 | + |
| 54 | + assert_equal :running_in_foreground, @driver.app_state('com.example.apple-samplecode.UICatalog') |
| 55 | + assert @driver.app_state('com.apple.SiriViewService') == :running_in_background |
| 56 | + |
| 57 | + @driver.activate_app 'com.example.apple-samplecode.UICatalog' |
| 58 | + sleep 1 # wait a bit for switching siri service with the test target app |
| 59 | + assert_equal :running_in_background_suspended, @driver.app_state('com.apple.SiriViewService') |
| 60 | + end |
| 61 | + |
| 62 | + def test_source |
| 63 | + @driver = @core.start_driver |
| 64 | + |
| 65 | + json = @driver.execute_script 'mobile: source', { format: :json } |
| 66 | + xml = @driver.execute_script 'mobile: source', { format: :xml } |
| 67 | + |
| 68 | + assert !json.empty? |
| 69 | + assert !xml.empty? |
| 70 | + end |
69 | 71 | end
|
70 | 72 | end
|
71 | 73 | end
|
0 commit comments