2 # This script check that Win32OLE can execute InvokeVerb method of FolderItem2.
12 class TestInvokeVerb < Test::Unit::TestCase
15 # make dummy.txt file for InvokeVerb test.
18 @fso = WIN32OLE.new('Scripting.FileSystemObject')
19 @dummy_file = @fso.GetTempName
20 @cfolder = @fso.getFolder(".")
21 f = @cfolder.CreateTextFile(@dummy_file)
23 @dummy_path = @cfolder.path + "\\" + @dummy_file
25 @shell=WIN32OLE.new('Shell.Application')
26 @nsp = @shell.NameSpace(@cfolder.path)
27 @fi2 = @nsp.parseName(@dummy_file)
32 # Search the 'Create Shortcut (&S)' string in Japanese.
33 # Yes, I know the string in the Windows 2000 Japanese Edition.
34 # But I do not know about the string in any other Windows.
37 verbs.extend(Enumerable)
38 @cp = WIN32OLE.codepage
40 WIN32OLE.codepage = 932
43 @shortcut = verbs.collect{|verb|
46 name.unpack("C*") == [131, 86, 131, 135, 129, 91, 131, 103, 131, 74, 131, 98, 131, 103, 130, 204, 141, 236, 144, 172, 40, 38, 83, 41]
47 # /.*\(\&S\)$/ =~ name
53 @cfolder.files.each do |f|
55 linkinfo = @nsp.parseName(f.name).getLink
56 arlink.push f if linkinfo.path == path
63 links = find_link(@dummy_path)
68 # Now create shortcut to @dummy_path
69 arg = WIN32OLE_VARIANT.new(@shortcut)
72 # Now search shortcut to @dummy_path
73 links = find_link(@dummy_path)
75 @lpath = links[0].path
80 @fso.deleteFile(@lpath)
83 @fso.deleteFile(@dummy_path)
85 WIN32OLE.codepage = @cp