summaryrefslogtreecommitdiff
path: root/test/win32ole
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-10 12:15:04 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-10 12:15:04 +0000
commit22fe2621196c18c2afe134b51e1e367f9915275b (patch)
treeb3f292da1dc5c91956acaa3c31a79a23a0ad46cd /test/win32ole
parent3cf69b5d69db2249130e9b2767f745e1a71620af (diff)
* test/win32ole/test_err_in_callback.rb: InternetExplorer should
be closed. * test/win32ole/err_in_callback.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/win32ole')
-rw-r--r--test/win32ole/err_in_callback.rb6
-rw-r--r--test/win32ole/test_err_in_callback.rb28
2 files changed, 19 insertions, 15 deletions
diff --git a/test/win32ole/err_in_callback.rb b/test/win32ole/err_in_callback.rb
index d09870c..6a0b711 100644
--- a/test/win32ole/err_in_callback.rb
+++ b/test/win32ole/err_in_callback.rb
@@ -5,7 +5,11 @@ WIN32OLE_EVENT.message_loop
sleep 0.2
ev = WIN32OLE_EVENT.new(ie)
-ev.on_event('BeforeNavigate2') {|*args|
+ev.on_event('NavigateComplete2') {|*args|
foo
}
ie.navigate(ARGV.shift)
+while ie.readystate != 4
+ WIN32OLE_EVENT.message_loop
+ sleep 0.2
+end
diff --git a/test/win32ole/test_err_in_callback.rb b/test/win32ole/test_err_in_callback.rb
index 11ea627..710d365 100644
--- a/test/win32ole/test_err_in_callback.rb
+++ b/test/win32ole/test_err_in_callback.rb
@@ -28,14 +28,14 @@ if defined?(WIN32OLE)
def create_temp_html
fso = WIN32OLE.new('Scripting.FileSystemObject')
- dummy_file = fso.GetTempName + ".html"
+ @dummy_file = fso.GetTempName + ".html"
cfolder = fso.getFolder(".")
@str = "This is test HTML file for Win32OLE (#{Time.now})"
- f = cfolder.CreateTextFile(dummy_file)
+ f = cfolder.CreateTextFile(@dummy_file)
f.writeLine("<html><body><div id='str'>#{@str}</div></body></html>")
f.close
- @f = dummy_file
- dummy_path = cfolder.path + "\\" + dummy_file
+ @f = @dummy_file
+ dummy_path = cfolder.path + "\\" + @dummy_file
dummy_path
end
@@ -54,26 +54,26 @@ if defined?(WIN32OLE)
def ie_quit
sh = WIN32OLE.new('Shell.Application')
sh.windows.each do |w|
- if w.ole_type.name == 'IWebBrowser2'
- 20.times do |i|
- if w.locationURL != "" && w.document
- break
- end
- WIN32OLE_EVENT.message_loop
- sleep 1
- end
- e = w.document.getElementById("str")
+ i = 0
+ begin
+ i = i + 1
+ WIN32OLE_EVENT.message_loop
+ sleep 0.1
+ e = w.document.all.item("str")
if e && e.innerHTML == @str
w.quit
WIN32OLE_EVENT.message_loop
sleep 0.2
+ break
end
+ next if i > 1000
+ rescue
+ retry
end
end
end
def teardown
- WIN32OLE_EVENT.message_loop
ie_quit
File.unlink(@f)
File.unlink("test_err_in_callback.log")