rformspec 0.4-x86-mingw32 → 0.5.1-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +57 -49
- data/MIT-LICENSE +21 -21
- data/README +24 -24
- data/Rakefile +63 -63
- data/docs/index.html +183 -183
- data/lib/ext/rspec_rformunit.rb +46 -46
- data/lib/rformspec.rb +41 -41
- data/lib/rformspec/control.rb +160 -153
- data/lib/rformspec/driver.rb +120 -72
- data/lib/rformspec/form_testcase.rb +40 -40
- data/lib/rformspec/keyboard.rb +24 -24
- data/lib/rformspec/mouse.rb +55 -55
- data/lib/rformspec/open_file_dialog.rb +19 -19
- data/lib/rformspec/process.rb +27 -27
- data/lib/rformspec/saveas_file_dialog.rb +18 -18
- data/lib/rformspec/testwise_plugin.rb +92 -0
- data/lib/rformspec/window.rb +130 -114
- data/sample/form_calculator/calc_helper.rb +68 -68
- data/sample/form_calculator/calc_spec.rb +33 -33
- data/sample/form_calculator/calculator.tpr +27 -27
- data/sample/form_calculator/calculator.tws +13 -13
- data/sample/mouse.rb +19 -19
- data/sample/notepad.rb +19 -19
- data/sample/notepad1.rb +14 -14
- data/sample/test_calc.rb +33 -33
- metadata +9 -7
data/lib/ext/rspec_rformunit.rb
CHANGED
@@ -1,46 +1,46 @@
|
|
1
|
-
class RSpecFormUnit
|
2
|
-
include YourModule # change to your module containing common methods used in your specs
|
3
|
-
|
4
|
-
def setup
|
5
|
-
@driver = GUIDriver.new()
|
6
|
-
|
7
|
-
@driver.AutoItSetOption("CaretCoordMode",0);
|
8
|
-
@driver.AutoItSetOption("ColorMode",1);
|
9
|
-
@driver.AutoItSetOption("MouseCoordMode",0);
|
10
|
-
@driver.AutoItSetOption("PixelCoordMode",0);
|
11
|
-
@driver.AutoItSetOption("SendKeyDelay", 20)
|
12
|
-
|
13
|
-
#Add it yourself
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
def timeout_check_equal(duration, expected, &block)
|
18
|
-
execute_ok = false
|
19
|
-
duration.times do
|
20
|
-
sleep(1)
|
21
|
-
text = instance_eval(&block)
|
22
|
-
execute_ok = true and break if (text == expected)
|
23
|
-
end
|
24
|
-
execute_ok.should == true
|
25
|
-
end
|
26
|
-
|
27
|
-
def timeout_check_include?(duration, expected, &block)
|
28
|
-
execute_ok = false
|
29
|
-
duration.times do
|
30
|
-
sleep(1)
|
31
|
-
text = instance_eval(&block)
|
32
|
-
execute_ok = true and break if text and text.include?(expected)
|
33
|
-
end
|
34
|
-
execute_ok.should == true
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
module Spec
|
39
|
-
module Runner
|
40
|
-
class Context
|
41
|
-
def before_context_eval
|
42
|
-
inherit RSpecFormUnit
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
1
|
+
class RSpecFormUnit
|
2
|
+
include YourModule # change to your module containing common methods used in your specs
|
3
|
+
|
4
|
+
def setup
|
5
|
+
@driver = GUIDriver.new()
|
6
|
+
|
7
|
+
@driver.AutoItSetOption("CaretCoordMode",0);
|
8
|
+
@driver.AutoItSetOption("ColorMode",1);
|
9
|
+
@driver.AutoItSetOption("MouseCoordMode",0);
|
10
|
+
@driver.AutoItSetOption("PixelCoordMode",0);
|
11
|
+
@driver.AutoItSetOption("SendKeyDelay", 20)
|
12
|
+
|
13
|
+
#Add it yourself
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def timeout_check_equal(duration, expected, &block)
|
18
|
+
execute_ok = false
|
19
|
+
duration.times do
|
20
|
+
sleep(1)
|
21
|
+
text = instance_eval(&block)
|
22
|
+
execute_ok = true and break if (text == expected)
|
23
|
+
end
|
24
|
+
execute_ok.should == true
|
25
|
+
end
|
26
|
+
|
27
|
+
def timeout_check_include?(duration, expected, &block)
|
28
|
+
execute_ok = false
|
29
|
+
duration.times do
|
30
|
+
sleep(1)
|
31
|
+
text = instance_eval(&block)
|
32
|
+
execute_ok = true and break if text and text.include?(expected)
|
33
|
+
end
|
34
|
+
execute_ok.should == true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Spec
|
39
|
+
module Runner
|
40
|
+
class Context
|
41
|
+
def before_context_eval
|
42
|
+
inherit RSpecFormUnit
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/rformspec.rb
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
#***********************************************************
|
2
|
-
#* Copyright (c) 2006, Zhimin Zhan.
|
3
|
-
#* Distributed open-source, see full license in MIT-LICENSE
|
4
|
-
#***********************************************************
|
5
|
-
|
6
|
-
# Extra full path to load libraries
|
7
|
-
require File.dirname(__FILE__) + "/rformspec/driver"
|
8
|
-
require File.dirname(__FILE__) + "/rformspec/control"
|
9
|
-
require File.dirname(__FILE__) + "/rformspec/mouse"
|
10
|
-
require File.dirname(__FILE__) + "/rformspec/keyboard"
|
11
|
-
require File.dirname(__FILE__) + "/rformspec/window"
|
12
|
-
require File.dirname(__FILE__) + "/rformspec/open_file_dialog"
|
13
|
-
require File.dirname(__FILE__) + "/rformspec/saveas_file_dialog"
|
14
|
-
require File.dirname(__FILE__) + "/rformspec/process"
|
15
|
-
require File.dirname(__FILE__) + "/rformspec/form_testcase"
|
16
|
-
|
17
|
-
module RFormSpec
|
18
|
-
|
19
|
-
class AutoIt
|
20
|
-
|
21
|
-
def self.init
|
22
|
-
$a3 = WIN32OLE.new('AutoItX3.Control')
|
23
|
-
|
24
|
-
$a3.AutoItSetOption("WinSearchChildren", 1); # Search Children window as well
|
25
|
-
$a3.AutoItSetOption("WinTitleMatchMode", 2);
|
26
|
-
|
27
|
-
$a3.AutoItSetOption("CaretCoordMode", 0);
|
28
|
-
$a3.AutoItSetOption("ColorMode", 1);
|
29
|
-
$a3.AutoItSetOption("MouseCoordMode", 0);
|
30
|
-
$a3.AutoItSetOption("PixelCoordMode", 0);
|
31
|
-
$a3.AutoItSetOption("SendKeyDelay", 15)
|
32
|
-
return $a3
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.set_option(key, value)
|
36
|
-
self.init if $a3.nil?
|
37
|
-
$a3.AutoItSetOption(key, value)
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
1
|
+
#***********************************************************
|
2
|
+
#* Copyright (c) 2006, Zhimin Zhan.
|
3
|
+
#* Distributed open-source, see full license in MIT-LICENSE
|
4
|
+
#***********************************************************
|
5
|
+
|
6
|
+
# Extra full path to load libraries
|
7
|
+
require File.dirname(__FILE__) + "/rformspec/driver"
|
8
|
+
require File.dirname(__FILE__) + "/rformspec/control"
|
9
|
+
require File.dirname(__FILE__) + "/rformspec/mouse"
|
10
|
+
require File.dirname(__FILE__) + "/rformspec/keyboard"
|
11
|
+
require File.dirname(__FILE__) + "/rformspec/window"
|
12
|
+
require File.dirname(__FILE__) + "/rformspec/open_file_dialog"
|
13
|
+
require File.dirname(__FILE__) + "/rformspec/saveas_file_dialog"
|
14
|
+
require File.dirname(__FILE__) + "/rformspec/process"
|
15
|
+
require File.dirname(__FILE__) + "/rformspec/form_testcase"
|
16
|
+
|
17
|
+
module RFormSpec
|
18
|
+
|
19
|
+
class AutoIt
|
20
|
+
|
21
|
+
def self.init
|
22
|
+
$a3 = WIN32OLE.new('AutoItX3.Control')
|
23
|
+
|
24
|
+
$a3.AutoItSetOption("WinSearchChildren", 1); # Search Children window as well
|
25
|
+
$a3.AutoItSetOption("WinTitleMatchMode", 2);
|
26
|
+
|
27
|
+
$a3.AutoItSetOption("CaretCoordMode", 0);
|
28
|
+
$a3.AutoItSetOption("ColorMode", 1);
|
29
|
+
$a3.AutoItSetOption("MouseCoordMode", 0);
|
30
|
+
$a3.AutoItSetOption("PixelCoordMode", 0);
|
31
|
+
$a3.AutoItSetOption("SendKeyDelay", 15)
|
32
|
+
return $a3
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.set_option(key, value)
|
36
|
+
self.init if $a3.nil?
|
37
|
+
$a3.AutoItSetOption(key, value)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
data/lib/rformspec/control.rb
CHANGED
@@ -1,153 +1,160 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/driver"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
@
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
ret
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
ret
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
1
|
+
require File.dirname(__FILE__) + "/driver"
|
2
|
+
module RFormSpec
|
3
|
+
class BaseControl
|
4
|
+
include Driver
|
5
|
+
|
6
|
+
attr_accessor :parent_win, :control_id
|
7
|
+
|
8
|
+
def initialize(win, ctrl_id)
|
9
|
+
@parent_win = win
|
10
|
+
@control_id = ctrl_id
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_text(new_text)
|
14
|
+
driver.ControlSetText(@parent_win.title, @parent_win.text, @control_id, new_text)
|
15
|
+
end
|
16
|
+
|
17
|
+
def send_text(text)
|
18
|
+
driver.ControlSend(@parent_win.title, @parent_win.text, @control_id, text)
|
19
|
+
end
|
20
|
+
alias send_keys send_text
|
21
|
+
|
22
|
+
def get_text
|
23
|
+
driver.ControlGetText(@parent_win.title, @parent_win.text, @control_id)
|
24
|
+
end
|
25
|
+
|
26
|
+
def focus
|
27
|
+
driver.ControlFocus(@parent_win.title, @parent_win.text, @control_id)
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_enabled?
|
31
|
+
ret = driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "IsEnabled" ,"")
|
32
|
+
ret == 1 or ret == "1"
|
33
|
+
end
|
34
|
+
|
35
|
+
def is_visible?
|
36
|
+
ret = driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "IsVisible" ,"")
|
37
|
+
ret == 1 or ret == "1"
|
38
|
+
end
|
39
|
+
|
40
|
+
def click
|
41
|
+
driver.ControlClick(@parent_win.title, @parent_win.text, @control_id)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
class TextBox < BaseControl
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
class Label < BaseControl
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
class CheckBox < BaseControl
|
55
|
+
def check
|
56
|
+
driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "Check" ,"")
|
57
|
+
end
|
58
|
+
|
59
|
+
def uncheck
|
60
|
+
driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "UnCheck" ,"")
|
61
|
+
end
|
62
|
+
|
63
|
+
def is_checked?
|
64
|
+
driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "IsChecked" ,"") == 1
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
class RadioButton < BaseControl
|
70
|
+
def check
|
71
|
+
driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "Check" ,"")
|
72
|
+
end
|
73
|
+
|
74
|
+
def uncheck
|
75
|
+
driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "UnCheck" ,"")
|
76
|
+
end
|
77
|
+
|
78
|
+
def is_checked?
|
79
|
+
driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "IsChecked" ,"") == 1
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
class ComboBox < BaseControl
|
85
|
+
|
86
|
+
def show_dropdown
|
87
|
+
driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "ShowDropDown" ,"")
|
88
|
+
end
|
89
|
+
|
90
|
+
def hide_dropdown
|
91
|
+
driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "HideDropDown" ,"")
|
92
|
+
end
|
93
|
+
|
94
|
+
def select_option(option)
|
95
|
+
driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "SelectString", option)
|
96
|
+
end
|
97
|
+
|
98
|
+
def find_option(option)
|
99
|
+
driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "FindString", option)
|
100
|
+
end
|
101
|
+
|
102
|
+
def set_selection(ref)
|
103
|
+
driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "SetCurrentSelection", ref)
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
class Button < BaseControl
|
110
|
+
end
|
111
|
+
|
112
|
+
class Tab < BaseControl
|
113
|
+
|
114
|
+
def current
|
115
|
+
driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "CurrentTab" , "")
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
class ListView < BaseControl
|
121
|
+
|
122
|
+
def item_count
|
123
|
+
result = driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "GetItemCount" , "", "").to_i
|
124
|
+
result ? result.to_i : 0
|
125
|
+
end
|
126
|
+
|
127
|
+
# row and column index starts from 0,
|
128
|
+
def get_item_text(row, col = 0)
|
129
|
+
driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "GetText" , "#{row}", col)
|
130
|
+
end
|
131
|
+
|
132
|
+
# can't use select, as it is Ruby keyword
|
133
|
+
def highlight(row_start, row_end = nil)
|
134
|
+
row_end ||= row_start
|
135
|
+
driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "Select" , "#{row_start}", "#{row_end}")
|
136
|
+
end
|
137
|
+
|
138
|
+
def de_highlight(row_start, row_end = nil)
|
139
|
+
row_end ||= row_start
|
140
|
+
driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "DeSelect" , "#{row_start}", "#{row_end}")
|
141
|
+
end
|
142
|
+
alias de_select de_highlight
|
143
|
+
|
144
|
+
def subitem_count
|
145
|
+
result = driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "GetSubItemCount" , "", "").to_i
|
146
|
+
result ? result.to_i : 0
|
147
|
+
end
|
148
|
+
|
149
|
+
def select_all
|
150
|
+
driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "SelectAll" , "", "")
|
151
|
+
end
|
152
|
+
|
153
|
+
def is_selected?(row)
|
154
|
+
1 == driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "IsSelected" , "#{row}", "")
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
end
|