osaka 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +32 -8
- data/lib/osaka/calculator.rb +10 -9
- data/lib/osaka/keynote.rb +4 -4
- data/lib/osaka/location.rb +4 -0
- data/lib/osaka/numbers.rb +1 -1
- data/lib/osaka/osakaexpectations.rb +132 -0
- data/lib/osaka/pages.rb +13 -13
- data/lib/osaka/{applicationwrapper.rb → remotecontrol.rb} +68 -31
- data/lib/osaka/scriptrunner.rb +9 -1
- data/lib/osaka/textedit.rb +4 -4
- data/lib/osaka/typicalapplication.rb +49 -107
- data/lib/osaka/typicalprintdialog.rb +32 -0
- data/lib/osaka/typicalsavedialog.rb +33 -0
- data/lib/osaka/version.rb +1 -1
- data/lib/osaka.rb +4 -2
- data/spec/assets/mail_merge_data.numbers +0 -0
- data/spec/assets/mail_merge_template.pages +0 -0
- data/spec/calculator_spec.rb +10 -12
- data/spec/integration_keynote_spec.rb +1 -0
- data/spec/integration_pages_numbers_mail_merge_spec.rb +1 -1
- data/spec/keynote_flows_spec.rb +4 -4
- data/spec/keynote_spec.rb +4 -4
- data/spec/location_spec.rb +6 -0
- data/spec/mailmergeflow_spec.rb +2 -2
- data/spec/numbers_spec.rb +2 -3
- data/spec/osakaexpectations_spec.rb +26 -0
- data/spec/pages_spec.rb +8 -8
- data/spec/remotecontrol_spec.rb +411 -0
- data/spec/scriptrunner_spec.rb +12 -0
- data/spec/textedit_spec.rb +2 -2
- data/spec/typicalapplication_spec.rb +195 -221
- data/spec/typicalprintdialog_spec.rb +33 -0
- data/spec/typicalsavedialog_spec.rb +51 -0
- metadata +10 -5
- data/lib/osaka/applicationwrapperexpectations.rb +0 -91
- data/spec/applicationwrapper_spec.rb +0 -296
@@ -1,104 +1,43 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Osaka
|
3
3
|
|
4
|
-
class TypicalSaveDialog
|
5
|
-
attr_accessor :wrapper
|
6
|
-
|
7
|
-
def initialize(self_location, wrapper)
|
8
|
-
@self_location = self_location
|
9
|
-
@wrapper = wrapper.clone
|
10
|
-
@wrapper.set_current_window("") if self_location.has_top_level_element?
|
11
|
-
end
|
12
|
-
|
13
|
-
def set_filename(filename)
|
14
|
-
@wrapper.set("value", at.text_field(1) + @self_location, filename)
|
15
|
-
end
|
16
|
-
|
17
|
-
def set_folder(pathname)
|
18
|
-
@wrapper.keystroke("g", [ :command, :shift ]).wait_until_exists(at.sheet(1) + @self_location)
|
19
|
-
@wrapper.set("value", at.text_field(1).sheet(1) + @self_location, pathname)
|
20
|
-
@wrapper.click(at.button("Go").sheet(1) + @self_location).wait_until_not_exists(at.sheet(1) + @self_location)
|
21
|
-
end
|
22
|
-
|
23
|
-
def click_save
|
24
|
-
@wrapper.click(at.button("Save") + @self_location).wait_until_not_exists(@self_location)
|
25
|
-
end
|
26
|
-
|
27
|
-
def save(filename)
|
28
|
-
set_filename(File.basename(filename))
|
29
|
-
set_folder(File.dirname(filename)) unless File.dirname(filename) == "."
|
30
|
-
click_save
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
class TypicalPrintDialog
|
36
|
-
attr_accessor :wrapper
|
37
|
-
|
38
|
-
def initialize(parent, wrapper)
|
39
|
-
@parent = parent
|
40
|
-
@wrapper = wrapper
|
41
|
-
end
|
42
|
-
|
43
|
-
def create_save_dialog(location, app)
|
44
|
-
TypicalSaveDialog.new(location, app)
|
45
|
-
end
|
46
|
-
|
47
|
-
def save_as_pdf(filename)
|
48
|
-
@wrapper.click!(at.menu_button("PDF") + @parent).wait_until_exists!(at.menu(1).menu_button("PDF") + @parent)
|
49
|
-
@wrapper.click!(at.menu_item(2).menu(1).menu_button("PDF") + @parent)
|
50
|
-
|
51
|
-
save_location = @wrapper.wait_until_exists!(at.window("Save"), at.sheet(1).window("Print"))
|
52
|
-
save_dialog = create_save_dialog(save_location, @wrapper)
|
53
|
-
save_dialog.save(filename)
|
54
|
-
|
55
|
-
@wrapper.until_not_exists!(@parent) {
|
56
|
-
# Weird, but sometimes the dialog "hangs around" and clicking this checkbox will make it go away.
|
57
|
-
# Anyone who knows a better solution, please let me know!
|
58
|
-
# This is for snow leopard
|
59
|
-
@wrapper.click!(at.checkbox(1) + @parent) if @wrapper.exists(at.checkbox(1) + @parent)
|
60
|
-
}
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
4
|
class ApplicationInfo
|
65
5
|
|
66
6
|
attr_reader :name
|
67
7
|
|
68
8
|
def initialize(script_info)
|
69
9
|
@name = script_info.match(/name:(.+?), creation date/)[1]
|
70
|
-
end
|
71
|
-
|
10
|
+
end
|
72
11
|
end
|
73
12
|
|
74
13
|
class TypicalApplication
|
75
14
|
|
76
|
-
attr_accessor :
|
15
|
+
attr_accessor :control
|
77
16
|
|
78
17
|
def initialize(name)
|
79
18
|
@name = name
|
80
|
-
@
|
19
|
+
@control = RemoteControl.new(name)
|
81
20
|
end
|
82
21
|
|
83
22
|
def initialize_copy(other)
|
84
23
|
super
|
85
|
-
@
|
24
|
+
@control = other.control.clone
|
86
25
|
end
|
87
26
|
|
88
27
|
def get_info
|
89
|
-
script_info =
|
28
|
+
script_info = control.tell("get info for (path to application \"#{@name}\")")
|
90
29
|
ApplicationInfo.new(script_info)
|
91
30
|
end
|
92
31
|
|
93
32
|
def open (filename)
|
94
33
|
abolutePathFileName = File.absolute_path(filename)
|
95
|
-
|
96
|
-
|
34
|
+
control.tell("open \"#{abolutePathFileName}\"")
|
35
|
+
control.set_current_window(File.basename(filename))
|
97
36
|
end
|
98
37
|
|
99
38
|
def wait_for_window_and_dialogs_to_close(option)
|
100
39
|
if (option != :user_chose)
|
101
|
-
|
40
|
+
control.until_not_exists!(control.base_location) {
|
102
41
|
close_dialog_sheet_with_dont_save
|
103
42
|
}
|
104
43
|
end
|
@@ -106,44 +45,44 @@ module Osaka
|
|
106
45
|
|
107
46
|
def wait_for_application_to_quit(option)
|
108
47
|
if (option != :user_chose)
|
109
|
-
while
|
48
|
+
while control.running?
|
110
49
|
close_dialog_sheet_with_dont_save
|
111
50
|
end
|
112
51
|
end
|
113
52
|
end
|
114
53
|
|
115
54
|
def close_dialog_sheet_with_dont_save
|
116
|
-
if (
|
117
|
-
|
55
|
+
if (control.exists?(at.sheet(1)))
|
56
|
+
control.click!(at.button("Don’t Save").sheet(1))
|
118
57
|
end
|
119
58
|
end
|
120
59
|
|
121
60
|
def quit(option = :user_chose)
|
122
|
-
if
|
123
|
-
|
61
|
+
if control.running?
|
62
|
+
control.quit
|
124
63
|
wait_for_application_to_quit(option)
|
125
64
|
end
|
126
65
|
end
|
127
66
|
|
128
67
|
def do_and_wait_for_new_window
|
129
|
-
|
130
|
-
latest_window_list = original_window_list =
|
68
|
+
control.activate
|
69
|
+
latest_window_list = original_window_list = control.window_list
|
131
70
|
yield
|
132
71
|
while (original_window_list == latest_window_list)
|
133
|
-
latest_window_list =
|
72
|
+
latest_window_list = control.window_list
|
134
73
|
end
|
135
74
|
(latest_window_list - original_window_list)[0]
|
136
75
|
end
|
137
76
|
|
138
77
|
def new_document
|
139
|
-
|
140
|
-
|
78
|
+
control.set_current_window(do_and_wait_for_new_window {
|
79
|
+
control.keystroke("n", :command)
|
141
80
|
})
|
142
|
-
|
81
|
+
control.focus
|
143
82
|
end
|
144
83
|
|
145
84
|
def duplicate_available?
|
146
|
-
|
85
|
+
control.exists?(at.menu_item("Duplicate").menu(1).menu_bar_item("File").menu_bar(1))
|
147
86
|
end
|
148
87
|
|
149
88
|
def duplicate
|
@@ -151,90 +90,93 @@ module Osaka
|
|
151
90
|
raise(Osaka::VersioningError, "MacOS Versioning Error: Duplicate is not available on this Mac version")
|
152
91
|
end
|
153
92
|
new_window = do_and_wait_for_new_window {
|
154
|
-
|
93
|
+
control.click_menu_bar(at.menu_item("Duplicate"), "File")
|
155
94
|
}
|
156
95
|
new_instance = clone
|
157
|
-
new_instance.
|
96
|
+
new_instance.control.set_current_window(do_and_wait_for_new_window {
|
158
97
|
sleep(0.4) # This sleep is added because mountain lion keynote crashes without it!
|
159
|
-
|
160
|
-
})
|
98
|
+
control.keystroke!(:return)
|
99
|
+
}) unless control.mac_version == :lion
|
161
100
|
|
162
101
|
new_instance
|
163
102
|
end
|
164
103
|
|
165
104
|
def save
|
166
|
-
|
105
|
+
control.keystroke("s", :command)
|
167
106
|
end
|
168
107
|
|
169
108
|
def save_pops_up_dialog?
|
170
|
-
|
109
|
+
control.exists?(at.menu_item("Save…").menu(1).menu_bar_item("File").menu_bar(1))
|
171
110
|
end
|
172
111
|
|
173
112
|
def save_dialog
|
174
113
|
if save_pops_up_dialog?
|
175
114
|
save
|
176
|
-
|
115
|
+
control.wait_until_exists(at.sheet(1))
|
177
116
|
else
|
178
|
-
|
117
|
+
control.keystroke("s", [:command, :shift]).wait_until_exists(at.sheet(1))
|
179
118
|
end
|
180
|
-
create_save_dialog(at.sheet(1))
|
119
|
+
create_save_dialog(at.sheet(1) + control.base_location)
|
181
120
|
end
|
182
121
|
|
183
122
|
def save_as(filename)
|
184
123
|
if duplicate_available?
|
185
|
-
new_instance = duplicate
|
186
|
-
close
|
187
|
-
@
|
188
|
-
end
|
124
|
+
new_instance = duplicate
|
125
|
+
close
|
126
|
+
@control = new_instance.control.clone
|
127
|
+
end
|
189
128
|
dialog = save_dialog
|
190
129
|
dialog.save(filename)
|
191
|
-
|
130
|
+
control.set_current_window(File.basename(filename))
|
192
131
|
end
|
193
132
|
|
194
133
|
def close(option = :user_chose)
|
195
|
-
|
134
|
+
control.keystroke("w", :command)
|
196
135
|
wait_for_window_and_dialogs_to_close(option)
|
197
136
|
end
|
198
137
|
|
199
138
|
def activate
|
200
|
-
|
139
|
+
if (control.mac_version == :lion)
|
140
|
+
control.launch unless control.running?
|
141
|
+
end
|
142
|
+
control.activate
|
201
143
|
end
|
202
144
|
|
203
145
|
def focus
|
204
|
-
|
146
|
+
control.focus
|
205
147
|
end
|
206
148
|
|
207
149
|
def running?
|
208
|
-
|
150
|
+
control.running?
|
209
151
|
end
|
210
152
|
|
211
153
|
def copy
|
212
|
-
|
154
|
+
control.keystroke("c", :command)
|
213
155
|
end
|
214
156
|
|
215
157
|
def paste
|
216
|
-
|
158
|
+
control.keystroke("v", :command)
|
217
159
|
end
|
218
160
|
|
219
161
|
def cut
|
220
|
-
|
162
|
+
control.keystroke("x", :command)
|
221
163
|
end
|
222
164
|
|
223
165
|
def select_all
|
224
|
-
|
166
|
+
control.keystroke("a", :command)
|
225
167
|
end
|
226
168
|
|
227
169
|
def create_print_dialog(location)
|
228
|
-
TypicalPrintDialog.new(
|
170
|
+
TypicalPrintDialog.new(control.name, location)
|
229
171
|
end
|
230
172
|
|
231
173
|
def create_save_dialog(location)
|
232
|
-
TypicalSaveDialog.new(
|
174
|
+
TypicalSaveDialog.new(control.name, location)
|
233
175
|
end
|
234
176
|
|
235
177
|
def print_dialog
|
236
|
-
|
237
|
-
create_print_dialog(at.sheet(1))
|
178
|
+
control.keystroke("p", :command).wait_until_exists(at.sheet(1))
|
179
|
+
create_print_dialog(at.sheet(1) + control.base_location)
|
238
180
|
end
|
239
181
|
|
240
182
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Osaka
|
3
|
+
|
4
|
+
class TypicalPrintDialog
|
5
|
+
attr_accessor :control
|
6
|
+
|
7
|
+
def initialize(application_name, own_location)
|
8
|
+
@control = Osaka::RemoteControl.new(application_name, own_location)
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_save_dialog(application_name, own_location)
|
12
|
+
TypicalSaveDialog.new(application_name, own_location)
|
13
|
+
end
|
14
|
+
|
15
|
+
def save_as_pdf(filename)
|
16
|
+
control.click!(at.menu_button("PDF")).wait_until_exists!(at.menu(1).menu_button("PDF"))
|
17
|
+
control.click!(at.menu_item(2).menu(1).menu_button("PDF"))
|
18
|
+
|
19
|
+
save_location = control.wait_until_exists!(at.window("Save"), at.sheet(1) + control.base_location)
|
20
|
+
save_dialog = create_save_dialog(control.name, save_location)
|
21
|
+
save_dialog.save(filename)
|
22
|
+
|
23
|
+
control.until_not_exists!(control.base_location) {
|
24
|
+
# Weird, but sometimes the dialog "hangs around" and clicking this checkbox will make it go away.
|
25
|
+
# Anyone who knows a better solution, please let me know!
|
26
|
+
# This is for snow leopard
|
27
|
+
control.click!(at.checkbox(1)) if control.exists?(at.checkbox(1))
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Osaka
|
3
|
+
|
4
|
+
class TypicalSaveDialog
|
5
|
+
attr_accessor :control
|
6
|
+
|
7
|
+
def initialize(application_name, own_location)
|
8
|
+
@control = Osaka::RemoteControl.new(application_name, own_location)
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_filename(filename)
|
12
|
+
control.set("value", at.text_field(1), filename)
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_folder(pathname)
|
16
|
+
control.keystroke("g", [ :command, :shift ]).wait_until_exists(at.sheet(1))
|
17
|
+
control.set("value", at.text_field(1).sheet(1), pathname)
|
18
|
+
control.click(at.button("Go").sheet(1)).wait_until_not_exists(at.sheet(1))
|
19
|
+
end
|
20
|
+
|
21
|
+
def click_save
|
22
|
+
control.click(at.button("Save")).wait_until_not_exists(control.base_location)
|
23
|
+
end
|
24
|
+
|
25
|
+
def save(filename)
|
26
|
+
set_filename(File.basename(filename))
|
27
|
+
set_folder(File.dirname(filename)) unless File.dirname(filename) == "."
|
28
|
+
click_save
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/lib/osaka/version.rb
CHANGED
data/lib/osaka.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
|
2
2
|
require 'osaka/scriptrunner'
|
3
3
|
require 'osaka/location'
|
4
|
-
require 'osaka/
|
5
|
-
require 'osaka/applicationwrapperexpectations'
|
4
|
+
require 'osaka/remotecontrol'
|
6
5
|
require 'osaka/typicalapplication'
|
6
|
+
require 'osaka/typicalsavedialog'
|
7
|
+
require 'osaka/typicalprintdialog'
|
7
8
|
require 'osaka/pages'
|
8
9
|
require 'osaka/numbers'
|
9
10
|
require 'osaka/keynote'
|
@@ -11,4 +12,5 @@ require 'osaka/calculator'
|
|
11
12
|
require 'osaka/textedit'
|
12
13
|
require 'osaka/mailmergeflow'
|
13
14
|
require 'osaka/keynoteflow'
|
15
|
+
require 'osaka/osakaexpectations'
|
14
16
|
|
Binary file
|
Binary file
|
data/spec/calculator_spec.rb
CHANGED
@@ -3,20 +3,18 @@ require 'osaka'
|
|
3
3
|
|
4
4
|
describe "Mac GUI Calculator" do
|
5
5
|
|
6
|
-
include(*Osaka::
|
6
|
+
include(*Osaka::OsakaExpectations)
|
7
7
|
|
8
8
|
subject { Osaka::Calculator.new }
|
9
|
-
let(:
|
9
|
+
let(:control) { subject.control = mock("RemoteControl", :mac_version => :mountain_lion)}
|
10
10
|
|
11
11
|
it "Should be setting the window when starting the Calculator" do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
wrapper.should_receive(:activate)
|
16
|
-
wrapper.should_receive(:current_window_name).and_return("")
|
12
|
+
|
13
|
+
expect_activate
|
14
|
+
expect_current_window_name.and_return("")
|
17
15
|
subject.should_receive(:wait_for_new_window).with([])
|
18
|
-
|
19
|
-
|
16
|
+
expect_window_list.and_return(["Calculator"])
|
17
|
+
expect_set_current_window("Calculator")
|
20
18
|
subject.activate
|
21
19
|
end
|
22
20
|
|
@@ -31,14 +29,14 @@ describe "Mac GUI Calculator" do
|
|
31
29
|
end
|
32
30
|
|
33
31
|
it "Should be able to quit the calculator" do
|
34
|
-
|
35
|
-
|
32
|
+
expect_running?.and_return(true)
|
33
|
+
expect_quit
|
36
34
|
subject.quit
|
37
35
|
end
|
38
36
|
|
39
37
|
it "Should be able to get the value from the screen" do
|
40
38
|
expect_wait_until_exists!(at.static_text(1).group(1))
|
41
|
-
|
39
|
+
expect_get!("value", at.static_text(1).group(1)).and_return("0")
|
42
40
|
subject.result.should == "0"
|
43
41
|
end
|
44
42
|
|
@@ -4,6 +4,7 @@ require 'osaka'
|
|
4
4
|
describe "Integration tests for Keynote and Common Flows" do
|
5
5
|
|
6
6
|
it "Should be able to do a combine with just one file" do
|
7
|
+
|
7
8
|
assets_directory = File.join(File.dirname(__FILE__), "assets")
|
8
9
|
|
9
10
|
keynote_file = File.join(assets_directory, "01_first_slides.key")
|
@@ -4,7 +4,7 @@ require 'osaka'
|
|
4
4
|
describe "Integration of mail merge flow with Pages and Numbers" do
|
5
5
|
|
6
6
|
it "Should mail merge the assets and generate a PDF" do
|
7
|
-
|
7
|
+
|
8
8
|
assets_directory = File.join(File.dirname(__FILE__), "assets")
|
9
9
|
numbers_data = File.join(assets_directory, "mail_merge_data.numbers")
|
10
10
|
pages_template = File.join(assets_directory, "mail_merge_template.pages")
|
data/spec/keynote_flows_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require "osaka"
|
|
3
3
|
|
4
4
|
describe "Common flows in keynote" do
|
5
5
|
|
6
|
-
let(:mock_keynote) {
|
6
|
+
let(:mock_keynote) { mock("First keynote")}
|
7
7
|
|
8
8
|
it "Should be able to combine just one single file" do
|
9
9
|
Osaka::Keynote.should_receive(:new).and_return(mock_keynote)
|
@@ -15,8 +15,8 @@ describe "Common flows in keynote" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "Should be able to combine multiple files in one result" do
|
18
|
-
mock2_keynote =
|
19
|
-
mock3_keynote =
|
18
|
+
mock2_keynote = mock("Second keynote")
|
19
|
+
mock3_keynote = mock("Third keynote")
|
20
20
|
Osaka::Keynote.should_receive(:new).and_return(mock_keynote, mock2_keynote, mock3_keynote)
|
21
21
|
mock_keynote.should_receive(:open).with("one_file.key")
|
22
22
|
mock_keynote.should_receive(:save_as).with("result.key")
|
@@ -50,7 +50,7 @@ describe "Common flows in keynote" do
|
|
50
50
|
it "Should be able to combine multiple files from one directory sorted with pattern" do
|
51
51
|
files_in_dir = [".", "..", "05_file.key", "02key.wrong", "another", "01hey.key", "last"]
|
52
52
|
files_in_dir_to_be_used = ["dirname/01hey.key", "dirname/05_file.key"]
|
53
|
-
mocked_dir =
|
53
|
+
mocked_dir = mock("Directory with keynote files")
|
54
54
|
Dir.should_receive(:new).with("dirname").and_return(mocked_dir)
|
55
55
|
mocked_dir.should_receive(:entries).and_return(files_in_dir)
|
56
56
|
CommonFlows.should_receive(:keynote_combine_files).with("results.key", files_in_dir_to_be_used)
|
data/spec/keynote_spec.rb
CHANGED
@@ -3,10 +3,10 @@ require 'osaka'
|
|
3
3
|
|
4
4
|
describe "Osaka::Keynote" do
|
5
5
|
|
6
|
-
include(*Osaka::
|
6
|
+
include(*Osaka::OsakaExpectations)
|
7
7
|
|
8
8
|
subject { Osaka::Keynote.new }
|
9
|
-
let(:
|
9
|
+
let(:control) {subject.control = mock("RemoteControl").as_null_object}
|
10
10
|
|
11
11
|
it "Should create the correct keynote print dialog" do
|
12
12
|
subject.create_print_dialog("window").should be_instance_of Osaka::KeynotePrintDialog
|
@@ -14,7 +14,7 @@ describe "Osaka::Keynote" do
|
|
14
14
|
|
15
15
|
it "Should be possible to select all the slides in the default location" do
|
16
16
|
slides_button_location = at.button("Slides").group(1).outline(1).scroll_area(2).splitter_group(1).splitter_group(1)
|
17
|
-
expect_exists(slides_button_location).and_return(true)
|
17
|
+
expect_exists?(slides_button_location).and_return(true)
|
18
18
|
expect_click(slides_button_location)
|
19
19
|
subject.should_receive(:select_all)
|
20
20
|
subject.select_all_slides
|
@@ -23,7 +23,7 @@ describe "Osaka::Keynote" do
|
|
23
23
|
it "Should be possible to select all the slides in the alternative location" do
|
24
24
|
slides_button_location = at.button("Slides").group(1).outline(1).scroll_area(2).splitter_group(1).splitter_group(1)
|
25
25
|
alternative_slides_button_location = at.button("Slides").group(1).outline(1).scroll_area(1).splitter_group(1).splitter_group(1)
|
26
|
-
expect_exists(slides_button_location).and_return(false)
|
26
|
+
expect_exists?(slides_button_location).and_return(false)
|
27
27
|
expect_click(alternative_slides_button_location)
|
28
28
|
subject.should_receive(:select_all)
|
29
29
|
subject.select_all_slides
|
data/spec/location_spec.rb
CHANGED
@@ -13,6 +13,12 @@ describe "Location path for an applescript command" do
|
|
13
13
|
location.to_s.should == "location"
|
14
14
|
end
|
15
15
|
|
16
|
+
it "Should be able to get the top-level element out" do
|
17
|
+
location = at.sheet(1).sheet(2).window("three")
|
18
|
+
location.top_level_element.should == at.window("three")
|
19
|
+
end
|
20
|
+
|
21
|
+
|
16
22
|
it "Should be able to create locations using at" do
|
17
23
|
at.button(1).to_s.should == "button 1"
|
18
24
|
end
|
data/spec/mailmergeflow_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require "osaka"
|
|
3
3
|
|
4
4
|
describe "Mail Merge to PDF common flow" do
|
5
5
|
|
6
|
-
let(:mock_numbers) {
|
7
|
-
let(:mock_pages) {
|
6
|
+
let(:mock_numbers) { mock("Number")}
|
7
|
+
let(:mock_pages) { mock("Pages") }
|
8
8
|
|
9
9
|
it "Should do a good mail merge with Pages and Keynote flow" do
|
10
10
|
Osaka::Numbers.should_receive(:new).and_return(mock_numbers)
|
data/spec/numbers_spec.rb
CHANGED
@@ -3,13 +3,12 @@ require 'osaka'
|
|
3
3
|
|
4
4
|
describe "Osaka::Numbers" do
|
5
5
|
|
6
|
-
include(*Osaka::
|
6
|
+
include(*Osaka::OsakaExpectations)
|
7
7
|
|
8
8
|
subject { Osaka::Numbers.new }
|
9
|
-
let(:
|
9
|
+
let(:control) { subject.control = mock("RemoteControl").as_null_object}
|
10
10
|
|
11
11
|
it "Should be able to fill in data in cells" do
|
12
|
-
# subject.wrapper.should_receive(:tell).with('tell document 1; tell sheet 1; tell table 1; set value of cell 1 of row 2 to "30"; end tell; end tell; end tell')
|
13
12
|
expect_tell('tell document 1; tell sheet 1; tell table 1; set value of cell 1 of row 2 to "30"; end tell; end tell; end tell')
|
14
13
|
subject.fill_cell(1, 2, "30")
|
15
14
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
require 'osaka'
|
3
|
+
|
4
|
+
describe "Osakas Ruby expectations" do
|
5
|
+
|
6
|
+
include(*Osaka::OsakaExpectations)
|
7
|
+
|
8
|
+
subject { mock("RemoteControl") }
|
9
|
+
let(:control) { subject }
|
10
|
+
|
11
|
+
it "Wait until exists can be called without a code block" do
|
12
|
+
expect_wait_until_exists!(at.window(1))
|
13
|
+
subject.wait_until_exists!(at.window(1))
|
14
|
+
end
|
15
|
+
|
16
|
+
it "Wait until exists can be called with a code block" do
|
17
|
+
code_block_been_called = false
|
18
|
+
expect_wait_until_exists!(at.window(1)).and_yield
|
19
|
+
|
20
|
+
subject.wait_until_exists!(at.window(1)) {
|
21
|
+
code_block_been_called = true
|
22
|
+
}
|
23
|
+
code_block_been_called.should be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/spec/pages_spec.rb
CHANGED
@@ -3,16 +3,16 @@ require 'osaka'
|
|
3
3
|
|
4
4
|
describe "Osaka::Pages" do
|
5
5
|
|
6
|
-
include(*Osaka::
|
6
|
+
include(*Osaka::OsakaExpectations)
|
7
7
|
|
8
8
|
subject { Osaka::Pages.new }
|
9
9
|
|
10
|
-
let (:
|
10
|
+
let (:control) { subject.control = mock("Remote Control").as_null_object}
|
11
11
|
|
12
12
|
it "Should be able to do mail merge to a PDF flow" do
|
13
13
|
|
14
|
-
mail_merge_dialog =
|
15
|
-
print_dialog =
|
14
|
+
mail_merge_dialog = mock("Pages Mail Merge Dialog")
|
15
|
+
print_dialog = mock("Generic Print Dialog")
|
16
16
|
|
17
17
|
subject.should_receive(:mail_merge).and_return(mail_merge_dialog)
|
18
18
|
mail_merge_dialog.should_receive(:merge).and_return(print_dialog)
|
@@ -23,14 +23,14 @@ describe "Osaka::Pages" do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "Should be able to select the Mail Merge" do
|
26
|
-
|
26
|
+
expect_current_window_name.any_number_of_times.and_return("Pages.pages")
|
27
27
|
expect_click_menu_bar(at.menu_item(20), "Edit")
|
28
28
|
expect_wait_until_exists(at.button("Merge").sheet(1))
|
29
29
|
subject.mail_merge
|
30
30
|
end
|
31
31
|
|
32
32
|
it "Should click the merge button of the mail merge dialog" do
|
33
|
-
|
33
|
+
expect_current_window_name.any_number_of_times.and_return("Pages.pages")
|
34
34
|
expect_click!(at.button("Merge").sheet(1))
|
35
35
|
expect_wait_until_exists!(at.menu_button("PDF").window("Print"))
|
36
36
|
subject.mail_merge.merge
|
@@ -39,10 +39,10 @@ end
|
|
39
39
|
|
40
40
|
describe "Osaka::Pages Mail Merge dialog" do
|
41
41
|
|
42
|
-
include(*Osaka::
|
42
|
+
include(*Osaka::OsakaExpectations)
|
43
43
|
|
44
44
|
subject { Osaka::PagesMailMergeDialog.new("", nil) }
|
45
|
-
let(:
|
45
|
+
let(:control) {subject.control = mock("RemoteControl").as_null_object}
|
46
46
|
|
47
47
|
it "Should be able to set the mail merge dialog to merge to new document" do
|
48
48
|
expect_click(at.pop_up_button(2).sheet(1))
|