appium_lib 8.1.0 → 8.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/docs/migration.md CHANGED
@@ -1,3 +1,26 @@
1
+ ### Breaking Changes in 8.2.0
2
+ change `Appium.load_appium_txt` to `Appium.load_settings`.
3
+
4
+ Old | New
5
+ :--|:--
6
+ `Appium.load_appium_txt` | `Appium.load_settings`
7
+
8
+ - after
9
+
10
+ ```
11
+ dir = File.expand_path(File.join(Dir.pwd, 'lib'))
12
+ appium_txt = File.join(Dir.pwd, 'appium.txt')
13
+ caps = Appium.load_settings file: appium_txt, verbose: true
14
+ ```
15
+
16
+ - before
17
+
18
+ ```
19
+ appium_txt = File.expand_path(File.join(Dir.pwd, 'lib'))
20
+ dir = appium_txt
21
+ caps = Appium.load_appium_txt file: appium_txt, verbose: true
22
+ ```
23
+
1
24
  ### Breaking Changes in 7.0
2
25
 
3
26
  Requires appium 1.4.0-beta or newer for iOS helper methods. appium_lib no longer automatically promotes methods on minispec. To restore the old behavior use: `Appium.promote_appium_methods ::Minitest::Spec`
@@ -17,12 +17,12 @@ describe 'driver' do
17
17
  data.strip.must_equal 174.chr('UTF-8')
18
18
  end
19
19
 
20
- t 'load_appium_txt' do
20
+ t 'load_settings' do
21
21
  # skip this test if we're using Sauce
22
22
  # the storage API doesn't have an on disk file
23
23
  skip if sauce?
24
- appium_txt = File.expand_path(File.join(Dir.pwd, 'lib'))
25
- opts = Appium.load_appium_txt file: appium_txt, verbose: true
24
+ appium_txt = File.join(Dir.pwd, 'appium.txt')
25
+ opts = Appium.load_settings file: appium_txt, verbose: true
26
26
 
27
27
  actual = ''
28
28
  actual = File.basename opts[:caps][:app] if opts && opts[:caps]
@@ -1,5 +1,5 @@
1
1
  module Appium
2
2
  # Version and Date are defined on the 'Appium' module, not 'Appium::Common'
3
- VERSION = '8.1.0' unless defined? ::Appium::VERSION
4
- DATE = '2016-11-18' unless defined? ::Appium::DATE
3
+ VERSION = '8.2.0' unless defined? ::Appium::VERSION
4
+ DATE = '2016-11-26' unless defined? ::Appium::DATE
5
5
  end
@@ -309,6 +309,7 @@ module Appium
309
309
  end
310
310
 
311
311
  add_touch_actions
312
+ add_ime_actions
312
313
  extend_search_contexts
313
314
  end
314
315
 
@@ -359,6 +360,29 @@ module Appium
359
360
  end
360
361
  end
361
362
 
363
+ # @private
364
+ def add_bridge_method(method)
365
+ if block_given?
366
+ create_bridge method, &Proc.new
367
+ else
368
+ create_bridge method
369
+ end
370
+
371
+ delegate_driver_method method
372
+ delegate_from_appium_driver method
373
+ end
374
+
375
+ # @private
376
+ def create_bridge(method)
377
+ Selenium::WebDriver::Remote::Bridge.class_eval do
378
+ if block_given?
379
+ class_eval(&Proc.new)
380
+ else
381
+ define_method(method) { execute method }
382
+ end
383
+ end
384
+ end
385
+
362
386
  # @!method find_element
363
387
  # @!method find_elements
364
388
  #
@@ -395,6 +419,80 @@ module Appium
395
419
  delegate_from_appium_driver(:pinch, Appium::MultiTouch)
396
420
  delegate_from_appium_driver(:zoom, Appium::MultiTouch)
397
421
  end
422
+
423
+ def add_ime_actions
424
+ # Commands for IME are defined in the following commands.rb, but the driver have no bridge.
425
+ # So, appium_lib define just bridge here.
426
+ # https://github.com/SeleniumHQ/selenium/blob/selenium-3.0.1/rb/lib/selenium/webdriver/remote/commands.rb#L184-L192
427
+
428
+ # @!method ime_activate
429
+ # Make an engine that is available active.
430
+ #
431
+ # Android only.
432
+ # @param [String] The IME owning the activity [required]
433
+ #
434
+ # ```ruby
435
+ # ime_activate engine: 'com.android.inputmethod.latin/.LatinIME'
436
+ # ```
437
+ add_bridge_method(:ime_activate) do
438
+ def ime_activate(ime_name)
439
+ execute :imeActivateEngine, {}, engine: ime_name
440
+ end
441
+ end
442
+
443
+ # @!method ime_available_engines
444
+ # List all available input engines on the machine.
445
+ # Android only.
446
+ #
447
+ # ```ruby
448
+ # ime_available_engines #=> Get the list of IME installed in the target device
449
+ # ```
450
+ add_bridge_method(:ime_available_engines) do
451
+ def ime_available_engines
452
+ execute :imeGetAvailableEngines
453
+ end
454
+ end
455
+
456
+ # @!method ime_active_engine
457
+ # Get the name of the active IME engine.
458
+ # Android only.
459
+ #
460
+ # ```ruby
461
+ # ime_active_engine #=> Get the current active IME such as 'com.android.inputmethod.latin/.LatinIME'
462
+ # ```
463
+ add_bridge_method(:ime_active_engine) do
464
+ def ime_active_engine
465
+ execute :imeGetActiveEngine
466
+ end
467
+ end
468
+
469
+ # @!method ime_activated
470
+ # Indicates whether IME input is active at the moment (not if it is available).
471
+ # Android only.
472
+ #
473
+ # ```ruby
474
+ # ime_activated #=> True if IME is activated
475
+ # ```
476
+ add_bridge_method(:ime_activated) do
477
+ def ime_activated
478
+ execute :imeIsActivated
479
+ end
480
+ end
481
+
482
+ # @!method ime_deactivate
483
+ # De-activates the currently-active IME engine.
484
+ #
485
+ # Android only.
486
+ #
487
+ # ```ruby
488
+ # ime_deactivate #=> Deactivate current IME engine
489
+ # ```
490
+ add_bridge_method(:ime_deactivate) do
491
+ def ime_deactivate
492
+ execute :imeDeactivate, {}
493
+ end
494
+ end
495
+ end
398
496
  end # class << self
399
497
 
400
498
  # @!method set_context
@@ -51,7 +51,6 @@ end
51
51
 
52
52
  module Appium
53
53
  # Load appium.txt (toml format)
54
- # the basedir of this file + appium.txt is what's used
55
54
  #
56
55
  # ```
57
56
  # [caps]
@@ -67,17 +66,15 @@ module Appium
67
66
  #
68
67
  # @param opts [Hash] file: '/path/to/appium.txt', verbose: true
69
68
  # @return [hash] the symbolized hash with updated :app and :require keys
70
- def self.load_appium_txt(opts = {})
69
+ def self.load_settings(opts = {})
71
70
  fail 'opts must be a hash' unless opts.is_a? Hash
72
71
  fail 'opts must not be empty' if opts.empty?
73
72
 
74
- file = opts[:file]
75
- fail 'Must pass file' unless file
73
+ toml = opts[:file]
74
+ fail 'Must pass file' unless toml
76
75
  verbose = opts.fetch :verbose, false
77
76
 
78
- parent_dir = File.dirname file
79
- toml = File.expand_path File.join parent_dir, 'appium.txt'
80
- Appium::Logger.info "appium.txt path: #{toml}" if verbose
77
+ Appium::Logger.info "appium settings path: #{toml}" if verbose
81
78
 
82
79
  toml_exists = File.exist? toml
83
80
  Appium::Logger.info "Exists? #{toml_exists}" if verbose
@@ -93,40 +90,47 @@ module Appium
93
90
  data[:caps][:app] = Appium::Driver.absolute_app_path data
94
91
  end
95
92
 
96
- # return list of require files as an array
97
- # nil if require doesn't exist
98
93
  if data && data[:appium_lib] && data[:appium_lib][:require]
99
- r = data[:appium_lib][:require]
100
- r = r.is_a?(Array) ? r : [r]
101
- # ensure files are absolute
102
- r.map! do |f|
103
- file = File.exist?(f) ? f : File.join(parent_dir, f)
104
- file = File.expand_path file
105
-
106
- File.exist?(file) ? file : nil
107
- end
108
- r.compact! # remove nils
94
+ parent_dir = File.dirname toml
95
+ data[:appium_lib][:require] = expand_required_files(parent_dir, data[:appium_lib][:require])
96
+ end
109
97
 
110
- files = []
98
+ data
99
+ end
111
100
 
112
- # now expand dirs
113
- r.each do |item|
114
- unless File.directory? item
115
- # save file
116
- files << item
117
- next # only look inside folders
118
- end
119
- Dir.glob(File.expand_path(File.join(item, '**', '*.rb'))) do |f|
120
- # do not add folders to the file list
121
- files << File.expand_path(f) unless File.directory? f
122
- end
123
- end
101
+ class << self
102
+ alias_method :load_appium_txt, :load_settings
103
+ end
124
104
 
125
- # Must not sort files. File order is specified in appium.txt
126
- data[:appium_lib][:require] = files
105
+ # @param base_dir [String] parent directory of loaded appium.txt (toml)
106
+ # @param file_paths
107
+ # @return list of require files as an array, nil if require doesn't exist
108
+ def self.expand_required_files(base_dir, file_paths)
109
+ # ensure files are absolute
110
+ Array(file_paths).map! do |f|
111
+ file = File.exist?(f) ? f : File.join(base_dir, f)
112
+ file = File.expand_path file
113
+
114
+ File.exist?(file) ? file : nil
127
115
  end
116
+ r.compact! # remove nils
128
117
 
129
- data
118
+ files = []
119
+
120
+ # now expand dirs
121
+ file_paths.each do |item|
122
+ unless File.directory? item
123
+ # save file
124
+ files << item
125
+ next # only look inside folders
126
+ end
127
+ Dir.glob(File.expand_path(File.join(item, '**', '*.rb'))) do |f|
128
+ # do not add folders to the file list
129
+ files << File.expand_path(f) unless File.directory? f
130
+ end
131
+ end
132
+
133
+ files
130
134
  end
131
135
 
132
136
  # convert all keys (including nested) to symbols
@@ -430,7 +434,7 @@ module Appium
430
434
  return app_path unless app_path.match(/[\/\\]/)
431
435
 
432
436
  # relative path that must be expanded.
433
- # absolute_app_path is called from load_appium_txt
437
+ # absolute_app_path is called from load_settings
434
438
  # and the txt file path is the base of the app path in that case.
435
439
  app_path = File.expand_path app_path
436
440
  fail "App doesn't exist #{app_path}" unless File.exist? app_path
data/release_notes.md CHANGED
@@ -1,6 +1,13 @@
1
+ #### v8.2.0 2016-11-26
2
+
3
+ - [4535ec9](https://github.com/appium/ruby_lib/commit/4535ec91f435255ae31b4c4fea9d96e5405d79f5) Release 8.2.0
4
+ - [8a08021](https://github.com/appium/ruby_lib/commit/8a080213dbe4843f50b6acfbe80628209bfd143d) add endpoint for handling IME in remote bridge (#400)
5
+ - [222cd47](https://github.com/appium/ruby_lib/commit/222cd47f69ba24b82a122734b0a136e5d6aed330) Allow to name toml files differently than appium.txt, fixes #280 (#397)
6
+ - [d3a9235](https://github.com/appium/ruby_lib/commit/d3a9235767d6ba770246afac0e62ac58da0eb4b0) update release note and documentation (#396)
7
+
1
8
  #### v8.1.0 2016-11-18
2
9
 
3
- - [0b476e7](https://github.com/appium/ruby_lib/commit/0b476e7c78f8cb829a909de55a402c6585ac5159) Release 8.1.0
10
+ - [95d3a65](https://github.com/appium/ruby_lib/commit/95d3a6535472559590c4d043e887d15acc445a1a) Release 8.1.0
4
11
  - [6c38ca5](https://github.com/appium/ruby_lib/commit/6c38ca5276342ade6168eb9080424a03608a1b3e) replace end_ to delta_ because end_ is deprecated in #380 (#392)
5
12
  - [09654ab](https://github.com/appium/ruby_lib/commit/09654ab9dbc69a31eff7e7bd426db985da09e3b8) Add EventListener to Driver (#389)
6
13
  - [2d8fc5f](https://github.com/appium/ruby_lib/commit/2d8fc5ff7acce9417847e66772b59fc691c1dbaa) Added touch id endpoint (#384)
@@ -1272,4 +1279,4 @@
1272
1279
 
1273
1280
  - [01f2d15](https://github.com/appium/ruby_lib/commit/01f2d150ae3d8e88970b361a8330c6ccc174097d) Release 0.0.19
1274
1281
  - [10eec2f](https://github.com/appium/ruby_lib/commit/10eec2f197899395978b73de049aed08ceda55cc) AppLib => AppiumLib
1275
- - [c1e3b4f](https://github.com/appium/ruby_lib/commit/c1e3b4f0a08be3a0aef65218220f09f4198683bf) AppLib => AppiumLib
1282
+ - [c1e3b4f](https://github.com/appium/ruby_lib/commit/c1e3b4f0a08be3a0aef65218220f09f4198683bf) AppLib => AppiumLib
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.0
4
+ version: 8.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - code@bootstraponline.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-18 00:00:00.000000000 Z
11
+ date: 2016-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver