rformspec 0.4-x86-mingw32 → 0.5.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -1,153 +1,160 @@
1
- require File.dirname(__FILE__) + "/driver"
2
-
3
- module RFormSpec
4
- class BaseControl
5
- include Driver
6
-
7
- attr_accessor :parent_win, :control_id
8
-
9
- def initialize(win, ctrl_id)
10
- @parent_win = win
11
- @control_id = ctrl_id
12
- end
13
-
14
- def set_text(new_text)
15
- driver.ControlSetText(@parent_win.title, @parent_win.text, @control_id, new_text)
16
- end
17
-
18
- def send_text(text)
19
- driver.ControlSend(@parent_win.title, @parent_win.text, @control_id, text)
20
- end
21
- alias send_keys send_text
22
-
23
- def get_text
24
- driver.ControlGetText(@parent_win.title, @parent_win.text, @control_id)
25
- end
26
-
27
- def focus
28
- driver.ControlFocus(@parent_win.title, @parent_win.text, @control_id)
29
- end
30
-
31
- def is_enabled?
32
- ret = driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "IsEnabled" ,"")
33
- ret == 1 or ret == "1"
34
- end
35
-
36
- def is_visible?
37
- ret = driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "IsVisible" ,"")
38
- ret == 1 or ret == "1"
39
- end
40
-
41
- def click
42
- driver.ControlClick(@parent_win.title, @parent_win.text, @control_id)
43
- end
44
-
45
- end
46
-
47
- class TextBox < BaseControl
48
-
49
- end
50
-
51
- class Label < BaseControl
52
-
53
- end
54
-
55
- class CheckBox < BaseControl
56
- def check
57
- driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "Check" ,"")
58
- end
59
-
60
- def uncheck
61
- driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "UnCheck" ,"")
62
- end
63
-
64
- def is_checked?
65
- driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "IsChecked" ,"") == 1
66
- end
67
-
68
- end
69
-
70
- class RadioButton < BaseControl
71
- def check
72
- driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "Check" ,"")
73
- end
74
-
75
- def uncheck
76
- driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "UnCheck" ,"")
77
- end
78
-
79
- def is_checked?
80
- driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "IsChecked" ,"") == 1
81
- end
82
-
83
- end
84
-
85
- class ComboBox < BaseControl
86
-
87
- def show_dropdown
88
- driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "ShowDropDown" ,"")
89
- end
90
-
91
- def hide_dropdown
92
- driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "HideDropDown" ,"")
93
- end
94
-
95
- def select_option(option)
96
- driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "SelectString" , option)
97
- end
98
-
99
- end
100
-
101
-
102
- class Button < BaseControl
103
- end
104
-
105
- class Tab < BaseControl
106
-
107
- def current
108
- driver.ControlCommand(@parent_win.title, @parent_win.text, @control_id, "CurrentTab" , "")
109
- end
110
-
111
- end
112
-
113
- class ListView < BaseControl
114
-
115
- def item_count
116
- result = driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "GetItemCount" , "", "").to_i
117
- result ? result.to_i : 0
118
- end
119
-
120
- # row and column index starts from 0,
121
- def get_item_text(row, col = 0)
122
- driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "GetText" , "#{row}", col)
123
- end
124
-
125
- # can't use select, as it is Ruby keyword
126
- def highlight(row_start, row_end = nil)
127
- row_end ||= row_start
128
- driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "Select" , "#{row_start}", "#{row_end}")
129
- end
130
-
131
- def de_highlight(row_start, row_end = nil)
132
- row_end ||= row_start
133
- driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "DeSelect" , "#{row_start}", "#{row_end}")
134
- end
135
- alias de_select de_highlight
136
-
137
- def subitem_count
138
- result = driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "GetSubItemCount" , "", "").to_i
139
- result ? result.to_i : 0
140
- end
141
-
142
- def select_all
143
- driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "SelectAll" , "", "")
144
- end
145
-
146
- def is_selected?(row)
147
- 1 == driver.ControlListView(@parent_win.title, @parent_win.text, @control_id, "IsSelected" , "#{row}", "")
148
- end
149
-
150
- end
151
-
152
-
153
- end
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