summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2016-12-14 20:09:14 +0300
committerTor Lillqvist <tml@collabora.com>2016-12-14 19:03:56 +0000
commit5ecd7ebbdf752eac48442006137d62426bf63c84 (patch)
tree37fbe3acbaeccccaf76fc9b7cd0edf99f32b2df0 /basic
parentd50c9221a50160ae38aa72ad87a1ad70a16b6b4c (diff)
Partially fix VBATest::testMiscOLEStuff for Win64
On Windows x64 there are two ODBCs - one for each bitness. A 64-bit build gets 64-bit ODBC, and there is no provider named "Microsoft Excel Driver (*.xls)", no normally the test is simply skipped. But if MS Excel is installed, then it installs provider "Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)", that was detected by previous code, but not used inside the VBAs. So, VBAs tried to use "Microsoft Excel Driver (*.xls)" unavailable to them. This patch allows using Excel's provider as well, thus allowing developer to test against 64-bit-specific regressions. However, the last test uses Microsoft.Jet.OLEDB.4.0 provider, that is unavailable on Win64. There are substitutions - Microsoft.ACE.OLEDB.12.0 and Microsoft.ACE.OLEDB.15.0, but there is no easy way to test if they are installed. Thus, that test is disabled on Win64 for now. Also, possible buffer overflow fixed, when byte count was passed to SQLGetInstalledDriversW instead of char count. Change-Id: Ib5c55251f0e92b3078a46aee173b5061439445ae Reviewed-on: https://gerrit.libreoffice.org/32019 Reviewed-by: Tor Lillqvist <tml@collabora.com> Tested-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'basic')
-rw-r--r--basic/qa/cppunit/test_vba.cxx25
-rw-r--r--basic/qa/vba_tests/ole_ObjAssignNoDflt.vb4
-rw-r--r--basic/qa/vba_tests/ole_ObjAssignToNothing.vb4
-rw-r--r--basic/qa/vba_tests/ole_dfltObjDflMethod.vb2
4 files changed, 20 insertions, 15 deletions
diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 4028ec461a40..91b26d8f6eb7 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -86,10 +86,10 @@ void VBATest::testMiscVBAFunctions()
void VBATest::testMiscOLEStuff()
{
-// Not much point even trying to run except on Windows. Does not work
-// on 64-bit Windows with Excel installed. (Without Excel doesn't
-// really do anything anyway, see "so skip test" below.)
-#if defined(_WIN32) && !defined(_WIN64)
+// Not much point even trying to run except on Windows.
+// (Without Excel doesn't really do anything anyway,
+// see "so skip test" below.)
+#if defined(_WIN32)
// test if we have the necessary runtime environment
// to run the OLE tests.
uno::Reference< lang::XMultiServiceFactory > xOLEFactory;
@@ -110,13 +110,15 @@ void VBATest::testMiscOLEStuff()
if ( !bOk )
return; // can't do anything, skip test
- sal_Unicode sBuf[1024*4];
- SQLGetInstalledDriversW( sBuf, sizeof( sBuf ), nullptr );
+ const int nBufSize = 1024 * 4;
+ sal_Unicode sBuf[nBufSize];
+ SQLGetInstalledDriversW( sBuf, nBufSize, nullptr );
const sal_Unicode *pODBCDriverName = sBuf;
bool bFound = false;
for (; wcslen( pODBCDriverName ) != 0; pODBCDriverName += wcslen( pODBCDriverName ) + 1 ) {
- if ( wcsstr( pODBCDriverName, L"Microsoft Excel Driver" ) != nullptr ) {
+ if( wcscmp( pODBCDriverName, L"Microsoft Excel Driver (*.xls)" ) == 0 ||
+ wcscmp( pODBCDriverName, L"Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)" ) == 0 ) {
bFound = true;
break;
}
@@ -127,18 +129,21 @@ void VBATest::testMiscOLEStuff()
const char* macroSource[] = {
"ole_ObjAssignNoDflt.vb",
"ole_ObjAssignToNothing.vb",
+#if !defined(_WIN64)
+ // This test uses Microsoft.Jet.OLEDB.4.0 Provider, that is unavailable on Win64
"ole_dfltObjDflMethod.vb",
+#endif
};
OUString sMacroPathURL = m_directories.getURLFromSrc("/basic/qa/vba_tests/");
- uno::Sequence< uno::Any > aArgs(1);
+ uno::Sequence< uno::Any > aArgs(2);
// path to test document
- OUString sPath = m_directories.getPathFromSrc("/basic/qa/vba_tests/data/")
- + "ADODBdata.xls";
+ OUString sPath = m_directories.getPathFromSrc("/basic/qa/vba_tests/data/ADODBdata.xls");
sPath = sPath.replaceAll( "/", "\\" );
aArgs[ 0 ] = uno::makeAny( sPath );
+ aArgs[ 1 ] = uno::makeAny( OUString(pODBCDriverName) );
for ( sal_uInt32 i=0; i<SAL_N_ELEMENTS( macroSource ); ++i )
{
diff --git a/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb b/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb
index 048ad5eb5e84..9a86424d3df5 100644
--- a/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb
+++ b/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb
@@ -1,5 +1,5 @@
Option VBASupport 1
-Function doUnitTest( TestData as String) as String
+Function doUnitTest(TestData as String, Driver as String) as String
Rem Ensure object assignment is by reference
Rem when object member is used ( as lhs )
Dim origTimeout As Long
@@ -9,7 +9,7 @@ origTimeout = cn.CommandTimeout
modifiedTimeout = origTimeout * 2
cn.CommandTimeout = modifiedTimeout
Dim conStr As String
-conStr = "Provider=MSDASQL;Driver={Microsoft Excel Driver (*.xls)};DBQ="
+conStr = "Provider=MSDASQL;Driver={" & Driver & "};DBQ="
conStr = conStr & TestData & "; ReadOnly=False;"
cn.Open conStr
Set objCmd = New ADODB.Command
diff --git a/basic/qa/vba_tests/ole_ObjAssignToNothing.vb b/basic/qa/vba_tests/ole_ObjAssignToNothing.vb
index b34163db73ce..d68664b41b72 100644
--- a/basic/qa/vba_tests/ole_ObjAssignToNothing.vb
+++ b/basic/qa/vba_tests/ole_ObjAssignToNothing.vb
@@ -1,12 +1,12 @@
Option VBASupport 1
-Function doUnitTest( TestData as String) as String
+Function doUnitTest(TestData as String, Driver as String) as String
Rem Ensure object assignment is by reference
Rem when object member is used ( as lhs )
Rem This time we are testing assigning with special Nothing
Rem keyword
Set cn = New ADODB.Connection
Dim conStr As String
-conStr = "Provider=MSDASQL;Driver={Microsoft Excel Driver (*.xls)};DBQ="
+conStr = "Provider=MSDASQL;Driver={" & Driver & "};DBQ="
conStr = conStr & TestData & "; ReadOnly=False;"
cn.Open conStr
Set objCmd = New ADODB.Command
diff --git a/basic/qa/vba_tests/ole_dfltObjDflMethod.vb b/basic/qa/vba_tests/ole_dfltObjDflMethod.vb
index f24786098e48..9ac50d9b5f9e 100644
--- a/basic/qa/vba_tests/ole_dfltObjDflMethod.vb
+++ b/basic/qa/vba_tests/ole_dfltObjDflMethod.vb
@@ -3,7 +3,7 @@ Option Explicit
Rem Test accessing an object that has default object member
Rem which in turn has a default member that is a method
-Function doUnitTest(TestData As String) As String
+Function doUnitTest(TestData As String, Driver as String) As String
doUnitTest = "Begin"
Dim modifiedTimout As Long
Dim cnn1 As New ADODB.Connection