summaryrefslogtreecommitdiff
path: root/ext/win32ole/tests
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-08-20 07:34:34 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-08-20 07:34:34 +0000
commitad4ef9cf0ae0caca0c5f2f968b1757300991a84d (patch)
tree74068a63c4d7de4b526606912d83bf64548d36c7 /ext/win32ole/tests
parentc2eda1c4e99be68e7c26ae2bc6c10e67c51d469a (diff)
add test script to check WIN32OLE can invoke InvokeVerb of FolderItem2
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/win32ole/tests')
-rw-r--r--ext/win32ole/tests/testINVOKEVERB.rb70
1 files changed, 70 insertions, 0 deletions
diff --git a/ext/win32ole/tests/testINVOKEVERB.rb b/ext/win32ole/tests/testINVOKEVERB.rb
new file mode 100644
index 0000000000..3510b9057c
--- /dev/null
+++ b/ext/win32ole/tests/testINVOKEVERB.rb
@@ -0,0 +1,70 @@
+#
+# This script check that Win32OLE can execute InvokeVerb method of FolderItem2.
+#
+
+require 'test/unit'
+require 'win32ole'
+
+class TestInvokeVerb < Test::Unit::TestCase
+ def setup
+ #
+ # make dummy.txt file for InvokeVerb test.
+ #
+ ofs = open('dummy.txt', 'w')
+ ofs.write('this is test')
+ ofs.close
+
+ @fso = WIN32OLE.new('Scripting.FileSystemObject')
+ @dummy_path = @fso.GetAbsolutePathName('dummy.txt')
+
+ @shell=WIN32OLE.new('Shell.Application')
+ @fi2 = @shell.NameSpace(@dummy_path).ParentFolder.ParseName(@shell.NameSpace(@dummy_path).Title)
+ @shortcut = nil
+
+ #
+ # Search the 'Create Shortcut (&S)' string.
+ # Yes, I know the string in the Windows 2000 Japanese Edition.
+ # But I do not know about the string in any other Windows.
+ #
+ @fi2.verbs.each do |v|
+ #
+ # We expect the 'Create Shortcut' string is end with '(&S)'.
+ #
+ if /.*\(\&S\)$/ =~ v.name
+ @shortcut = v.name
+ break
+ end
+ end
+ end
+
+ def test_invokeverb
+ # We expect there is no shortcut in this folder.
+ link = Dir["*.lnk"].find {|f| true}
+ assert(!link)
+
+ # Now create shortcut to "dummy.txt"
+ assert(@shortcut)
+ arg = WIN32OLE_VARIANT.new(@shortcut)
+ @fi2.InvokeVerb(arg)
+
+ # We expect there is shortcut in this folder
+ link = Dir["*.lnk"].find {|f| true}
+ assert(link)
+
+ # The shortcut is to the "dummy.txt"
+ @lpath = @fso.GetAbsolutePathName(link)
+ linkinfo = @shell.NameSpace(@lpath).Self.GetLink
+ assert_equal(@dummy_path, linkinfo.path)
+ end
+
+ def teardown
+ if @lpath
+ @fso.deleteFile(@lpath)
+ end
+ if @dummy_path
+ @fso.deleteFile(@dummy_path)
+ end
+ end
+
+end
+