[前][次][番号順一覧][スレッド一覧]

ruby-changes:17493

From: suke <ko1@a...>
Date: Thu, 14 Oct 2010 23:26:39 +0900 (JST)
Subject: [ruby-changes:17493] Ruby:r29498 (trunk): test/win32ole/test_folderitem2_invokeverb.rb: refactoring.

suke	2010-10-14 23:23:03 +0900 (Thu, 14 Oct 2010)

  New Revision: 29498

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29498

  Log:
    test/win32ole/test_folderitem2_invokeverb.rb: refactoring.

  Modified files:
    trunk/ChangeLog
    trunk/test/win32ole/test_folderitem2_invokeverb.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29497)
+++ ChangeLog	(revision 29498)
@@ -1,3 +1,7 @@
+Thu Oct 14 23:20:42 2010  Masaki Suketa <masaki.suketa@n...>
+
+	* test/win32ole/test_folderitem2_invokeverb.rb: refactoring.
+
 Thu Oct 14 22:18:29 2010  Koichi Sasada  <ko1@a...>
 
 	* insns.def, iseq.c, vm_insnhelper.c: rename variable name
Index: test/win32ole/test_folderitem2_invokeverb.rb
===================================================================
--- test/win32ole/test_folderitem2_invokeverb.rb	(revision 29497)
+++ test/win32ole/test_folderitem2_invokeverb.rb	(revision 29498)
@@ -11,41 +11,17 @@
 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 @@
     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 @dummy_path
         @fso.deleteFile(@dummy_path)
       end
-      WIN32OLE.codepage = @cp
     end
 
   end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]