summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--test/win32ole/orig_data.csv5
-rw-r--r--test/win32ole/test_win32ole_event.rb2
-rw-r--r--test/win32ole/test_win32ole_variant_outarg.rb69
-rw-r--r--test/win32ole/test_win32ole_variant_with_ie.rb53
5 files changed, 85 insertions, 54 deletions
diff --git a/ChangeLog b/ChangeLog
index 6413f78d585..76838aee967 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Mon Nov 3 00:36:44 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+
+ * 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@nifty.ne.jp>
* 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 00000000000..3931c6ad1b9
--- /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 84d1e00f218..dff9a68c9b6 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 00000000000..1e4892f7f14
--- /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 680f17ff540..00000000000
--- 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("<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