rformunit 0.1.0-mswin32 → 0.1.1-mswin32
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/Rakefile +1 -1
- data/docs/index.html +7 -9
- data/lib/rformunit/driver.rb +0 -16
- data/lib/rformunit/keyboard.rb +12 -1
- data/lib/rformunit/mouse.rb +26 -5
- data/lib/rformunit/process.rb +17 -4
- data/sample/calc.rb +2 -2
- data/sample/notepad.rb +6 -6
- data/sample/notepad1.rb +3 -3
- data/sample/test_calc.rb +2 -1
- metadata +2 -2
data/Rakefile
CHANGED
@@ -36,7 +36,7 @@ Rake::RDocTask.new { |rdoc|
|
|
36
36
|
spec = Gem::Specification.new do |s|
|
37
37
|
s.platform= Gem::Platform::WIN32
|
38
38
|
s.name = "rformunit"
|
39
|
-
s.version = "0.1.
|
39
|
+
s.version = "0.1.1"
|
40
40
|
s.summary = "An wrap of AUTOIT3 for functional testing of Windows form applications"
|
41
41
|
# s.description = ""
|
42
42
|
|
data/docs/index.html
CHANGED
@@ -31,8 +31,8 @@ BODY
|
|
31
31
|
<p>rFormUnit is a simple framework for automated testing <b>Windows Form</b> applications. It wraps <a href="http://www.autoitscript.com/autoit3/">AutoItX</a> COM API to provide an alternative way to write an easy to use, readable automated functional tests.
|
32
32
|
</p>
|
33
33
|
|
34
|
-
<p>Current release: 0.1.
|
35
|
-
<a href="releases/rformunit-0.1.
|
34
|
+
<p>Current release: 0.1.1<br/>
|
35
|
+
<a href="releases/rformunit-0.1.1-mswin32.gem">rformunit-0.1.1-mswin32.gem</a> or from <a href="http://rubyforge.org/projects/rformunit/">rubyforge.org</a>,
|
36
36
|
|
37
37
|
<!-- <a href="releases/changelog.txt">Change logs</a> <br/> -->
|
38
38
|
Documentation: <a href="rdoc/index.html">RDoc</a>, and Quick start guide below.
|
@@ -88,19 +88,17 @@ Send("n")
|
|
88
88
|
|
89
89
|
<td valign="top" nowrap="nowrap" class="green">
|
90
90
|
<pre>require 'rformunit'
|
91
|
+
|
91
92
|
include RFormUnit::Driver
|
92
93
|
|
93
|
-
|
94
|
+
RFormUnit::Process.run("NOTEPAD.EXE")
|
94
95
|
notepad_win = RFormUnit::Window.new('Untitled - Notepad')
|
95
|
-
|
96
|
-
keyboard.type("Hello from Notepad, {ENTER}1 2 3{ENTER}")
|
96
|
+
RFormUnit::Keyboard.type("Hello from Notepad, {ENTER}1 2 3 4 5 6 7 8 9 10{ENTER}")
|
97
97
|
sleep(0.5)
|
98
|
-
|
98
|
+
RFormUnit::Keyboard.press("+{UP 2}")
|
99
99
|
sleep(0.5)
|
100
|
-
|
101
100
|
notepad_win.close
|
102
101
|
|
103
|
-
|
104
102
|
notepad_confirm_dialog = RFormUnit::Window.new('Notepad', 'No')
|
105
103
|
notepad_confirm_dialog.click_button('&No')</pre>
|
106
104
|
</td>
|
@@ -114,7 +112,7 @@ notepad_confirm_dialog.click_button('&No')</pre>
|
|
114
112
|
|
115
113
|
class CalcTest < RFormUnit::FormTestCase
|
116
114
|
def setup
|
117
|
-
|
115
|
+
RFormUnit::Process.run("calc.exe")
|
118
116
|
@calc_win = RFormUnit::Window.new('Calculator')
|
119
117
|
end
|
120
118
|
|
data/lib/rformunit/driver.rb
CHANGED
@@ -25,21 +25,6 @@ module RFormUnit
|
|
25
25
|
@a3.AutoItSetOption(key,value)
|
26
26
|
end
|
27
27
|
|
28
|
-
def keyboard
|
29
|
-
return @keyboard if @keyboard
|
30
|
-
@keyboard = Keyboard.new
|
31
|
-
end
|
32
|
-
|
33
|
-
def mouse
|
34
|
-
return @mouse if @mouse
|
35
|
-
@mouse = Mouse.new
|
36
|
-
end
|
37
|
-
|
38
|
-
def process
|
39
|
-
return @process if @process
|
40
|
-
@process = Process.new
|
41
|
-
end
|
42
|
-
|
43
28
|
def wait_for_window(win, timeout=30)
|
44
29
|
driver.WinWait(win.title, win.text, timeout * 1000)
|
45
30
|
win
|
@@ -61,6 +46,5 @@ module RFormUnit
|
|
61
46
|
driver.WinClose(title)
|
62
47
|
end
|
63
48
|
|
64
|
-
|
65
49
|
end
|
66
50
|
end
|
data/lib/rformunit/keyboard.rb
CHANGED
@@ -1,10 +1,21 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/driver"
|
2
|
+
require 'singleton'
|
2
3
|
|
3
4
|
module RFormUnit
|
4
5
|
class Keyboard
|
6
|
+
include Singleton
|
5
7
|
include Driver
|
6
8
|
|
7
|
-
|
9
|
+
def self.type(keys)
|
10
|
+
instance._type(keys)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.press(key)
|
14
|
+
instance._type(key)
|
15
|
+
end
|
16
|
+
|
17
|
+
# instance methods
|
18
|
+
def _type(keystrokes)
|
8
19
|
driver.Send(keystrokes)
|
9
20
|
end
|
10
21
|
alias press type
|
data/lib/rformunit/mouse.rb
CHANGED
@@ -1,11 +1,32 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/driver"
|
2
|
+
require 'singleton'
|
2
3
|
|
3
4
|
module RFormUnit
|
4
5
|
|
5
6
|
class Mouse
|
7
|
+
include Singleton
|
6
8
|
include Driver
|
7
|
-
|
8
|
-
def click(x=nil, y=nil)
|
9
|
+
|
10
|
+
def self.click(x=nil, y=nil)
|
11
|
+
instance._click(x, y)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.right_click(x=nil, y=nil)
|
15
|
+
instance._right_click(x, y)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.double_click(x, y)
|
19
|
+
instance._double_click(x,y)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.move_to(x, y)
|
23
|
+
instance._move_to(x,y)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# intance methods
|
28
|
+
|
29
|
+
def _click(x=nil, y=nil)
|
9
30
|
if (x and y) then
|
10
31
|
driver.MouseClick("left", x, y)
|
11
32
|
else
|
@@ -13,7 +34,7 @@ module RFormUnit
|
|
13
34
|
end
|
14
35
|
end
|
15
36
|
|
16
|
-
def
|
37
|
+
def _right_click(x=nil, y=nil)
|
17
38
|
if (x and y) then
|
18
39
|
driver.MouseClick("right", x, y)
|
19
40
|
else
|
@@ -21,11 +42,11 @@ module RFormUnit
|
|
21
42
|
end
|
22
43
|
end
|
23
44
|
|
24
|
-
def
|
45
|
+
def _double_click(x, y)
|
25
46
|
driver.MouseClick("left", x, y, 2)
|
26
47
|
end
|
27
48
|
|
28
|
-
def
|
49
|
+
def _move_to(x, y)
|
29
50
|
driver.MouseMove(x,y)
|
30
51
|
end
|
31
52
|
|
data/lib/rformunit/process.rb
CHANGED
@@ -1,13 +1,26 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/driver"
|
2
|
+
require 'singleton'
|
2
3
|
|
3
4
|
module RFormUnit
|
5
|
+
|
4
6
|
class Process
|
5
|
-
include
|
7
|
+
include Singleton
|
8
|
+
include RFormUnit::Driver
|
9
|
+
|
10
|
+
def self.run(prog, work_path = nil)
|
11
|
+
instance._run(prog, work_path)
|
12
|
+
end
|
6
13
|
|
7
|
-
|
8
|
-
|
14
|
+
def self.execute(prog, work_path = nil)
|
15
|
+
instance._run(prog, work_path)
|
9
16
|
end
|
10
|
-
|
17
|
+
|
18
|
+
# instance methods
|
19
|
+
def _run(program, work_path = nil)
|
20
|
+
driver.Run(program, work_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
|
11
24
|
end
|
12
25
|
|
13
26
|
end
|
data/sample/calc.rb
CHANGED
@@ -4,7 +4,7 @@ module Calc
|
|
4
4
|
include RFormUnit::Driver
|
5
5
|
|
6
6
|
def start_calc
|
7
|
-
|
7
|
+
RFormUnit::Process.run("calc.exe")
|
8
8
|
RFormUnit::Window.new('Calculator')
|
9
9
|
end
|
10
10
|
|
@@ -19,7 +19,7 @@ module Calc
|
|
19
19
|
|
20
20
|
def quit_calc
|
21
21
|
focus_window('QPRIME')
|
22
|
-
|
22
|
+
RFormUnit::Keyboard.press("!{F4}")
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
data/sample/notepad.rb
CHANGED
@@ -2,15 +2,15 @@ require 'rformunit'
|
|
2
2
|
|
3
3
|
include RFormUnit::Driver
|
4
4
|
|
5
|
-
|
5
|
+
RFormUnit::Process.run("C:\\WINDOWS\\NOTEPAD.EXE")
|
6
6
|
notepad_win = RFormUnit::Window.new('Untitled - Notepad')
|
7
|
-
|
8
|
-
|
7
|
+
RFormUnit::Keyboard.type("Hello, Missing No. 5.{ENTER}1 2 3 4 6 7 8 9 10{ENTER}")
|
8
|
+
RFormUnit::Keyboard.press("+{UP 2}")
|
9
9
|
|
10
10
|
# move cursor up and insert the missing number
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
RFormUnit::Mouse.move_to(70, 65)
|
12
|
+
RFormUnit::Mouse.click
|
13
|
+
RFormUnit::Keyboard.type("5 ")
|
14
14
|
|
15
15
|
notepad_win.close
|
16
16
|
|
data/sample/notepad1.rb
CHANGED
@@ -2,11 +2,11 @@ require 'rformunit'
|
|
2
2
|
|
3
3
|
include RFormUnit::Driver
|
4
4
|
|
5
|
-
|
5
|
+
RFormUnit::Process.run("C:\\WINDOWS\\NOTEPAD.EXE")
|
6
6
|
notepad_win = RFormUnit::Window.new('Untitled - Notepad')
|
7
|
-
|
7
|
+
RFormUnit::Keyboard.type("Hello from Notepad, {ENTER}1 2 3 4 5 6 7 8 9 10{ENTER}")
|
8
8
|
sleep(0.5)
|
9
|
-
|
9
|
+
RFormUnit::Keyboard.press("+{UP 2}")
|
10
10
|
sleep(0.5)
|
11
11
|
notepad_win.close
|
12
12
|
|
data/sample/test_calc.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rformunit
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2006-11-
|
6
|
+
version: 0.1.1
|
7
|
+
date: 2006-11-29 00:00:00 +10:00
|
8
8
|
summary: An wrap of AUTOIT3 for functional testing of Windows form applications
|
9
9
|
require_paths:
|
10
10
|
- lib
|