rformunit 0.1.0-mswin32 → 0.1.1-mswin32

Sign up to get free protection for your applications and to get access to all the features.
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.0"
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.0<br/>
35
- &nbsp; <a href="releases/rformunit-0.1.0-mswin32.gem">rformunit-0.1.0-mswin32.gem</a> or from <a href="http://rubyforge.org/projects/rformunit/">rubyforge.org</a>,
34
+ <p>Current release: 0.1.1<br/>
35
+ &nbsp; <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
  <!-- &nbsp; <a href="releases/changelog.txt">Change logs</a> <br/> -->
38
38
  &nbsp; 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
- process.run("C:\\WINDOWS\\NOTEPAD.EXE")
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
- keyboard.press("+{UP 2}") # mouse.* for mouse operations
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 &lt; RFormUnit::FormTestCase
116
114
  def setup
117
- process.run("calc.exe")
115
+ RFormUnit::Process.run("calc.exe")
118
116
  @calc_win = RFormUnit::Window.new('Calculator')
119
117
  end
120
118
 
@@ -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
@@ -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
- def type(keystrokes)
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
@@ -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 right_click(x=nil, y=nil)
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 double_click(x, y)
45
+ def _double_click(x, y)
25
46
  driver.MouseClick("left", x, y, 2)
26
47
  end
27
48
 
28
- def move_to(x, y)
49
+ def _move_to(x, y)
29
50
  driver.MouseMove(x,y)
30
51
  end
31
52
 
@@ -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 Driver
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
- def run(program, work_path = nil)
8
- driver.Run(program, work_path)
14
+ def self.execute(prog, work_path = nil)
15
+ instance._run(prog, work_path)
9
16
  end
10
- alias execute run
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
- process.run("calc.exe")
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
- keyboard.press("!{F4}")
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
- process.run("C:\\WINDOWS\\NOTEPAD.EXE")
5
+ RFormUnit::Process.run("C:\\WINDOWS\\NOTEPAD.EXE")
6
6
  notepad_win = RFormUnit::Window.new('Untitled - Notepad')
7
- keyboard.type("Hello, Missing No. 5.{ENTER}1 2 3 4 6 7 8 9 10{ENTER}")
8
- keyboard.press("+{UP 2}")
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
- mouse.move_to(70, 65)
12
- mouse.click
13
- keyboard.type("5 ")
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
- process.run("C:\\WINDOWS\\NOTEPAD.EXE")
5
+ RFormUnit::Process.run("C:\\WINDOWS\\NOTEPAD.EXE")
6
6
  notepad_win = RFormUnit::Window.new('Untitled - Notepad')
7
- keyboard.type("Hello from Notepad, {ENTER}1 2 3 4 5 6 7 8 9 10{ENTER}")
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
- keyboard.press("+{UP 2}")
9
+ RFormUnit::Keyboard.press("+{UP 2}")
10
10
  sleep(0.5)
11
11
  notepad_win.close
12
12
 
data/sample/test_calc.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'rformunit'
2
2
 
3
3
  class CalcTest < RFormUnit::FormTestCase
4
+
4
5
  def setup
5
- process.run("calc.exe")
6
+ RFormUnit::Process.run("calc.exe")
6
7
  @calc_win = RFormUnit::Window.new('Calculator')
7
8
  end
8
9
 
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.0
7
- date: 2006-11-28 00:00:00 +10:00
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