xcmonkey 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -9
- data/bin/xcmonkey +5 -3
- data/lib/xcmonkey/driver.rb +13 -2
- data/lib/xcmonkey/version.rb +1 -1
- data/spec/driver_spec.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48bd9b79b2370e4f20366973e689af344f6c75729b361658fbc5bb2c02c38253
|
4
|
+
data.tar.gz: c207e8dbe7c820623f60a9c0b9e8ea8a7e5bce18bfe10f9d5c27e8928829889d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c0f1f52ad5e8118799556e4e1ba3a49574c504cf2a840fe0369e06c6dbab260fd0a9c275ada9efb789a865759ac48f7d46f9348cde5b2cb53a44969b5189cf9
|
7
|
+
data.tar.gz: 761ffee247c8646bc24dee5fd3f473414402033d3c9a773fe87623579aef93155ecbafc3d412111396945ae485d74b28d6916e5e287754a82b15fcfc792b0c47
|
data/README.md
CHANGED
@@ -11,13 +11,11 @@
|
|
11
11
|
|
12
12
|
## Description
|
13
13
|
|
14
|
-
*xcmonkey* is a tool for doing randomised UI testing of iOS apps.
|
14
|
+
*xcmonkey* is a tool for doing randomised UI testing of iOS apps. It's inspired by and has similar goals to [*monkey*](https://developer.android.com/studio/test/monkey) on Android.
|
15
15
|
|
16
|
-
|
16
|
+
Under the hood, *xcmonkey* uses [iOS Development Bridge](https://fbidb.io/) as a driver, that's why it's pretty smart and can do a lot of things, such as taps, swipes and presses. All that comes «pseudo-random» because it has access to the screen hierarchy, and so can either do actions blindly (like tapping on random points) or precisely (like tapping on the existing elements).
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
## Requirements
|
18
|
+
## Prerequisites
|
21
19
|
|
22
20
|
```bash
|
23
21
|
brew install facebook/fb/idb-companion
|
@@ -30,7 +28,7 @@ pip3.6 install fb-idb
|
|
30
28
|
gem install xcmonkey
|
31
29
|
```
|
32
30
|
|
33
|
-
If you prefer to use [bundler](https://bundler.io/), add the following line to your `Gemfile`:
|
31
|
+
If you prefer to use [*bundler*](https://bundler.io/), add the following line to your `Gemfile`:
|
34
32
|
|
35
33
|
```ruby
|
36
34
|
gem 'xcmonkey'
|
@@ -72,13 +70,13 @@ $ xcmonkey describe -x 20 -y 625 --udid "413EA256-CFFB-4312-94A6-12592BEE4CBA"
|
|
72
70
|
20:05:20.212: Device info: iPhone 14 Pro | 413EA256-CFFB-4312-94A6-12592BEE4CBA | Booted | simulator | iOS 16.2 | x86_64 | /tmp/idb/413EA256-CFFB-4312-94A6-12592BEE4CBA_companion.sock
|
73
71
|
|
74
72
|
20:05:21.713: x:20 y:625 point info: {
|
75
|
-
"AXFrame": "{{19, 624.
|
73
|
+
"AXFrame": "{{19, 624.3}, {86, 130.6}}",
|
76
74
|
"AXUniqueId": "ShortcutsRowCell",
|
77
75
|
"frame": {
|
78
|
-
"y": 624.
|
76
|
+
"y": 624.3,
|
79
77
|
"x": 19,
|
80
78
|
"width": 86,
|
81
|
-
"height": 130.
|
79
|
+
"height": 130.6
|
82
80
|
},
|
83
81
|
"role_description": "button",
|
84
82
|
"AXLabel": "Home",
|
data/bin/xcmonkey
CHANGED
@@ -16,13 +16,15 @@ module Xcmonkey
|
|
16
16
|
c.description = 'Runs monkey test'
|
17
17
|
c.option('-u', '--udid STRING', String, 'Set device UDID')
|
18
18
|
c.option('-b', '--bundle-id STRING', String, 'Set target bundle identifier')
|
19
|
-
c.option('-d', '--duration SECONDS', Integer, 'Test duration in seconds')
|
19
|
+
c.option('-d', '--duration SECONDS', Integer, 'Test duration in seconds. Defaults to `60`')
|
20
|
+
c.option('-k', '--enable-simulator-keyboard', 'Should simulator keyboard be enabled? Defaults to `true`')
|
20
21
|
c.action do |args, options|
|
21
|
-
options.default(duration: 60)
|
22
|
+
options.default(duration: 60, enable_simulator_keyboard: true)
|
22
23
|
params = {
|
23
24
|
udid: options.udid,
|
24
25
|
bundle_id: options.bundle_id,
|
25
|
-
duration: options.duration
|
26
|
+
duration: options.duration,
|
27
|
+
simulator_keyboard: options.enable_simulator_keyboard
|
26
28
|
}
|
27
29
|
Xcmonkey.new(params).run
|
28
30
|
end
|
data/lib/xcmonkey/driver.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
class Driver
|
2
|
-
attr_accessor :udid, :bundle_id, :duration
|
2
|
+
attr_accessor :udid, :bundle_id, :duration, :enable_simulator_keyboard
|
3
3
|
|
4
4
|
def initialize(params)
|
5
5
|
self.udid = params[:udid]
|
6
6
|
self.bundle_id = params[:bundle_id]
|
7
7
|
self.duration = params[:duration]
|
8
|
+
self.enable_simulator_keyboard = params[:enable_simulator_keyboard]
|
8
9
|
ensure_driver_installed
|
9
10
|
end
|
10
11
|
|
@@ -76,6 +77,12 @@ class Driver
|
|
76
77
|
`idb shutdown #{udid}`
|
77
78
|
end
|
78
79
|
|
80
|
+
def configure_simulator_keyboard
|
81
|
+
shutdown_simulator
|
82
|
+
keyboard_status = enable_simulator_keyboard ? 0 : 1
|
83
|
+
`defaults write com.apple.iphonesimulator ConnectHardwareKeyboard #{keyboard_status}`
|
84
|
+
end
|
85
|
+
|
79
86
|
def list_targets
|
80
87
|
@list_targets ||= `idb list-targets`.split("\n")
|
81
88
|
@list_targets
|
@@ -92,8 +99,12 @@ class Driver
|
|
92
99
|
def ensure_device_exists
|
93
100
|
device = list_targets.detect { |target| target.include?(udid) }
|
94
101
|
Logger.error("Can't find device #{udid}") if device.nil?
|
102
|
+
|
95
103
|
Logger.info('Device info:', payload: device)
|
96
|
-
|
104
|
+
if device.include?('simulator')
|
105
|
+
configure_simulator_keyboard
|
106
|
+
boot_simulator
|
107
|
+
end
|
97
108
|
end
|
98
109
|
|
99
110
|
def list_apps
|
data/lib/xcmonkey/version.rb
CHANGED
data/spec/driver_spec.rb
CHANGED
@@ -122,6 +122,26 @@ describe Driver do
|
|
122
122
|
expect(driver.press_duration).to be_between(0.5, 1.5)
|
123
123
|
end
|
124
124
|
|
125
|
+
it 'verifies that simulator keyboard can be enabled' do
|
126
|
+
allow(driver).to receive(:is_simulator_keyboard_enabled?).and_return(false)
|
127
|
+
driver = described_class.new(udid: udid, bundle_id: bundle_id, enable_simulator_keyboard: true)
|
128
|
+
expect(driver).to receive(:shutdown_simulator)
|
129
|
+
driver.configure_simulator_keyboard
|
130
|
+
keyboard_state = `defaults read com.apple.iphonesimulator`.split("\n").grep(/ConnectHardwareKeyboard/)
|
131
|
+
expect(keyboard_state).not_to be_empty
|
132
|
+
expect(keyboard_state.first).to include('0')
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'verifies that simulator keyboard can be disabled' do
|
136
|
+
allow(driver).to receive(:is_simulator_keyboard_enabled?).and_return(true)
|
137
|
+
driver = described_class.new(udid: udid, bundle_id: bundle_id, enable_simulator_keyboard: false)
|
138
|
+
expect(driver).to receive(:shutdown_simulator)
|
139
|
+
driver.configure_simulator_keyboard
|
140
|
+
keyboard_state = `defaults read com.apple.iphonesimulator`.split("\n").grep(/ConnectHardwareKeyboard/)
|
141
|
+
expect(keyboard_state).not_to be_empty
|
142
|
+
expect(keyboard_state.first).to include('1')
|
143
|
+
end
|
144
|
+
|
125
145
|
it 'verifies that app can be launched' do
|
126
146
|
expect(Logger).not_to receive(:error)
|
127
147
|
expect(Logger).to receive(:info)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcmonkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alteral
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|