Skip to content

Commit 9dfa0b9

Browse files
authored
refactor: replace core directory to core library (#718)
* replace core directory to core library * add recording related command tests * remove source_window * remove current app * remove unused rubocop rule * remove some test code * remove unnecessary tests since they'be already tested in core * remove the core library related tests
1 parent 04a6f45 commit 9dfa0b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+9
-2731
lines changed

android_tests/lib/android/specs/android/helper.rb

-32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# rubocop:disable Metrics/LineLength
2-
31
# rake android[android/helper]
42
describe 'android/helper' do
53
t 'tags' do
@@ -78,34 +76,4 @@ def id_value
7876
t 'ids' do
7977
wait { ids('android:id/text1').length.must_equal 12 }
8078
end
81-
82-
t '_parse_current_app_line' do
83-
# test values from appium's test/unit/adb-specs.js
84-
expected = [
85-
# api 16 line
86-
['mFocusedApp=AppWindowToken{417ee228 token=Token{41602f78 ActivityRecord{41798a08 io.appium.android.apis/.ApiDemos}}}',
87-
'io.appium.android.apis',
88-
'.ApiDemos'],
89-
# api 18 line
90-
['mFocusedApp=AppWindowToken{41744660 token=Token{41ac7198 ActivityRecord{41af55c8 u0 io.appium.android.apis/.ApiDemos}}}',
91-
'io.appium.android.apis',
92-
'.ApiDemos'],
93-
# api 19
94-
['mFocusedApp=AppWindowToken{b40af858 token=Token{b3e2ce38 ActivityRecord{b3eb47d8 u0 io.appium.android.apis/.ApiDemos t6}}}',
95-
'io.appium.android.apis',
96-
'.ApiDemos'],
97-
# api 16 selendroid
98-
['mFocusedApp=AppWindowToken{4157a2c8 token=Token{41582628 ActivityRecord{415821f0 com.android.launcher/com.android.launcher2.Launcher}}}',
99-
'com.android.launcher',
100-
'com.android.launcher2.Launcher']
101-
]
102-
103-
expected.each do |line, package, activity|
104-
parsed = _parse_current_app_line(line)
105-
raise "failed to parse #{line}" if parsed.nil?
106-
parsed.package.must_equal package
107-
parsed.activity.must_equal activity
108-
parsed.am_start.must_equal package + '/' + activity
109-
end
110-
end
11179
end

android_tests/lib/android/specs/common/command.rb

-65
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
# rake android[common/device]
22
describe 'common/device' do
3-
# Not yet implemented
4-
t 'shake' do
5-
# TODO: write test
6-
end
7-
8-
t 'remove & install' do
9-
# TODO: write test
10-
# remove 'com.example.android.apis'
11-
# install ENV['APP_PATH']
12-
end
13-
143
t 'get_performance_data_types' do
154
expected = %w(batteryinfo cpuinfo memoryinfo networkinfo)
165
get_performance_data_types.sort.must_equal expected
@@ -19,26 +8,6 @@
198
data_type: 'cpuinfo').must_equal [%w(user kernel), %w(0 0)]
209
end
2110

22-
t 'device_time' do
23-
Date.parse(device_time)
24-
end
25-
26-
t 'get_system_bars' do
27-
get_system_bars
28-
end
29-
30-
t 'get_display_density' do
31-
(get_display_density > 0).must_equal true
32-
end
33-
34-
t 'system_bars' do
35-
is_keyboard_shown.must_equal false
36-
end
37-
38-
t 'background_app' do
39-
wait { background_app 5 }
40-
end
41-
4211
t 'start_activity' do
4312
wait { current_activity.must_equal '.ApiDemos' }
4413
start_activity app_package: 'io.appium.android.apis',
@@ -55,31 +24,6 @@
5524
wait { current_package.must_equal 'io.appium.android.apis' }
5625
end
5726

58-
t 'installed' do
59-
wait { app_installed?('fake_app').must_equal false }
60-
end
61-
62-
t 'reset' do
63-
reset
64-
wait { text(1).text.must_equal 'API Demos' }
65-
end
66-
67-
t 'device_locked? and unlock' do
68-
lock 5
69-
wait { device_locked?.must_equal true }
70-
unlock
71-
wait { device_locked?.must_equal false }
72-
end
73-
74-
t 'close & launch' do
75-
close_app
76-
launch_app
77-
end
78-
79-
t 'current_activity' do
80-
wait { current_activity.must_equal '.ApiDemos' }
81-
end
82-
8327
t 'app_strings' do
8428
wait_true { app_strings.key? 'activity_save_restore' }
8529
end
@@ -97,69 +41,4 @@ def must_return_element(element)
9741
# http://developer.android.com/reference/android/view/KeyEvent.html
9842
long_press_keycode 176
9943
end
100-
101-
t 'open_notifications' do
102-
# test & comments from https://github.com/appium/appium/blob/master/test/functional/android/apidemos/notifications-specs.js#L19
103-
# get to the notification page
104-
wait { scroll_to('App').click }
105-
wait { scroll_to('Notification').click }
106-
wait { scroll_to('Status Bar').click }
107-
# create a notification
108-
wait { button(':-|').click }
109-
open_notifications
110-
# shouldn't see the elements behind shade
111-
wait_true { !exists { find(':-|') } }
112-
# should see the notification
113-
wait_true { text_exact 'Mood ring' }
114-
# return to app
115-
back
116-
# should be able to see elements from app
117-
wait_true { button(':-|') }
118-
119-
# go back, waiting for each page to load.
120-
# if we go back using 3.times { back }
121-
# then android will flake out and discard some back events
122-
back
123-
wait { text('Status Bar') }
124-
back
125-
wait { text('Notification') }
126-
back
127-
wait { text('App') }
128-
end
129-
130-
t 'push and pull file' do
131-
file = 'A Fine Day'
132-
path = '/data/local/tmp/remote.txt'
133-
wait do
134-
push_file path, file
135-
read_file = pull_file path
136-
read_file.must_equal file
137-
end
138-
end
139-
140-
t 'pull_folder' do
141-
data = pull_folder '/data/local/tmp'
142-
data.length.must_be :>, 100
143-
end
144-
145-
t 'ime_available_engines' do
146-
ime_latin = 'com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME'
147-
148-
wait { find('app').click }
149-
wait { find('Search').click }
150-
wait { find('Invoke Search').click }
151-
152-
imes = ime_available_engines
153-
imes.include?(ime_latin).must_equal true
154-
155-
wait { ime_activate(ime_latin) }
156-
ime_active_engine.must_equal ime_latin
157-
ime_activated.must_equal true
158-
159-
wait { ime_deactivate }
160-
ime_active_engine.wont_equal ime_latin
161-
162-
wait { ime_activate(ime_latin) }
163-
ime_active_engine.must_equal ime_latin
164-
end
16544
end

android_tests/lib/android/specs/common/web_context.rb

-16
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,4 @@ def undo_setcontext_nav
4141

4242
undo_setcontext_nav
4343
end
44-
45-
t 'within_context' do
46-
$driver.within_context 'NATIVE_APP' do
47-
wait { current_context.must_equal 'NATIVE_APP' }
48-
end
49-
end
50-
51-
t 'switch_to_default_context' do
52-
wait do
53-
switch_to_default_context
54-
current_context.must_equal 'NATIVE_APP'
55-
end
56-
57-
wait { set_context 'NATIVE_APP' }
58-
wait { current_context.must_equal 'NATIVE_APP' }
59-
end
6044
end

android_tests/lib/android/specs/driver.rb

-51
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,6 @@ def sauce?
3434
apk_name.must_equal 'api.apk'
3535
end
3636

37-
t 'verify Appium::Core::Base::Capabilities.create_capabilities' do
38-
expected_app = File.absolute_path('../test_apps/api.apk')
39-
caps = ::Appium::Core::Base::Capabilities.create_capabilities(platformName: 'Android',
40-
app: expected_app,
41-
appPackage: 'io.appium.android.apis',
42-
appActivity: 'io.appium.android.apis.ApiDemos',
43-
deviceName: 'Nexus 7',
44-
some_capability: 'some_capability')
45-
caps_with_json = JSON.parse(caps.to_json)
46-
caps_with_json['platformName'].must_equal 'Android'
47-
caps_with_json['app'].must_equal expected_app
48-
caps_with_json['appPackage'].must_equal 'io.appium.android.apis'
49-
caps_with_json['appActivity'].must_equal 'io.appium.android.apis.ApiDemos'
50-
caps_with_json['deviceName'].must_equal 'Nexus 7'
51-
caps_with_json['someCapability'].must_equal 'some_capability'
52-
53-
caps[:platformName].must_equal 'Android'
54-
caps[:app].must_equal expected_app
55-
caps[:appPackage].must_equal 'io.appium.android.apis'
56-
caps[:appActivity].must_equal 'io.appium.android.apis.ApiDemos'
57-
caps[:deviceName].must_equal 'Nexus 7'
58-
caps[:some_capability].must_equal 'some_capability'
59-
end
60-
6137
t 'verify all attributes' do
6238
actual = driver_attributes
6339
caps_app_for_teardown = actual[:caps][:app]
@@ -109,11 +85,6 @@ def sauce?
10985
raise message
11086
end
11187
end
112-
113-
t 'default timeout for http client' do
114-
http_client.open_timeout.must_equal 999_999
115-
http_client.read_timeout.must_equal 999_999
116-
end
11788
end
11889

11990
describe 'Appium::Driver' do
@@ -190,28 +161,6 @@ def validate_path(path)
190161
client_version.must_equal expected
191162
end
192163

193-
# Skip:
194-
# ios_capabilities # save for iOS tests
195-
# absolute_app_path # tested already by starting the driver for this test
196-
# server_url # sauce labs only
197-
198-
t 'set_immediate_value' do
199-
back # To go to top
200-
201-
wait { find('app').click }
202-
wait { find('activity').click }
203-
wait { find('custom title').click }
204-
205-
message = 'hello'
206-
207-
wait do
208-
elem = textfield(1)
209-
elem.clear
210-
set_immediate_value(elem, message)
211-
elem.text.must_equal message
212-
end
213-
end
214-
215164
t 'restart' do
216165
set_wait 1 # ensure wait is 1 before we restart.
217166
restart

appium_lib.gemspec

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ Gem::Specification.new do |s|
1313
s.homepage = 'https://github.com/appium/ruby_lib' # published as appium_lib
1414
s.require_paths = ['lib']
1515

16-
s.add_runtime_dependency 'selenium-webdriver', '~> 3.4', '>= 3.4.1'
17-
s.add_runtime_dependency 'awesome_print', '~> 1.8'
18-
s.add_runtime_dependency 'json', '>= 1.8'
16+
s.add_runtime_dependency 'appium_lib_core', '~> 0.1'
1917
s.add_runtime_dependency 'tomlrb', '~> 1.1'
2018
s.add_runtime_dependency 'nokogiri', '~> 1.6', '>= 1.6.6'
2119

0 commit comments

Comments
 (0)