summaryrefslogtreecommitdiff
path: root/test/win32ole
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-14 14:23:03 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-14 14:23:03 +0000
commit22c791e16375e036a20401bcbf291dbf93a24c24 (patch)
treebaf6627023b5ec20b7c550126fd50a985683fec6 /test/win32ole
parent559fd3e439194bbc8d55cae30c8c1ba13832c8e8 (diff)
test/win32ole/test_folderitem2_invokeverb.rb: refactoring.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/win32ole')
-rw-r--r--test/win32ole/test_folderitem2_invokeverb.rb63
1 files changed, 16 insertions, 47 deletions
diff --git a/test/win32ole/test_folderitem2_invokeverb.rb b/test/win32ole/test_folderitem2_invokeverb.rb
index 7f42bc5..c5ec88c 100644
--- a/test/win32ole/test_folderitem2_invokeverb.rb
+++ b/test/win32ole/test_folderitem2_invokeverb.rb
@@ -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
-
- @shell=WIN32OLE.new('Shell.Application')
- @nsp = @shell.NameSpace(@cfolder.path)
- @fi2 = @nsp.parseName(@dummy_file)
-
- @shortcut = nil
+ @dummy_path = @cfolder.path + "\\" + dummy_file
- #
- # 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