appium_lib_core 1.3.8 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac826aa2f98ead54a80272abc7fb36447e3a327b
4
- data.tar.gz: a818a3ac3ffd0ed8c398da5c28c5cf65d9efa298
3
+ metadata.gz: 816965726811ed0e4814ff74f562f821a1d02a96
4
+ data.tar.gz: 48de6d03d02f08681e80b2f830e415016016b57f
5
5
  SHA512:
6
- metadata.gz: ab9ce470ee4053c5a22369b943ded09ac5f4b5671ae114736317730ca1a042eab6b87b1df77a8e53efb5328dba8101400a21b34872d3d1140624ad28f46208f1
7
- data.tar.gz: abd00234f100e065759513a4b9ac1133f610bb09920e13b2826ee83b3940077d1a9db7a5a64135ea85e8a3c75cd7591bbf1678f5887a737a0633f770cf3022e1
6
+ metadata.gz: fe453c38eee0cdf8405c19580f48de596338054bd4208e245a81825da5d229c65732c62327047f0da48169e2522dacbd8181ffe70c357abd25f6f2f938a70a80
7
+ data.tar.gz: da619b8b509db626f9dfbadc38048d9673e632bd505cb343750b3f6153b8871fd59c3d20d426656e3b741e320b498bfa4f94548ced25d145a0fb595df9087f1b
@@ -12,6 +12,9 @@ For features or bug fixes, please submit a pull request. Ideally there would be
12
12
  - Android
13
13
  - `rake test:func:android`
14
14
 
15
+ ## Merge
16
+ - Squash and merge when we merge PRs to the master
17
+
15
18
  ## Publishing on rubygems
16
19
 
17
20
  0. Ensure you have `~/.gem/credentials` If not run [the following command](http://guides.rubygems.org/make-your-own-gem/) (replace username with your rubygems user)
@@ -13,7 +13,7 @@ before_install:
13
13
 
14
14
  script:
15
15
  - bundle exec rake rubocop
16
- - bundle exec rake test:unit
16
+ - bundle exec parallel_test test/unit/ -n 4
17
17
 
18
18
  notifications:
19
19
  email:
@@ -8,6 +8,14 @@ All notable changes to this project will be documented in this file.
8
8
 
9
9
  ### Deprecations
10
10
 
11
+ ## [1.4.0] - 2018-04-15
12
+ ### Enhancements
13
+ - Add a support for WebSocket client based on Faye::WebSocket::Client [#74](https://github.com/appium/ruby_lib_core/pull/74)
14
+
15
+ ### Bug fixes
16
+
17
+ ### Deprecations
18
+
11
19
  ## [1.3.8] - 2018-04-12
12
20
  ### Enhancements
13
21
  - Make no-argument commands friendly for IDE
data/README.md CHANGED
@@ -19,7 +19,7 @@ Run unit tests which check each method and commands, URL, using the webmock.
19
19
 
20
20
  ```bash
21
21
  $ bundle install
22
- $ rake test:unit
22
+ $ bundle exec parallel_test test/unit/
23
23
  ```
24
24
 
25
25
  ### Functional Tests
data/Rakefile CHANGED
@@ -46,6 +46,13 @@ namespace :test do
46
46
  t.libs << 'lib'
47
47
  t.test_files = FileList['test/unit/android/**/*_test.rb']
48
48
  end
49
+
50
+ desc('Run all common related unit tests in test directory')
51
+ Rake::TestTask.new(:common) do |t|
52
+ t.libs << 'test'
53
+ t.libs << 'lib'
54
+ t.test_files = FileList['test/unit/common/**/*_test.rb']
55
+ end
49
56
  end
50
57
  end
51
58
 
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_runtime_dependency 'selenium-webdriver', '~> 3.5'
26
26
  spec.add_runtime_dependency 'json', '>= 1.8'
27
+ spec.add_runtime_dependency 'faye-websocket', '~> 0.10.0'
27
28
 
28
29
  spec.add_development_dependency 'bundler', '~> 1.14'
29
30
  spec.add_development_dependency 'rake', '~> 12.0'
@@ -35,4 +36,5 @@ Gem::Specification.new do |spec|
35
36
  spec.add_development_dependency 'appium_thor', '~> 0.0', '>= 0.0.7'
36
37
  spec.add_development_dependency 'pry'
37
38
  spec.add_development_dependency 'pry-byebug'
39
+ spec.add_development_dependency 'parallel_tests'
38
40
  end
@@ -4,3 +4,4 @@ require_relative 'common/log'
4
4
  require_relative 'common/command'
5
5
  require_relative 'common/device'
6
6
  require_relative 'common/base'
7
+ require_relative 'common/ws/websocket'
@@ -0,0 +1,151 @@
1
+ require 'faye/websocket'
2
+ require 'eventmachine'
3
+
4
+ module Appium
5
+ module Core
6
+ class WebSocket
7
+ attr_reader :client, :endpoint
8
+
9
+ # A websocket client based on Faye::WebSocket::Client .
10
+ # Uses eventmachine to wait response from the peer. The eventmachine works on a thread. The thread will exit
11
+ # with close method.
12
+ #
13
+ # @param [String] url: URL to establish web socket connection. If the URL has no port, the client use:
14
+ # `ws`: 80, `wss`: 443 ports.
15
+ # @param [Array] protocols: An array of strings representing acceptable subprotocols for use over the socket.
16
+ # The driver will negotiate one of these to use via the Sec-WebSocket-Protocol header
17
+ # if supported by the other peer. Default is nil.
18
+ # The protocols is equal to https://github.com/faye/faye-websocket-ruby/ 's one for client.
19
+ # @param [Hash] options: Initialize options for Faye client. Read https://github.com/faye/faye-websocket-ruby#initialization-options
20
+ # for more details. Default is `{}`.
21
+ #
22
+ # @example
23
+ # ws = WebSocket.new(url: "ws://#{host}:#{port}/ws/session/#{@session_id}/appium/device/logcat")
24
+ # ws.client #=> #<Faye::WebSocket::Client:.....> # An instance of Faye::WebSocket::Client
25
+ # ws.message 'some message' #=> nil. Send a message to the peer.
26
+ # ws.close #=> Kill the thread which run a eventmachine.
27
+ #
28
+ def initialize(url:, protocols: nil, options: {})
29
+ @endpoint = url
30
+
31
+ @ws_thread = Thread.new do
32
+ EM.run do
33
+ @client ||= ::Faye::WebSocket::Client.new(url, protocols, options)
34
+
35
+ @client.on :open do |_open|
36
+ handle_open
37
+ end
38
+
39
+ @client.on :message do |message|
40
+ handle_message_data(message.data)
41
+ end
42
+
43
+ @client.on :error do |_error|
44
+ handle_error
45
+ end
46
+
47
+ @client.on :close do |close|
48
+ handle_close(close.code, close.reason)
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ # Client
55
+
56
+ #
57
+ # Sends a ping frame with an optional message and fires the callback when a matching pong is received.
58
+ #
59
+ # @params [String] message A message to send ping.
60
+ # @params [Block] &callback
61
+ #
62
+ # @example
63
+ # ws = WebSocket.new(url: "ws://#{host}:#{port}/ws/session/#{@session_id}/appium/device/logcat")
64
+ # ws.ping 'message'
65
+ #
66
+ def ping(message, &callback)
67
+ @client.ping message, &callback
68
+ end
69
+
70
+ # Accepts either a String or an Array of byte-sized integers and sends a text or binary message over the connection
71
+ # to the other peer; binary data must be encoded as an Array.
72
+ #
73
+ # @params [String|Array] message A message to send a text or binary message over the connection
74
+ #
75
+ # @example
76
+ # ws = WebSocket.new(url: "ws://#{host}:#{port}/ws/session/#{@session_id}/appium/device/logcat")
77
+ # ws.send 'happy testing'
78
+ #
79
+ def send(message)
80
+ @client.send message
81
+ end
82
+
83
+ # Closes the connection, sending the given status code and reason text, both of which are optional.
84
+ #
85
+ # @params [Integer] code: A status code to send to the peer with close signal. Default is nil.
86
+ # @params [String] reason: A reason to send to the peer with close signal. Default is 'close from ruby_lib_core'.
87
+ #
88
+ # @example
89
+ # ws = WebSocket.new(url: "ws://#{host}:#{port}/ws/session/#{@session_id}/appium/device/logcat")
90
+ # ws.close reason: 'a something special reason'
91
+ #
92
+ def close(code: nil, reason: 'close from ruby_lib_core')
93
+ if @client.nil?
94
+ ::Appium::Logger.warn 'Websocket was closed'
95
+ else
96
+ @client.close code, reason
97
+ end
98
+ @ws_thread.exit
99
+ end
100
+
101
+ # Response from server
102
+
103
+ #
104
+ # Fires when the socket connection is established. Event has no attributes.
105
+ #
106
+ # Default is just put a debug message.
107
+ #
108
+ def handle_open
109
+ ::Appium::Logger.debug %W(#{self.class} :open)
110
+ end
111
+
112
+ # Standard out by default
113
+ # In general, users should customise only message_data
114
+
115
+ #
116
+ # Fires when the socket receives a message. The message gas one `data` attribute and this method can handle the data.
117
+ # The data is either a String (for text frames) or an Array of byte-sized integers (for binary frames).
118
+ #
119
+ # Default is just put a debug message and puts the result on standard out.
120
+ # In general, users should override this handler to handle messages from the peer.
121
+ #
122
+ def handle_message_data(data)
123
+ ::Appium::Logger.debug %W(#{self.class} :message #{data})
124
+ $stdout << "#{data}\n"
125
+ end
126
+
127
+ #
128
+ # Fires when there is a protocol error due to bad data sent by the other peer.
129
+ # This event is purely informational, you do not need to implement error recovery.
130
+ #
131
+ # Default is just put a error message.
132
+ #
133
+ def handle_error
134
+ ::Appium::Logger.error %W(#{self.class} :error)
135
+ end
136
+
137
+ #
138
+ # Fires when either the client or the server closes the connection. The method gets `code` and `reason` attributes.
139
+ # They expose the status code and message sent by the peer that closed the connection.
140
+ #
141
+ # Default is just put a error message.
142
+ # The methods also clear `client` instance and stop the eventmachine which is called in initialising this class.
143
+ #
144
+ def handle_close(code, reason)
145
+ ::Appium::Logger.debug %W(#{self.class} :close #{code} #{reason})
146
+ @client = nil
147
+ EM.stop
148
+ end
149
+ end # module WebSocket
150
+ end # module Core
151
+ end # module Appium
@@ -39,6 +39,7 @@ module Appium
39
39
  # Provide Appium::Drive like { appium_lib: { port: 8080 } }
40
40
  # @return [Integer]
41
41
  attr_reader :port
42
+ DEFAULT_APPIUM_PORT = 4723
42
43
 
43
44
  # Return a time wait timeout. 30 seconds is by default.
44
45
  # Wait time for ::Appium::Core::Base::Wait, wait and wait_true
@@ -428,7 +429,7 @@ module Appium
428
429
  @export_session = appium_lib_opts.fetch :export_session, false
429
430
  @export_session_path = appium_lib_opts.fetch :export_session_path, '/tmp/appium_lib_session'
430
431
 
431
- @port = appium_lib_opts.fetch :port, 4723
432
+ @port = appium_lib_opts.fetch :port, DEFAULT_APPIUM_PORT
432
433
 
433
434
  # timeout and interval used in ::Appium::Comm.wait/wait_true
434
435
  @wait_timeout = appium_lib_opts.fetch :wait_timeout, 30
@@ -1,6 +1,6 @@
1
1
  module Appium
2
2
  module Core
3
- VERSION = '1.3.8'.freeze unless defined? ::Appium::Core::VERSION
4
- DATE = '2018-04-12'.freeze unless defined? ::Appium::Core::DATE
3
+ VERSION = '1.4.0'.freeze unless defined? ::Appium::Core::VERSION
4
+ DATE = '2018-04-15'.freeze unless defined? ::Appium::Core::DATE
5
5
  end
6
6
  end
@@ -1,3 +1,11 @@
1
+ #### v1.4.0 2018-04-15
2
+
3
+ - [5cc89aa](https://github.com/appium/ruby_lib_core/commit/5cc89aa4a9533e174527db5b805b96cf2b45a9ac) Release 1.4.0
4
+ - [598460c](https://github.com/appium/ruby_lib_core/commit/598460cb9a040ec4d0bd3351bbdb0fb9412428e2) implement websocket client (#74)
5
+ - [56a60c6](https://github.com/appium/ruby_lib_core/commit/56a60c6b49b0a36c2e6af34a9d22d828ba38e721) add squash and merge for ontributing.md
6
+ - [6fc0a30](https://github.com/appium/ruby_lib_core/commit/6fc0a303073c895494c172a0ec4d196fefed694e) add parallel tests (#73)
7
+
8
+
1
9
  #### v1.3.8 2018-04-13
2
10
 
3
11
  - [f5e1c39](https://github.com/appium/ruby_lib_core/commit/f5e1c39ed07c191c89a491c407d0fc368459367c) Release 1.3.8
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_lib_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.8
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuaki MATSUO
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-12 00:00:00.000000000 Z
11
+ date: 2018-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faye-websocket
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.10.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.10.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -184,6 +198,20 @@ dependencies:
184
198
  - - ">="
185
199
  - !ruby/object:Gem::Version
186
200
  version: '0'
201
+ - !ruby/object:Gem::Dependency
202
+ name: parallel_tests
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ type: :development
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
187
215
  description: Minimal Ruby library for Appium.
188
216
  email:
189
217
  - fly.49.89.over@gmail.com
@@ -232,6 +260,7 @@ files:
232
260
  - lib/appium_lib_core/common/error.rb
233
261
  - lib/appium_lib_core/common/log.rb
234
262
  - lib/appium_lib_core/common/logger.rb
263
+ - lib/appium_lib_core/common/ws/websocket.rb
235
264
  - lib/appium_lib_core/device/app_state.rb
236
265
  - lib/appium_lib_core/device/clipboard_content_type.rb
237
266
  - lib/appium_lib_core/device/multi_touch.rb