summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-04-30 09:33:19 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-30 09:33:19 +0200
commitc917579a15d60a7b70c5fc5f00f6451da7c4e608 (patch)
tree1c89cd1f66ff5147e494a6493e81239e4a644911 /tests
parentac06bfdc76414c8d8c727ff5278b1baafe610860 (diff)
parent85e3c53e5c5e2de993c90ece324a68d0ff62f417 (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/bic/data/QtGui.5.0.0.linux-gcc-amd64.txt31
-rw-r--r--tests/auto/bic/data/QtGui.5.0.0.linux-gcc-ia32.txt31
-rw-r--r--tests/auto/bic/data/QtOpenGL.5.0.0.linux-gcc-amd64.txt31
-rw-r--r--tests/auto/bic/data/QtOpenGL.5.0.0.linux-gcc-ia32.txt31
-rw-r--r--tests/auto/bic/data/QtPrintSupport.5.0.0.linux-gcc-amd64.txt31
-rw-r--r--tests/auto/bic/data/QtPrintSupport.5.0.0.linux-gcc-ia32.txt31
-rw-r--r--tests/auto/bic/data/QtWidgets.5.0.0.linux-gcc-amd64.txt31
-rw-r--r--tests/auto/bic/data/QtWidgets.5.0.0.linux-gcc-ia32.txt31
-rw-r--r--tests/auto/cmake/CMakeLists.txt6
-rw-r--r--tests/auto/cmake/test_egl_lib/CMakeLists.txt14
-rw-r--r--tests/auto/cmake/test_egl_lib/main.cpp48
-rw-r--r--tests/auto/cmake/test_opengl_lib/CMakeLists.txt24
-rw-r--r--tests/auto/cmake/test_opengl_lib/main.cpp65
-rw-r--r--tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp4
-rw-r--r--tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp5
-rw-r--r--tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp41
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp3
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp6
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_databases.h70
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp186
-rw-r--r--tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp47
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp245
-rw-r--r--tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp12
-rw-r--r--tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp81
-rw-r--r--tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp9
-rw-r--r--tests/auto/tools/tools.pro1
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp34
-rw-r--r--tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp21
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp30
-rw-r--r--tests/benchmarks/corelib/tools/qlocale/main.cpp83
-rw-r--r--tests/benchmarks/corelib/tools/qlocale/qlocale.pro5
-rw-r--r--tests/benchmarks/corelib/tools/tools.pro1
-rw-r--r--tests/benchmarks/sql/kernel/qsqlquery/main.cpp32
-rw-r--r--tests/manual/dialogs/filedialogpanel.cpp2
34 files changed, 745 insertions, 578 deletions
diff --git a/tests/auto/bic/data/QtGui.5.0.0.linux-gcc-amd64.txt b/tests/auto/bic/data/QtGui.5.0.0.linux-gcc-amd64.txt
index d2db7b0a8f..6a7d5535fb 100644
--- a/tests/auto/bic/data/QtGui.5.0.0.linux-gcc-amd64.txt
+++ b/tests/auto/bic/data/QtGui.5.0.0.linux-gcc-amd64.txt
@@ -3981,40 +3981,15 @@ QScreenOrientationChangeEvent (0x7f7180294bc8) 0
QEvent (0x7f71806522a0) 0
primary-for QScreenOrientationChangeEvent (0x7f7180294bc8)
-Class QAccessible::QPrivateSignal
- size=1 align=1
- base size=0 base align=1
-QAccessible::QPrivateSignal (0x7f7180652360) 0 empty
-
Class QAccessible::State
size=8 align=8
base size=5 base align=8
QAccessible::State (0x7f71806523c0) 0
-Vtable for QAccessible
-QAccessible::_ZTV11QAccessible: 14u entries
-0 (int (*)(...))0
-8 (int (*)(...))(& _ZTI11QAccessible)
-16 (int (*)(...))QAccessible::metaObject
-24 (int (*)(...))QAccessible::qt_metacast
-32 (int (*)(...))QAccessible::qt_metacall
-40 (int (*)(...))QAccessible::~QAccessible
-48 (int (*)(...))QAccessible::~QAccessible
-56 (int (*)(...))QObject::event
-64 (int (*)(...))QObject::eventFilter
-72 (int (*)(...))QObject::timerEvent
-80 (int (*)(...))QObject::childEvent
-88 (int (*)(...))QObject::customEvent
-96 (int (*)(...))QObject::connectNotify
-104 (int (*)(...))QObject::disconnectNotify
-
Class QAccessible
- size=16 align=8
- base size=16 base align=8
-QAccessible (0x7f7180294d68) 0
- vptr=((& QAccessible::_ZTV11QAccessible) + 16u)
- QObject (0x7f7180652300) 0
- primary-for QAccessible (0x7f7180294d68)
+ size=1 align=1
+ base size=0 base align=1
+QAccessible (0x7f7180294d68) 0 empty
Vtable for QAccessibleInterface
QAccessibleInterface::_ZTV20QAccessibleInterface: 23u entries
diff --git a/tests/auto/bic/data/QtGui.5.0.0.linux-gcc-ia32.txt b/tests/auto/bic/data/QtGui.5.0.0.linux-gcc-ia32.txt
index 433c0eaacc..33fb2fd8a0 100644
--- a/tests/auto/bic/data/QtGui.5.0.0.linux-gcc-ia32.txt
+++ b/tests/auto/bic/data/QtGui.5.0.0.linux-gcc-ia32.txt
@@ -3981,40 +3981,15 @@ QScreenOrientationChangeEvent (0xb3a816cc) 0
QEvent (0xb392ecb0) 0
primary-for QScreenOrientationChangeEvent (0xb3a816cc)
-Class QAccessible::QPrivateSignal
- size=1 align=1
- base size=0 base align=1
-QAccessible::QPrivateSignal (0xb392ee70) 0 empty
-
Class QAccessible::State
size=8 align=4
base size=5 base align=4
QAccessible::State (0xb392eea8) 0
-Vtable for QAccessible
-QAccessible::_ZTV11QAccessible: 14u entries
-0 (int (*)(...))0
-4 (int (*)(...))(& _ZTI11QAccessible)
-8 (int (*)(...))QAccessible::metaObject
-12 (int (*)(...))QAccessible::qt_metacast
-16 (int (*)(...))QAccessible::qt_metacall
-20 (int (*)(...))QAccessible::~QAccessible
-24 (int (*)(...))QAccessible::~QAccessible
-28 (int (*)(...))QObject::event
-32 (int (*)(...))QObject::eventFilter
-36 (int (*)(...))QObject::timerEvent
-40 (int (*)(...))QObject::childEvent
-44 (int (*)(...))QObject::customEvent
-48 (int (*)(...))QObject::connectNotify
-52 (int (*)(...))QObject::disconnectNotify
-
Class QAccessible
- size=8 align=4
- base size=8 base align=4
-QAccessible (0xb3a81708) 0
- vptr=((& QAccessible::_ZTV11QAccessible) + 8u)
- QObject (0xb392ed90) 0
- primary-for QAccessible (0xb3a81708)
+ size=1 align=1
+ base size=0 base align=1
+QAccessible (0xb3a81708) 0 empty
Vtable for QAccessibleInterface
QAccessibleInterface::_ZTV20QAccessibleInterface: 23u entries
diff --git a/tests/auto/bic/data/QtOpenGL.5.0.0.linux-gcc-amd64.txt b/tests/auto/bic/data/QtOpenGL.5.0.0.linux-gcc-amd64.txt
index 125e529c33..ebf0273f77 100644
--- a/tests/auto/bic/data/QtOpenGL.5.0.0.linux-gcc-amd64.txt
+++ b/tests/auto/bic/data/QtOpenGL.5.0.0.linux-gcc-amd64.txt
@@ -3981,40 +3981,15 @@ QScreenOrientationChangeEvent (0x7f04b8f8bbc8) 0
QEvent (0x7f04b8efe720) 0
primary-for QScreenOrientationChangeEvent (0x7f04b8f8bbc8)
-Class QAccessible::QPrivateSignal
- size=1 align=1
- base size=0 base align=1
-QAccessible::QPrivateSignal (0x7f04b8efe7e0) 0 empty
-
Class QAccessible::State
size=8 align=8
base size=5 base align=8
QAccessible::State (0x7f04b8efe840) 0
-Vtable for QAccessible
-QAccessible::_ZTV11QAccessible: 14u entries
-0 (int (*)(...))0
-8 (int (*)(...))(& _ZTI11QAccessible)
-16 (int (*)(...))QAccessible::metaObject
-24 (int (*)(...))QAccessible::qt_metacast
-32 (int (*)(...))QAccessible::qt_metacall
-40 (int (*)(...))QAccessible::~QAccessible
-48 (int (*)(...))QAccessible::~QAccessible
-56 (int (*)(...))QObject::event
-64 (int (*)(...))QObject::eventFilter
-72 (int (*)(...))QObject::timerEvent
-80 (int (*)(...))QObject::childEvent
-88 (int (*)(...))QObject::customEvent
-96 (int (*)(...))QObject::connectNotify
-104 (int (*)(...))QObject::disconnectNotify
-
Class QAccessible
- size=16 align=8
- base size=16 base align=8
-QAccessible (0x7f04b8f8bd68) 0
- vptr=((& QAccessible::_ZTV11QAccessible) + 16u)
- QObject (0x7f04b8efe780) 0
- primary-for QAccessible (0x7f04b8f8bd68)
+ size=1 align=1
+ base size=0 base align=1
+QAccessible (0x7f04b8f8bd68) 0 empty
Vtable for QAccessibleInterface
QAccessibleInterface::_ZTV20QAccessibleInterface: 23u entries
diff --git a/tests/auto/bic/data/QtOpenGL.5.0.0.linux-gcc-ia32.txt b/tests/auto/bic/data/QtOpenGL.5.0.0.linux-gcc-ia32.txt
index 7d8a99d222..8ced43438f 100644
--- a/tests/auto/bic/data/QtOpenGL.5.0.0.linux-gcc-ia32.txt
+++ b/tests/auto/bic/data/QtOpenGL.5.0.0.linux-gcc-ia32.txt
@@ -3981,40 +3981,15 @@ QScreenOrientationChangeEvent (0xb3b78e10) 0
QEvent (0xb39dbe38) 0
primary-for QScreenOrientationChangeEvent (0xb3b78e10)
-Class QAccessible::QPrivateSignal
- size=1 align=1
- base size=0 base align=1
-QAccessible::QPrivateSignal (0xb39dba48) 0 empty
-
Class QAccessible::State
size=8 align=4
base size=5 base align=4
QAccessible::State (0xb39dbe00) 0
-Vtable for QAccessible
-QAccessible::_ZTV11QAccessible: 14u entries
-0 (int (*)(...))0
-4 (int (*)(...))(& _ZTI11QAccessible)
-8 (int (*)(...))QAccessible::metaObject
-12 (int (*)(...))QAccessible::qt_metacast
-16 (int (*)(...))QAccessible::qt_metacall
-20 (int (*)(...))QAccessible::~QAccessible
-24 (int (*)(...))QAccessible::~QAccessible
-28 (int (*)(...))QObject::event
-32 (int (*)(...))QObject::eventFilter
-36 (int (*)(...))QObject::timerEvent
-40 (int (*)(...))QObject::childEvent
-44 (int (*)(...))QObject::customEvent
-48 (int (*)(...))QObject::connectNotify
-52 (int (*)(...))QObject::disconnectNotify
-
Class QAccessible
- size=8 align=4
- base size=8 base align=4
-QAccessible (0xb3b78e4c) 0
- vptr=((& QAccessible::_ZTV11QAccessible) + 8u)
- QObject (0xb39dbf18) 0
- primary-for QAccessible (0xb3b78e4c)
+ size=1 align=1
+ base size=0 base align=1
+QAccessible (0xb3b78e4c) 0 empty
Vtable for QAccessibleInterface
QAccessibleInterface::_ZTV20QAccessibleInterface: 23u entries
diff --git a/tests/auto/bic/data/QtPrintSupport.5.0.0.linux-gcc-amd64.txt b/tests/auto/bic/data/QtPrintSupport.5.0.0.linux-gcc-amd64.txt
index 20988597b1..28a8468405 100644
--- a/tests/auto/bic/data/QtPrintSupport.5.0.0.linux-gcc-amd64.txt
+++ b/tests/auto/bic/data/QtPrintSupport.5.0.0.linux-gcc-amd64.txt
@@ -3986,40 +3986,15 @@ QScreenOrientationChangeEvent (0x7f0bd5ed8bc8) 0
QEvent (0x7f0bd5e7e300) 0
primary-for QScreenOrientationChangeEvent (0x7f0bd5ed8bc8)
-Class QAccessible::QPrivateSignal
- size=1 align=1
- base size=0 base align=1
-QAccessible::QPrivateSignal (0x7f0bd5e7e3c0) 0 empty
-
Class QAccessible::State
size=8 align=8
base size=5 base align=8
QAccessible::State (0x7f0bd5e7e420) 0
-Vtable for QAccessible
-QAccessible::_ZTV11QAccessible: 14u entries
-0 (int (*)(...))0
-8 (int (*)(...))(& _ZTI11QAccessible)
-16 (int (*)(...))QAccessible::metaObject
-24 (int (*)(...))QAccessible::qt_metacast
-32 (int (*)(...))QAccessible::qt_metacall
-40 (int (*)(...))QAccessible::~QAccessible
-48 (int (*)(...))QAccessible::~QAccessible
-56 (int (*)(...))QObject::event
-64 (int (*)(...))QObject::eventFilter
-72 (int (*)(...))QObject::timerEvent
-80 (int (*)(...))QObject::childEvent
-88 (int (*)(...))QObject::customEvent
-96 (int (*)(...))QObject::connectNotify
-104 (int (*)(...))QObject::disconnectNotify
-
Class QAccessible
- size=16 align=8
- base size=16 base align=8
-QAccessible (0x7f0bd5ed8d68) 0
- vptr=((& QAccessible::_ZTV11QAccessible) + 16u)
- QObject (0x7f0bd5e7e360) 0
- primary-for QAccessible (0x7f0bd5ed8d68)
+ size=1 align=1
+ base size=0 base align=1
+QAccessible (0x7f0bd5ed8d68) 0 empty
Vtable for QAccessibleInterface
QAccessibleInterface::_ZTV20QAccessibleInterface: 23u entries
diff --git a/tests/auto/bic/data/QtPrintSupport.5.0.0.linux-gcc-ia32.txt b/tests/auto/bic/data/QtPrintSupport.5.0.0.linux-gcc-ia32.txt
index 6162fcde57..be5a9dc941 100644
--- a/tests/auto/bic/data/QtPrintSupport.5.0.0.linux-gcc-ia32.txt
+++ b/tests/auto/bic/data/QtPrintSupport.5.0.0.linux-gcc-ia32.txt
@@ -3981,40 +3981,15 @@ QScreenOrientationChangeEvent (0xb3b227bc) 0
QEvent (0xb39d0e38) 0
primary-for QScreenOrientationChangeEvent (0xb3b227bc)
-Class QAccessible::QPrivateSignal
- size=1 align=1
- base size=0 base align=1
-QAccessible::QPrivateSignal (0xb39d0a48) 0 empty
-
Class QAccessible::State
size=8 align=4
base size=5 base align=4
QAccessible::State (0xb39d0e00) 0
-Vtable for QAccessible
-QAccessible::_ZTV11QAccessible: 14u entries
-0 (int (*)(...))0
-4 (int (*)(...))(& _ZTI11QAccessible)
-8 (int (*)(...))QAccessible::metaObject
-12 (int (*)(...))QAccessible::qt_metacast
-16 (int (*)(...))QAccessible::qt_metacall
-20 (int (*)(...))QAccessible::~QAccessible
-24 (int (*)(...))QAccessible::~QAccessible
-28 (int (*)(...))QObject::event
-32 (int (*)(...))QObject::eventFilter
-36 (int (*)(...))QObject::timerEvent
-40 (int (*)(...))QObject::childEvent
-44 (int (*)(...))QObject::customEvent
-48 (int (*)(...))QObject::connectNotify
-52 (int (*)(...))QObject::disconnectNotify
-
Class QAccessible
- size=8 align=4
- base size=8 base align=4
-QAccessible (0xb3b227f8) 0
- vptr=((& QAccessible::_ZTV11QAccessible) + 8u)
- QObject (0xb39d0f18) 0
- primary-for QAccessible (0xb3b227f8)
+ size=1 align=1
+ base size=0 base align=1
+QAccessible (0xb3b227f8) 0 empty
Vtable for QAccessibleInterface
QAccessibleInterface::_ZTV20QAccessibleInterface: 23u entries
diff --git a/tests/auto/bic/data/QtWidgets.5.0.0.linux-gcc-amd64.txt b/tests/auto/bic/data/QtWidgets.5.0.0.linux-gcc-amd64.txt
index 35a4d3a30a..d89eb8d488 100644
--- a/tests/auto/bic/data/QtWidgets.5.0.0.linux-gcc-amd64.txt
+++ b/tests/auto/bic/data/QtWidgets.5.0.0.linux-gcc-amd64.txt
@@ -3981,40 +3981,15 @@ QScreenOrientationChangeEvent (0x7f871fa70bc8) 0
QEvent (0x7f871fa15300) 0
primary-for QScreenOrientationChangeEvent (0x7f871fa70bc8)
-Class QAccessible::QPrivateSignal
- size=1 align=1
- base size=0 base align=1
-QAccessible::QPrivateSignal (0x7f871fa153c0) 0 empty
-
Class QAccessible::State
size=8 align=8
base size=5 base align=8
QAccessible::State (0x7f871fa15420) 0
-Vtable for QAccessible
-QAccessible::_ZTV11QAccessible: 14u entries
-0 (int (*)(...))0
-8 (int (*)(...))(& _ZTI11QAccessible)
-16 (int (*)(...))QAccessible::metaObject
-24 (int (*)(...))QAccessible::qt_metacast
-32 (int (*)(...))QAccessible::qt_metacall
-40 (int (*)(...))QAccessible::~QAccessible
-48 (int (*)(...))QAccessible::~QAccessible
-56 (int (*)(...))QObject::event
-64 (int (*)(...))QObject::eventFilter
-72 (int (*)(...))QObject::timerEvent
-80 (int (*)(...))QObject::childEvent
-88 (int (*)(...))QObject::customEvent
-96 (int (*)(...))QObject::connectNotify
-104 (int (*)(...))QObject::disconnectNotify
-
Class QAccessible
- size=16 align=8
- base size=16 base align=8
-QAccessible (0x7f871fa70d68) 0
- vptr=((& QAccessible::_ZTV11QAccessible) + 16u)
- QObject (0x7f871fa15360) 0
- primary-for QAccessible (0x7f871fa70d68)
+ size=1 align=1
+ base size=0 base align=1
+QAccessible (0x7f871fa70d68) 0 empty
Vtable for QAccessibleInterface
QAccessibleInterface::_ZTV20QAccessibleInterface: 23u entries
diff --git a/tests/auto/bic/data/QtWidgets.5.0.0.linux-gcc-ia32.txt b/tests/auto/bic/data/QtWidgets.5.0.0.linux-gcc-ia32.txt
index fe8f00314f..b1b1eb5c38 100644
--- a/tests/auto/bic/data/QtWidgets.5.0.0.linux-gcc-ia32.txt
+++ b/tests/auto/bic/data/QtWidgets.5.0.0.linux-gcc-ia32.txt
@@ -3981,40 +3981,15 @@ QScreenOrientationChangeEvent (0xb3ae37bc) 0
QEvent (0xb3990e38) 0
primary-for QScreenOrientationChangeEvent (0xb3ae37bc)
-Class QAccessible::QPrivateSignal
- size=1 align=1
- base size=0 base align=1
-QAccessible::QPrivateSignal (0xb3990a48) 0 empty
-
Class QAccessible::State
size=8 align=4
base size=5 base align=4
QAccessible::State (0xb3990e00) 0
-Vtable for QAccessible
-QAccessible::_ZTV11QAccessible: 14u entries
-0 (int (*)(...))0
-4 (int (*)(...))(& _ZTI11QAccessible)
-8 (int (*)(...))QAccessible::metaObject
-12 (int (*)(...))QAccessible::qt_metacast
-16 (int (*)(...))QAccessible::qt_metacall
-20 (int (*)(...))QAccessible::~QAccessible
-24 (int (*)(...))QAccessible::~QAccessible
-28 (int (*)(...))QObject::event
-32 (int (*)(...))QObject::eventFilter
-36 (int (*)(...))QObject::timerEvent
-40 (int (*)(...))QObject::childEvent
-44 (int (*)(...))QObject::customEvent
-48 (int (*)(...))QObject::connectNotify
-52 (int (*)(...))QObject::disconnectNotify
-
Class QAccessible
- size=8 align=4
- base size=8 base align=4
-QAccessible (0xb3ae37f8) 0
- vptr=((& QAccessible::_ZTV11QAccessible) + 8u)
- QObject (0xb3990f18) 0
- primary-for QAccessible (0xb3ae37f8)
+ size=1 align=1
+ base size=0 base align=1
+QAccessible (0xb3ae37f8) 0 empty
Vtable for QAccessibleInterface
QAccessibleInterface::_ZTV20QAccessibleInterface: 23u entries
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 77cf81989a..25f2ab6a87 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -106,7 +106,7 @@ if (NOT NO_WIDGETS)
list(APPEND qt_module_includes
Widgets QWidget
OpenGL QGLBuffer
- PrintSupport QPrintDialog
+ PrintSupport QPrinter
)
endif()
@@ -121,6 +121,10 @@ test_module_includes(
)
expect_pass(test_concurrent_module)
expect_pass(test_openglextensions_module)
+if (QT_WITH_ANGLE OR (NOT WIN32 AND NOT APPLE))
+ expect_pass(test_egl_lib)
+endif()
+expect_pass(test_opengl_lib)
if (NOT CMAKE_VERSION VERSION_LESS 2.8.11)
expect_pass(test_interface)
diff --git a/tests/auto/cmake/test_egl_lib/CMakeLists.txt b/tests/auto/cmake/test_egl_lib/CMakeLists.txt
new file mode 100644
index 0000000000..87a598fa99
--- /dev/null
+++ b/tests/auto/cmake/test_egl_lib/CMakeLists.txt
@@ -0,0 +1,14 @@
+
+cmake_minimum_required(VERSION 2.8)
+
+project(test_egl_lib)
+
+find_package(Qt5Gui REQUIRED)
+
+include_directories(${Qt5Gui_INCLUDE_DIRS} ${Qt5Gui_EGL_INCLUDE_DIRS} )
+add_definitions(${Qt5Gui_DEFINITIONS})
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Gui_EXECUTABLE_COMPILE_FLAGS}")
+
+add_executable(myobject main.cpp )
+target_link_libraries(myobject ${Qt5Gui_LIBRARIES} ${Qt5Gui_EGL_LIBRARIES})
diff --git a/tests/auto/cmake/test_egl_lib/main.cpp b/tests/auto/cmake/test_egl_lib/main.cpp
new file mode 100644
index 0000000000..f3a9dc6cd1
--- /dev/null
+++ b/tests/auto/cmake/test_egl_lib/main.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <EGL/egl.h>
+
+int main(int argc, char **argv)
+{
+ eglGetError();
+ return 0;
+}
diff --git a/tests/auto/cmake/test_opengl_lib/CMakeLists.txt b/tests/auto/cmake/test_opengl_lib/CMakeLists.txt
new file mode 100644
index 0000000000..d602bcda9b
--- /dev/null
+++ b/tests/auto/cmake/test_opengl_lib/CMakeLists.txt
@@ -0,0 +1,24 @@
+
+cmake_minimum_required(VERSION 2.8)
+
+project(test_opengl_lib)
+
+find_package(Qt5Gui REQUIRED)
+
+include_directories(${Qt5Gui_INCLUDE_DIRS} ${Qt5Gui_OPENGL_INCLUDE_DIRS} )
+add_definitions(${Qt5Gui_DEFINITIONS})
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Gui_EXECUTABLE_COMPILE_FLAGS}")
+
+if (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL GLES)
+ add_definitions(-DGL_IMPLEMENTATION_GLES1)
+elseif (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL GLESv2)
+ add_definitions(-DGL_IMPLEMENTATION_GLES2)
+elseif (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL GL)
+ add_definitions(-DGL_IMPLEMENTATION_GL)
+else()
+ message(SEND_ERROR "Qt5Gui_OPENGL_IMPLEMENTATION does not contain valid data.")
+endif()
+
+add_executable(myobject main.cpp )
+target_link_libraries(myobject ${Qt5Gui_LIBRARIES} ${Qt5Gui_OPENGL_LIBRARIES})
diff --git a/tests/auto/cmake/test_opengl_lib/main.cpp b/tests/auto/cmake/test_opengl_lib/main.cpp
new file mode 100644
index 0000000000..450b759bc8
--- /dev/null
+++ b/tests/auto/cmake/test_opengl_lib/main.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#if GL_IMPLEMENTATION_GLES1
+#include <GLES/gl.h>
+#elif GL_IMPLEMENTATION_GLES2
+#include <GLES2/gl2.h>
+#elif GL_IMPLEMENTATION_GL
+
+#include <qglobal.h>
+#ifdef Q_OS_WIN
+#include <qt_windows.h>
+#endif
+
+#ifdef Q_OS_MAC
+#include <OpenGL/gl.h>
+#else
+#include <GL/gl.h>
+#endif
+#endif
+
+int main(int argc, char **argv)
+{
+ glGetError();
+ return 0;
+}
diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
index d2fb56ce02..2d2ae14fb8 100644
--- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -891,6 +891,10 @@ void tst_QAbstractItemModel::moveColumns()
QCOMPARE(model.moveColumns(QModelIndex(), 6, 4, QModelIndex(), 1), true);
QCOMPARE(columnsAboutToBeMovedSpy.count(), 1);
QCOMPARE(columnsMovedSpy.count(), 1);
+
+ QCOMPARE(model.moveColumn(QModelIndex(), 4, QModelIndex(), 1), true);
+ QCOMPARE(columnsAboutToBeMovedSpy.count(), 2);
+ QCOMPARE(columnsMovedSpy.count(), 2);
}
void tst_QAbstractItemModel::reset()
diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
index a6134de497..c77b4eea42 100644
--- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
@@ -510,6 +510,11 @@ void tst_QKeySequence::toStringFromKeycode_data()
QTest::newRow("A") << QKeySequence(Qt::Key_A) << "A";
QTest::newRow("-1") << QKeySequence(-1) << "";
QTest::newRow("Unknown") << QKeySequence(Qt::Key_unknown) << "";
+ QTest::newRow("Ctrl+Numpad+Ins") << QKeySequence(Qt::ControlModifier | Qt::KeypadModifier | Qt::Key_Insert) << "Ctrl+Numpad+Ins";
+ QTest::newRow("Ctrl+Numpad+Del") << QKeySequence(Qt::ControlModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Numpad+Del";
+ QTest::newRow("Ctrl+Alt+Numpad+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Numpad+Del";
+ QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+ QTest::newRow("Ctrl+Numpad+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Numpad+Ins";
}
void tst_QKeySequence::toStringFromKeycode()
diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
index d57a99a758..e06285dc67 100644
--- a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
+++ b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
@@ -87,6 +87,8 @@ private slots:
void inNetworkAccessManager_data();
void inNetworkAccessManager();
#endif
+ void genericSystemProxy();
+ void genericSystemProxy_data();
private:
QString formatProxyName(const QNetworkProxy & proxy) const;
@@ -367,6 +369,45 @@ void tst_QNetworkProxyFactory::inNetworkAccessManager()
#endif //QT_NO_BEARERMANAGEMENT
+Q_DECLARE_METATYPE(QNetworkProxy::ProxyType)
+
+void tst_QNetworkProxyFactory::genericSystemProxy()
+{
+ QFETCH(QByteArray, envVar);
+ QFETCH(QByteArray, url);
+ QFETCH(QNetworkProxy::ProxyType, proxyType);
+ QFETCH(QString, hostName);
+ QFETCH(int, port);
+
+// The generic system proxy is only available on the following platforms
+#if (!defined Q_OS_BLACKBERRY) && (!defined Q_OS_WIN) && ((!defined Q_OS_MAC) || defined Q_OS_IOS)
+ qputenv(envVar, url);
+ const QList<QNetworkProxy> systemProxy = QNetworkProxyFactory::systemProxyForQuery();
+ QCOMPARE(systemProxy.size(), 1);
+ QCOMPARE(systemProxy.first().type(), proxyType);
+ QCOMPARE(systemProxy.first().hostName(), hostName);
+ QCOMPARE(systemProxy.first().port(), static_cast<quint16>(port));
+ qunsetenv(envVar);
+#else
+ QSKIP("Generic system proxy not available on this platform.");
+#endif
+}
+
+void tst_QNetworkProxyFactory::genericSystemProxy_data()
+{
+ QTest::addColumn<QByteArray>("envVar");
+ QTest::addColumn<QByteArray>("url");
+ QTest::addColumn<QNetworkProxy::ProxyType>("proxyType");
+ QTest::addColumn<QString>("hostName");
+ QTest::addColumn<int>("port");
+
+ QTest::newRow("no proxy") << QByteArray("http_proxy") << QByteArray() << QNetworkProxy::NoProxy
+ << QString() << 0;
+ QTest::newRow("socks5") << QByteArray("http_proxy") << QByteArray("socks5://127.0.0.1:4242")
+ << QNetworkProxy::Socks5Proxy << QString("127.0.0.1") << 4242;
+ QTest::newRow("http") << QByteArray("http_proxy") << QByteArray("http://example.com:666")
+ << QNetworkProxy::HttpProxy << QString("example.com") << 666;
+}
class QSPFQThread : public QThread
{
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index feb6978690..f3adb2b52f 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -2135,7 +2135,8 @@ void tst_QSslSocket::writeBigChunk()
QFAIL("Error while writing! Check if the OpenSSL BIO size is limited?!");
}
// also check the error string. If another error (than UnknownError) occurred, it should be different than before
- QVERIFY(errorBefore == errorAfter);
+ QVERIFY2(errorBefore == errorAfter || socket->error() == QAbstractSocket::RemoteHostClosedError,
+ QByteArray("unexpected error: ").append(qPrintable(errorAfter)));
// check that everything has been written to OpenSSL
QVERIFY(socket->bytesToWrite() == 0);
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index af8e4472ed..557189f4e2 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -2600,6 +2600,12 @@ void tst_QAccessibility::treeTest()
QCOMPARE(iface->indexOfChild(child2), 4);
QCOMPARE(child2->text(QAccessible::Name), QString("Austria"));
+ treeView->setHeaderHidden(true);
+ QAccessibleInterface *accSpain = iface->child(0);
+ QCOMPARE(accSpain->role(), QAccessible::TreeItem);
+ QCOMPARE(iface->indexOfChild(accSpain), 0);
+ treeView->setHeaderHidden(false);
+
QTestAccessibility::clearEvents();
// table 2
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
index e47140b61b..af3c5b2e90 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
@@ -108,14 +108,21 @@ inline QString fixupTableName(const QString &tableName, QSqlDatabase db)
inline static QString qTableName(const QString& prefix, const char *sourceFileName, QSqlDatabase db)
{
- return fixupTableName(QString(QLatin1String("dbtst") + QString::number(qHash(QLatin1String(sourceFileName) +
+ QString tableStr = QLatin1String("dbtst");
+ if (db.driverName().toLower().contains("ODBC"))
+ tableStr += QLatin1String("_odbc");
+ return fixupTableName(QString(QLatin1String("dbtst") + db.driverName() +
+ QString::number(qHash(QLatin1String(sourceFileName) +
"_" + qGetHostName().replace( "-", "_" )), 16) + "_" + prefix), db);
}
inline static QString qTableName(const QString& prefix, QSqlDatabase db)
{
- return fixupTableName(QString(db.driver()->escapeIdentifier(prefix + "_" + qGetHostName(), QSqlDriver::TableName)),
- db);
+ QString tableStr;
+ if (db.driverName().toLower().contains("ODBC"))
+ tableStr += QLatin1String("_odbc");
+ return fixupTableName(QString(db.driver()->escapeIdentifier(prefix + tableStr + "_" +
+ qGetHostName(), QSqlDriver::TableName)),db);
}
inline static bool testWhiteSpaceNames( const QString &name )
@@ -240,6 +247,7 @@ public:
void addDbs()
{
+ //addDb("QOCI", "localhost", "system", "penandy");
// addDb( "QOCI8", "//horsehead.nokia.troll.no:1521/pony.troll.no", "scott", "tiger" ); // Oracle 9i on horsehead
// addDb( "QOCI8", "//horsehead.nokia.troll.no:1521/ustest.troll.no", "scott", "tiger", "" ); // Oracle 9i on horsehead
// addDb( "QOCI8", "//iceblink.nokia.troll.no:1521/ice.troll.no", "scott", "tiger", "" ); // Oracle 8 on iceblink (not currently working)
@@ -372,7 +380,7 @@ public:
bool wasDropped;
QSqlQuery q( db );
QStringList dbtables=db.tables();
-
+ QSqlDriverPrivate::DBMSType dbType = getDatabaseType(db);
foreach(const QString &tableName, tableNames)
{
wasDropped = true;
@@ -384,7 +392,7 @@ public:
foreach(const QString &table2, dbtables.filter(table, Qt::CaseInsensitive)) {
if(table2.compare(table.section('.', -1, -1), Qt::CaseInsensitive) == 0) {
table=db.driver()->escapeIdentifier(table2, QSqlDriver::TableName);
- if(isPostgreSQL(db))
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
wasDropped = q.exec( "drop table " + table + " cascade");
else
wasDropped = q.exec( "drop table " + table);
@@ -449,25 +457,26 @@ public:
// blobSize is only used if the db doesn't have a generic blob type
static QString blobTypeName( QSqlDatabase db, int blobSize = 10000 )
{
- if ( db.driverName().startsWith( "QMYSQL" ) )
+ const QSqlDriverPrivate::DBMSType dbType = getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::MySqlServer)
return "longblob";
- if ( db.driverName().startsWith( "QPSQL" ) )
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
return "bytea";
- if ( db.driverName().startsWith( "QTDS" )
- || isSqlServer( db )
+ if (dbType == QSqlDriverPrivate::Sybase
+ || dbType == QSqlDriverPrivate::MSSqlServer
|| isMSAccess( db ) )
return "image";
- if ( db.driverName().startsWith( "QDB2" ) )
+ if (dbType == QSqlDriverPrivate::DB2)
return QString( "blob(%1)" ).arg( blobSize );
- if ( db.driverName().startsWith( "QIBASE" ) )
+ if (dbType == QSqlDriverPrivate::Interbase)
return QString( "blob sub_type 0 segment size 4096" );
- if ( db.driverName().startsWith( "QOCI" )
- || db.driverName().startsWith( "QSQLITE" ) )
+ if (dbType == QSqlDriverPrivate::Oracle
+ || dbType == QSqlDriverPrivate::SQLite)
return "blob";
qDebug() << "tst_Databases::blobTypeName: Don't know the blob type for" << dbToString( db );
@@ -477,22 +486,24 @@ public:
static QString dateTimeTypeName(QSqlDatabase db)
{
- if (db.driverName().startsWith("QPSQL"))
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
return QLatin1String("timestamp");
- if (db.driverName().startsWith("QOCI") && getOraVersion(db) >= 9)
+ if (dbType == QSqlDriverPrivate::Oracle && getOraVersion(db) >= 9)
return QLatin1String("timestamp(0)");
return QLatin1String("datetime");
}
static QString autoFieldName( QSqlDatabase db )
{
- if ( db.driverName().startsWith( "QMYSQL" ) )
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::MySqlServer)
return "AUTO_INCREMENT";
- if ( db.driverName().startsWith( "QTDS" ) )
+ if (dbType == QSqlDriverPrivate::Sybase || dbType == QSqlDriverPrivate::MSSqlServer)
return "IDENTITY";
-/* if ( db.driverName().startsWith( "QPSQL" ) )
+/* if (dbType == QSqlDriverPrivate::PostgreSQL)
return "SERIAL";*/
-// if ( db.driverName().startsWith( "QDB2" ) )
+// if (dbType == QSqlDriverPrivate::DB2)
// return "GENERATED BY DEFAULT AS IDENTITY";
return QString();
@@ -522,10 +533,10 @@ public:
return result.toLocal8Bit();
}
- static bool isSqlServer( QSqlDatabase db )
+ static QSqlDriverPrivate::DBMSType getDatabaseType(QSqlDatabase db)
{
QSqlDriverPrivate *d = static_cast<QSqlDriverPrivate *>(QObjectPrivate::get(db.driver()));
- return d->dbmsType == QSqlDriverPrivate::MSSqlServer;
+ return d->dbmsType;
}
static bool isMSAccess( QSqlDatabase db )
@@ -533,23 +544,6 @@ public:
return db.databaseName().contains( "Access Driver", Qt::CaseInsensitive );
}
- static bool isPostgreSQL( QSqlDatabase db )
- {
- QSqlDriverPrivate *d = static_cast<QSqlDriverPrivate *>(QObjectPrivate::get(db.driver()));
- return d->dbmsType == QSqlDriverPrivate::PostgreSQL;
- }
-
- static bool isMySQL( QSqlDatabase db )
- {
- QSqlDriverPrivate *d = static_cast<QSqlDriverPrivate *>(QObjectPrivate::get(db.driver()));
- return d->dbmsType == QSqlDriverPrivate::MySqlServer;
- }
- static bool isDB2( QSqlDatabase db )
- {
- QSqlDriverPrivate *d = static_cast<QSqlDriverPrivate *>(QObjectPrivate::get(db.driver()));
- return d->dbmsType == QSqlDriverPrivate::DB2;
- }
-
// -1 on fail, else Oracle version
static int getOraVersion( QSqlDatabase db )
{
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
index b958a30108..91ed7360c3 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
@@ -145,8 +145,8 @@ private slots:
void psql_escapedIdentifiers();
void psql_escapeBytea_data() { generic_data("QPSQL"); }
void psql_escapeBytea();
- void bug_249059_data() { generic_data("QPSQL"); }
- void bug_249059();
+ void psql_bug249059_data() { generic_data("QPSQL"); }
+ void psql_bug249059();
void mysqlOdbc_unsignedIntegers_data() { generic_data(); }
void mysqlOdbc_unsignedIntegers();
@@ -242,14 +242,16 @@ struct FieldDef {
// excluding the primary key field
static int createFieldTable(const FieldDef fieldDefs[], QSqlDatabase db)
{
- tst_Databases::safeDropTable(db, qTableName("qtestfields", __FILE__, db));
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ const QString tableName = qTableName("qtestfields", __FILE__, db);
+ tst_Databases::safeDropTable(db, tableName);
QSqlQuery q(db);
// construct a create table statement consisting of all fieldtypes
- QString qs = "create table " + qTableName("qtestfields", __FILE__, db);
+ QString qs = "create table " + tableName;
QString autoName = tst_Databases::autoFieldName(db);
if (tst_Databases::isMSAccess(db))
qs.append(" (id int not null");
- else if (tst_Databases::isPostgreSQL(db))
+ else if (dbType == QSqlDriverPrivate::PostgreSQL)
qs.append(" (id serial not null");
else
qs.append(QString("(id integer not null %1 primary key").arg(autoName));
@@ -257,9 +259,8 @@ static int createFieldTable(const FieldDef fieldDefs[], QSqlDatabase db)
int i = 0;
for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) {
qs += QString(",\n %1 %2").arg(fieldDefs[ i ].fieldName()).arg(fieldDefs[ i ].typeName);
- if ((db.driverName().startsWith("QTDS") || tst_Databases::isSqlServer(db)) && fieldDefs[ i ].nullable) {
+ if ((dbType == QSqlDriverPrivate::Sybase || dbType == QSqlDriverPrivate::MSSqlServer) && fieldDefs[i].nullable)
qs += " null";
- }
}
if (tst_Databases::isMSAccess(db))
@@ -286,31 +287,33 @@ void tst_QSqlDatabase::createTestTables(QSqlDatabase db)
{
if (!db.isValid())
return;
+ const QString tableName = qTableName("qtest", __FILE__, db);
QSqlQuery q(db);
- if (db.driverName().startsWith("QMYSQL"))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::MySqlServer) {
// ### stupid workaround until we find a way to hardcode this
// in the MySQL server startup script
q.exec("set table_type=innodb");
- else if (tst_Databases::isSqlServer(db)) {
+ } else if (dbType == QSqlDriverPrivate::MSSqlServer) {
QVERIFY_SQL(q, exec("SET ANSI_DEFAULTS ON"));
QVERIFY_SQL(q, exec("SET IMPLICIT_TRANSACTIONS OFF"));
- } else if(tst_Databases::isPostgreSQL(db))
+ } else if (dbType == QSqlDriverPrivate::PostgreSQL) {
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
-
+ }
// please never ever change this table; otherwise fix all tests ;)
if (tst_Databases::isMSAccess(db)) {
- QVERIFY_SQL(q, exec("create table " + qTableName("qtest", __FILE__, db) +
+ QVERIFY_SQL(q, exec("create table " + tableName +
" (id int not null, t_varchar varchar(40) not null, t_char char(40), "
"t_numeric number, primary key (id, t_varchar))"));
} else {
- QVERIFY_SQL(q, exec("create table " + qTableName("qtest", __FILE__, db) +
+ QVERIFY_SQL(q, exec("create table " + tableName +
" (id integer not null, t_varchar varchar(40) not null, "
"t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar))"));
}
if (testWhiteSpaceNames(db.driverName())) {
QString qry = "create table "
- + db.driver()->escapeIdentifier(qTableName("qtest", __FILE__, db) + " test", QSqlDriver::TableName)
+ + db.driver()->escapeIdentifier(tableName + " test", QSqlDriver::TableName)
+ '('
+ db.driver()->escapeIdentifier(QLatin1String("test test"), QSqlDriver::FieldName)
+ " int not null primary key)";
@@ -323,16 +326,17 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db)
if (!db.isValid())
return;
- if(tst_Databases::isPostgreSQL(db)) {
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::PostgreSQL) {
QSqlQuery q(db);
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
}
// drop the view first, otherwise we'll get dependency problems
tst_Databases::safeDropViews(db, QStringList() << qTableName("qtest_view", __FILE__, db) << qTableName("qtest_view2", __FILE__, db));
-
+ const QString qtestTable = qTableName("qtest", __FILE__, db);
QStringList tableNames;
- tableNames << qTableName("qtest", __FILE__, db)
+ tableNames << qtestTable
<< qTableName("qtestfields", __FILE__, db)
<< qTableName("qtestalter", __FILE__, db)
<< qTableName("qtest_temp", __FILE__, db)
@@ -354,17 +358,17 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db)
<< qTableName("bug_249059", __FILE__, db);
QSqlQuery q(0, db);
- if (db.driverName().startsWith("QPSQL")) {
+ if (dbType == QSqlDriverPrivate::PostgreSQL) {
q.exec("drop schema " + qTableName("qtestschema", __FILE__, db) + " cascade");
q.exec("drop schema " + qTableName("qtestScHeMa", __FILE__, db) + " cascade");
}
if (testWhiteSpaceNames(db.driverName()))
- tableNames << db.driver()->escapeIdentifier(qTableName("qtest", __FILE__, db) + " test", QSqlDriver::TableName);
+ tableNames << db.driver()->escapeIdentifier(qtestTable + " test", QSqlDriver::TableName);
tst_Databases::safeDropTables(db, tableNames);
- if (db.driverName().startsWith("QOCI")) {
+ if (dbType == QSqlDriverPrivate::Oracle) {
q.exec("drop user "+qTableName("CREATOR", __FILE__, db)+ " cascade");
q.exec("drop user "+qTableName("APPUSER", __FILE__, db) + " cascade");
q.exec("DROP TABLE sys."+qTableName("mypassword", __FILE__, db));
@@ -489,7 +493,8 @@ void tst_QSqlDatabase::open()
QVERIFY(!db.isOpenError());
}
- if (db.driverName().startsWith("QSQLITE") && db.databaseName() == ":memory:") {
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::SQLite && db.databaseName() == ":memory:") {
// tables in in-memory databases don't survive an open/close
createTestTables(db);
populateTestTables(db);
@@ -501,6 +506,7 @@ void tst_QSqlDatabase::tables()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
const QString qtest(qTableName("qtest", __FILE__, db)), qtest_view(qTableName("qtest_view", __FILE__, db)), temp_tab(qTableName("test_tab", __FILE__, db));
@@ -555,9 +561,8 @@ void tst_QSqlDatabase::tables()
QVERIFY(tables.contains(temp_tab, Qt::CaseInsensitive));
QVERIFY(tables.contains(qtest, Qt::CaseInsensitive));
- if (db.driverName().startsWith("QPSQL")) {
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
QVERIFY(tables.contains(qtest + " test"));
- }
}
void tst_QSqlDatabase::whitespaceInIdentifiers()
@@ -565,6 +570,7 @@ void tst_QSqlDatabase::whitespaceInIdentifiers()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
if (testWhiteSpaceNames(db.driverName())) {
const QString tableName(qTableName("qtest", __FILE__, db) + " test");
@@ -573,7 +579,7 @@ void tst_QSqlDatabase::whitespaceInIdentifiers()
QSqlRecord rec = db.record(db.driver()->escapeIdentifier(tableName, QSqlDriver::TableName));
QCOMPARE(rec.count(), 1);
QCOMPARE(rec.fieldName(0), QString("test test"));
- if(db.driverName().startsWith("QOCI"))
+ if (dbType == QSqlDriverPrivate::Oracle)
QCOMPARE(rec.field(0).type(), QVariant::Double);
else
QCOMPARE(rec.field(0).type(), QVariant::Int);
@@ -581,7 +587,7 @@ void tst_QSqlDatabase::whitespaceInIdentifiers()
QSqlIndex idx = db.primaryIndex(db.driver()->escapeIdentifier(tableName, QSqlDriver::TableName));
QCOMPARE(idx.count(), 1);
QCOMPARE(idx.fieldName(0), QString("test test"));
- if(db.driverName().startsWith("QOCI"))
+ if (dbType == QSqlDriverPrivate::Oracle)
QCOMPARE(idx.field(0).type(), QVariant::Double);
else
QCOMPARE(idx.field(0).type(), QVariant::Int);
@@ -670,13 +676,13 @@ void tst_QSqlDatabase::testRecord(const FieldDef fieldDefs[], const QSqlRecord&
void tst_QSqlDatabase::commonFieldTest(const FieldDef fieldDefs[], QSqlDatabase db, const int fieldCount)
{
CHECK_DATABASE(db);
-
- QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__, db));
+ const QString tableName = qTableName("qtestfields", __FILE__, db);
+ QSqlRecord rec = db.record(tableName);
QCOMPARE((int)rec.count(), fieldCount+1);
testRecord(fieldDefs, rec, db);
QSqlQuery q(db);
- QVERIFY_SQL(q, exec("select * from " + qTableName("qtestfields", __FILE__, db)));
+ QVERIFY_SQL(q, exec("select * from " + tableName));
}
void tst_QSqlDatabase::recordTDS()
@@ -772,12 +778,13 @@ void tst_QSqlDatabase::recordOCI()
commonFieldTest(fieldDefs, db, fieldCount);
// some additional tests
- QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__, db));
+ const QString tableName = qTableName("qtestfields", __FILE__, db);
+ QSqlRecord rec = db.record(tableName);
QCOMPARE(rec.field("T_NUMBER").length(), 10);
QCOMPARE(rec.field("T_NUMBER").precision(), 5);
QSqlQuery q(db);
- QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtestfields", __FILE__, db)));
+ QVERIFY_SQL(q, exec("SELECT * FROM " + tableName));
rec = q.record();
QCOMPARE(rec.field("T_NUMBER").length(), 10);
QCOMPARE(rec.field("T_NUMBER").precision(), 5);
@@ -831,14 +838,15 @@ void tst_QSqlDatabase::recordPSQL()
QSqlQuery q(db);
- if(tst_Databases::isPostgreSQL(db))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
-
- q.exec("drop sequence " + qTableName("qtestfields", __FILE__, db) + "_t_bigserial_seq");
- q.exec("drop sequence " + qTableName("qtestfields", __FILE__, db) + "_t_serial_seq");
+ const QString tableName = qTableName("qtestfields", __FILE__, db);
+ q.exec("drop sequence " + tableName + "_t_bigserial_seq");
+ q.exec("drop sequence " + tableName + "_t_serial_seq");
// older psql cut off the table name
- q.exec("drop sequence " + qTableName("qtestfields", __FILE__, db).left(15) + "_t_bigserial_seq");
- q.exec("drop sequence " + qTableName("qtestfields", __FILE__, db).left(18) + "_t_serial_seq");
+ q.exec("drop sequence " + tableName + "_t_bigserial_seq");
+ q.exec("drop sequence " + tableName + "_t_serial_seq");
const int fieldCount = createFieldTable(fieldDefs, db);
QVERIFY(fieldCount > 0);
@@ -1017,7 +1025,8 @@ void tst_QSqlDatabase::recordSQLServer()
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- if (!tst_Databases::isSqlServer(db))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType != QSqlDriverPrivate::MSSqlServer)
QSKIP("SQL server specific test");
// ### TODO: Add the rest of the fields
@@ -1075,6 +1084,7 @@ void tst_QSqlDatabase::transaction()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
const QString qtest(qTableName("qtest", __FILE__, db));
if (!db.driver()->hasFeature(QSqlDriver::Transactions))
@@ -1105,15 +1115,13 @@ void tst_QSqlDatabase::transaction()
QCOMPARE(q.value(0).toInt(), 41);
q.clear(); // for SQLite which does not allow any references on rows that shall be rolled back
if (!db.rollback()) {
- if (db.driverName().startsWith("QMYSQL"))
+ if (dbType == QSqlDriverPrivate::MySqlServer)
QSKIP("MySQL transaction failed: " + tst_Databases::printError(db.lastError()));
else
QFAIL("Could not rollback transaction: " + tst_Databases::printError(db.lastError()));
}
QVERIFY_SQL(q, exec("select * from " + qtest + " where id = 41"));
- if(db.driverName().startsWith("QODBC") && dbName.contains("MySQL"))
- QEXPECT_FAIL("", "Some odbc drivers don't actually roll back despite telling us they do, especially the mysql driver", Continue);
QVERIFY(!q.next());
populateTestTables(db);
@@ -1124,23 +1132,24 @@ void tst_QSqlDatabase::bigIntField()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- QString drvName = db.driverName();
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
const QString qtest_bigint(qTableName("qtest_bigint", __FILE__, db));
QSqlQuery q(db);
q.setForwardOnly(true);
- if (drvName.startsWith("QOCI"))
+
+ if (dbType == QSqlDriverPrivate::Oracle)
q.setNumericalPrecisionPolicy(QSql::LowPrecisionInt64);
- if (drvName.startsWith("QMYSQL")) {
+ if (dbType == QSqlDriverPrivate::MySqlServer) {
QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit bigint, t_u64bit bigint unsigned)"));
- } else if (drvName.startsWith("QPSQL")
- || drvName.startsWith("QDB2")
- || tst_Databases::isSqlServer(db)) {
+ } else if (dbType == QSqlDriverPrivate::PostgreSQL
+ || dbType == QSqlDriverPrivate::DB2
+ || dbType == QSqlDriverPrivate::MSSqlServer) {
QVERIFY_SQL(q, exec("create table " + qtest_bigint + "(id int, t_s64bit bigint, t_u64bit bigint)"));
- } else if (drvName.startsWith("QOCI")) {
+ } else if (dbType == QSqlDriverPrivate::Oracle) {
QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit int, t_u64bit int)"));
- //} else if (drvName.startsWith("QIBASE")) {
+ //} else if (dbType == QSqlDriverPrivate::Interbase) {
// QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit int64, t_u64bit int64)"));
} else {
QSKIP("no 64 bit integer support");
@@ -1149,7 +1158,7 @@ void tst_QSqlDatabase::bigIntField()
qlonglong ll = Q_INT64_C(9223372036854775807);
qulonglong ull = Q_UINT64_C(18446744073709551615);
- if (drvName.startsWith("QMYSQL") || drvName.startsWith("QOCI")) {
+ if (dbType == QSqlDriverPrivate::MySqlServer || dbType == QSqlDriverPrivate::Oracle) {
q.bindValue(0, 0);
q.bindValue(1, ll);
q.bindValue(2, ull);
@@ -1173,12 +1182,12 @@ void tst_QSqlDatabase::bigIntField()
QVERIFY(q.next());
QCOMPARE(q.value(1).toDouble(), (double)ll);
QCOMPARE(q.value(1).toLongLong(), ll);
- if(drvName.startsWith("QOCI"))
+ if (dbType == QSqlDriverPrivate::Oracle)
QEXPECT_FAIL("", "Oracle driver lacks support for unsigned int64 types", Continue);
QCOMPARE(q.value(2).toULongLong(), ull);
QVERIFY(q.next());
QCOMPARE(q.value(1).toLongLong(), -ll);
- if(drvName.startsWith("QOCI"))
+ if (dbType == QSqlDriverPrivate::Oracle)
QEXPECT_FAIL("", "Oracle driver lacks support for unsigned int64 types", Continue);
QCOMPARE(q.value(2).toULongLong(), ull);
}
@@ -1188,12 +1197,11 @@ void tst_QSqlDatabase::caseSensivity()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
bool cs = false;
- if (db.driverName().startsWith("QMYSQL")
- || db.driverName().startsWith("QSQLITE")
- || db.driverName().startsWith("QTDS")
- || db.driverName().startsWith("QODBC"))
+ if (dbType == QSqlDriverPrivate::MySqlServer || dbType == QSqlDriverPrivate::SQLite || dbType == QSqlDriverPrivate::Sybase
+ || dbType == QSqlDriverPrivate::MSSqlServer || db.driverName().startsWith("QODBC"))
cs = true;
QSqlRecord rec = db.record(qTableName("qtest", __FILE__, db));
@@ -1222,7 +1230,8 @@ void tst_QSqlDatabase::noEscapedFieldNamesInRecord()
CHECK_DATABASE(db);
QString fieldname("t_varchar");
- if (db.driverName().startsWith("QOCI") || db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QDB2"))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::DB2)
fieldname = fieldname.toUpper();
QSqlQuery q(db);
@@ -1241,14 +1250,12 @@ void tst_QSqlDatabase::psql_schemas()
QSKIP("server does not support schemas");
QSqlQuery q(db);
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
- if(tst_Databases::isPostgreSQL(db)) {
- QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
- }
+ const QString schemaName = qTableName("qtestschema", __FILE__, db);
+ QVERIFY_SQL(q, exec("CREATE SCHEMA " + schemaName));
- QVERIFY_SQL(q, exec("CREATE SCHEMA " + qTableName("qtestschema", __FILE__, db)));
-
- QString table = qTableName("qtestschema", __FILE__, db) + '.' + qTableName("qtesttable", __FILE__, db);
+ QString table = schemaName + '.' + qTableName("qtesttable", __FILE__, db);
QVERIFY_SQL(q, exec("CREATE TABLE " + table + " (id int primary key, name varchar(20))"));
QVERIFY(db.tables().contains(table));
@@ -1274,9 +1281,7 @@ void tst_QSqlDatabase::psql_escapedIdentifiers()
QSKIP("server does not support schemas");
QSqlQuery q(db);
-
- if(tst_Databases::isPostgreSQL(db))
- QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
const QString schemaName(qTableName("qtestScHeMa", __FILE__, db)),
tableName(qTableName("qtest", __FILE__, db)),
@@ -1339,7 +1344,7 @@ void tst_QSqlDatabase::psql_escapeBytea()
QCOMPARE(i, 4);
}
-void tst_QSqlDatabase::bug_249059()
+void tst_QSqlDatabase::psql_bug249059()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
@@ -1408,7 +1413,8 @@ void tst_QSqlDatabase::precisionPolicy()
QString query = QString("SELECT num FROM %1 WHERE id = 1").arg(tableName);
QVERIFY_SQL(q, exec(query));
QVERIFY_SQL(q, next());
- if(db.driverName().startsWith("QSQLITE"))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::SQLite)
QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue);
QCOMPARE(q.value(0).type(), QVariant::String);
@@ -1423,7 +1429,7 @@ void tst_QSqlDatabase::precisionPolicy()
q.setNumericalPrecisionPolicy(QSql::LowPrecisionInt32);
QVERIFY_SQL(q, exec(query));
QVERIFY_SQL(q, next());
- if(db.driverName().startsWith("QSQLITE"))
+ if (dbType == QSqlDriverPrivate::SQLite)
QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue);
QCOMPARE(q.value(0).type(), QVariant::Int);
QCOMPARE(q.value(0).toInt(), 123);
@@ -1431,7 +1437,7 @@ void tst_QSqlDatabase::precisionPolicy()
q.setNumericalPrecisionPolicy(QSql::LowPrecisionDouble);
QVERIFY_SQL(q, exec(query));
QVERIFY_SQL(q, next());
- if(db.driverName().startsWith("QSQLITE"))
+ if (dbType == QSqlDriverPrivate::SQLite)
QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue);
QCOMPARE(q.value(0).type(), QVariant::Double);
QCOMPARE(q.value(0).toDouble(), (double)123);
@@ -1439,7 +1445,7 @@ void tst_QSqlDatabase::precisionPolicy()
query = QString("SELECT num FROM %1 WHERE id = 2").arg(tableName);
QVERIFY_SQL(q, exec(query));
QVERIFY_SQL(q, next());
- if(db.driverName().startsWith("QSQLITE"))
+ if (dbType == QSqlDriverPrivate::SQLite)
QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue);
QCOMPARE(q.value(0).type(), QVariant::Double);
QCOMPARE(q.value(0).toDouble(), QString("1850000000000.0001").toDouble());
@@ -1448,7 +1454,7 @@ void tst_QSqlDatabase::precisionPolicy()
q.setNumericalPrecisionPolicy(QSql::HighPrecision);
QVERIFY_SQL(q, exec(query));
QVERIFY_SQL(q, next());
- if(db.driverName().startsWith("QSQLITE"))
+ if (dbType == QSqlDriverPrivate::SQLite)
QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue);
QCOMPARE(q.value(0).type(), QVariant::String);
@@ -1475,7 +1481,7 @@ void tst_QSqlDatabase::mysqlOdbc_unsignedIntegers()
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- if (!db.driverName().startsWith("QODBC") || !dbName.toUpper().contains("MYSQL"))
+ if (tst_Databases::getDatabaseType(db) != QSqlDriverPrivate::MySqlServer || !db.driverName().startsWith("QODBC"))
QSKIP("MySQL through ODBC-driver specific test");
QSqlQuery q(db);
@@ -1659,9 +1665,6 @@ void tst_QSqlDatabase::ibase_procWithReturnValues()
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- if (!db.driverName().startsWith("QIBASE"))
- QSKIP("InterBase specific test");
-
const QString procName(qTableName("qtest_proc2", __FILE__, db));
QSqlQuery q(db);
@@ -1703,12 +1706,12 @@ void tst_QSqlDatabase::formatValueTrimStrings()
CHECK_DATABASE(db);
QSqlQuery q(db);
+ const QString tableName = qTableName("qtest", __FILE__, db);
+ QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (50, 'Trim Test ', 'Trim Test 2 ')").arg(tableName)));
+ QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (51, 'TrimTest', 'Trim Test 2')").arg(tableName)));
+ QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (52, ' ', ' ')").arg(tableName)));
- QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (50, 'Trim Test ', 'Trim Test 2 ')").arg(qTableName("qtest", __FILE__, db))));
- QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (51, 'TrimTest', 'Trim Test 2')").arg(qTableName("qtest", __FILE__, db))));
- QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (52, ' ', ' ')").arg(qTableName("qtest", __FILE__, db))));
-
- QVERIFY_SQL(q, exec(QString("SELECT t_varchar, t_char FROM %1 WHERE id >= 50 AND id <= 52 ORDER BY id").arg(qTableName("qtest", __FILE__, db))));
+ QVERIFY_SQL(q, exec(QString("SELECT t_varchar, t_char FROM %1 WHERE id >= 50 AND id <= 52 ORDER BY id").arg(tableName)));
QVERIFY_SQL(q, next());
@@ -1729,13 +1732,14 @@ void tst_QSqlDatabase::odbc_reopenDatabase()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
+ const QString tableName = qTableName("qtest", __FILE__, db);
CHECK_DATABASE(db);
QSqlQuery q(db);
- QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest", __FILE__, db)));
+ QVERIFY_SQL(q, exec("SELECT * from " + tableName));
QVERIFY_SQL(q, next());
db.open();
- QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest", __FILE__, db)));
+ QVERIFY_SQL(q, exec("SELECT * from " + tableName));
QVERIFY_SQL(q, next());
db.open();
}
@@ -1746,14 +1750,16 @@ void tst_QSqlDatabase::odbc_bindBoolean()
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- if (tst_Databases::isMySQL(db))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::MySqlServer)
QSKIP("MySql has inconsistent behaviour of bit field type across versions.");
QSqlQuery q(db);
- QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("qtestBindBool", __FILE__, db) + "(id int, boolvalue bit)"));
+ const QString tableName = qTableName("qtestBindBool", __FILE__, db);
+ QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + "(id int, boolvalue bit)"));
// Bind and insert
- QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("qtestBindBool", __FILE__, db) + " VALUES(?, ?)"));
+ QVERIFY_SQL(q, prepare("INSERT INTO " + tableName + " VALUES(?, ?)"));
q.bindValue(0, 1);
q.bindValue(1, true);
QVERIFY_SQL(q, exec());
@@ -1762,7 +1768,7 @@ void tst_QSqlDatabase::odbc_bindBoolean()
QVERIFY_SQL(q, exec());
// Retrive
- QVERIFY_SQL(q, exec("SELECT id, boolvalue FROM " + qTableName("qtestBindBool", __FILE__, db) + " ORDER BY id"));
+ QVERIFY_SQL(q, exec("SELECT id, boolvalue FROM " + tableName + " ORDER BY id"));
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).toInt(), 1);
QCOMPARE(q.value(1).toBool(), true);
@@ -1779,7 +1785,8 @@ void tst_QSqlDatabase::odbc_testqGetString()
const QString testqGetString(qTableName("testqGetString", __FILE__, db));
QSqlQuery q(db);
- if (tst_Databases::isSqlServer(db))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::MSSqlServer)
QVERIFY_SQL(q, exec("CREATE TABLE " + testqGetString + "(id int, vcvalue varchar(MAX))"));
else if(tst_Databases::isMSAccess(db))
QVERIFY_SQL(q, exec("CREATE TABLE " + testqGetString + "(id int, vcvalue memo)"));
@@ -1958,7 +1965,8 @@ void tst_QSqlDatabase::odbc_uniqueidentifier()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- if (!tst_Databases::isSqlServer(db))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType != QSqlDriverPrivate::MSSqlServer)
QSKIP("SQL Server (ODBC) specific test");
const QString tableName(qTableName("qtest_sqlguid", __FILE__, db));
@@ -2183,7 +2191,7 @@ void tst_QSqlDatabase::mysql_savepointtest()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 1 ).toDouble()<4.1 )
+ if (tst_Databases::getMySqlVersion(db).section(QChar('.'), 0, 1).toDouble() < 4.1)
QSKIP( "Test requires MySQL >= 4.1");
QSqlQuery q(db);
diff --git a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp
index 3500e26f5e..53e5451e06 100644
--- a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp
+++ b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp
@@ -79,7 +79,8 @@ void tst_QSqlDriver::recreateTestTables(QSqlDatabase db)
QSqlQuery q(db);
const QString relTEST1(qTableName("relTEST1", __FILE__, db));
- if(tst_Databases::isPostgreSQL(db))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
tst_Databases::safeDropTable( db, relTEST1 );
@@ -129,23 +130,24 @@ void tst_QSqlDriver::record()
QSqlRecord rec = db.driver()->record(tablename);
QCOMPARE(rec.count(), 4);
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
// QTBUG-1363: QSqlField::length() always return -1 when using QODBC3 driver and QSqlDatabase::record()
- if (db.driverName().startsWith("QODBC") && tst_Databases::isSqlServer(db))
+ if (dbType == QSqlDriverPrivate::MSSqlServer && db.driverName().startsWith("QODBC"))
QCOMPARE(rec.field(1).length(), 20);
- if (db.driverName().startsWith("QIBASE")|| db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2)
for(int i = 0; i < fields.count(); ++i)
fields[i] = fields[i].toUpper();
for (int i = 0; i < fields.count(); ++i)
QCOMPARE(rec.fieldName(i), fields[i]);
- if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2)
tablename = tablename.toUpper();
- else if (db.driverName().startsWith("QPSQL"))
+ else if (dbType == QSqlDriverPrivate::PostgreSQL)
tablename = tablename.toLower();
- if(!db.driverName().startsWith("QODBC") && !db.databaseName().contains("PostgreSql")) {
+ if (dbType != QSqlDriverPrivate::PostgreSQL && !db.driverName().startsWith("QODBC")) {
//check we can get records using a properly quoted table name
rec = db.driver()->record(db.driver()->escapeIdentifier(tablename,QSqlDriver::TableName));
QCOMPARE(rec.count(), 4);
@@ -154,18 +156,15 @@ void tst_QSqlDriver::record()
for (int i = 0; i < fields.count(); ++i)
QCOMPARE(rec.fieldName(i), fields[i]);
- if( db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2)
tablename = tablename.toLower();
- else if (db.driverName().startsWith("QPSQL"))
+ else if (dbType == QSqlDriverPrivate::PostgreSQL)
tablename = tablename.toUpper();
//check that we can't get records using incorrect tablename casing that's been quoted
rec = db.driver()->record(db.driver()->escapeIdentifier(tablename,QSqlDriver::TableName));
- if (tst_Databases::isMySQL(db)
- || db.driverName().startsWith("QSQLITE")
- || db.driverName().startsWith("QTDS")
- || tst_Databases::isSqlServer(db)
- || tst_Databases::isMSAccess(db))
+ if (dbType == QSqlDriverPrivate::MySqlServer || dbType == QSqlDriverPrivate::SQLite || dbType == QSqlDriverPrivate::Sybase
+ || dbType == QSqlDriverPrivate::MSSqlServer || tst_Databases::isMSAccess(db))
QCOMPARE(rec.count(), 4); //mysql, sqlite and tds will match
else
QCOMPARE(rec.count(), 0);
@@ -183,23 +182,24 @@ void tst_QSqlDriver::primaryIndex()
QSqlIndex index = db.driver()->primaryIndex(tablename);
QCOMPARE(index.count(), 1);
- if( db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2)
QCOMPARE(index.fieldName(0), QString::fromLatin1("ID"));
else
QCOMPARE(index.fieldName(0), QString::fromLatin1("id"));
//check that we can get the primary index using a quoted tablename
- if( db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2)
tablename = tablename.toUpper();
- else if (db.driverName().startsWith("QPSQL"))
+ else if (dbType == QSqlDriverPrivate::PostgreSQL)
tablename = tablename.toLower();
- if(!db.driverName().startsWith("QODBC") && !db.databaseName().contains("PostgreSql")) {
+ if (dbType != QSqlDriverPrivate::PostgreSQL && !db.driverName().startsWith("QODBC")) {
index = db.driver()->primaryIndex(db.driver()->escapeIdentifier(tablename, QSqlDriver::TableName));
QCOMPARE(index.count(), 1);
}
- if( db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2)
QCOMPARE(index.fieldName(0), QString::fromLatin1("ID"));
else
QCOMPARE(index.fieldName(0), QString::fromLatin1("id"));
@@ -207,17 +207,14 @@ void tst_QSqlDriver::primaryIndex()
//check that we can not get the primary index using a quoted but incorrect table name casing
- if( db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2)
tablename = tablename.toLower();
- else if (db.driverName().startsWith("QPSQL"))
+ else if (dbType == QSqlDriverPrivate::PostgreSQL)
tablename = tablename.toUpper();
index = db.driver()->primaryIndex(db.driver()->escapeIdentifier(tablename, QSqlDriver::TableName));
- if (tst_Databases::isMySQL(db)
- || db.driverName().startsWith("QSQLITE")
- || db.driverName().startsWith("QTDS")
- || tst_Databases::isSqlServer(db)
- || tst_Databases::isMSAccess(db))
+ if (dbType == QSqlDriverPrivate::MySqlServer || dbType == QSqlDriverPrivate::SQLite || dbType == QSqlDriverPrivate::Sybase
+ || dbType == QSqlDriverPrivate::MSSqlServer || tst_Databases::isMSAccess(db))
QCOMPARE(index.count(), 1); //mysql will always find the table name regardless of casing
else
QCOMPARE(index.count(), 0);
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index ff458d6f2b..1a100ce706 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -97,7 +97,7 @@ private slots:
void record_sqlite();
void finish_data() { generic_data(); }
void finish();
- void sqlite_finish_data() { generic_data(); }
+ void sqlite_finish_data() { generic_data("QSQLITE"); }
void sqlite_finish();
void nextResult_data() { generic_data(); }
void nextResult();
@@ -107,14 +107,14 @@ private slots:
void forwardOnly();
// bug specific tests
- void bitField_data() {generic_data("QTDS"); }
- void bitField();
- void nullBlob_data() { generic_data("QOCI"); }
- void nullBlob();
+ void tds_bitField_data() { generic_data("QTDS"); }
+ void tds_bitField();
+ void oci_nullBlob_data() { generic_data("QOCI"); }
+ void oci_nullBlob();
void blob_data() { generic_data(); }
void blob();
- void rawField_data() { generic_data("QOCI"); }
- void rawField();
+ void oci_rawField_data() { generic_data("QOCI"); }
+ void oci_rawField();
void precision_data() { generic_data(); }
void precision();
void nullResult_data() { generic_data(); }
@@ -131,8 +131,8 @@ private slots:
void synonyms();
void oraOutValues_data() { generic_data("QOCI"); }
void oraOutValues();
- void mysqlOutValues_data() { generic_data("QMYSQL"); }
- void mysqlOutValues();
+ void mysql_outValues_data() { generic_data("QMYSQL"); }
+ void mysql_outValues();
void oraClob_data() { generic_data("QOCI"); }
void oraClob();
void oraLong_data() { generic_data("QOCI"); }
@@ -163,8 +163,8 @@ private slots:
void lastQuery();
void bindBool_data() { generic_data(); }
void bindBool();
- void bindWithDoubleColonCastOperator_data() { generic_data(); }
- void bindWithDoubleColonCastOperator();
+ void psql_bindWithDoubleColonCastOperator_data() { generic_data("QPSQL"); }
+ void psql_bindWithDoubleColonCastOperator();
void queryOnInvalidDatabase_data() { generic_data(); }
void queryOnInvalidDatabase();
void createQueryOnClosedDatabase_data() { generic_data(); }
@@ -286,7 +286,7 @@ void tst_QSqlQuery::cleanup()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
-
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
if ( QTest::currentTestFunction() == QLatin1String( "numRowsAffected" )
|| QTest::currentTestFunction() == QLatin1String( "transactions" )
|| QTest::currentTestFunction() == QLatin1String( "size" )
@@ -295,8 +295,7 @@ void tst_QSqlQuery::cleanup()
populateTestTables( db );
}
- if ( QTest::currentTestFailed() && ( db.driverName().startsWith( "QOCI" )
- || db.driverName().startsWith( "QODBC" ) ) ) {
+ if (QTest::currentTestFailed() && (dbType == QSqlDriverPrivate::Oracle || db.driverName().startsWith("QODBC"))) {
//since Oracle ODBC totally craps out on error, we init again
db.close();
db.open();
@@ -315,6 +314,7 @@ void tst_QSqlQuery::generic_data(const QString& engine)
void tst_QSqlQuery::dropTestTables( QSqlDatabase db )
{
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QStringList tablenames;
// drop all the table in case a testcase failed
tablenames << qtest
@@ -351,24 +351,24 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db )
<< qTableName("qtest_oraOCINumber", __FILE__, db)
<< qTableName("bug2192", __FILE__, db);
- if ( db.driverName().startsWith("QPSQL") )
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
tablenames << qTableName("task_233829", __FILE__, db);
- if ( db.driverName().startsWith("QSQLITE") )
+ if (dbType == QSqlDriverPrivate::SQLite)
tablenames << qTableName("record_sqlite", __FILE__, db);
- if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QOCI" ) )
+ if (dbType == QSqlDriverPrivate::MSSqlServer || dbType == QSqlDriverPrivate::Oracle)
tablenames << qTableName("qtest_longstr", __FILE__, db);
- if (tst_Databases::isSqlServer( db ))
+ if (dbType == QSqlDriverPrivate::MSSqlServer)
db.exec("DROP PROCEDURE " + qTableName("test141895_proc", __FILE__, db));
- if (tst_Databases::isMySQL( db ))
- db.exec("DROP PROCEDURE IF EXISTS "+qTableName("bug6852_proc", __FILE__, db));
+ if (dbType == QSqlDriverPrivate::MySqlServer)
+ db.exec("DROP PROCEDURE IF EXISTS "+ qTableName("bug6852_proc", __FILE__, db));
tst_Databases::safeDropTables( db, tablenames );
- if ( db.driverName().startsWith( "QOCI" ) ) {
+ if (dbType == QSqlDriverPrivate::Oracle) {
QSqlQuery q( db );
q.exec("DROP PACKAGE " + qTableName("pkg", __FILE__, db));
}
@@ -377,20 +377,20 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db )
void tst_QSqlQuery::createTestTables( QSqlDatabase db )
{
QSqlQuery q( db );
-
- if ( db.driverName().startsWith( "QMYSQL" ) )
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::MySqlServer)
// ### stupid workaround until we find a way to hardcode this
// in the MySQL server startup script
q.exec( "set table_type=innodb" );
- else if(tst_Databases::isPostgreSQL(db))
+ else if (dbType == QSqlDriverPrivate::PostgreSQL)
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
- if(tst_Databases::isPostgreSQL(db))
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
QVERIFY_SQL( q, exec( "create table " + qtest + " (id serial NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id)) WITH OIDS" ) );
else
QVERIFY_SQL( q, exec( "create table " + qtest + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) );
- if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) )
+ if (dbType == QSqlDriverPrivate::MSSqlServer || dbType == QSqlDriverPrivate::Sybase)
QVERIFY_SQL(q, exec("create table " + qTableName("qtest_null", __FILE__, db) + " (id int null, t_varchar varchar(20) null)"));
else
QVERIFY_SQL(q, exec("create table " + qTableName("qtest_null", __FILE__, db) + " (id int, t_varchar varchar(20))"));
@@ -429,8 +429,8 @@ void tst_QSqlQuery::char1Select()
QVERIFY_SQL(q, exec("insert into " + tbl + " values ('a')"));
QVERIFY_SQL(q, exec("select * from " + tbl));
QVERIFY( q.next() );
-
- if ( db.driverName().startsWith( "QIBASE" ) )
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::Interbase)
QCOMPARE( q.value( 0 ).toString().left( 1 ), QString( "a" ) );
else
QCOMPARE( q.value( 0 ).toString(), QString( "a" ) );
@@ -444,8 +444,8 @@ void tst_QSqlQuery::char1SelectUnicode()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
-
- if(db.driverName().startsWith("QDB2"))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::DB2)
QSKIP("Needs someone with more Unicode knowledge than I have to fix");
if ( db.driver()->hasFeature( QSqlDriver::Unicode ) ) {
@@ -458,16 +458,14 @@ void tst_QSqlQuery::char1SelectUnicode()
QString createQuery;
const QString char1SelectUnicode(qTableName("char1SU", __FILE__, db));
- if ( tst_Databases::isSqlServer( db ) )
+ if (dbType == QSqlDriverPrivate::MSSqlServer)
createQuery = "create table " + char1SelectUnicode + "(id nchar(1))";
- else if ( db.driverName().startsWith( "QDB2" )
- || db.driverName().startsWith( "QOCI" )
- || db.driverName().startsWith( "QPSQL" ) )
+ else if (dbType == QSqlDriverPrivate::DB2 || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::PostgreSQL)
createQuery = "create table " + char1SelectUnicode + " (id char(3))";
- else if ( db.driverName().startsWith( "QIBASE" ) )
+ else if (dbType == QSqlDriverPrivate::Interbase)
createQuery = "create table " + char1SelectUnicode +
" (id char(1) character set unicode_fss)";
- else if ( db.driverName().startsWith( "QMYSQL" ) )
+ else if (dbType == QSqlDriverPrivate::MySqlServer)
createQuery = "create table " + char1SelectUnicode + " (id char(1)) "
"default character set 'utf8'";
else
@@ -531,18 +529,18 @@ void tst_QSqlQuery::oraRowId()
QCOMPARE( q.value( 0 ).toString(), QString( "b" ) );
}
-void tst_QSqlQuery::mysqlOutValues()
+void tst_QSqlQuery::mysql_outValues()
{
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
+ if (tst_Databases::getMySqlVersion(db).section(QChar('.'), 0, 0 ).toInt() < 5)
+ QSKIP( "Test requires MySQL >= 5.0");
+
const QString hello(qTableName("hello", __FILE__, db)), qtestproc(qTableName("qtestproc", __FILE__, db));
QSqlQuery q( db );
- if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 )
- QSKIP( "Test requires MySQL >= 5.0");
-
q.exec( "drop function " + hello );
QVERIFY_SQL(q, exec("create function " + hello + " (s char(20)) returns varchar(50) READS SQL DATA return concat('Hello ', s)"));
@@ -593,10 +591,11 @@ void tst_QSqlQuery::bindBool()
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
QSqlQuery q(db);
-
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
const QString tableName(qTableName("bindBool", __FILE__, db));
+
q.exec("DROP TABLE " + tableName);
- QString colType = db.driverName().startsWith("QPSQL") ? QLatin1String("BOOLEAN") : QLatin1String("INT");
+ QString colType = dbType == QSqlDriverPrivate::PostgreSQL ? QLatin1String("BOOLEAN") : QLatin1String("INT");
QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id INT, flag " + colType + " NOT NULL, PRIMARY KEY(id))"));
for (int i = 0; i < 2; ++i) {
@@ -849,14 +848,14 @@ void tst_QSqlQuery::outValues()
QSqlQuery q( db );
q.setForwardOnly( true );
-
- if ( db.driverName().startsWith( "QOCI" ) ) {
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::Oracle) {
QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x out int) is\n"
"begin\n"
" x := 42;\n"
"end;\n" ) );
QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) );
- } else if ( db.driverName().startsWith( "QDB2" ) ) {
+ } else if (dbType == QSqlDriverPrivate::DB2) {
q.exec( "drop procedure " + tst_outValues ); //non-fatal
QVERIFY_SQL( q, exec( "CREATE PROCEDURE " + tst_outValues + " (OUT x int)\n"
"LANGUAGE SQL\n"
@@ -864,7 +863,7 @@ void tst_QSqlQuery::outValues()
" SET x = 42;\n"
"END P1" ) );
QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) );
- } else if ( tst_Databases::isSqlServer( db ) ) {
+ } else if (dbType == QSqlDriverPrivate::MSSqlServer) {
q.exec( "drop procedure " + tst_outValues ); //non-fatal
QVERIFY_SQL( q, exec( "create procedure " + tst_outValues + " (@x int out) as\n"
"begin\n"
@@ -938,7 +937,7 @@ void tst_QSqlQuery::value()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
-
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QSqlQuery q( db );
QVERIFY_SQL( q, exec( "select id, t_varchar, t_char from " + qtest + " order by id" ) );
int i = 1;
@@ -947,14 +946,14 @@ void tst_QSqlQuery::value()
QCOMPARE( q.value( 0 ).toInt(), i );
QCOMPARE( q.value( "id" ).toInt(), i );
- if ( db.driverName().startsWith( "QIBASE" ) )
+ if (dbType == QSqlDriverPrivate::Interbase)
QVERIFY( q.value( 1 ).toString().startsWith( "VarChar" + QString::number( i ) ) );
else if ( q.value( 1 ).toString().right( 1 ) == " " )
QCOMPARE( q.value( 1 ).toString(), ( "VarChar" + QString::number( i ) + " " ) );
else
QCOMPARE( q.value( 1 ).toString(), ( "VarChar" + QString::number( i ) ) );
- if ( db.driverName().startsWith( "QIBASE" ) )
+ if (dbType == QSqlDriverPrivate::Interbase)
QVERIFY( q.value( 2 ).toString().startsWith( "Char" + QString::number( i ) ) );
else if ( q.value( 2 ).toString().right( 1 ) != " " )
QCOMPARE( q.value( 2 ).toString(), ( "Char" + QString::number( i ) ) );
@@ -1397,24 +1396,21 @@ void tst_QSqlQuery::isNull()
}
/*! TDS specific BIT field test */
-void tst_QSqlQuery::bitField()
+void tst_QSqlQuery::tds_bitField()
{
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
-
- if ( !db.driverName().startsWith( "QTDS" ) )
- QSKIP( "TDS specific test");
-
+ const QString tableName = qTableName("qtest_bittest", __FILE__, db);
QSqlQuery q( db );
- QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bittest", __FILE__, db) + " (bitty bit)"));
+ QVERIFY_SQL(q, exec("create table " + tableName + " (bitty bit)"));
- QVERIFY_SQL(q, exec("insert into " + qTableName("qtest_bittest", __FILE__, db) + " values (0)"));
+ QVERIFY_SQL(q, exec("insert into " + tableName + " values (0)"));
- QVERIFY_SQL(q, exec("insert into " + qTableName("qtest_bittest", __FILE__, db) + " values (1)"));
+ QVERIFY_SQL(q, exec("insert into " + tableName + " values (1)"));
- QVERIFY_SQL(q, exec("select bitty from " + qTableName("qtest_bittest", __FILE__, db)));
+ QVERIFY_SQL(q, exec("select bitty from " + tableName));
QVERIFY( q.next() );
@@ -1427,7 +1423,7 @@ void tst_QSqlQuery::bitField()
/*! Oracle specific NULL BLOB test */
-void tst_QSqlQuery::nullBlob()
+void tst_QSqlQuery::oci_nullBlob()
{
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
@@ -1457,7 +1453,7 @@ void tst_QSqlQuery::nullBlob()
}
/* Oracle specific RAW field test */
-void tst_QSqlQuery::rawField()
+void tst_QSqlQuery::oci_rawField()
{
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
@@ -1487,13 +1483,13 @@ void tst_QSqlQuery::precision()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- const QString qtest_precision(qTableName("qtest_precision", __FILE__, db));
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::Interbase)
+ QSKIP("DB unable to store high precision");
+ const QString qtest_precision(qTableName("qtest_precision", __FILE__, db));
static const char* precStr = "1.2345678901234567891";
- if ( db.driverName().startsWith( "QIBASE" ) )
- QSKIP( "DB unable to store high precision");
-
{
// need a new scope for SQLITE
QSqlQuery q( db );
@@ -1518,10 +1514,10 @@ void tst_QSqlQuery::precision()
i++;
// MySQL and TDS have crappy precisions by default
- if ( db.driverName().startsWith( "QMYSQL" ) ) {
+ if (dbType == QSqlDriverPrivate::MySqlServer) {
if ( i < 17 )
QWARN( "MySQL didn't return the right precision" );
- } else if ( db.driverName().startsWith( "QTDS" ) ) {
+ } else if (dbType == QSqlDriverPrivate::Sybase) {
if ( i < 18 )
QWARN( "TDS didn't return the right precision" );
} else {
@@ -1563,14 +1559,14 @@ void tst_QSqlQuery::transaction()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
-
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
if ( !db.driver()->hasFeature( QSqlDriver::Transactions ) )
QSKIP( "DBMS not transaction capable");
// this is the standard SQL
QString startTransactionStr( "start transaction" );
- if ( db.driverName().startsWith( "QMYSQL" ) )
+ if (dbType == QSqlDriverPrivate::MySqlServer)
startTransactionStr = "begin work";
QSqlQuery q( db );
@@ -1608,7 +1604,7 @@ void tst_QSqlQuery::transaction()
QCOMPARE( q.value( 0 ).toInt(), 41 );
if ( !q.exec( "rollback" ) ) {
- if ( db.driverName().startsWith( "QMYSQL" ) ) {
+ if (dbType == QSqlDriverPrivate::MySqlServer) {
qDebug( "MySQL: %s", qPrintable(tst_Databases::printError( q.lastError() ) ));
QSKIP( "MySQL transaction failed "); //non-fatal
} else
@@ -1646,12 +1642,11 @@ void tst_QSqlQuery::joins()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
const QString qtestj1(qTableName("qtestj1", __FILE__, db)), qtestj2(qTableName("qtestj2", __FILE__, db));
- if ( db.driverName().startsWith( "QOCI" )
- || db.driverName().startsWith( "QTDS" )
- || db.driverName().startsWith( "QODBC" )
- || db.driverName().startsWith( "QIBASE" ) )
+ if (dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::Sybase
+ || dbType == QSqlDriverPrivate::Interbase || db.driverName().startsWith("QODBC"))
// Oracle broken beyond recognition - cannot outer join on more than
// one table.
QSKIP( "DBMS cannot understand standard SQL");
@@ -1731,11 +1726,12 @@ void tst_QSqlQuery::prepare_bind_exec()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
const QString qtest_prepare(qTableName("qtest_prepare", __FILE__, db));
- if(db.driverName().startsWith("QIBASE") && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb"))
+ if (dbType == QSqlDriverPrivate::Interbase && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb"))
QSKIP("Can't transliterate extended unicode to ascii");
- if(db.driverName().startsWith("QDB2"))
+ if (dbType == QSqlDriverPrivate::DB2)
QSKIP("Needs someone with more Unicode knowledge than I have to fix");
{
@@ -1752,13 +1748,13 @@ void tst_QSqlQuery::prepare_bind_exec()
useUnicode = false;
QString createQuery;
-
- if(tst_Databases::isPostgreSQL(db))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
- if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) )
+ if (dbType == QSqlDriverPrivate::MSSqlServer || dbType == QSqlDriverPrivate::Sybase)
createQuery = "create table " + qtest_prepare + " (id int primary key, name nvarchar(200) null, name2 nvarchar(200) null)";
- else if ( tst_Databases::isMySQL(db) && useUnicode )
+ else if (dbType == QSqlDriverPrivate::MySqlServer && useUnicode)
createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200) character set utf8, name2 varchar(200) character set utf8)";
else
createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200), name2 varchar(200))";
@@ -2026,7 +2022,8 @@ void tst_QSqlQuery::sqlServerLongStrings()
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- if ( !tst_Databases::isSqlServer( db ) )
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType != QSqlDriverPrivate::MSSqlServer)
QSKIP( "SQL Server specific test");
QSqlQuery q( db );
@@ -2071,7 +2068,7 @@ void tst_QSqlQuery::invalidQuery()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
-
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QSqlQuery q( db );
QVERIFY( !q.exec() );
@@ -2081,7 +2078,7 @@ void tst_QSqlQuery::invalidQuery()
QVERIFY( !q.next() );
QVERIFY( !q.isActive() );
- if ( !db.driverName().startsWith( "QOCI" ) && !db.driverName().startsWith( "QDB2" ) && !db.driverName().startsWith( "QODBC" ) ) {
+ if (dbType != QSqlDriverPrivate::Oracle && dbType != QSqlDriverPrivate::DB2 && !db.driverName().startsWith("QODBC")) {
// oracle and db2 just prepares everything without complaining
if ( db.driver()->hasFeature( QSqlDriver::PreparedQueries ) )
QVERIFY( !q.prepare( "blahfasel" ) );
@@ -2343,17 +2340,12 @@ void tst_QSqlQuery::lastQuery()
QCOMPARE( q.executedQuery(), sql );
}
-void tst_QSqlQuery::bindWithDoubleColonCastOperator()
+void tst_QSqlQuery::psql_bindWithDoubleColonCastOperator()
{
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- // Only PostgreSQL support the double-colon cast operator
-
- if ( !db.driverName().startsWith( "QPSQL" ) )
- QSKIP( "Test requires PostgreSQL");
-
const QString tablename(qTableName("bindtest", __FILE__, db));
QSqlQuery q( db );
@@ -2413,13 +2405,11 @@ void tst_QSqlQuery::createQueryOnClosedDatabase()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
-
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
// Only supported by these drivers
- if ( !db.driverName().startsWith( "QPSQL" )
- && !db.driverName().startsWith( "QOCI" )
- && !db.driverName().startsWith( "QMYSQL" )
- && !db.driverName().startsWith( "QDB2" ) )
+ if (dbType != QSqlDriverPrivate::PostgreSQL && dbType != QSqlDriverPrivate::Oracle
+ && dbType != QSqlDriverPrivate::MySqlServer && dbType != QSqlDriverPrivate::DB2)
QSKIP( "Test is specific for PostgreSQL, Oracle, MySql and DB2");
db.close();
@@ -2505,8 +2495,6 @@ void tst_QSqlQuery::sqlite_finish()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- if (db.driverName() != QLatin1String("QSQLITE"))
- QSKIP("Sqlite3 specific test");
if ( db.databaseName().startsWith( ':' ) )
QSKIP( "This test requires a database on the filesystem, not in-memory");
@@ -2549,7 +2537,7 @@ void tst_QSqlQuery::nextResult()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
-
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
if ( !db.driver()->hasFeature( QSqlDriver::MultipleResultSets ) || !db.driver()->hasFeature( QSqlDriver::BatchOperations ) )
QSKIP( "DBMS does not support multiple result sets or batch operations");
@@ -2558,14 +2546,6 @@ void tst_QSqlQuery::nextResult()
if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 )
QSKIP( "Test requires MySQL >= 5.0");
- enum DriverType { ODBC, MYSQL, DB2 };
- DriverType driverType = ODBC;
-
- if ( db.driverName().startsWith( "QMYSQL" ) )
- driverType = MYSQL;
- else if ( db.driverName().startsWith( "QDB2" ) )
- driverType = DB2;
-
const QString tableName(qTableName("more_results", __FILE__, db));
QVERIFY_SQL( q, exec( "CREATE TABLE " + tableName + " (id integer, text varchar(20), num numeric(6, 3), empty varchar(10));" ) );
@@ -2597,7 +2577,7 @@ void tst_QSqlQuery::nextResult()
// Query that returns two result sets (batch sql)
// When working with multiple result sets SQL Server insists on non-scrollable cursors
- if ( driverType == ODBC )
+ if (db.driverName().startsWith("QODBC"))
q.setForwardOnly( true );
QVERIFY_SQL( q, exec( "SELECT id FROM " + tableName + "; SELECT text, num FROM " + tableName + ';' ) );
@@ -2618,7 +2598,7 @@ void tst_QSqlQuery::nextResult()
QCOMPARE( q.record().field( 1 ).name().toUpper(), QString( "NUM" ) );
- if ( driverType == MYSQL )
+ if (dbType == QSqlDriverPrivate::MySqlServer)
QCOMPARE( q.record().field( 1 ).type(), QVariant::String );
else
QCOMPARE( q.record().field( 1 ).type(), QVariant::Double );
@@ -2674,13 +2654,13 @@ void tst_QSqlQuery::nextResult()
q.exec( QString( "DROP PROCEDURE %1;" ).arg( procName ) );
- if ( driverType == MYSQL )
+ if (dbType == QSqlDriverPrivate::MySqlServer)
QVERIFY_SQL( q, exec( QString( "CREATE PROCEDURE %1()"
"\nBEGIN"
"\nSELECT id, text FROM %2;"
"\nSELECT empty, num, text, id FROM %3;"
"\nEND" ).arg( procName ).arg( tableName ).arg( tableName ) ) );
- else if ( driverType == DB2 )
+ else if (dbType == QSqlDriverPrivate::DB2)
QVERIFY_SQL( q, exec( QString( "CREATE PROCEDURE %1()"
"\nRESULT SETS 2"
"\nLANGUAGE SQL"
@@ -2696,7 +2676,7 @@ void tst_QSqlQuery::nextResult()
"\nSELECT id, text FROM %2"
"\nSELECT empty, num, text, id FROM %3" ).arg( procName ).arg( tableName ).arg( tableName ) ) );
- if ( driverType == MYSQL || driverType == DB2 ) {
+ if (dbType == QSqlDriverPrivate::MySqlServer || dbType == QSqlDriverPrivate::DB2) {
q.setForwardOnly( true );
QVERIFY_SQL( q, exec( QString( "CALL %1()" ).arg( procName ) ) );
} else {
@@ -2722,7 +2702,7 @@ void tst_QSqlQuery::nextResult()
}
// MySQL also counts the CALL itself as a result
- if ( driverType == MYSQL ) {
+ if (dbType == QSqlDriverPrivate::MySqlServer) {
QVERIFY( q.nextResult() );
QVERIFY( !q.isSelect() ); // ... but it's not a select
QCOMPARE( q.numRowsAffected(), 0 ); // ... and no rows are affected (at least not with this procedure)
@@ -2757,10 +2737,11 @@ void tst_QSqlQuery::blobsPreparedQuery()
// In PostgreSQL a BLOB is not called a BLOB, but a BYTEA! :-)
// ... and in SQL Server it can be called a lot, but IMAGE will do.
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QString typeName( "BLOB" );
- if ( db.driverName().startsWith( "QPSQL" ) )
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
typeName = "BYTEA";
- else if ( db.driverName().startsWith( "QODBC" ) && tst_Databases::isSqlServer( db ))
+ else if (dbType == QSqlDriverPrivate::MSSqlServer)
typeName = "IMAGE";
QVERIFY_SQL( q, exec( QString( "CREATE TABLE %1(id INTEGER, data %2)" ).arg( tableName ).arg( typeName ) ) );
@@ -2994,7 +2975,8 @@ void tst_QSqlQuery::sqlServerReturn0()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- if (!tst_Databases::isSqlServer( db ))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType != QSqlDriverPrivate::MSSqlServer)
QSKIP("SQL Server specific test");
const QString tableName(qTableName("test141895", __FILE__, db)), procName(qTableName("test141895_proc", __FILE__, db));
@@ -3088,9 +3070,9 @@ void tst_QSqlQuery::QTBUG_18435()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
-
- if (!db.driverName().startsWith("QODBC") || !tst_Databases::isSqlServer(db))
- return;
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType != QSqlDriverPrivate::MSSqlServer || !db.driverName().startsWith("QODBC"))
+ QSKIP("SQL Server specific test");
QSqlQuery q(db);
QString procName(qTableName("qtbug_18435_proc", __FILE__, db));
@@ -3120,8 +3102,6 @@ void tst_QSqlQuery::QTBUG_5251()
CHECK_DATABASE( db );
const QString timetest(qTableName("timetest", __FILE__, db));
- if (!db.driverName().startsWith( "QPSQL" )) return;
-
QSqlQuery q(db);
q.exec("DROP TABLE " + timetest);
QVERIFY_SQL(q, exec("CREATE TABLE " + timetest + " (t TIME)"));
@@ -3172,7 +3152,8 @@ void tst_QSqlQuery::QTBUG_6618()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- if (!tst_Databases::isSqlServer( db ))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType != QSqlDriverPrivate::MSSqlServer)
QSKIP("SQL Server specific test");
QSqlQuery q(db);
@@ -3588,7 +3569,8 @@ void tst_QSqlQuery::sqlite_constraint()
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- if (db.driverName() != QLatin1String("QSQLITE"))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType != QSqlDriverPrivate::SQLite)
QSKIP("Sqlite3 specific test");
QSqlQuery q(db);
@@ -3639,9 +3621,10 @@ void tst_QSqlQuery::aggregateFunctionTypes()
CHECK_DATABASE(db);
QVariant::Type intType = QVariant::Int;
// QPSQL uses LongLong for manipulation of integers
- if (db.driverName().startsWith("QPSQL") || db.driverName().startsWith("QMYSQL"))
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::MySqlServer || dbType == QSqlDriverPrivate::PostgreSQL)
intType = QVariant::LongLong;
- else if (db.driverName().startsWith("QOCI"))
+ else if (dbType == QSqlDriverPrivate::Oracle)
intType = QVariant::Double;
{
const QString tableName(qTableName("numericFunctionsWithIntValues", __FILE__, db));
@@ -3653,9 +3636,9 @@ void tst_QSqlQuery::aggregateFunctionTypes()
// First test without any entries
QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName));
QVERIFY(q.next());
- if (db.driverName().startsWith("QSQLITE"))
+ if (dbType == QSqlDriverPrivate::SQLite)
QCOMPARE(q.record().field(0).type(), QVariant::Invalid);
- else if (db.driverName().startsWith("QMYSQL"))
+ else if (dbType == QSqlDriverPrivate::MySqlServer)
QCOMPARE(q.record().field(0).type(), QVariant::Double);
else
QCOMPARE(q.record().field(0).type(), intType);
@@ -3666,15 +3649,15 @@ void tst_QSqlQuery::aggregateFunctionTypes()
QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName));
QVERIFY(q.next());
QCOMPARE(q.value(0).toInt(), 3);
- if (db.driverName().startsWith("QMYSQL"))
+ if (dbType == QSqlDriverPrivate::MySqlServer)
QCOMPARE(q.record().field(0).type(), QVariant::Double);
else
QCOMPARE(q.record().field(0).type(), intType);
QVERIFY_SQL(q, exec("SELECT AVG(id) FROM " + tableName));
QVERIFY(q.next());
- if (db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QPSQL")
- || db.driverName().startsWith("QMYSQL") || db.driverName().startsWith("QOCI")) {
+ if (dbType == QSqlDriverPrivate::SQLite || dbType == QSqlDriverPrivate::PostgreSQL || dbType == QSqlDriverPrivate::MySqlServer
+ || dbType == QSqlDriverPrivate::Oracle) {
QCOMPARE(q.value(0).toDouble(), 1.5);
QCOMPARE(q.record().field(0).type(), QVariant::Double);
} else {
@@ -3707,7 +3690,7 @@ void tst_QSqlQuery::aggregateFunctionTypes()
// First test without any entries
QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName));
QVERIFY(q.next());
- if (db.driverName().startsWith("QSQLITE"))
+ if (dbType == QSqlDriverPrivate::SQLite)
QCOMPARE(q.record().field(0).type(), QVariant::Invalid);
else
QCOMPARE(q.record().field(0).type(), QVariant::Double);
@@ -3741,7 +3724,7 @@ void tst_QSqlQuery::aggregateFunctionTypes()
QCOMPARE(q.record().field(0).type(), QVariant::Double);
// PSQL does not have support for the round() function
- if (!db.driverName().startsWith("QPSQL")) {
+ if (dbType != QSqlDriverPrivate::PostgreSQL) {
QVERIFY_SQL(q, exec("SELECT ROUND(id, 1) FROM " + tableName + " WHERE id=1.5"));
QVERIFY(q.next());
QCOMPARE(q.value(0).toDouble(), 1.5);
@@ -3749,7 +3732,7 @@ void tst_QSqlQuery::aggregateFunctionTypes()
QVERIFY_SQL(q, exec("SELECT ROUND(id, 0) FROM " + tableName + " WHERE id=2.5"));
QVERIFY(q.next());
- if (db.driverName().startsWith("QMYSQL"))
+ if (dbType == QSqlDriverPrivate::MySqlServer)
QCOMPARE(q.value(0).toDouble(), 2.0);
else
QCOMPARE(q.value(0).toDouble(), 3.0);
@@ -3765,7 +3748,7 @@ void tst_QSqlQuery::aggregateFunctionTypes()
QVERIFY_SQL(q, exec("SELECT MAX(txt) FROM " + tableName));
QVERIFY(q.next());
- if (db.driverName().startsWith("QSQLITE"))
+ if (dbType == QSqlDriverPrivate::SQLite)
QCOMPARE(q.record().field(0).type(), QVariant::Invalid);
else
QCOMPARE(q.record().field(0).type(), QVariant::String);
diff --git a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
index cb9b4a5c1f..c5eafb37fb 100644
--- a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
+++ b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
@@ -158,7 +158,8 @@ void tst_QSqlQueryModel::createTestTables(QSqlDatabase db)
{
dropTestTables(db);
QSqlQuery q(db);
- if(tst_Databases::isPostgreSQL(db))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
QVERIFY_SQL( q, exec("create table " + qTableName("test", __FILE__, db) + "(id integer not null, name varchar(20), title integer, primary key (id))"));
QVERIFY_SQL( q, exec("create table " + qTableName("test2", __FILE__, db) + "(id integer not null, title varchar(20), primary key (id))"));
@@ -312,12 +313,13 @@ void tst_QSqlQueryModel::insertColumn()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
DBTestModel model;
model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db));
model.fetchMore(); // necessary???
- bool isToUpper = db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2");
+ bool isToUpper = (dbType == QSqlDriverPrivate::Interbase) || (dbType == QSqlDriverPrivate::Oracle) || (dbType == QSqlDriverPrivate::DB2);
const QString idColumn(isToUpper ? "ID" : "id");
const QString nameColumn(isToUpper ? "NAME" : "name");
const QString titleColumn(isToUpper ? "TITLE" : "title");
@@ -415,13 +417,14 @@ void tst_QSqlQueryModel::record()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QSqlQueryModel model;
model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db));
QSqlRecord rec = model.record();
- bool isToUpper = db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2");
+ bool isToUpper = (dbType == QSqlDriverPrivate::Interbase) || (dbType == QSqlDriverPrivate::Oracle) || (dbType == QSqlDriverPrivate::DB2);
QCOMPARE(rec.count(), 3);
QCOMPARE(rec.fieldName(0), isToUpper ? QString("ID") : QString("id"));
@@ -445,6 +448,7 @@ void tst_QSqlQueryModel::setHeaderData()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QSqlQueryModel model;
@@ -465,7 +469,7 @@ void tst_QSqlQueryModel::setHeaderData()
QVERIFY(!model.setHeaderData(7, Qt::Horizontal, "foo", Qt::ToolTipRole));
QVERIFY(!model.headerData(7, Qt::Horizontal, Qt::ToolTipRole).isValid());
- bool isToUpper = db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2");
+ bool isToUpper = (dbType == QSqlDriverPrivate::Interbase) || (dbType == QSqlDriverPrivate::Oracle) || (dbType == QSqlDriverPrivate::DB2);
QCOMPARE(model.headerData(0, Qt::Horizontal).toString(), isToUpper ? QString("ID") : QString("id"));
QCOMPARE(model.headerData(1, Qt::Horizontal).toString(), isToUpper ? QString("NAME") : QString("name"));
QCOMPARE(model.headerData(2, Qt::Horizontal).toString(), QString("bar"));
diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
index b218a0c4f7..37c08e5101 100644
--- a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
+++ b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
@@ -151,14 +151,15 @@ void tst_QSqlRelationalTableModel::initTestCase()
{
foreach (const QString &dbname, dbs.dbNames) {
QSqlDatabase db=QSqlDatabase::database(dbname);
- if (db.driverName().startsWith("QIBASE"))
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::Interbase) {
db.exec("SET DIALECT 3");
- else if (tst_Databases::isSqlServer(db)) {
+ } else if (dbType == QSqlDriverPrivate::MSSqlServer) {
db.exec("SET ANSI_DEFAULTS ON");
db.exec("SET IMPLICIT_TRANSACTIONS OFF");
- }
- else if(tst_Databases::isPostgreSQL(db))
+ } else if (dbType == QSqlDriverPrivate::PostgreSQL) {
db.exec("set client_min_messages='warning'");
+ }
recreateTestTables(db);
}
}
@@ -245,6 +246,7 @@ void tst_QSqlRelationalTableModel::setData()
QFETCH_GLOBAL(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
// set the values using OnRowChange Strategy
{
@@ -327,7 +329,7 @@ void tst_QSqlRelationalTableModel::setData()
//sybase doesn't allow tables with the same alias used twice as col names
//so don't set up an identical relation when using the tds driver
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
model.setRelation(3, QSqlRelation(reltest2, "tid", "title"));
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
@@ -340,7 +342,7 @@ void tst_QSqlRelationalTableModel::setData()
QCOMPARE(model.data(model.index(2, 1)).toString(), QString("vohi2"));
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
else
QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
@@ -358,12 +360,12 @@ void tst_QSqlRelationalTableModel::setData()
QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
model.setRelation(3, QSqlRelation(reltest2, "tid", "title"));
QVERIFY_SQL(model, select());
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
else
QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
@@ -560,6 +562,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies()
QFETCH_GLOBAL(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QSqlRelationalTableModel model(0, db);
@@ -567,14 +570,14 @@ void tst_QSqlRelationalTableModel::insertWithStrategies()
model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
model.setSort(0, Qt::AscendingOrder);
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
model.setRelation(3, QSqlRelation(reltest2, "tid", "title"));
QVERIFY_SQL(model, select());
QCOMPARE(model.data(model.index(0,0)).toInt(), 1);
QCOMPARE(model.data(model.index(0,1)).toString(), QString("harry"));
QCOMPARE(model.data(model.index(0,2)).toString(), QString("herr"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister"));
else
QCOMPARE(model.data(model.index(0,3)).toInt(), 2);
@@ -588,7 +591,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies()
QCOMPARE(model.data(model.index(0,0)).toInt(), 1011);
QCOMPARE(model.data(model.index(0,1)).toString(), QString("test"));
QCOMPARE(model.data(model.index(0,2)).toString(), QString("mister"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
QCOMPARE(model.data(model.index(0,3)).toString(), QString("herr"));
else
QCOMPARE(model.data(model.index(0,3)).toInt(), 1);
@@ -596,7 +599,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies()
QCOMPARE(model.data(model.index(1,0)).toInt(), 1);
QCOMPARE(model.data(model.index(1,1)).toString(), QString("harry"));
QCOMPARE(model.data(model.index(1,2)).toString(), QString("herr"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
QCOMPARE(model.data(model.index(1,3)).toString(), QString("mister"));
else
QCOMPARE(model.data(model.index(1,3)).toInt(), 2);
@@ -613,7 +616,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies()
QCOMPARE(model.data(model.index(0,1)).toString(), QString("harry"));
QCOMPARE(model.data(model.index(0,2)).toString(), QString("herr"));
- if (!db.driverName().startsWith("QTDS")) {
+ if (dbType != QSqlDriverPrivate::Sybase) {
QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister"));
model.setData(model.index(0,3),1);
QCOMPARE(model.data(model.index(0,3)).toString(), QString("herr"));
@@ -637,7 +640,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies()
QCOMPARE(model.data(model.index(0,0)).toInt(),1012);
QCOMPARE(model.data(model.index(0,1)).toString(), QString("george"));
QCOMPARE(model.data(model.index(0,2)).toString(), QString("mister"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister"));
else
QCOMPARE(model.data(model.index(0,3)).toInt(), 2);
@@ -646,7 +649,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies()
QCOMPARE(model.data(model.index(1,0)).toInt(),1013);
QCOMPARE(model.data(model.index(1,1)).toString(), QString("kramer"));
QCOMPARE(model.data(model.index(1,2)).toString(), QString("mister"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
QCOMPARE(model.data(model.index(1,3)).toString(), QString("herr"));
else
QCOMPARE(model.data(model.index(1,3)).toInt(), 1);
@@ -654,7 +657,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies()
QCOMPARE(model.data(model.index(2,0)).toInt(), 1);
QCOMPARE(model.data(model.index(2,1)).toString(), QString("harry"));
QCOMPARE(model.data(model.index(2,2)).toString(), QString("herr"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
QCOMPARE(model.data(model.index(2,3)).toString(), QString("herr"));
else
QCOMPARE(model.data(model.index(2,3)).toInt(), 1);
@@ -751,12 +754,13 @@ void tst_QSqlRelationalTableModel::sort()
QFETCH_GLOBAL(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
model.setRelation(3, QSqlRelation(reltest2, "tid", "title"));
model.setSort(2, Qt::DescendingOrder);
@@ -772,7 +776,7 @@ void tst_QSqlRelationalTableModel::sort()
model.setSort(3, Qt::AscendingOrder);
QVERIFY_SQL(model, select());
- if (!db.driverName().startsWith("QTDS")) {
+ if (dbType != QSqlDriverPrivate::Sybase) {
QCOMPARE(model.rowCount(), 4);
QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
QCOMPARE(model.data(model.index(1, 3)).toString(), QString("mister"));
@@ -801,7 +805,7 @@ void tst_QSqlRelationalTableModel::sort()
model.setSort(3, Qt::AscendingOrder);
QVERIFY_SQL(model, select());
- if (!db.driverName().startsWith("QTDS")) {
+ if (dbType != QSqlDriverPrivate::Sybase) {
QCOMPARE(model.rowCount(), 6);
QCOMPARE(model.data(model.index(0, 3)).toString(), QString(""));
QCOMPARE(model.data(model.index(1, 3)).toString(), QString("herr"));
@@ -916,13 +920,14 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache()
QFETCH_GLOBAL(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
model.setRelation(3, QSqlRelation(reltest2, "tid", "title"));
model.setSort(1, Qt::AscendingOrder);
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
@@ -932,7 +937,7 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache()
QCOMPARE(model.data(model.index(3, 0)).toInt(), 3);
QCOMPARE(model.data(model.index(3, 1)).toString(), QString("vohi"));
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
QCOMPARE(model.data(model.index(3, 3)).toString(), QString("mister"));
else
QCOMPARE(model.data(model.index(3, 3)).toInt(), 2 );
@@ -947,7 +952,7 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache()
QCOMPARE(model.data(model.index(0, 0)).toInt(), 7);
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("anders"));
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
else
QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
@@ -955,7 +960,7 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache()
QCOMPARE(model.data(model.index(4, 0)).toInt(), 3);
QCOMPARE(model.data(model.index(4, 1)).toString(), QString("vohi"));
QCOMPARE(model.data(model.index(4, 2)).toString(), QString("herr"));
- if (!db.driverName().startsWith("QTDS"))
+ if (dbType != QSqlDriverPrivate::Sybase)
QCOMPARE(model.data(model.index(4, 3)).toString(), QString("mister"));
else
QCOMPARE(model.data(model.index(4, 3)).toInt(), 2);
@@ -969,6 +974,7 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames()
QFETCH_GLOBAL(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QSqlRelationalTableModel model(0, db);
model.setTable(reltest3);
@@ -979,7 +985,7 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames()
model.setRelation(2, QSqlRelation(reltest4, "id", "name"));
QVERIFY_SQL(model, select());
- if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) {
QCOMPARE(model.record(1).value((reltest4+QLatin1String("_name_2")).toUpper()).toString(),
QString("Trondheim"));
} else {
@@ -992,7 +998,7 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames()
rec.setValue(1, "Berge");
rec.setValue(2, 1); // Must insert the key value
- if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) {
QCOMPARE(rec.fieldName(0), QLatin1String("ID"));
QCOMPARE(rec.fieldName(1), QLatin1String("NAME")); // This comes from main table
} else {
@@ -1001,7 +1007,7 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames()
}
// The duplicate field names is aliased because it's comes from the relation's display column.
- if(db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2)
QCOMPARE(rec.fieldName(2), (reltest4+QLatin1String("_name_2")).toUpper());
else
QCOMPARE(rec.fieldName(2), reltest4+QLatin1String("_name_2"));
@@ -1090,8 +1096,9 @@ void tst_QSqlRelationalTableModel::casing()
QFETCH_GLOBAL(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
- if (db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QIBASE") || tst_Databases::isSqlServer(db))
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::SQLite || dbType == QSqlDriverPrivate::MSSqlServer)
QSKIP("The casing test for this database is irrelevant since this database does not treat different cases as separate entities");
QSqlQuery q(db);
@@ -1110,7 +1117,7 @@ void tst_QSqlRelationalTableModel::casing()
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db) + " values(2, 'george', 2)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db) + " values(4, 'kramer', 2)"));
- if (db.driverName().startsWith("QOCI")) {
+ if (dbType == QSqlDriverPrivate::Oracle) {
//try an owner that doesn't exist
QSqlRecord rec = db.driver()->record("doug." + qTableName("CASETEST1", db).toUpper());
QCOMPARE( rec.count(), 0);
@@ -1156,13 +1163,15 @@ void tst_QSqlRelationalTableModel::escapedRelations()
QFETCH_GLOBAL(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+
recreateTestTables(db);
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
//try with relation table name quoted
- if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) {
model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(reltest2.toUpper(),QSqlDriver::TableName),
"tid",
"title"));
@@ -1187,7 +1196,7 @@ void tst_QSqlRelationalTableModel::escapedRelations()
//try with index column quoted
model.setJoinMode(QSqlRelationalTableModel::InnerJoin);
- if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) {
model.setRelation(2, QSqlRelation(reltest2,
db.driver()->escapeIdentifier("tid", QSqlDriver::FieldName).toUpper(),
"title"));
@@ -1211,7 +1220,7 @@ void tst_QSqlRelationalTableModel::escapedRelations()
//try with display column quoted
model.setJoinMode(QSqlRelationalTableModel::InnerJoin);
- if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) {
model.setRelation(2, QSqlRelation(reltest2,
"tid",
@@ -1237,7 +1246,7 @@ void tst_QSqlRelationalTableModel::escapedRelations()
//try with tablename and index and display columns quoted in the relation
model.setJoinMode(QSqlRelationalTableModel::InnerJoin);
- if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) {
model.setRelation(2, QSqlRelation(reltest2,
"tid",
db.driver()->escapeIdentifier("title", QSqlDriver::FieldName).toUpper()));
@@ -1265,12 +1274,13 @@ void tst_QSqlRelationalTableModel::escapedTableName()
QFETCH_GLOBAL(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
// set the values using OnRowChange Strategy with an escaped tablename
{
QSqlRelationalTableModel model(0, db);
- if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) {
model.setTable(db.driver()->escapeIdentifier(reltest1.toUpper(), QSqlDriver::TableName));
} else {
model.setTable(db.driver()->escapeIdentifier(reltest1, QSqlDriver::TableName));
@@ -1317,7 +1327,7 @@ void tst_QSqlRelationalTableModel::escapedTableName()
{
QSqlRelationalTableModel model(0, db);
- if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ if (dbType == QSqlDriverPrivate::Interbase || dbType == QSqlDriverPrivate::Oracle || dbType == QSqlDriverPrivate::DB2) {
model.setTable(db.driver()->escapeIdentifier(reltest1.toUpper(), QSqlDriver::TableName));
} else {
model.setTable(db.driver()->escapeIdentifier(reltest1, QSqlDriver::TableName));
@@ -1453,8 +1463,9 @@ void tst_QSqlRelationalTableModel::psqlSchemaTest()
QFETCH_GLOBAL(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
- if(!tst_Databases::isPostgreSQL(db))
+ if (dbType != QSqlDriverPrivate::PostgreSQL)
QSKIP("Postgresql specific test");
QSqlRelationalTableModel model(0, db);
diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
index 771c224963..628a34f6f4 100644
--- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -168,8 +168,9 @@ void tst_QSqlTableModel::dropTestTables()
{
for (int i = 0; i < dbs.dbNames.count(); ++i) {
QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i));
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QSqlQuery q(db);
- if(tst_Databases::isPostgreSQL(db))
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
QStringList tableNames;
@@ -196,6 +197,7 @@ void tst_QSqlTableModel::createTestTables()
{
for (int i = 0; i < dbs.dbNames.count(); ++i) {
QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i));
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QSqlQuery q(db);
QVERIFY_SQL( q, exec("create table " + test + "(id int, name varchar(20), title int)"));
@@ -204,7 +206,7 @@ void tst_QSqlTableModel::createTestTables()
QVERIFY_SQL( q, exec("create table " + test3 + "(id int, random varchar(20), randomtwo varchar(20))"));
- if(!tst_Databases::isSqlServer(db))
+ if (dbType != QSqlDriverPrivate::MSSqlServer)
QVERIFY_SQL(q, exec("create table " + qTableName("test4", __FILE__, db) + "(column1 varchar(50), column2 varchar(50), column3 varchar(50))"));
else
QVERIFY_SQL(q, exec("create table " + qTableName("test4", __FILE__, db) + "(column1 varchar(50), column2 varchar(50) NULL, column3 varchar(50))"));
@@ -1705,10 +1707,11 @@ void tst_QSqlTableModel::primaryKeyOrder()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QSqlQuery q(db);
- if(tst_Databases::isPostgreSQL(db))
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
QVERIFY_SQL(q, exec("create table " + qTableName("foo", __FILE__, db) + "(a varchar(20), id int not null primary key, b varchar(20))"));
diff --git a/tests/auto/tools/tools.pro b/tests/auto/tools/tools.pro
index 9b4d2ca22a..5367e8b7ef 100644
--- a/tests/auto/tools/tools.pro
+++ b/tests/auto/tools/tools.pro
@@ -6,3 +6,4 @@ SUBDIRS=\
rcc \
qtHaveModule(dbus): SUBDIRS += qdbuscpp2xml qdbusxml2cpp
+!qtHaveModule(widgets): SUBDIRS -= uic
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 3710645514..dfb780c8fa 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -201,6 +201,7 @@ private slots:
void taskQTBUG_7774_RtoLVisualRegionForSelection();
void taskQTBUG_8777_scrollToSpans();
void taskQTBUG_10169_sizeHintForRow();
+ void taskQTBUG_30653_doItemsLayout();
void mouseWheel_data();
void mouseWheel();
@@ -4124,5 +4125,38 @@ void tst_QTableView::viewOptions()
QVERIFY(options.showDecorationSelected);
}
+void tst_QTableView::taskQTBUG_30653_doItemsLayout()
+{
+ QWidget topLevel;
+ QtTestTableView view(&topLevel);
+
+ QtTestTableModel model(5, 5);
+ view.setModel(&model);
+
+ QtTestItemDelegate delegate;
+ delegate.hint = QSize(50, 50);
+ view.setItemDelegate(&delegate);
+
+ view.resizeRowsToContents();
+ view.resizeColumnsToContents();
+
+ // show two and half rows/cols
+ int extraWidth = view.verticalHeader()->sizeHint().width() + view.verticalScrollBar()->sizeHint().width();
+ int extraHeight = view.horizontalHeader()->sizeHint().height() + view.horizontalScrollBar()->sizeHint().height();
+ view.resize(125 + extraWidth, 125 + extraHeight);
+
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+
+ // the offset after scrollToBottom() and doItemsLayout() should not differ
+ // as the view content should stay aligned to the last section
+ view.scrollToBottom();
+ int scrollToBottomOffset = view.verticalHeader()->offset();
+ view.doItemsLayout();
+ int doItemsLayoutOffset = view.verticalHeader()->offset();
+
+ QCOMPARE(scrollToBottomOffset, doItemsLayoutOffset);
+}
+
QTEST_MAIN(tst_QTableView)
#include "tst_qtableview.moc"
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
index 227a31b10d..84d796f657 100644
--- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
@@ -68,6 +68,7 @@ public slots:
private slots:
void insertSpacerItem();
+ void insertLayout();
void sizeHint();
void sizeConstraints();
void setGeometry();
@@ -166,6 +167,26 @@ void tst_QBoxLayout::insertSpacerItem()
window->show();
}
+void tst_QBoxLayout::insertLayout()
+{
+ QWidget *window = new QWidget;
+ QVBoxLayout *vbox = new QVBoxLayout(window);
+ QVBoxLayout *dummyParentLayout = new QVBoxLayout;
+ QHBoxLayout *subLayout = new QHBoxLayout;
+ dummyParentLayout->addLayout(subLayout);
+ QCOMPARE(subLayout->parent(), dummyParentLayout);
+ QCOMPARE(dummyParentLayout->count(), 1);
+
+ // add subLayout to another layout
+ QTest::ignoreMessage(QtWarningMsg, "QLayout::addChildLayout: layout \"\" already has a parent");
+ vbox->addLayout(subLayout);
+ QCOMPARE((subLayout->parent() == vbox), (vbox->count() == 1));
+
+ delete dummyParentLayout;
+ delete window;
+}
+
+
void tst_QBoxLayout::sizeHint()
{
QWidget *window = new QWidget;
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 69d890fb7a..25e1dc3fa0 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -2089,11 +2089,14 @@ public:
void tst_QWidget::resizeEvent()
{
+ QSKIP("QTBUG-30744");
+
{
QWidget wParent;
wParent.resize(200, 200);
ResizeWidget wChild(&wParent);
wParent.show();
+ QTest::qWaitForWindowExposed(&wParent);
QCOMPARE (wChild.m_resizeEventCount, 1); // initial resize event before paint
wParent.hide();
QSize safeSize(640,480);
@@ -2109,6 +2112,7 @@ void tst_QWidget::resizeEvent()
ResizeWidget wTopLevel;
wTopLevel.resize(200, 200);
wTopLevel.show();
+ QTest::qWaitForWindowExposed(&wTopLevel);
QCOMPARE (wTopLevel.m_resizeEventCount, 1); // initial resize event before paint for toplevels
wTopLevel.hide();
QSize safeSize(640,480);
@@ -2117,6 +2121,7 @@ void tst_QWidget::resizeEvent()
wTopLevel.resize(safeSize);
QCOMPARE (wTopLevel.m_resizeEventCount, 1);
wTopLevel.show();
+ QTest::qWaitForWindowExposed(&wTopLevel);
QCOMPARE (wTopLevel.m_resizeEventCount, 2);
}
}
@@ -4428,11 +4433,8 @@ void tst_QWidget::setWindowGeometry()
widget.setGeometry(rect);
widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
- if (m_platform == QStringLiteral("windows")) {
- QEXPECT_FAIL("130,100 0x200, flags 0", "QTBUG-26424", Continue);
- QEXPECT_FAIL("130,50 0x0, flags 0", "QTBUG-26424", Continue);
- }
+ if (rect.isValid())
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
QTRY_COMPARE(widget.geometry(), rect);
// setGeometry() while shown
@@ -4462,7 +4464,8 @@ void tst_QWidget::setWindowGeometry()
// show() again, geometry() should still be the same
widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ if (rect.isValid())
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
QTRY_COMPARE(widget.geometry(), rect);
// final hide(), again geometry() should be unchanged
@@ -4478,7 +4481,8 @@ void tst_QWidget::setWindowGeometry()
widget.setWindowFlags(Qt::WindowFlags(windowFlags));
widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ if (rect.isValid())
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
widget.setGeometry(rect);
QTest::qWait(10);
QTRY_COMPARE(widget.geometry(), rect);
@@ -4510,7 +4514,8 @@ void tst_QWidget::setWindowGeometry()
// show() again, geometry() should still be the same
widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ if (rect.isValid())
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
QTest::qWait(10);
QTRY_COMPARE(widget.geometry(), rect);
@@ -4655,7 +4660,8 @@ void tst_QWidget::windowMoveResize()
// show() again, pos() should be the same
widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ if (rect.isValid())
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
QApplication::processEvents();
QTRY_COMPARE(widget.pos(), rect.topLeft());
QTRY_COMPARE(widget.size(), rect.size());
@@ -4674,7 +4680,8 @@ void tst_QWidget::windowMoveResize()
widget.setWindowFlags(Qt::WindowFlags(windowFlags));
widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ if (rect.isValid())
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
QApplication::processEvents();
widget.move(rect.topLeft());
widget.resize(rect.size());
@@ -4724,7 +4731,8 @@ void tst_QWidget::windowMoveResize()
// show() again, pos() should be the same
widget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ if (rect.isValid())
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
QTest::qWait(10);
QTRY_COMPARE(widget.pos(), rect.topLeft());
QTRY_COMPARE(widget.size(), rect.size());
diff --git a/tests/benchmarks/corelib/tools/qlocale/main.cpp b/tests/benchmarks/corelib/tools/qlocale/main.cpp
new file mode 100644
index 0000000000..c62baf556e
--- /dev/null
+++ b/tests/benchmarks/corelib/tools/qlocale/main.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QLocale>
+#include <QTest>
+
+class tst_QLocale : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void toUpper_QLocale_1();
+ void toUpper_QLocale_2();
+ void toUpper_QString();
+};
+
+static QString data()
+{
+ return QStringLiteral("/qt-5/qtbase/tests/benchmarks/corelib/tools/qlocale");
+}
+
+#define LOOP(s) for (int i = 0; i < 5000; ++i) { s; }
+
+void tst_QLocale::toUpper_QLocale_1()
+{
+ QString s = data();
+ QBENCHMARK { LOOP(QLocale().toUpper(s)) }
+}
+
+void tst_QLocale::toUpper_QLocale_2()
+{
+ QString s = data();
+ QLocale l;
+ QBENCHMARK { LOOP(l.toUpper(s)) }
+}
+
+void tst_QLocale::toUpper_QString()
+{
+ QString s = data();
+ QBENCHMARK { LOOP(s.toUpper()) }
+}
+
+QTEST_MAIN(tst_QLocale)
+
+#include "main.moc"
diff --git a/tests/benchmarks/corelib/tools/qlocale/qlocale.pro b/tests/benchmarks/corelib/tools/qlocale/qlocale.pro
new file mode 100644
index 0000000000..9e8f2721c9
--- /dev/null
+++ b/tests/benchmarks/corelib/tools/qlocale/qlocale.pro
@@ -0,0 +1,5 @@
+TARGET = tst_bench_qlocale
+QT = core testlib
+
+SOURCES += main.cpp
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/benchmarks/corelib/tools/tools.pro b/tests/benchmarks/corelib/tools/tools.pro
index 7565b1a167..ce3e75acd7 100644
--- a/tests/benchmarks/corelib/tools/tools.pro
+++ b/tests/benchmarks/corelib/tools/tools.pro
@@ -5,6 +5,7 @@ SUBDIRS = \
qbytearray \
qcontiguouscache \
qlist \
+ qlocale \
qmap \
qrect \
qregexp \
diff --git a/tests/benchmarks/sql/kernel/qsqlquery/main.cpp b/tests/benchmarks/sql/kernel/qsqlquery/main.cpp
index 2bce545f90..4e6a444366 100644
--- a/tests/benchmarks/sql/kernel/qsqlquery/main.cpp
+++ b/tests/benchmarks/sql/kernel/qsqlquery/main.cpp
@@ -117,6 +117,7 @@ void tst_QSqlQuery::cleanup()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
+ const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
if ( QTest::currentTestFunction() == QLatin1String( "numRowsAffected" )
|| QTest::currentTestFunction() == QLatin1String( "transactions" )
@@ -126,8 +127,7 @@ void tst_QSqlQuery::cleanup()
populateTestTables( db );
}
- if ( QTest::currentTestFailed() && ( db.driverName().startsWith( "QOCI" )
- || db.driverName().startsWith( "QODBC" ) ) ) {
+ if (QTest::currentTestFailed() && (dbType == QSqlDriverPrivate::Oracle || db.driverName().startsWith("QODBC"))) {
//since Oracle ODBC totally craps out on error, we init again
db.close();
db.open();
@@ -146,6 +146,7 @@ void tst_QSqlQuery::generic_data(const QString& engine)
void tst_QSqlQuery::dropTestTables( QSqlDatabase db )
{
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
QStringList tablenames;
// drop all the table in case a testcase failed
tablenames << qtest
@@ -179,24 +180,24 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db )
<< qTableName("test141895", __FILE__, db)
<< qTableName("qtest_oraOCINumber", __FILE__, db);
- if ( db.driverName().startsWith("QPSQL") )
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
tablenames << qTableName("task_233829", __FILE__, db);
- if ( db.driverName().startsWith("QSQLITE") )
+ if (dbType == QSqlDriverPrivate::SQLite)
tablenames << qTableName("record_sqlite", __FILE__, db);
- if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QOCI" ) )
+ if (dbType == QSqlDriverPrivate::MSSqlServer || dbType == QSqlDriverPrivate::Oracle)
tablenames << qTableName("qtest_longstr", __FILE__, db);
- if (tst_Databases::isSqlServer( db ))
+ if (dbType == QSqlDriverPrivate::MSSqlServer)
db.exec("DROP PROCEDURE " + qTableName("test141895_proc", __FILE__, db));
- if (tst_Databases::isMySQL( db ))
+ if (dbType == QSqlDriverPrivate::MySqlServer)
db.exec("DROP PROCEDURE IF EXISTS "+qTableName("bug6852_proc", __FILE__, db));
tst_Databases::safeDropTables( db, tablenames );
- if ( db.driverName().startsWith( "QOCI" ) ) {
+ if (dbType == QSqlDriverPrivate::Oracle) {
QSqlQuery q( db );
q.exec("DROP PACKAGE " + qTableName("pkg", __FILE__, db));
}
@@ -204,24 +205,25 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db )
void tst_QSqlQuery::createTestTables( QSqlDatabase db )
{
+ const QString qtestNull = qTableName("qtest_null", __FILE__, db);
QSqlQuery q( db );
-
- if ( db.driverName().startsWith( "QMYSQL" ) )
+ QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db);
+ if (dbType == QSqlDriverPrivate::MySqlServer)
// ### stupid workaround until we find a way to hardcode this
// in the MySQL server startup script
q.exec( "set table_type=innodb" );
- else if (tst_Databases::isPostgreSQL(db))
+ else if (dbType == QSqlDriverPrivate::PostgreSQL)
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
- if (tst_Databases::isPostgreSQL(db))
+ if (dbType == QSqlDriverPrivate::PostgreSQL)
QVERIFY_SQL( q, exec( "create table " + qtest + " (id serial NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id)) WITH OIDS" ) );
else
QVERIFY_SQL( q, exec( "create table " + qtest + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) );
- if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) )
- QVERIFY_SQL(q, exec("create table " + qTableName("qtest_null", __FILE__, db) + " (id int null, t_varchar varchar(20) null)" ) );
+ if (dbType == QSqlDriverPrivate::MSSqlServer || dbType == QSqlDriverPrivate::Sybase)
+ QVERIFY_SQL(q, exec("create table " + qtestNull + " (id int null, t_varchar varchar(20) null)"));
else
- QVERIFY_SQL(q, exec("create table " + qTableName("qtest_null", __FILE__, db) + " (id int, t_varchar varchar(20))" ) );
+ QVERIFY_SQL(q, exec("create table " + qtestNull + " (id int, t_varchar varchar(20))"));
}
void tst_QSqlQuery::populateTestTables( QSqlDatabase db )
diff --git a/tests/manual/dialogs/filedialogpanel.cpp b/tests/manual/dialogs/filedialogpanel.cpp
index b524e3d669..69e25e753a 100644
--- a/tests/manual/dialogs/filedialogpanel.cpp
+++ b/tests/manual/dialogs/filedialogpanel.cpp
@@ -455,7 +455,7 @@ void FileDialogPanel::restoreDefaults()
m_readOnly->setChecked(d.isReadOnly());
m_native->setChecked(true);
m_directory->setText(QDir::homePath());
- m_defaultSuffix->setText(QLatin1String(".txt"));
+ m_defaultSuffix->setText(QLatin1String("txt"));
m_nameFilters->setPlainText(QLatin1String("Any files (*)\nImage files (*.png *.xpm *.jpg)\nText files (*.txt)"));
m_selectedFileName->setText(QString());
m_selectedNameFilter->setText(QString());