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:
parent
559fd3e439
commit
22c791e163
@ -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>
|
Thu Oct 14 22:18:29 2010 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* insns.def, iseq.c, vm_insnhelper.c: rename variable name
|
* insns.def, iseq.c, vm_insnhelper.c: rename variable name
|
||||||
|
@ -11,41 +11,17 @@ require 'test/unit'
|
|||||||
if defined?(WIN32OLE)
|
if defined?(WIN32OLE)
|
||||||
class TestInvokeVerb < Test::Unit::TestCase
|
class TestInvokeVerb < Test::Unit::TestCase
|
||||||
def setup
|
def setup
|
||||||
#
|
# make dummy file for InvokeVerb test.
|
||||||
# make dummy.txt file for InvokeVerb test.
|
|
||||||
#
|
|
||||||
|
|
||||||
@fso = WIN32OLE.new('Scripting.FileSystemObject')
|
@fso = WIN32OLE.new('Scripting.FileSystemObject')
|
||||||
@dummy_file = @fso.GetTempName
|
dummy_file = @fso.GetTempName
|
||||||
@cfolder = @fso.getFolder(".")
|
@cfolder = @fso.getFolder(".")
|
||||||
f = @cfolder.CreateTextFile(@dummy_file)
|
f = @cfolder.CreateTextFile(dummy_file)
|
||||||
f.close
|
f.close
|
||||||
@dummy_path = @cfolder.path + "\\" + @dummy_file
|
@dummy_path = @cfolder.path + "\\" + dummy_file
|
||||||
|
|
||||||
@shell=WIN32OLE.new('Shell.Application')
|
shell=WIN32OLE.new('Shell.Application')
|
||||||
@nsp = @shell.NameSpace(@cfolder.path)
|
@nsp = shell.NameSpace(@cfolder.path)
|
||||||
@fi2 = @nsp.parseName(@dummy_file)
|
@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
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_link(path)
|
def find_link(path)
|
||||||
@ -60,19 +36,14 @@ if defined?(WIN32OLE)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_invokeverb
|
def test_invokeverb
|
||||||
# this test should run only when "Create Shortcut (&S)"
|
|
||||||
# is found in context menu,
|
|
||||||
|
|
||||||
# in Windows Vista (not tested), Windows 7
|
# in Windows Vista (not tested), Windows 7
|
||||||
# The verb must be in English.
|
# The verb must be in English.
|
||||||
# Creating Shortcut is "Link"
|
# Creating Shortcut is "Link"
|
||||||
if @shortcut
|
|
||||||
@shortcut = "Link"
|
|
||||||
links = find_link(@dummy_path)
|
links = find_link(@dummy_path)
|
||||||
assert_equal(0, links.size)
|
assert_equal(0, links.size)
|
||||||
|
|
||||||
# Now create shortcut to @dummy_path
|
# Now create shortcut to @dummy_path
|
||||||
arg = WIN32OLE_VARIANT.new(@shortcut)
|
arg = WIN32OLE_VARIANT.new("Link")
|
||||||
@fi2.InvokeVerb(arg)
|
@fi2.InvokeVerb(arg)
|
||||||
|
|
||||||
# Now search shortcut to @dummy_path
|
# Now search shortcut to @dummy_path
|
||||||
@ -80,7 +51,6 @@ if defined?(WIN32OLE)
|
|||||||
assert_equal(1, links.size)
|
assert_equal(1, links.size)
|
||||||
@lpath = links[0].path
|
@lpath = links[0].path
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
if @lpath
|
if @lpath
|
||||||
@ -89,7 +59,6 @@ if defined?(WIN32OLE)
|
|||||||
if @dummy_path
|
if @dummy_path
|
||||||
@fso.deleteFile(@dummy_path)
|
@fso.deleteFile(@dummy_path)
|
||||||
end
|
end
|
||||||
WIN32OLE.codepage = @cp
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user