1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test/win32ole/test_folderitem2_invokeverb.rb: refactoring.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
suke 2010-10-14 14:23:03 +00:00
parent 559fd3e439
commit 22c791e163
2 changed files with 20 additions and 47 deletions

View file

@ -1,3 +1,7 @@
Thu Oct 14 23:20:42 2010 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* test/win32ole/test_folderitem2_invokeverb.rb: refactoring.
Thu Oct 14 22:18:29 2010 Koichi Sasada <ko1@atdot.net>
* insns.def, iseq.c, vm_insnhelper.c: rename variable name

View file

@ -11,41 +11,17 @@ require 'test/unit'
if defined?(WIN32OLE)
class TestInvokeVerb < Test::Unit::TestCase
def setup
#
# make dummy.txt file for InvokeVerb test.
#
# make dummy file for InvokeVerb test.
@fso = WIN32OLE.new('Scripting.FileSystemObject')
@dummy_file = @fso.GetTempName
dummy_file = @fso.GetTempName
@cfolder = @fso.getFolder(".")
f = @cfolder.CreateTextFile(@dummy_file)
f = @cfolder.CreateTextFile(dummy_file)
f.close
@dummy_path = @cfolder.path + "\\" + @dummy_file
@dummy_path = @cfolder.path + "\\" + dummy_file
@shell=WIN32OLE.new('Shell.Application')
@nsp = @shell.NameSpace(@cfolder.path)
@fi2 = @nsp.parseName(@dummy_file)
@shortcut = nil
#
# Search the 'Create Shortcut (&S)' string in Japanese.
# Yes, I know the string in the Windows 2000 Japanese Edition.
# But I do not know about the string in any other Windows.
#
verbs = @fi2.verbs
verbs.extend(Enumerable)
@cp = WIN32OLE.codepage
begin
WIN32OLE.codepage = 932
rescue
end
@shortcut = verbs.collect{|verb|
verb.name
}.find {|name|
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]
# /.*\(\&S\)$/ =~ name
}
shell=WIN32OLE.new('Shell.Application')
@nsp = shell.NameSpace(@cfolder.path)
@fi2 = @nsp.parseName(dummy_file)
end
def find_link(path)
@ -60,26 +36,20 @@ if defined?(WIN32OLE)
end
def test_invokeverb
# this test should run only when "Create Shortcut (&S)"
# is found in context menu,
# in Windows Vista (not tested), Windows 7
# The verb must be in English.
# Creating Shortcut is "Link"
if @shortcut
@shortcut = "Link"
links = find_link(@dummy_path)
assert_equal(0, links.size)
links = find_link(@dummy_path)
assert_equal(0, links.size)
# Now create shortcut to @dummy_path
arg = WIN32OLE_VARIANT.new(@shortcut)
@fi2.InvokeVerb(arg)
# Now create shortcut to @dummy_path
arg = WIN32OLE_VARIANT.new("Link")
@fi2.InvokeVerb(arg)
# Now search shortcut to @dummy_path
links = find_link(@dummy_path)
assert_equal(1, links.size)
@lpath = links[0].path
end
# Now search shortcut to @dummy_path
links = find_link(@dummy_path)
assert_equal(1, links.size)
@lpath = links[0].path
end
def teardown
@ -89,7 +59,6 @@ if defined?(WIN32OLE)
if @dummy_path
@fso.deleteFile(@dummy_path)
end
WIN32OLE.codepage = @cp
end
end