watirsplash 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,3 +1,10 @@
1
+ === Version 0.2.1 / 2010-05-27
2
+
3
+ * added compatibility with Win32::Screenshot 0.0.4
4
+ * wait_until behaves exactly the same as with Watir - throws Exception upon timeout
5
+ * removed wait_until! - use wait_until instead
6
+ * added wait_until? which returns true if condition was true and doesn't throw Exception upon timeout
7
+
1
8
  === Version 0.2.0 / 2010-05-03
2
9
 
3
10
  PS! This version has some backwards incompatible changes!
data/Rakefile CHANGED
@@ -34,7 +34,7 @@ Execute "watirsplash generate" under your project's directory to generate defaul
34
34
  gem.add_dependency("rmagick")
35
35
  gem.add_dependency("syntax")
36
36
  gem.add_dependency("win32console")
37
- gem.add_dependency("win32screenshot")
37
+ gem.add_dependency("win32screenshot", ">=0.0.4")
38
38
  end
39
39
  Jeweler::GemcutterTasks.new
40
40
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/lib/watirsplash.rb CHANGED
@@ -2,8 +2,6 @@ require "rubygems"
2
2
  require "require_all"
3
3
  require "spec"
4
4
  require "watir"
5
- require "win32screenshot"
6
- require_rel "watirsplash/win32screenshot"
7
5
  require_rel "watirsplash/waiter"
8
6
  require_rel "watirsplash/spec_helper"
9
7
  require_rel "watirsplash/spec"
@@ -23,7 +23,7 @@ class AutoItHelper
23
23
  # activates window automatically and makes sure that the field's
24
24
  # value got changed
25
25
  def set_field(window_title, field_name, field_value)
26
- wait_until! do
26
+ wait_until do
27
27
  activate_window(window_title) &&
28
28
  @@autoit.ControlFocus(window_title, "", field_name) == 1 &&
29
29
  @@autoit.ControlSetText(window_title, "", field_name, field_value) == 1 &&
@@ -35,11 +35,11 @@ class AutoItHelper
35
35
  # activates window automatically and makes sure that the click
36
36
  # was successful
37
37
  def click_button(window_title, button_name)
38
- wait_until! do
38
+ wait_until do
39
39
  activate_window(window_title) &&
40
40
  @@autoit.ControlFocus(window_title, "", button_name) == 1 &&
41
41
  @@autoit.ControlClick(window_title, "", button_name) == 1 &&
42
- wait_until(3) {@@autoit.WinExists(window_title) == 0}
42
+ wait_until?(3) {@@autoit.WinExists(window_title) == 0}
43
43
  end
44
44
  end
45
45
 
@@ -1,5 +1,5 @@
1
1
  require 'spec/runner/formatter/html_formatter'
2
- require 'win32screenshot'
2
+ require 'win32/screenshot'
3
3
  require 'rmagick'
4
4
  require 'pathname'
5
5
  require 'fileutils'
@@ -71,11 +71,12 @@ module WatirSplash
71
71
  def save_screenshot(description="Screenshot", hwnd=@browser.hwnd) # :nodoc:
72
72
  begin
73
73
  @browser.bring_to_front
74
- width, height, blob = Win32::Screenshot.capture_hwnd(hwnd)
75
- file_name = file_path("screenshot.png", description)
76
- img = Magick::ImageList.new
77
- img.from_blob(blob)
78
- img.write(file_name)
74
+ Win32::Screenshot.hwnd(hwnd) do |width, height, blob|
75
+ file_name = file_path("screenshot.png", description)
76
+ img = Magick::ImageList.new
77
+ img.from_blob(blob)
78
+ img.write(file_name)
79
+ end
79
80
  rescue => e
80
81
  $stderr.puts "saving of screenshot failed: #{e.message}"
81
82
  $stderr.puts e.backtrace
@@ -31,7 +31,7 @@ module WatirSplash
31
31
  file_path = native_file_path(file_path(file_name))
32
32
  AutoItHelper.set_edit(file_path)
33
33
  AutoItHelper.click_save("Save As")
34
- wait_until! {File.exists?(file_path)}
34
+ wait_until {File.exists?(file_path)}
35
35
  file_path
36
36
  end
37
37
 
@@ -1,24 +1,24 @@
1
1
  module WatirSplash
2
2
  module Waiter
3
- # waits until some condition is true and
3
+ # waits until specified condition is true and
4
4
  # throws Watir::Exception::TimeOutException upon timeout
5
5
  #
6
6
  # examples:
7
- # wait_until! {text_field(:name => 'x').exists?} # waits until text field exists
8
- # wait_until!(5) {...} # waits maximum of 5 seconds condition to be true
9
- def wait_until! *arg
7
+ # wait_until {text_field(:name => 'x').exists?} # waits until text field exists
8
+ # wait_until(5) {...} # waits maximum of 5 seconds for the condition to be true
9
+ def wait_until *arg
10
10
  Watir::Waiter.wait_until(*arg) {yield}
11
11
  end
12
12
 
13
- # waits until some condition is true and
13
+ # waits until specified condition is true and
14
14
  # returns false if timeout occurred, true otherwise
15
15
  #
16
16
  # examples:
17
- # wait_until {text_field(:name => 'x').exists?} # waits until text field exists
18
- # wait_until(5) {...} # waits maximum of 5 seconds condition to be true
19
- def wait_until *arg
17
+ # wait_until? {text_field(:name => 'x').exists?} # waits until text field exists
18
+ # wait_until?(5) {...} # waits maximum of 5 seconds for the condition to be true
19
+ def wait_until? *arg
20
20
  begin
21
- wait_until!(*arg) {yield}
21
+ wait_until(*arg) {yield}
22
22
  rescue Watir::Exception::TimeOutException
23
23
  return false
24
24
  end
@@ -18,18 +18,18 @@ describe WatirSplash::SpecHelper do
18
18
  end
19
19
 
20
20
  it "has wait_until" do
21
- result = wait_until {sleep 0.1; true}
21
+ lambda {wait_until(0.5) {sleep 0.1; true}}.should_not raise_exception
22
+ lambda {wait_until(0.5) {sleep 0.1; false}}.should raise_exception(Watir::Exception::TimeOutException)
23
+ end
24
+
25
+ it "has wait_until?" do
26
+ result = wait_until? {sleep 0.1; true}
22
27
  result.should be_true
23
28
 
24
- result = wait_until(0.5) {sleep 0.1; false}
29
+ result = wait_until?(0.5) {sleep 0.1; false}
25
30
  result.should be_false
26
31
  end
27
32
 
28
- it "has wait_until!" do
29
- lambda {wait_until!(0.5) {sleep 0.1; true}}.should_not raise_exception
30
- lambda {wait_until!(0.5) {sleep 0.1; false}}.should raise_exception(Watir::Exception::TimeOutException)
31
- end
32
-
33
33
  it "has file_path methods formatter" do
34
34
  file_name = "blah.temp"
35
35
  ext = File.extname(file_name)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jarmo Pertman
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-04 00:00:00 +03:00
17
+ date: 2010-05-27 00:00:00 +03:00
18
18
  default_executable: watirsplash
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -114,7 +114,9 @@ dependencies:
114
114
  - !ruby/object:Gem::Version
115
115
  segments:
116
116
  - 0
117
- version: "0"
117
+ - 0
118
+ - 4
119
+ version: 0.0.4
118
120
  type: :runtime
119
121
  version_requirements: *id008
120
122
  description: WatirSplash makes testing of web applications splashin' easy by combining best features of Watir, RSpec and Ruby!
@@ -143,7 +145,6 @@ files:
143
145
  - lib/watirsplash/util.rb
144
146
  - lib/watirsplash/waiter.rb
145
147
  - lib/watirsplash/watir.rb
146
- - lib/watirsplash/win32screenshot.rb
147
148
  - spec/spec.opts
148
149
  - spec/spec_helper_spec.rb
149
150
  - spec/spec_match_array_spec.rb
@@ -166,7 +167,7 @@ licenses: []
166
167
  post_install_message: |-
167
168
  *************************
168
169
 
169
- Thank you for installing WatirSplash 0.2.0! Don't forget to take a look at README and History files!
170
+ Thank you for installing WatirSplash 0.2.1! Don't forget to take a look at README and History files!
170
171
 
171
172
  Execute "watirsplash generate" under your project's directory to generate default project structure.
172
173
 
@@ -201,7 +202,7 @@ rubyforge_project:
201
202
  rubygems_version: 1.3.6
202
203
  signing_key:
203
204
  specification_version: 3
204
- summary: watirsplash 0.2.0
205
+ summary: watirsplash 0.2.1
205
206
  test_files:
206
207
  - spec/spec_helper_spec.rb
207
208
  - spec/spec_match_array_spec.rb
@@ -1,52 +0,0 @@
1
- module Win32
2
- module Screenshot
3
-
4
- # added patches by Tony Popiel for fixing the problem
5
- # of failing to take a screenshot of every size of the window
6
- # http://rubyforge.org/tracker/index.php?func=detail&aid=26216&group_id=2683&atid=10359
7
- module_function
8
-
9
- def capture(hScreenDC, x1, y1, x2, y2)
10
- w = x2-x1
11
- h = y2-y1
12
-
13
- # Reserve some memory
14
- hmemDC = createCompatibleDC(hScreenDC)
15
- hmemBM = createCompatibleBitmap(hScreenDC, w, h)
16
- selectObject(hmemDC, hmemBM)
17
- bitBlt(hmemDC, 0, 0, w, h, hScreenDC, 0, 0, SRCCOPY)
18
- # changed line
19
- # hpxldata = globalAlloc(GMEM_FIXED, w * h * 3)
20
- hpxldata = globalAlloc(GMEM_FIXED, ((w*h*3)+(w%4)*h))
21
- lpvpxldata = globalLock(hpxldata)
22
-
23
- # Bitmap header
24
- # http://www.fortunecity.com/skyscraper/windows/364/bmpffrmt.html
25
- bmInfo = [40, w, h, 1, 24, 0, 0, 0, 0, 0, 0, 0].pack('LLLSSLLLLLL').to_ptr
26
-
27
- getDIBits(hmemDC, hmemBM, 0, h, lpvpxldata, bmInfo, DIB_RGB_COLORS)
28
-
29
- bmFileHeader = [
30
- 19778,
31
- # changed line
32
- # (w * h * 3) + 40 + 14,
33
- (w * h * 3) + (w%4)*h + 40 + 14,
34
- 0,
35
- 0,
36
- 54
37
- ].pack('SLSSL').to_ptr
38
-
39
- # changed line
40
- # data = bmFileHeader.to_s(14) + bmInfo.to_s(40) + lpvpxldata.to_s(w * h * 3)
41
- data = bmFileHeader.to_s(14) + bmInfo.to_s(40) + lpvpxldata.to_s((w*h*3)+(w%4)*h)
42
-
43
- globalUnlock(hpxldata)
44
- globalFree(hpxldata)
45
- deleteObject(hmemBM)
46
- deleteDC(hmemDC)
47
- releaseDC(0, hScreenDC)
48
-
49
- return [w, h, data]
50
- end
51
- end
52
- end