From 7aff5a1b8c935d1868f62144beca8b02a854e5d6 Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Sat, 25 Aug 2018 12:25:51 +0900 Subject: [PATCH 1/4] get rid of target --- README.md | 2 +- lib/appium_lib_core/common/base/bridge.rb | 4 +-- .../common/touch_action/multi_touch.rb | 2 +- .../common/touch_action/touch_actions.rb | 2 +- lib/appium_lib_core/driver.rb | 26 +++++++++---------- .../functional/android/android/device_test.rb | 2 +- .../android/android/search_context_test.rb | 2 +- test/functional/android/driver_test.rb | 2 +- test/functional/android/patch_test.rb | 2 +- .../android/webdriver/create_session_test.rb | 6 ++--- .../android/webdriver/device_test.rb | 2 +- .../android/webdriver/w3c_actions_test.rb | 2 +- test/functional/ios/driver_test.rb | 2 +- test/functional/ios/ios/device_test.rb | 2 +- .../functional/ios/ios/search_context_test.rb | 2 +- test/functional/ios/patch_test.rb | 2 +- .../ios/webdriver/create_session_test.rb | 6 ++--- test/functional/ios/webdriver/device_test.rb | 2 +- .../ios/webdriver/w3c_actions_test.rb | 2 +- .../device/mjsonwp/app_management_test.rb | 2 +- .../android/device/mjsonwp/commands_test.rb | 2 +- .../android/device/mjsonwp/contexts_test.rb | 2 +- .../android/device/mjsonwp/definition_test.rb | 2 +- .../device/mjsonwp/device_lock_test.rb | 2 +- .../device/mjsonwp/image_comparison_test.rb | 2 +- .../device/mjsonwp/ime_actions_test.rb | 2 +- .../android/device/mjsonwp/keyboard_test.rb | 2 +- .../android/device/mjsonwp/screenshot_test.rb | 2 +- .../android/device/w3c/app_management_test.rb | 2 +- test/unit/android/device/w3c/commands_test.rb | 2 +- test/unit/android/device/w3c/contexts_test.rb | 2 +- .../android/device/w3c/definition_test.rb | 2 +- .../android/device/w3c/device_lock_test.rb | 2 +- .../device/w3c/image_comparison_test.rb | 2 +- .../android/device/w3c/ime_actions_test.rb | 2 +- test/unit/android/device/w3c/keyboard_test.rb | 2 +- .../android/device/w3c/screenshot_test.rb | 2 +- .../android/webdriver/mjsonwp/alerts_test.rb | 2 +- .../webdriver/mjsonwp/commands_test.rb | 2 +- .../webdriver/mjsonwp/timeouts_test.rb | 2 +- .../android/webdriver/w3c/actions_test.rb | 2 +- .../unit/android/webdriver/w3c/alerts_test.rb | 2 +- .../android/webdriver/w3c/commands_test.rb | 2 +- .../android/webdriver/w3c/timeouts_test.rb | 2 +- test/unit/common/element_test.rb | 2 +- test/unit/common_test.rb | 10 +++---- test/unit/driver_test.rb | 4 +-- test/unit/image_element_test.rb | 2 +- test/unit/ios/device/mjsonwp/commands_test.rb | 2 +- .../ios/device/mjsonwp/definition_test.rb | 2 +- test/unit/ios/device/w3c/commands_test.rb | 2 +- test/unit/ios/device/w3c/definition_test.rb | 2 +- 52 files changed, 74 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index 644da8c8..d888ffb1 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ opts = { wait: 30 } } -@core = Appium::Core.for(self, opts) # create a core driver with `opts` and extend methods into `self` +@core = Appium::Core.for(opts) # create a core driver with `opts` @driver = @core.start_driver # Launch iPhone Simulator and `MyiOS.app` diff --git a/lib/appium_lib_core/common/base/bridge.rb b/lib/appium_lib_core/common/base/bridge.rb index 024c098f..e2af5a64 100644 --- a/lib/appium_lib_core/common/base/bridge.rb +++ b/lib/appium_lib_core/common/base/bridge.rb @@ -67,7 +67,7 @@ def self.handshake(**opts) # wait: 30 # } # } - # core = ::Appium::Core.for(self, caps) + # core = ::Appium::Core.for(caps) # driver = core.start_driver #=> driver.dialect == :oss # # @example @@ -85,7 +85,7 @@ def self.handshake(**opts) # wait: 30 # } # } - # core = ::Appium::Core.for(self, caps) + # core = ::Appium::Core.for(caps) # driver = core.start_driver #=> driver.dialect == :w3c if the Appium server support W3C. # def create_session(desired_capabilities) diff --git a/lib/appium_lib_core/common/touch_action/multi_touch.rb b/lib/appium_lib_core/common/touch_action/multi_touch.rb index 1ea29787..e88a46a3 100644 --- a/lib/appium_lib_core/common/touch_action/multi_touch.rb +++ b/lib/appium_lib_core/common/touch_action/multi_touch.rb @@ -9,7 +9,7 @@ module Core # # @example # - # @driver = Appium::Core.for(self, opts).start_driver + # @driver = Appium::Core.for(opts).start_driver # action_1 = TouchAction.new(@driver).press(x: 45, y: 100).wait(5).release # action_2 = TouchAction.new(@driver).tap(element: el, x: 50, y:5, count: 3) # diff --git a/lib/appium_lib_core/common/touch_action/touch_actions.rb b/lib/appium_lib_core/common/touch_action/touch_actions.rb index 099ff581..bbdc45a7 100644 --- a/lib/appium_lib_core/common/touch_action/touch_actions.rb +++ b/lib/appium_lib_core/common/touch_action/touch_actions.rb @@ -12,7 +12,7 @@ module Core # # @example # - # @driver = Appium::Core.for(self, opts).start_driver + # @driver = Appium::Core.for(opts).start_driver # action = TouchAction.new(@driver).press(x: 45, y: 100).wait(5).release # action.perform # action = TouchAction.new(@driver).swipe(....) diff --git a/lib/appium_lib_core/driver.rb b/lib/appium_lib_core/driver.rb index 5aef6046..1a835e43 100644 --- a/lib/appium_lib_core/driver.rb +++ b/lib/appium_lib_core/driver.rb @@ -103,7 +103,7 @@ class Driver # listener: nil, # } # } - # @core = Appium::Core.for(self, opts) # create a core driver with `opts` and extend methods into `self` + # @core = Appium::Core.for(opts) # create a core driver with `opts` and extend methods into `self` # @core.start_driver(server_url: server_url) # start driver # # # Start iOS driver with .zip file over HTTP @@ -125,11 +125,11 @@ class Driver # listener: nil, # } # } - # @core = Appium::Core.for(self, opts) + # @core = Appium::Core.for(opts) # @core.start_driver(server_url: server_url) # - def self.for(target, opts = {}) - new(target, opts) + def self.for(opts = {}) + new(opts) end # @private @@ -139,8 +139,8 @@ def self.for(target, opts = {}) end # @private - def initialize(target, opts = {}) - @delegate_target = target # for testing purpose + def initialize(opts = {}) + @delegate_target = self # for testing purpose opts = Appium.symbolize_keys opts validate_keys(opts) @@ -152,7 +152,7 @@ def initialize(target, opts = {}) set_appium_device set_automation_name - extend_for(device: @device, automation_name: @automation_name, target: target) + extend_for(device: @device, automation_name: @automation_name) self # rubocop:disable Lint/Void end @@ -190,8 +190,8 @@ def initialize(target, opts = {}) # } # } # - # @core = Appium::Core.for(self, opts) # create a core driver with `opts` and extend methods into `self` - # @driver = @core.start_driver + # @core = Appium::Core.for(opts) # create a core driver with `opts` and extend methods into `self` + # @driver = @core.start_driver server_url: "http://127.0.0.1:8000/wd/hub" # def start_driver(server_url: nil, @@ -318,9 +318,9 @@ def screenshot(png_save_path) private # @private - def extend_for(device:, automation_name:, target:) - target.extend Appium::Core - target.extend Appium::Core::Device + def extend_for(device:, automation_name:) + self.extend Appium::Core + self.extend Appium::Core::Device case device when :android @@ -352,7 +352,7 @@ def extend_for(device:, automation_name:, target:) Appium::Logger.warn('no device matched') end - target + self end # @private diff --git a/test/functional/android/android/device_test.rb b/test/functional/android/android/device_test.rb index c2a8c55c..02e363bb 100644 --- a/test/functional/android/android/device_test.rb +++ b/test/functional/android/android/device_test.rb @@ -6,7 +6,7 @@ class AppiumLibCoreTest module Android class DeviceTest < AppiumLibCoreTest::Function::TestCase def setup - @@core ||= ::Appium::Core.for(self, Caps.android) + @@core ||= ::Appium::Core.for(Caps.android) @driver = @@core.start_driver end diff --git a/test/functional/android/android/search_context_test.rb b/test/functional/android/android/search_context_test.rb index 1193bb65..6bc2b6a9 100644 --- a/test/functional/android/android/search_context_test.rb +++ b/test/functional/android/android/search_context_test.rb @@ -6,7 +6,7 @@ class AppiumLibCoreTest module Android class SearchContextTest < AppiumLibCoreTest::Function::TestCase def setup - @@core ||= ::Appium::Core.for(self, Caps.android) + @@core ||= ::Appium::Core.for(Caps.android) @driver = @@core.start_driver end diff --git a/test/functional/android/driver_test.rb b/test/functional/android/driver_test.rb index 252f817d..c62cbdb4 100644 --- a/test/functional/android/driver_test.rb +++ b/test/functional/android/driver_test.rb @@ -5,7 +5,7 @@ class AppiumLibCoreTest class DriverTest < AppiumLibCoreTest::Function::TestCase def setup - @@core ||= ::Appium::Core.for(self, Caps.android) + @@core ||= ::Appium::Core.for(Caps.android) @driver = @@core.start_driver end diff --git a/test/functional/android/patch_test.rb b/test/functional/android/patch_test.rb index b9e7ec9f..4771f738 100644 --- a/test/functional/android/patch_test.rb +++ b/test/functional/android/patch_test.rb @@ -5,7 +5,7 @@ class AppiumLibCoreTest class PathTest < AppiumLibCoreTest::Function::TestCase def setup - @@core ||= ::Appium::Core.for(self, Caps.android) + @@core ||= ::Appium::Core.for(Caps.android) @driver = @@core.start_driver end diff --git a/test/functional/android/webdriver/create_session_test.rb b/test/functional/android/webdriver/create_session_test.rb index cd1b5a59..b404406d 100644 --- a/test/functional/android/webdriver/create_session_test.rb +++ b/test/functional/android/webdriver/create_session_test.rb @@ -7,7 +7,7 @@ class CreateSessionTestTest < AppiumLibCoreTest::Function::TestCase def test_mjsonwp caps = Caps.android[:caps].merge({ forceMjsonwp: true }) new_caps = Caps.android.merge({ caps: caps }) - core = ::Appium::Core.for(self, new_caps) + core = ::Appium::Core.for(new_caps) driver = core.start_driver @@ -20,7 +20,7 @@ def test_mjsonwp def test_w3c caps = Caps.android[:caps].merge({ forceMjsonwp: false }) new_caps = Caps.android.merge({ caps: caps }) - core = ::Appium::Core.for(self, new_caps) + core = ::Appium::Core.for(new_caps) driver = core.start_driver @@ -32,7 +32,7 @@ def test_w3c # Require Appium 1.7.2+ def test_w3c_default caps = Caps.android - core = ::Appium::Core.for(self, caps) + core = ::Appium::Core.for(caps) driver = core.start_driver diff --git a/test/functional/android/webdriver/device_test.rb b/test/functional/android/webdriver/device_test.rb index d3abdbaa..8aa84141 100644 --- a/test/functional/android/webdriver/device_test.rb +++ b/test/functional/android/webdriver/device_test.rb @@ -6,7 +6,7 @@ class AppiumLibCoreTest module WebDriver class DeviceTest < AppiumLibCoreTest::Function::TestCase def setup - @@core ||= ::Appium::Core.for(self, Caps.android) + @@core ||= ::Appium::Core.for(Caps.android) @driver = @@core.start_driver end diff --git a/test/functional/android/webdriver/w3c_actions_test.rb b/test/functional/android/webdriver/w3c_actions_test.rb index 49d9c9c0..f8712556 100644 --- a/test/functional/android/webdriver/w3c_actions_test.rb +++ b/test/functional/android/webdriver/w3c_actions_test.rb @@ -6,7 +6,7 @@ class AppiumLibCoreTest module WebDriver class W3CActionsTest < AppiumLibCoreTest::Function::TestCase def setup - @@core ||= ::Appium::Core.for(self, Caps.android) + @@core ||= ::Appium::Core.for(Caps.android) @driver = @@core.start_driver end diff --git a/test/functional/ios/driver_test.rb b/test/functional/ios/driver_test.rb index 81a020e3..74d31771 100644 --- a/test/functional/ios/driver_test.rb +++ b/test/functional/ios/driver_test.rb @@ -5,7 +5,7 @@ class AppiumLibCoreTest class DriverTest < AppiumLibCoreTest::Function::TestCase def setup - @@core ||= ::Appium::Core.for(self, Caps.ios) + @@core ||= ::Appium::Core.for(Caps.ios) @@driver ||= @@core.start_driver end diff --git a/test/functional/ios/ios/device_test.rb b/test/functional/ios/ios/device_test.rb index 594dfdd5..344f0133 100644 --- a/test/functional/ios/ios/device_test.rb +++ b/test/functional/ios/ios/device_test.rb @@ -7,7 +7,7 @@ class AppiumLibCoreTest module Ios class DeviceTest < AppiumLibCoreTest::Function::TestCase def setup - @@core ||= ::Appium::Core.for(self, Caps.ios) + @@core ||= ::Appium::Core.for(Caps.ios) @@driver ||= @@core.start_driver end diff --git a/test/functional/ios/ios/search_context_test.rb b/test/functional/ios/ios/search_context_test.rb index 43ba1528..3eb816de 100644 --- a/test/functional/ios/ios/search_context_test.rb +++ b/test/functional/ios/ios/search_context_test.rb @@ -6,7 +6,7 @@ class AppiumLibCoreTest module Ios class SearchContextTest < AppiumLibCoreTest::Function::TestCase def setup - @@core ||= ::Appium::Core.for(self, Caps.ios) + @@core ||= ::Appium::Core.for(Caps.ios) @@driver ||= @@core.start_driver end diff --git a/test/functional/ios/patch_test.rb b/test/functional/ios/patch_test.rb index b4c3b528..38e78f4f 100644 --- a/test/functional/ios/patch_test.rb +++ b/test/functional/ios/patch_test.rb @@ -5,7 +5,7 @@ class AppiumLibCoreTest class PathTest < AppiumLibCoreTest::Function::TestCase def setup - @@core ||= ::Appium::Core.for(self, Caps.ios) + @@core ||= ::Appium::Core.for(Caps.ios) @@driver ||= @@core.start_driver end diff --git a/test/functional/ios/webdriver/create_session_test.rb b/test/functional/ios/webdriver/create_session_test.rb index 38192cd1..b696cf80 100644 --- a/test/functional/ios/webdriver/create_session_test.rb +++ b/test/functional/ios/webdriver/create_session_test.rb @@ -7,7 +7,7 @@ class CreateSessionTestTest < AppiumLibCoreTest::Function::TestCase def test_mjsonwp caps = Caps.ios[:caps].merge({ forceMjsonwp: true }) new_caps = Caps.ios.merge({ caps: caps }) - core = ::Appium::Core.for(self, new_caps) + core = ::Appium::Core.for(new_caps) driver = core.start_driver @@ -20,7 +20,7 @@ def test_mjsonwp def test_w3c caps = Caps.ios[:caps].merge({ forceMjsonwp: false }) new_caps = Caps.ios.merge({ caps: caps }) - core = ::Appium::Core.for(self, new_caps) + core = ::Appium::Core.for(new_caps) driver = core.start_driver @@ -32,7 +32,7 @@ def test_w3c # Require Appium 1.7.2+ def test_w3c_default caps = Caps.ios - core = ::Appium::Core.for(self, caps) + core = ::Appium::Core.for(caps) driver = core.start_driver diff --git a/test/functional/ios/webdriver/device_test.rb b/test/functional/ios/webdriver/device_test.rb index 791950ed..0ca56655 100644 --- a/test/functional/ios/webdriver/device_test.rb +++ b/test/functional/ios/webdriver/device_test.rb @@ -6,7 +6,7 @@ class AppiumLibCoreTest module WebDriver class DeviceTest < AppiumLibCoreTest::Function::TestCase def setup - @@core ||= ::Appium::Core.for(self, Caps.ios) + @@core ||= ::Appium::Core.for(Caps.ios) @@driver ||= @@core.start_driver end diff --git a/test/functional/ios/webdriver/w3c_actions_test.rb b/test/functional/ios/webdriver/w3c_actions_test.rb index 2624c379..ca5ec2e5 100644 --- a/test/functional/ios/webdriver/w3c_actions_test.rb +++ b/test/functional/ios/webdriver/w3c_actions_test.rb @@ -6,7 +6,7 @@ class AppiumLibCoreTest module WebDriver class W3CActionsTest < AppiumLibCoreTest::Function::TestCase def setup - @@core ||= ::Appium::Core.for(self, Caps.ios) + @@core ||= ::Appium::Core.for(Caps.ios) @@driver ||= @@core.start_driver end diff --git a/test/unit/android/device/mjsonwp/app_management_test.rb b/test/unit/android/device/mjsonwp/app_management_test.rb index 82dd7d95..36b2000f 100644 --- a/test/unit/android/device/mjsonwp/app_management_test.rb +++ b/test/unit/android/device/mjsonwp/app_management_test.rb @@ -11,7 +11,7 @@ class AppManagementTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session end diff --git a/test/unit/android/device/mjsonwp/commands_test.rb b/test/unit/android/device/mjsonwp/commands_test.rb index ce1baf4c..890f36ef 100644 --- a/test/unit/android/device/mjsonwp/commands_test.rb +++ b/test/unit/android/device/mjsonwp/commands_test.rb @@ -11,7 +11,7 @@ class CommandsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session end diff --git a/test/unit/android/device/mjsonwp/contexts_test.rb b/test/unit/android/device/mjsonwp/contexts_test.rb index 7876392c..7e547ad7 100644 --- a/test/unit/android/device/mjsonwp/contexts_test.rb +++ b/test/unit/android/device/mjsonwp/contexts_test.rb @@ -11,7 +11,7 @@ class ContextsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session end diff --git a/test/unit/android/device/mjsonwp/definition_test.rb b/test/unit/android/device/mjsonwp/definition_test.rb index c1495950..10e2e5ac 100644 --- a/test/unit/android/device/mjsonwp/definition_test.rb +++ b/test/unit/android/device/mjsonwp/definition_test.rb @@ -10,7 +10,7 @@ class DefinitionTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session end diff --git a/test/unit/android/device/mjsonwp/device_lock_test.rb b/test/unit/android/device/mjsonwp/device_lock_test.rb index 2c39a80b..44c96211 100644 --- a/test/unit/android/device/mjsonwp/device_lock_test.rb +++ b/test/unit/android/device/mjsonwp/device_lock_test.rb @@ -11,7 +11,7 @@ class DeviceLockTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session end diff --git a/test/unit/android/device/mjsonwp/image_comparison_test.rb b/test/unit/android/device/mjsonwp/image_comparison_test.rb index f89a9a59..36550326 100644 --- a/test/unit/android/device/mjsonwp/image_comparison_test.rb +++ b/test/unit/android/device/mjsonwp/image_comparison_test.rb @@ -11,7 +11,7 @@ class CommandsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session end diff --git a/test/unit/android/device/mjsonwp/ime_actions_test.rb b/test/unit/android/device/mjsonwp/ime_actions_test.rb index d3e0baa6..dfcdf43e 100644 --- a/test/unit/android/device/mjsonwp/ime_actions_test.rb +++ b/test/unit/android/device/mjsonwp/ime_actions_test.rb @@ -11,7 +11,7 @@ class ImeActionsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session end diff --git a/test/unit/android/device/mjsonwp/keyboard_test.rb b/test/unit/android/device/mjsonwp/keyboard_test.rb index 278e01c2..a05158de 100644 --- a/test/unit/android/device/mjsonwp/keyboard_test.rb +++ b/test/unit/android/device/mjsonwp/keyboard_test.rb @@ -11,7 +11,7 @@ class KeyboardTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session end diff --git a/test/unit/android/device/mjsonwp/screenshot_test.rb b/test/unit/android/device/mjsonwp/screenshot_test.rb index b951e2c9..724a4412 100644 --- a/test/unit/android/device/mjsonwp/screenshot_test.rb +++ b/test/unit/android/device/mjsonwp/screenshot_test.rb @@ -11,7 +11,7 @@ class ScreenshotTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session end diff --git a/test/unit/android/device/w3c/app_management_test.rb b/test/unit/android/device/w3c/app_management_test.rb index ebccfc16..6daf8e3e 100644 --- a/test/unit/android/device/w3c/app_management_test.rb +++ b/test/unit/android/device/w3c/app_management_test.rb @@ -10,7 +10,7 @@ class AppManagementTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/android/device/w3c/commands_test.rb b/test/unit/android/device/w3c/commands_test.rb index 2bc10381..26bde3a2 100644 --- a/test/unit/android/device/w3c/commands_test.rb +++ b/test/unit/android/device/w3c/commands_test.rb @@ -10,7 +10,7 @@ class CommandsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/android/device/w3c/contexts_test.rb b/test/unit/android/device/w3c/contexts_test.rb index 17ec9d70..0dddb7c1 100644 --- a/test/unit/android/device/w3c/contexts_test.rb +++ b/test/unit/android/device/w3c/contexts_test.rb @@ -10,7 +10,7 @@ class ContextsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/android/device/w3c/definition_test.rb b/test/unit/android/device/w3c/definition_test.rb index f0e03384..b1be23d0 100644 --- a/test/unit/android/device/w3c/definition_test.rb +++ b/test/unit/android/device/w3c/definition_test.rb @@ -10,7 +10,7 @@ class DefinitionTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/android/device/w3c/device_lock_test.rb b/test/unit/android/device/w3c/device_lock_test.rb index a46be9cf..7803d870 100644 --- a/test/unit/android/device/w3c/device_lock_test.rb +++ b/test/unit/android/device/w3c/device_lock_test.rb @@ -10,7 +10,7 @@ class DeviceLockTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/android/device/w3c/image_comparison_test.rb b/test/unit/android/device/w3c/image_comparison_test.rb index aea81ada..472f858e 100644 --- a/test/unit/android/device/w3c/image_comparison_test.rb +++ b/test/unit/android/device/w3c/image_comparison_test.rb @@ -10,7 +10,7 @@ class ImageComparisonTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/android/device/w3c/ime_actions_test.rb b/test/unit/android/device/w3c/ime_actions_test.rb index cce9f3bb..5e4b6db0 100644 --- a/test/unit/android/device/w3c/ime_actions_test.rb +++ b/test/unit/android/device/w3c/ime_actions_test.rb @@ -10,7 +10,7 @@ class ImeActionsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/android/device/w3c/keyboard_test.rb b/test/unit/android/device/w3c/keyboard_test.rb index 303c9c4e..bad1c0ac 100644 --- a/test/unit/android/device/w3c/keyboard_test.rb +++ b/test/unit/android/device/w3c/keyboard_test.rb @@ -10,7 +10,7 @@ class KeyboardTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/android/device/w3c/screenshot_test.rb b/test/unit/android/device/w3c/screenshot_test.rb index c67ee2c4..c37b4c34 100644 --- a/test/unit/android/device/w3c/screenshot_test.rb +++ b/test/unit/android/device/w3c/screenshot_test.rb @@ -10,7 +10,7 @@ class ScreenshotTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/android/webdriver/mjsonwp/alerts_test.rb b/test/unit/android/webdriver/mjsonwp/alerts_test.rb index 1cf38a07..1e6c14c8 100644 --- a/test/unit/android/webdriver/mjsonwp/alerts_test.rb +++ b/test/unit/android/webdriver/mjsonwp/alerts_test.rb @@ -10,7 +10,7 @@ class AlertsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session end diff --git a/test/unit/android/webdriver/mjsonwp/commands_test.rb b/test/unit/android/webdriver/mjsonwp/commands_test.rb index 43033485..3c78c550 100644 --- a/test/unit/android/webdriver/mjsonwp/commands_test.rb +++ b/test/unit/android/webdriver/mjsonwp/commands_test.rb @@ -10,7 +10,7 @@ class CommandsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session end diff --git a/test/unit/android/webdriver/mjsonwp/timeouts_test.rb b/test/unit/android/webdriver/mjsonwp/timeouts_test.rb index 3504d31c..671e429a 100644 --- a/test/unit/android/webdriver/mjsonwp/timeouts_test.rb +++ b/test/unit/android/webdriver/mjsonwp/timeouts_test.rb @@ -10,7 +10,7 @@ class TimeoutsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session end diff --git a/test/unit/android/webdriver/w3c/actions_test.rb b/test/unit/android/webdriver/w3c/actions_test.rb index 979a1ddd..e14f7073 100644 --- a/test/unit/android/webdriver/w3c/actions_test.rb +++ b/test/unit/android/webdriver/w3c/actions_test.rb @@ -10,7 +10,7 @@ class ActionsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/android/webdriver/w3c/alerts_test.rb b/test/unit/android/webdriver/w3c/alerts_test.rb index 9f34c584..d12e1a50 100644 --- a/test/unit/android/webdriver/w3c/alerts_test.rb +++ b/test/unit/android/webdriver/w3c/alerts_test.rb @@ -10,7 +10,7 @@ class AlertsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/android/webdriver/w3c/commands_test.rb b/test/unit/android/webdriver/w3c/commands_test.rb index d9fbfd4b..63376084 100644 --- a/test/unit/android/webdriver/w3c/commands_test.rb +++ b/test/unit/android/webdriver/w3c/commands_test.rb @@ -10,7 +10,7 @@ class CommandsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/android/webdriver/w3c/timeouts_test.rb b/test/unit/android/webdriver/w3c/timeouts_test.rb index 1a66fb01..8f3e9472 100644 --- a/test/unit/android/webdriver/w3c/timeouts_test.rb +++ b/test/unit/android/webdriver/w3c/timeouts_test.rb @@ -10,7 +10,7 @@ class TimeoutsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/common/element_test.rb b/test/unit/common/element_test.rb index 6a7740c9..1d589124 100644 --- a/test/unit/common/element_test.rb +++ b/test/unit/common/element_test.rb @@ -7,7 +7,7 @@ class ElementTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) @driver ||= android_mock_create_session_w3c end diff --git a/test/unit/common_test.rb b/test/unit/common_test.rb index 024ad60c..5b46ca76 100644 --- a/test/unit/common_test.rb +++ b/test/unit/common_test.rb @@ -55,7 +55,7 @@ def test_create_session_force_mjsonwp .with(body: { ms: 20_000 }.to_json) .to_return(headers: Mock::HEADER, status: 200, body: { value: nil }.to_json) - driver = ::Appium::Core.for(self, { caps: CAPS.merge({ forceMjsonwp: true }), appium_lib: {} }).start_driver + driver = ::Appium::Core.for({ caps: CAPS.merge({ forceMjsonwp: true }), appium_lib: {} }).start_driver assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1) assert_requested(:post, "#{Mock::SESSION}/timeouts/implicit_wait", body: { ms: 20_000 }.to_json, times: 1) @@ -74,7 +74,7 @@ def test_create_session_force_mjsonwp_false .with(body: { implicit: 20_000 }.to_json) .to_return(headers: Mock::HEADER, status: 200, body: { value: nil }.to_json) - driver = ::Appium::Core.for(self, { caps: CAPS.merge({ forceMjsonwp: false }), appium_lib: {} }).start_driver + driver = ::Appium::Core.for({ caps: CAPS.merge({ forceMjsonwp: false }), appium_lib: {} }).start_driver assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1) assert_requested(:post, "#{Mock::SESSION}/timeouts", body: { implicit: 20_000 }.to_json, times: 1) @@ -113,7 +113,7 @@ def test_create_session_force_mjsonwp_with_source_package .with(body: { ms: 20_000 }.to_json) .to_return(headers: Mock::HEADER, status: 200, body: { value: nil }.to_json) - core = ::Appium::Core.for(self, { caps: http_caps.merge({ forceMjsonwp: true }), appium_lib: {} }) + core = ::Appium::Core.for({ caps: http_caps.merge({ forceMjsonwp: true }), appium_lib: {} }) core.start_driver assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1) @@ -134,7 +134,7 @@ def test_create_session_w3c .with(body: { implicit: 20_000 }.to_json) .to_return(headers: Mock::HEADER, status: 200, body: { value: nil }.to_json) - driver = ::Appium::Core.for(self, { caps: CAPS, appium_lib: {} }).start_driver + driver = ::Appium::Core.for({ caps: CAPS, appium_lib: {} }).start_driver assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1) assert_requested(:post, "#{Mock::SESSION}/timeouts", body: { implicit: 20_000 }.to_json, times: 1) @@ -182,7 +182,7 @@ def test_create_session_w3c_with_http_package .with(body: { implicit: 20_000 }.to_json) .to_return(headers: Mock::HEADER, status: 200, body: { value: nil }.to_json) - core = ::Appium::Core.for(self, { caps: http_caps, appium_lib: {} }) + core = ::Appium::Core.for({ caps: http_caps, appium_lib: {} }) core.start_driver assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1) diff --git a/test/unit/driver_test.rb b/test/unit/driver_test.rb index 7b15b7d6..cbfcd239 100644 --- a/test/unit/driver_test.rb +++ b/test/unit/driver_test.rb @@ -5,12 +5,12 @@ class DriverTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.android) + @core ||= ::Appium::Core.for(Caps.android) end class ExampleDriver def initialize(opts) - ::Appium::Core.for(self, opts) + ::Appium::Core.for(opts) end end diff --git a/test/unit/image_element_test.rb b/test/unit/image_element_test.rb index ed24a231..1a588c2f 100644 --- a/test/unit/image_element_test.rb +++ b/test/unit/image_element_test.rb @@ -5,7 +5,7 @@ class ImageElementTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.ios) + @core ||= ::Appium::Core.for(Caps.ios) end def test_mjsonwp diff --git a/test/unit/ios/device/mjsonwp/commands_test.rb b/test/unit/ios/device/mjsonwp/commands_test.rb index 154b58c3..45bbfe51 100644 --- a/test/unit/ios/device/mjsonwp/commands_test.rb +++ b/test/unit/ios/device/mjsonwp/commands_test.rb @@ -10,7 +10,7 @@ class CommandsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.ios) + @core ||= ::Appium::Core.for(Caps.ios) @driver ||= ios_mock_create_session end diff --git a/test/unit/ios/device/mjsonwp/definition_test.rb b/test/unit/ios/device/mjsonwp/definition_test.rb index 898c7488..55221c42 100644 --- a/test/unit/ios/device/mjsonwp/definition_test.rb +++ b/test/unit/ios/device/mjsonwp/definition_test.rb @@ -10,7 +10,7 @@ class DefinitionTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.ios) + @core ||= ::Appium::Core.for(Caps.ios) @driver ||= ios_mock_create_session end diff --git a/test/unit/ios/device/w3c/commands_test.rb b/test/unit/ios/device/w3c/commands_test.rb index f899a7ef..8d8b8712 100644 --- a/test/unit/ios/device/w3c/commands_test.rb +++ b/test/unit/ios/device/w3c/commands_test.rb @@ -10,7 +10,7 @@ class CommandsTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.ios) + @core ||= ::Appium::Core.for(Caps.ios) @driver ||= ios_mock_create_session_w3c end diff --git a/test/unit/ios/device/w3c/definition_test.rb b/test/unit/ios/device/w3c/definition_test.rb index 03f3201a..8e846c08 100644 --- a/test/unit/ios/device/w3c/definition_test.rb +++ b/test/unit/ios/device/w3c/definition_test.rb @@ -10,7 +10,7 @@ class DefinitionTest < Minitest::Test include AppiumLibCoreTest::Mock def setup - @core ||= ::Appium::Core.for(self, Caps.ios) + @core ||= ::Appium::Core.for(Caps.ios) @driver ||= ios_mock_create_session_w3c end From 9c246dad18252a1da1243ec1266776aea7870103 Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Sat, 25 Aug 2018 12:32:03 +0900 Subject: [PATCH 2/4] fix rubocop --- lib/appium_lib_core/driver.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/appium_lib_core/driver.rb b/lib/appium_lib_core/driver.rb index 1a835e43..81363151 100644 --- a/lib/appium_lib_core/driver.rb +++ b/lib/appium_lib_core/driver.rb @@ -319,8 +319,8 @@ def screenshot(png_save_path) # @private def extend_for(device:, automation_name:) - self.extend Appium::Core - self.extend Appium::Core::Device + extend Appium::Core + extend Appium::Core::Device case device when :android From 98e4977f0426a052dcdcae42483d3696ed65220b Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Sat, 25 Aug 2018 13:16:58 +0900 Subject: [PATCH 3/4] update readme and changelog --- CHANGELOG.md | 2 ++ README.md | 4 ++-- lib/appium_lib_core/device.rb | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d78615ea..b680cd99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file. ### Bug fixes ### Deprecations +- `@core = Appium::Core.for(self, opts)` is deprecated in favor of `@core = Appium::Core.for(opts)` + - Call `extend Appium::Core::Device` if you'd like to extend methods defined in `Appium::Core` ## [1.9.2] - 2018-08-23 ### Enhancements diff --git a/README.md b/README.md index d888ffb1..ab204dc3 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ Run functional tests which require the Appium server and real device, Simulator/ - Start Appium server ```bash -$ npm install -g appium -$ appium +$ npm install -g appium opencv4nodejs +$ appium --relaxed-security # To run all tests in rocal ``` - Conduct tests diff --git a/lib/appium_lib_core/device.rb b/lib/appium_lib_core/device.rb index e9628305..64d63a5e 100644 --- a/lib/appium_lib_core/device.rb +++ b/lib/appium_lib_core/device.rb @@ -7,7 +7,7 @@ class << self def extended(_mod) extend_webdriver_with_forwardable - # Compatibility for appium_lib + # Compatibility for appium_lib. Below command are extended by `extend Appium::Core::Deivce`in appium_lib. # TODO: Will remove [ :take_element_screenshot, :save_viewport_screenshot, From eae4e513cd0a70ba05ee1509b89e641de52ad654 Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Sat, 25 Aug 2018 17:17:44 +0900 Subject: [PATCH 4/4] add a line in changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b680cd99..ba97376c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. ### Deprecations - `@core = Appium::Core.for(self, opts)` is deprecated in favor of `@core = Appium::Core.for(opts)` - Call `extend Appium::Core::Device` if you'd like to extend methods defined in `Appium::Core` + - Read [#816](https://github.com/appium/ruby_lib/pull/816) as an example ## [1.9.2] - 2018-08-23 ### Enhancements