ruby-changes:8558
From: suke <ko1@a...>
Date: Mon, 3 Nov 2008 00:41:20 +0900 (JST)
Subject: [ruby-changes:8558] Ruby:r20091 (trunk): * test/win32ole/test_win32ole_event.rb: rename test class.
suke 2008-11-03 00:41:02 +0900 (Mon, 03 Nov 2008) New Revision: 20091 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20091 Log: * test/win32ole/test_win32ole_event.rb: rename test class. * test/win32ole/test_win32ole_variant_outarg.rb: add in order to use ADO instead of Internet Explorer. remove test/win32ole/test_win32ole_variant_with_ie.rb. * test/win32ole/orig_data.csv: ditto. Added files: trunk/test/win32ole/orig_data.csv trunk/test/win32ole/test_win32ole_variant_outarg.rb Removed files: trunk/test/win32ole/test_win32ole_variant_with_ie.rb Modified files: trunk/ChangeLog trunk/test/win32ole/test_win32ole_event.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 20090) +++ ChangeLog (revision 20091) @@ -1,3 +1,13 @@ +Mon Nov 3 00:36:44 2008 Masaki Suketa <masaki.suketa@n...> + + * test/win32ole/test_win32ole_event.rb: rename test class. + + * test/win32ole/test_win32ole_variant_outarg.rb: add in order + to use ADO instead of Internet Explorer. + remove test/win32ole/test_win32ole_variant_with_ie.rb. + + * test/win32ole/orig_data.csv: ditto. + Sun Nov 2 23:08:08 2008 Masaki Suketa <masaki.suketa@n...> * test/win32ole/test_err_in_callback.rb: add teardown. Index: test/win32ole/test_win32ole_variant_with_ie.rb =================================================================== --- test/win32ole/test_win32ole_variant_with_ie.rb (revision 20090) +++ test/win32ole/test_win32ole_variant_with_ie.rb (revision 20091) @@ -1,53 +0,0 @@ -# This is test script to check WIN32OLE_VARIANT using Internet Explorer -begin - require 'win32ole' -rescue LoadError -end -require 'test/unit' - -if defined?(WIN32OLE) - class TestWIN32OLE_VARIANT_WITH_IE < Test::Unit::TestCase - def create_temp_html - fso = WIN32OLE.new('Scripting.FileSystemObject') - dummy_file = fso.GetTempName + ".html" - cfolder = fso.getFolder(".") - f = cfolder.CreateTextFile(dummy_file) - f.writeLine("<html><body>This is test HTML file for Win32OLE.</body></html>") - f.close - dummy_path = cfolder.path + "\\" + dummy_file - dummy_path - end - def setup - @f = create_temp_html - @ie = WIN32OLE.new('InternetExplorer.Application') - @ie.visible = true - @ie.navigate("file:///#{@f}") - while @ie.busy - sleep 0.5 - end - end - def test_variant_ref_and_argv - @ie.execWB(19, 0, nil, -1) - size = WIN32OLE::ARGV[3] - assert(size >= 0) - - obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF) - @ie.execWb(19, 0, nil, obj) - assert_equal(size, obj.value) - assert_equal(size, WIN32OLE::ARGV[3]) - - obj = WIN32OLE_VARIANT.new(-1, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF) - @ie.execWb(19, 0, nil, obj) - assert_equal(size, obj.value) - assert_equal(size, WIN32OLE::ARGV[3]) - end - - def teardown - File.unlink(@f) - if @ie - @ie.quit - @ie = nil - end - end - end -end Index: test/win32ole/orig_data.csv =================================================================== --- test/win32ole/orig_data.csv (revision 0) +++ test/win32ole/orig_data.csv (revision 20091) @@ -0,0 +1,5 @@ +ID,VALUE +1,"A" +2,"B" +3,"C" +4,"B" Index: test/win32ole/test_win32ole_event.rb =================================================================== --- test/win32ole/test_win32ole_event.rb (revision 20090) +++ test/win32ole/test_win32ole_event.rb (revision 20091) @@ -27,7 +27,7 @@ STDERR.puts("\n#{__FILE__} skipped(ActiveX Data Object Library not found.)") end if dotest - class TestWIN32OLE_EVENT_ADO < Test::Unit::TestCase + class TestWIN32OLE_EVENT < Test::Unit::TestCase CONNSTR="Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=.;" module ADO end Index: test/win32ole/test_win32ole_variant_outarg.rb =================================================================== --- test/win32ole/test_win32ole_variant_outarg.rb (revision 0) +++ test/win32ole/test_win32ole_variant_outarg.rb (revision 20091) @@ -0,0 +1,69 @@ +begin + require 'win32ole' +rescue LoadError +end +require 'test/unit' +require 'fileutils' + +def ado_csv_installed? + installed = false + if defined?(WIN32OLE) + db = nil + begin + db = WIN32OLE.new('ADODB.Connection') + db.connectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=.;" + db.open + db.close + db = nil + installed = true + rescue + end + end + installed +end + +if defined?(WIN32OLE_VARIANT) + dotest = ado_csv_installed? + if !dotest + STDERR.puts("\n#{__FILE__} skipped(ActiveX Data Object Library not found.)") + end + if dotest + class TestWIN32OLE_VARIANT_OUTARG < Test::Unit::TestCase + module ADO + end + CONNSTR="Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=.;" + def setup + FileUtils.cp(File.dirname(__FILE__) + '/orig_data.csv', './data.csv') + @db = WIN32OLE.new('ADODB.Connection') + if !defined?(ADO::AdStateOpen) + WIN32OLE.const_load(@db, ADO) + end + @db.connectionString = CONNSTR + @db.open + end + + def test_variant_ref_and_argv + sql = "INSERT INTO data.csv VALUES (5, 'E')" + @db.execute(sql, -1) + c = WIN32OLE::ARGV[1] + assert_equal(1, WIN32OLE::ARGV[1]) + obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF) + assert_equal(nil, obj.value) + @db.execute(sql , obj) + assert_equal(1, obj.value) + obj = WIN32OLE_VARIANT.new(-100, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF) + assert_equal(-100, obj.value) + @db.execute(sql, obj) + assert_equal(1, obj.value) + end + + def teardown + if @db && @db.state == ADO::AdStateOpen + @db.close + end + File.unlink("data.csv") + end + + end + end +end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/