summaryrefslogtreecommitdiff
path: root/test/win32ole
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-13 12:36:26 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-13 12:36:26 +0000
commit6e0ed5570ec963b357e82b82a09d239fea17dee8 (patch)
treefb41472b257d16cc925b7d51bbb6116c853179ab /test/win32ole
parentb7000ccfa0a81d8cf6349b46ab618316552f3338 (diff)
* ext/win32ole/win32ole.c (EVENTSINK_Invoke): using hash
to set value to the reference argument of event. * test/win32ole/test_win32ole_event.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/win32ole')
-rw-r--r--test/win32ole/test_win32ole_event.rb83
1 files changed, 82 insertions, 1 deletions
diff --git a/test/win32ole/test_win32ole_event.rb b/test/win32ole/test_win32ole_event.rb
index 42e80ce..dafabff 100644
--- a/test/win32ole/test_win32ole_event.rb
+++ b/test/win32ole/test_win32ole_event.rb
@@ -164,6 +164,76 @@ if defined?(WIN32OLE_EVENT)
assert_equal(bl, @ie.locationURL)
end
+ def test_on_event_hash_return
+ ev = WIN32OLE_EVENT.new(@ie)
+ ev.on_event('BeforeNavigate2'){|*args|
+ {:return => 1, :Cancel => true}
+ }
+ bl = @ie.locationURL
+ @ie.navigate("file:///#{@f}")
+ while @ie.busy
+ sleep 0.1
+ WIN32OLE_EVENT.message_loop
+ end
+ assert_equal(bl, @ie.locationURL)
+ end
+
+ def test_on_event_hash_return2
+ ev = WIN32OLE_EVENT.new(@ie)
+ ev.on_event('BeforeNavigate2'){|*args|
+ {:Cancel => true}
+ }
+ bl = @ie.locationURL
+ @ie.navigate("file:///#{@f}")
+ while @ie.busy
+ sleep 0.1
+ WIN32OLE_EVENT.message_loop
+ end
+ assert_equal(bl, @ie.locationURL)
+ end
+
+ def test_on_event_hash_return3
+ ev = WIN32OLE_EVENT.new(@ie)
+ ev.on_event('BeforeNavigate2'){|*args|
+ {'Cancel' => true}
+ }
+ bl = @ie.locationURL
+ @ie.navigate("file:///#{@f}")
+ while @ie.busy
+ sleep 0.1
+ WIN32OLE_EVENT.message_loop
+ end
+ assert_equal(bl, @ie.locationURL)
+ end
+
+ def test_on_event_hash_return4
+ ev = WIN32OLE_EVENT.new(@ie)
+ ev.on_event('BeforeNavigate2'){|*args|
+ {'return' => 2, 'Cancel' => true}
+ }
+ bl = @ie.locationURL
+ @ie.navigate("file:///#{@f}")
+ while @ie.busy
+ sleep 0.1
+ WIN32OLE_EVENT.message_loop
+ end
+ assert_equal(bl, @ie.locationURL)
+ end
+
+ def test_on_event_hash_return5
+ ev = WIN32OLE_EVENT.new(@ie)
+ ev.on_event('BeforeNavigate2'){|*args|
+ {6 => true}
+ }
+ bl = @ie.locationURL
+ @ie.navigate("file:///#{@f}")
+ while @ie.busy
+ sleep 0.1
+ WIN32OLE_EVENT.message_loop
+ end
+ assert_equal(bl, @ie.locationURL)
+ end
+
def handler1
@event2 = "handler1"
end
@@ -180,8 +250,19 @@ if defined?(WIN32OLE_EVENT)
@ie.quit
WIN32OLE_EVENT.message_loop
@ie = nil
- File.unlink(@f)
+ WIN32OLE_EVENT.message_loop
+ sleep 0.1
+ begin
+ File.unlink(@f)
+ rescue Error::EACCESS
+ WIN32OLE_EVENT.message_loop
+ sleep 0.2
+ File.unlink(@f)
+ end
+
GC.start
+ WIN32OLE_EVENT.message_loop
+ sleep 0.1
end
end
end