mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
f35fb72f44
commit
1dead12e7f
5 changed files with 85 additions and 54 deletions
10
ChangeLog
10
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.
|
||||
|
|
5
test/win32ole/orig_data.csv
Normal file
5
test/win32ole/orig_data.csv
Normal file
|
@ -0,0 +1,5 @@
|
|||
ID,VALUE
|
||||
1,"A"
|
||||
2,"B"
|
||||
3,"C"
|
||||
4,"B"
|
|
|
@ -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
|
||||
|
|
69
test/win32ole/test_win32ole_variant_outarg.rb
Normal file
69
test/win32ole/test_win32ole_variant_outarg.rb
Normal file
|
@ -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
|
|
@ -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
|
Loading…
Reference in a new issue