Sha256: d5109fac6378eb420db6b50537e334620251d25895e9c2c143d7ce4a86a95196
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
$LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'win32/screenshot' require 'rspec' require 'fileutils' module SpecHelper HWND_TOPMOST = -1 HWND_NOTOPMOST = -2 SWP_NOSIZE = 1 SWP_NOMOVE = 2 SWP_SHOWWINDOW = 40 extend FFI::Library ffi_lib 'user32' ffi_convention :stdcall # user32.dll attach_function :set_window_pos, :SetWindowPos, [:long, :long, :int, :int, :int, :int, :int], :bool def save_and_verify_image(img, file=nil) FileUtils.mkdir @temp_dir unless File.exists?(@temp_dir) file_name = File.join @temp_dir, "#{file}.bmp" img.write file_name expect(img.bitmap[0..1]).to eq('BM') end def resize title hwnd = RAutomation::Window.new(:title => title).hwnd set_window_pos(hwnd, HWND_TOPMOST, 0, 0, 150, 238, SWP_NOMOVE) set_window_pos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE) sleep 1 end end RSpec.configure do |config| config.include(SpecHelper) config.before(:suite) {FileUtils.rm Dir.glob(File.join(File.dirname(__FILE__), "tmp/*"))} config.before(:all) {@temp_dir = File.join(File.dirname(__FILE__), 'tmp')} end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
win32screenshot-4.0.0 | spec/spec_helper.rb |
win32screenshot-3.1.0 | spec/spec_helper.rb |