summaryrefslogtreecommitdiff
path: root/basic/qa/cppunit
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/qa/cppunit
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/qa/cppunit')
-rw-r--r--basic/qa/cppunit/test_vba.cxx25
1 files changed, 15 insertions, 10 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 )
{