From 1dead12e7f01a0d6e2093af4ad685e3c6e13e4af Mon Sep 17 00:00:00 2001 From: suke Date: Sun, 2 Nov 2008 15:41:02 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 +++ test/win32ole/orig_data.csv | 5 ++ test/win32ole/test_win32ole_event.rb | 2 +- test/win32ole/test_win32ole_variant_outarg.rb | 69 +++++++++++++++++++ .../win32ole/test_win32ole_variant_with_ie.rb | 53 -------------- 5 files changed, 85 insertions(+), 54 deletions(-) create mode 100644 test/win32ole/orig_data.csv create mode 100644 test/win32ole/test_win32ole_variant_outarg.rb delete mode 100644 test/win32ole/test_win32ole_variant_with_ie.rb diff --git a/ChangeLog b/ChangeLog index 6413f78d58..76838aee96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon Nov 3 00:36:44 2008 Masaki Suketa + + * 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 * test/win32ole/test_err_in_callback.rb: add teardown. diff --git a/test/win32ole/orig_data.csv b/test/win32ole/orig_data.csv new file mode 100644 index 0000000000..3931c6ad1b --- /dev/null +++ b/test/win32ole/orig_data.csv @@ -0,0 +1,5 @@ +ID,VALUE +1,"A" +2,"B" +3,"C" +4,"B" diff --git a/test/win32ole/test_win32ole_event.rb b/test/win32ole/test_win32ole_event.rb index 84d1e00f21..dff9a68c9b 100644 --- a/test/win32ole/test_win32ole_event.rb +++ b/test/win32ole/test_win32ole_event.rb @@ -27,7 +27,7 @@ if defined?(WIN32OLE_EVENT) 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 diff --git a/test/win32ole/test_win32ole_variant_outarg.rb b/test/win32ole/test_win32ole_variant_outarg.rb new file mode 100644 index 0000000000..1e4892f7f1 --- /dev/null +++ b/test/win32ole/test_win32ole_variant_outarg.rb @@ -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 diff --git a/test/win32ole/test_win32ole_variant_with_ie.rb b/test/win32ole/test_win32ole_variant_with_ie.rb deleted file mode 100644 index 680f17ff54..0000000000 --- a/test/win32ole/test_win32ole_variant_with_ie.rb +++ /dev/null @@ -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("This is test HTML file for Win32OLE.") - 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