osaka 0.4.11 → 0.4.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/osaka/remotecontrol.rb +2 -1
- data/lib/osaka/version.rb +1 -1
- data/spec/remotecontrol_spec.rb +67 -64
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b98f479a2e3a76f17e9727eacb616a4668126f06
|
4
|
+
data.tar.gz: 2cc8d297e7bc54fa57120ba557988582ffc27874
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f269e4e1d5fbf49387ffe48a7adfec8881f221e13b73800d550b9da99809af18bbc1e401f281ede9b9462588e97f21407acd2b0a4c81318e8815e0e9f27380be
|
7
|
+
data.tar.gz: f8ad1bf37387d5b294c7d86e39cd7aaf2e7fc104743abb1eb6c994d5a76d245a25228cfdabe4744b8c11f4436187161b67baa2f052da5e1a5750a4e6b513c641
|
data/lib/osaka/remotecontrol.rb
CHANGED
@@ -195,6 +195,7 @@ module Osaka
|
|
195
195
|
end
|
196
196
|
|
197
197
|
def get!(element, location = "")
|
198
|
+
debug_print "Getting attribute '#{element}' of: #{construct_prefixed_location(location)}"
|
198
199
|
system_event!("get #{element}#{construct_prefixed_location(location)}").strip
|
199
200
|
end
|
200
201
|
|
@@ -223,7 +224,7 @@ module Osaka
|
|
223
224
|
|
224
225
|
def standard_window_list
|
225
226
|
window_list.collect { |window|
|
226
|
-
if get!("subrole", at.window(window)) == "AXStandardWindow"
|
227
|
+
if exists?(at.window(window)) && get!("subrole", at.window(window)) == "AXStandardWindow"
|
227
228
|
window
|
228
229
|
end
|
229
230
|
}.compact
|
data/lib/osaka/version.rb
CHANGED
data/spec/remotecontrol_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe "Osaka::RemoteControl" do
|
|
13
13
|
before (:each) do
|
14
14
|
Osaka::ScriptRunner.enable_debug_prints
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
after (:each) do
|
18
18
|
Osaka::ScriptRunner.disable_debug_prints
|
19
19
|
end
|
@@ -22,19 +22,19 @@ describe "Osaka::RemoteControl" do
|
|
22
22
|
expect_execute_osascript.and_return("An Error")
|
23
23
|
expect(subject).to receive(:puts).with(/#{action}/)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
it "Should be able to print warning messages" do
|
27
27
|
expect(subject).to receive(:puts).with("Osaka WARNING while doing ThisAction: Message")
|
28
28
|
subject.print_warning("ThisAction", "Message")
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
context "Query things from the OS" do
|
32
32
|
|
33
33
|
it "Should be possible to check whether an application is still running" do
|
34
34
|
expect_execute_osascript("tell application \"System Events\"; (name of processes) contains \"#{name}\"; end tell").and_return("false")
|
35
35
|
expect(subject.running?).to be false
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
it "Can get the OS version (lion)" do
|
39
39
|
expect_execute_osascript("system version of (system info)").and_return("10.7.4\n")
|
40
40
|
expect(subject.mac_version).to eq :lion
|
@@ -55,42 +55,42 @@ describe "Osaka::RemoteControl" do
|
|
55
55
|
expect_execute_osascript("system version of (system info)").and_return("1\n")
|
56
56
|
expect(subject.mac_version).to eq :other
|
57
57
|
end
|
58
|
-
end
|
58
|
+
end
|
59
59
|
|
60
60
|
context "Able to compare different remote controls" do
|
61
|
-
|
61
|
+
|
62
62
|
it "Should be able to clone controls" do
|
63
63
|
subject.set_current_window "Window"
|
64
64
|
new_control = subject.clone
|
65
65
|
expect(new_control).to eq subject
|
66
|
-
expect(new_control).not_to be subject
|
66
|
+
expect(new_control).not_to be subject
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
it "Should be having different current window instances when cloning" do
|
70
70
|
subject.set_current_window "Window"
|
71
71
|
new_control = subject.clone
|
72
72
|
new_control.set_current_window "Not the same"
|
73
73
|
expect(subject.current_window_name).not_to be new_control.current_window_name
|
74
|
-
|
74
|
+
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
it "Should be able to compare objects using names" do
|
78
78
|
expect(subject).to eq Osaka::RemoteControl.new(name)
|
79
79
|
expect(subject).not_to eq Osaka::RemoteControl.new("otherName")
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
it "Should be able to compare objects using window" do
|
83
83
|
equal_object = Osaka::RemoteControl.new(name)
|
84
84
|
unequal_object = Osaka::RemoteControl.new(name)
|
85
85
|
equal_object.set_current_window("Window")
|
86
86
|
subject.set_current_window("Window")
|
87
87
|
unequal_object.set_current_window "Another Window"
|
88
|
-
|
88
|
+
|
89
89
|
expect(subject).to eq equal_object
|
90
90
|
expect(subject).not_to eq unequal_object
|
91
91
|
end
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
context "Basic control functionality of telling and sending system events" do
|
95
95
|
|
96
96
|
quoted_name = "\"#{name}\""
|
@@ -116,9 +116,9 @@ describe "Osaka::RemoteControl" do
|
|
116
116
|
subject.system_event("quit")
|
117
117
|
end
|
118
118
|
end
|
119
|
-
|
119
|
+
|
120
120
|
context "Check whether things exist or not" do
|
121
|
-
|
121
|
+
|
122
122
|
it "Should be able to check whether a location exists" do
|
123
123
|
expect_execute_osascript(/exists button 1/).and_return("true\n")
|
124
124
|
expect(subject.exists?(at.button(1))).to be true
|
@@ -129,9 +129,9 @@ describe "Osaka::RemoteControl" do
|
|
129
129
|
expect(subject.not_exists?(at.window(1))).to be true
|
130
130
|
end
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
context "Waiting and doing until elements exist or not" do
|
134
|
-
|
134
|
+
|
135
135
|
it "Should be able to wait for only one location to exist" do
|
136
136
|
expect_exists?(at.button(1)).and_return(false, false, true)
|
137
137
|
expect(subject.wait_until_exists!(at.button(1))).to eq at.button(1)
|
@@ -142,7 +142,7 @@ describe "Osaka::RemoteControl" do
|
|
142
142
|
expect_exists?(at.button(1)).and_return(false, false, true)
|
143
143
|
expect(subject.wait_until_exists(at.button(1))).to eq at.button(1)
|
144
144
|
end
|
145
|
-
|
145
|
+
|
146
146
|
it "Should be able to wait until multiple locations exists and return the one that happened" do
|
147
147
|
expect_exists?(at.button(1)).and_return(false, false, false)
|
148
148
|
expect_exists?(at.sheet(5)).and_return(false, false, true)
|
@@ -155,29 +155,29 @@ describe "Osaka::RemoteControl" do
|
|
155
155
|
expect_exists?(at.sheet(5)).and_return(false, true)
|
156
156
|
expect(subject.wait_until_exists(at.button(1), at.sheet(5))).to eq at.sheet(5)
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
it "Should be able to wait for one location to NOT exist" do
|
160
160
|
expect_not_exists?(at.button(1)).and_return(false, false, true)
|
161
|
-
expect(subject.wait_until_not_exists!(at.button(1))).to eq at.button(1)
|
161
|
+
expect(subject.wait_until_not_exists!(at.button(1))).to eq at.button(1)
|
162
162
|
end
|
163
163
|
|
164
164
|
it "Should be able to wait for one location to NOT exist (with activate)" do
|
165
165
|
expect_activate
|
166
166
|
expect_not_exists?(at.button(4)).and_return(false, true)
|
167
|
-
expect(subject.wait_until_not_exists(at.button(4))).to eq at.button(4)
|
167
|
+
expect(subject.wait_until_not_exists(at.button(4))).to eq at.button(4)
|
168
168
|
end
|
169
|
-
|
169
|
+
|
170
170
|
it "Should be able to loop over some script until something happens" do
|
171
171
|
expect(Timeout).to receive(:timeout).with(10).and_yield
|
172
172
|
expect_execute_osascript.and_return("false", "false", "true")
|
173
173
|
expect_activate.twice
|
174
|
-
|
175
|
-
|
174
|
+
|
175
|
+
|
176
176
|
subject.until_exists!(at.window(1)) {
|
177
177
|
subject.activate
|
178
178
|
}
|
179
179
|
end
|
180
|
-
|
180
|
+
|
181
181
|
it "Should print a proper error message when it times out while waiting for something" do
|
182
182
|
expect(Timeout).to receive(:timeout).with(10).and_raise(Timeout::Error.new)
|
183
183
|
expect { subject.until_exists!(at.window(1)) }.to raise_error(Osaka::TimeoutError, "Timed out while waiting for: window 1")
|
@@ -200,17 +200,17 @@ describe "Osaka::RemoteControl" do
|
|
200
200
|
expect_execute_and_warning_for("activate")
|
201
201
|
subject.activate
|
202
202
|
end
|
203
|
-
|
203
|
+
|
204
204
|
it "Should be able to launch and deal with the warning" do
|
205
205
|
expect_execute_and_warning_for("launch")
|
206
|
-
subject.launch
|
206
|
+
subject.launch
|
207
207
|
end
|
208
208
|
end
|
209
|
-
|
210
|
-
|
209
|
+
|
210
|
+
|
211
211
|
|
212
212
|
context "Can send keystrokes to the application" do
|
213
|
-
|
213
|
+
|
214
214
|
it "Should be able to generate keystroke events" do
|
215
215
|
expect_execute_osascript(/keystroke "p"/).and_return("")
|
216
216
|
subject.keystroke!("p")
|
@@ -230,17 +230,17 @@ describe "Osaka::RemoteControl" do
|
|
230
230
|
expect_activate
|
231
231
|
expect_focus
|
232
232
|
expect_keystroke!("a")
|
233
|
-
subject.keystroke("a")
|
233
|
+
subject.keystroke("a")
|
234
234
|
end
|
235
235
|
|
236
236
|
it "Should be able to do keystrokes with command down" do
|
237
237
|
expect_execute_osascript(/keystroke "p" using {command down}/).and_return("")
|
238
|
-
subject.keystroke!("p", :command)
|
238
|
+
subject.keystroke!("p", :command)
|
239
239
|
end
|
240
240
|
|
241
241
|
it "Should be able to do keystrokes with option and command down" do
|
242
242
|
expect_execute_osascript(/keystroke "p" using {option down, command down}/).and_return("")
|
243
|
-
subject.keystroke!("p", [ :option, :command ])
|
243
|
+
subject.keystroke!("p", [ :option, :command ])
|
244
244
|
end
|
245
245
|
|
246
246
|
it "Should be able to do a keystroke and wait until something happen in one easy line" do
|
@@ -254,11 +254,11 @@ describe "Osaka::RemoteControl" do
|
|
254
254
|
expect_focus
|
255
255
|
expect_execute_osascript(/keystroke "p"/).and_return("")
|
256
256
|
expect_execute_osascript(/exists window 1/).and_return("true")
|
257
|
-
subject.keystroke("p").wait_until_exists!(at.window(1))
|
257
|
+
subject.keystroke("p").wait_until_exists!(at.window(1))
|
258
258
|
end
|
259
|
-
|
259
|
+
|
260
260
|
end
|
261
|
-
|
261
|
+
|
262
262
|
context "Can send mouse clicks to the application" do
|
263
263
|
|
264
264
|
it "Should be able to do clicks" do
|
@@ -269,7 +269,7 @@ describe "Osaka::RemoteControl" do
|
|
269
269
|
it "Should be able to do click and activate" do
|
270
270
|
expect_activate
|
271
271
|
expect_click!("button")
|
272
|
-
subject.click("button")
|
272
|
+
subject.click("button")
|
273
273
|
end
|
274
274
|
|
275
275
|
it "Should be able to do clicks and wait until something happened in one easy line" do
|
@@ -288,18 +288,18 @@ describe "Osaka::RemoteControl" do
|
|
288
288
|
it "Should be able to click on menu bar items" do
|
289
289
|
expect_activate
|
290
290
|
expect_click!(at.menu_item("Hey").menu(1).menu_bar_item("File").menu_bar(1))
|
291
|
-
subject.click_menu_bar(at.menu_item("Hey"), "File")
|
291
|
+
subject.click_menu_bar(at.menu_item("Hey"), "File")
|
292
292
|
end
|
293
|
-
|
293
|
+
|
294
294
|
end
|
295
|
-
|
295
|
+
|
296
296
|
context "Control should be able to set and get different application values" do
|
297
|
-
|
297
|
+
|
298
298
|
it "Should be able to set a value to an element" do
|
299
299
|
expect_system_event!(/set value of window 1 to "newvalue"/).and_return("")
|
300
300
|
subject.set!("value", at.window(1), "newvalue")
|
301
301
|
end
|
302
|
-
|
302
|
+
|
303
303
|
it "Prints a warning when setting and element and output is received" do
|
304
304
|
expect_execute_and_warning_for("set")
|
305
305
|
subject.set!("value", at.window(1), "newvalue")
|
@@ -307,7 +307,7 @@ describe "Osaka::RemoteControl" do
|
|
307
307
|
|
308
308
|
it "Should be able to set to boolean values" do
|
309
309
|
expect_system_event!(/set value of window 1 to true/).and_return("")
|
310
|
-
subject.set!("value", at.window(1), true)
|
310
|
+
subject.set!("value", at.window(1), true)
|
311
311
|
end
|
312
312
|
|
313
313
|
it "Should be able to get a value from an element" do
|
@@ -324,7 +324,7 @@ describe "Osaka::RemoteControl" do
|
|
324
324
|
it "Should combine the location and the window" do
|
325
325
|
subject.set_current_window("1")
|
326
326
|
expect_system_event!(/get value of dialog 2 of window "1"/).and_return("1\n")
|
327
|
-
expect(subject.get!("value", at.dialog(2))).to eq "1"
|
327
|
+
expect(subject.get!("value", at.dialog(2))).to eq "1"
|
328
328
|
end
|
329
329
|
|
330
330
|
it "Should be able to get values from the application itself" do
|
@@ -345,27 +345,30 @@ describe "Osaka::RemoteControl" do
|
|
345
345
|
|
346
346
|
it "Should be able get an array with one window name when there is exactly one window" do
|
347
347
|
expect_get_app!("windows").and_return("window one of application process process\n")
|
348
|
-
expect(subject.window_list).to eq ["one"]
|
348
|
+
expect(subject.window_list).to eq ["one"]
|
349
349
|
end
|
350
|
-
|
350
|
+
|
351
351
|
it "Should be able to get a list of standard windows which is empty" do
|
352
352
|
expect(subject).to receive(:window_list).and_return([])
|
353
353
|
subject.standard_window_list
|
354
354
|
end
|
355
|
-
|
355
|
+
|
356
356
|
it "Should be able to get a list of all the standard windows when there are only standard windows " do
|
357
357
|
expect(subject).to receive(:window_list).and_return(["window 1"])
|
358
|
+
expect_exists?(at.window("window 1")).and_return(true)
|
358
359
|
expect_get!("subrole", at.window("window 1")).and_return("AXStandardWindow")
|
359
360
|
expect(subject.standard_window_list).to eq ["window 1"]
|
360
361
|
end
|
361
|
-
|
362
|
+
|
362
363
|
it "Should be able to get a list of all the standard windows excluding the floating ones" do
|
363
364
|
expect(subject).to receive(:window_list).and_return(["window", "float"])
|
365
|
+
expect_exists?(at.window("window")).and_return(true)
|
366
|
+
expect_exists?(at.window("float")).and_return(true)
|
364
367
|
expect_get!("subrole", at.window("window")).and_return("AXStandardWindow")
|
365
368
|
expect_get!("subrole", at.window("float")).and_return("AXFloatingWindow")
|
366
|
-
expect(subject.standard_window_list).to eq ["window"]
|
369
|
+
expect(subject.standard_window_list).to eq ["window"]
|
367
370
|
end
|
368
|
-
|
371
|
+
|
369
372
|
it "Should be able to get the attributes of a window and parse the result" do
|
370
373
|
expect_get!("attributes", at.window(1)).and_return("attribute AXRole of window 1 of application process ApplicationName, attribute AXRoleDescription of window 1 of application process ApplicationName, attribute AXSubrole of window 1 of application process ApplicationName")
|
371
374
|
expect(subject.attributes(at.window(1))).to eq ["AXRole", "AXRoleDescription", "AXSubrole"]
|
@@ -375,7 +378,7 @@ describe "Osaka::RemoteControl" do
|
|
375
378
|
expect_get!("attributes", at.window(1)).and_return("attribute AXRole of application process ApplicationName, attribute AXRoleDescription of application process ApplicationName")
|
376
379
|
expect(subject.attributes(at.window(1))).to eq ["AXRole", "AXRoleDescription"]
|
377
380
|
end
|
378
|
-
|
381
|
+
|
379
382
|
end
|
380
383
|
|
381
384
|
describe "Dealing with base locations and window lists" do
|
@@ -387,44 +390,44 @@ describe "Osaka::RemoteControl" do
|
|
387
390
|
|
388
391
|
it "Should be able to get an array of multiple window names" do
|
389
392
|
expect_get_app!("windows").and_return("window one of application process process, window two of application process process\n")
|
390
|
-
expect(subject.window_list).to eq ["one", "two"]
|
393
|
+
expect(subject.window_list).to eq ["one", "two"]
|
391
394
|
end
|
392
|
-
|
395
|
+
|
393
396
|
it "Should be able to focus the currently active window" do
|
394
397
|
subject.base_location = at.sheet(1).window("boo")
|
395
398
|
expect_system_event!("set value of attribute \"AXMain\" of window \"boo\" to true")
|
396
399
|
subject.focus!
|
397
400
|
end
|
398
|
-
|
399
|
-
it "Should initialize the current window when it is not focused yet" do
|
401
|
+
|
402
|
+
it "Should initialize the current window when it is not focused yet" do
|
400
403
|
expect_window_list.and_return(["1"])
|
401
404
|
expect_focus!
|
402
405
|
subject.focus
|
403
406
|
expect(subject.current_window_name).to eq "1"
|
404
407
|
end
|
405
|
-
|
408
|
+
|
406
409
|
it "Should be able to extract the current window name also when the base location has more than just a window " do
|
407
410
|
subject.base_location = at.sheet(1).window("Window")
|
408
|
-
expect(subject.current_window_name).to eq "Window"
|
411
|
+
expect(subject.current_window_name).to eq "Window"
|
409
412
|
end
|
410
413
|
|
411
414
|
it "Shouldn't initialize current window when it is already set" do
|
412
415
|
subject.set_current_window("1")
|
413
416
|
expect_not_exists?(at.window("1")).and_return(false)
|
414
417
|
expect_focus!
|
415
|
-
|
418
|
+
|
416
419
|
subject.focus
|
417
420
|
expect(subject.base_location).to eq at.window("1")
|
418
421
|
end
|
419
|
-
|
422
|
+
|
420
423
|
it "Should re-initialize the current window when it doesn't exist anymore" do
|
421
424
|
subject.set_current_window("1")
|
422
425
|
expect_not_exists?(at.window("1")).and_return(true)
|
423
426
|
expect_window_list.and_return(["2"])
|
424
427
|
expect_focus!
|
425
|
-
|
428
|
+
|
426
429
|
subject.focus
|
427
|
-
expect(subject.current_window_name).to eq "2"
|
430
|
+
expect(subject.current_window_name).to eq "2"
|
428
431
|
end
|
429
432
|
|
430
433
|
it "Should focus the current window when it doesn't have focus" do
|
@@ -433,11 +436,11 @@ describe "Osaka::RemoteControl" do
|
|
433
436
|
expect_focus!
|
434
437
|
subject.focus
|
435
438
|
end
|
436
|
-
|
439
|
+
|
437
440
|
it "Shouldn't focus when there is no window set at all" do
|
438
441
|
expect_window_list.and_return([""])
|
439
442
|
subject.focus
|
440
443
|
end
|
441
|
-
|
442
|
-
end
|
444
|
+
|
445
|
+
end
|
443
446
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osaka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bas Vodde
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|