win32screenshot 0.0.2 → 0.0.4

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.
@@ -1,2 +0,0 @@
1
- require 'test/unit'
2
- require File.dirname(__FILE__) + '/../lib/win32screenshot'
@@ -1,43 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
- require 'rubygems'
3
- require 'RMagick'
4
-
5
- # Prereqs for this test:
6
- # * Must be run from a command window with dimensions 1600x1200 pixels (160x60 characters, default font)
7
- # * Screen res must be 1600x1200
8
- # * Must have a maximised Firefox open
9
- #
10
- class Win32screenshotTest < Test::Unit::TestCase
11
-
12
- def test_should_capture_foreground
13
- width, height, bmp = Win32::Screenshot.foreground
14
- assert_equal 1280, width
15
- assert_equal 720, height
16
- assert_image(bmp)
17
- end
18
-
19
- def test_should_capture_desktop
20
- width, height, bmp = Win32::Screenshot.desktop
21
- assert_equal 1600, width
22
- assert_equal 1200, height
23
- assert_image(bmp)
24
- end
25
-
26
- def test_should_capture_window_by_title
27
- width, height, bmp = Win32::Screenshot.window(/Firefox/)
28
- assert_equal 1600, width
29
- assert_equal 1147, height
30
- assert_image(bmp, "ff.png")
31
- end
32
-
33
-
34
- def assert_image(bmp, file=nil)
35
- assert_equal 'BM', bmp[0..1]
36
- img = Magick::Image.from_blob(bmp)
37
- png = img[0].to_blob do
38
- self.format = 'PNG'
39
- end
40
- assert_equal "\211PNG", png[0..3]
41
- File.open(file, "wb") {|io| io.write(png)} unless file.nil?
42
- end
43
- end