Slightly improved start/stop code in Watir test
This commit is contained in:
parent
7f9211d36b
commit
b432bbd3ae
|
@ -8,20 +8,31 @@ require(File.expand_path(File.dirname(__FILE__) + "/../../config/environment"))
|
|||
INSTIKI_PORT = 2501
|
||||
HOME = "http://localhost:#{INSTIKI_PORT}"
|
||||
|
||||
class Win32API
|
||||
# FIXME this should raise an error whenever an API call returns an error
|
||||
# alias __original_call call
|
||||
# def call(*args)
|
||||
# __original_call(*args)
|
||||
# last_error = Win32API.new('kernel32.dll', 'GetLastError', '', 'L').__original_call()
|
||||
# raise "Win32API call to #{args.inspect} has failed with error code #{last_error}" if last_error
|
||||
# end
|
||||
end
|
||||
|
||||
class E2EInstikiTest < Test::Unit::TestCase
|
||||
|
||||
def startup
|
||||
|
||||
createProcess = Win32API.new('kernel32.dll', 'CreateProcess', 'pplllllppp', 'L')
|
||||
startupinfo = [ 68 ].pack('lx64')
|
||||
@@instiki = [ 0,0,0,0 ].pack('llll')
|
||||
createProcess.call(nil,
|
||||
createProcess =
|
||||
startup_info = [68].pack('lx64')
|
||||
@@instiki = [0, 0, 0, 0].pack('llll')
|
||||
Win32API.new('kernel32.dll', 'CreateProcess', 'pplllllppp', 'L').call(
|
||||
nil,
|
||||
"ruby #{RAILS_ROOT}/instiki.rb --storage #{prepare_storage} " +
|
||||
" --port #{INSTIKI_PORT} --environment development",
|
||||
0, 0, 1, 0, 0, "c:\\", startupinfo, @@instiki)
|
||||
0, 0, 1, 0, 0, '.', startup_info, @@instiki)
|
||||
|
||||
sleep 5
|
||||
@@ie = Watir::IE.start("http://localhost:2501")
|
||||
@@ie = Watir::IE.start(HOME)
|
||||
|
||||
setup_web
|
||||
setup_home_page
|
||||
|
@ -30,16 +41,12 @@ class E2EInstikiTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def self.shutdown
|
||||
process_id = @@instiki.unpack('llll')[2]
|
||||
right_to_terminate_process = 1
|
||||
handle = Win32API.new('kernel32.dll', 'OpenProcess', 'lil', 'l').call(
|
||||
right_to_terminate_process, 0, process_id)
|
||||
Win32API.new('kernel32.dll', 'TerminateProcess', 'll', 'L').call(handle, 0)
|
||||
|
||||
processid = @@instiki.unpack('llll')[2]
|
||||
|
||||
openProcess = Win32API.new('kernel32.dll', 'OpenProcess', 'lil', 'l')
|
||||
handle = openProcess.call(1, 0, processid)
|
||||
|
||||
terminateProcess = Win32API.new('kernel32.dll', 'TerminateProcess', 'll', 'L')
|
||||
terminateProcess.call(handle, 0)
|
||||
|
||||
# todo this doesn't actually shut down anything
|
||||
@@ie.close if defined? @@ie
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue