Merge branch 'master' of git://scm.dev.nokia.troll.no/qt/qtbase-staging

* 'master' of git://scm.dev.nokia.troll.no/qt/qtbase-staging:
  tests: fixed compilation of tst_qtextstream
  QUiLoader, QAbstractFormBuilder: Introduce errorString().
  Enable configuration for Xcb
  Fall back to using paths for large fonts in drawStaticText()
  Add ability to work around non-standard GLES implementations
  Fix broken drawing with large fonts using QStaticText and FreeType
  Remove Q_ASSERT's from qdbustype autotest
  Remove autotest code for Qt3Support library.
This commit is contained in:
Qt Continuous Integration System 2011-05-19 10:07:06 +10:00
commit 4299467335
52 changed files with 258 additions and 3988 deletions

23
configure vendored
View File

@ -751,6 +751,7 @@ CFG_DECORATION_PLUGIN_AVAILABLE=
CFG_DECORATION_PLUGIN=
CFG_XINPUT=runtime
CFG_XKB=auto
CFG_XCB=no
CFG_NIS=auto
CFG_CUPS=auto
CFG_ICONV=auto
@ -1043,7 +1044,7 @@ while [ "$#" -gt 0 ]; do
VAL=no
;;
#Qt style yes options
-incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-egl|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-carbon|-universal|-harfbuzz|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-audio-backend|-svg|-declarative|-declarative-debug|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config|-s60|-usedeffiles|-icu)
-incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-egl|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-xcb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-carbon|-universal|-harfbuzz|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-audio-backend|-svg|-declarative|-declarative-debug|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config|-s60|-usedeffiles|-icu)
VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
VAL=yes
;;
@ -1971,6 +1972,13 @@ while [ "$#" -gt 0 ]; do
UNKNOWN_OPT=yes
fi
;;
xcb)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_XCB="$VAL"
else
UNKNOWN_OPT=yes
fi
;;
cups)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_CUPS="$VAL"
@ -3711,6 +3719,14 @@ if [ "$OPT_HELP" = "yes" ]; then
PHN=" "
fi
if [ "$CFG_XCB" = "no" ]; then
XCY=" "
XCN="*"
else
XCY="*"
XCN=" "
fi
cat <<EOF
Usage: $relconf [-h] [-prefix <dir>] [-prefix-install] [-bindir <dir>] [-libdir <dir>]
[-docdir <dir>] [-headerdir <dir>] [-plugindir <dir> ] [-importdir <dir>] [-datadir <dir>]
@ -4061,6 +4077,9 @@ if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "ye
$SBN -no-separate-debug-info . Do not store debug information in a separate file.
$SBY -separate-debug-info .... Strip debug information into a separate .debug file.
$XKN -no-xcb ............ Do not compile Xcb (X protocol C-language Binding) support.
$XKY -xcb ............... Compile Xcb support.
EOF
fi # X11/QWS
@ -7281,6 +7300,7 @@ fi
[ "$CFG_OPENSSL" = "yes" ] && QT_CONFIG="$QT_CONFIG openssl"
[ "$CFG_OPENSSL" = "linked" ] && QT_CONFIG="$QT_CONFIG openssl-linked"
[ "$CFG_MAC_HARFBUZZ" = "yes" ] && QT_CONFIG="$QT_CONFIG harfbuzz"
[ "$CFG_XCB" = "yes" ] && QT_CONFIG="$QT_CONFIG xcb"
if [ "$PLATFORM_X11" = "yes" ]; then
[ "$CFG_SM" = "yes" ] && QT_CONFIG="$QT_CONFIG x11sm"
@ -8845,6 +8865,7 @@ if [ "$PLATFORM_MAC" = "yes" ]; then
fi
echo "ICD support ............ $CFG_ICD"
echo "libICU support ......... $CFG_ICU"
echo "Xcb support ............ $CFG_XCB"
echo
[ "$CFG_PTMALLOC" != "no" ] && echo "Use ptmalloc ........... $CFG_PTMALLOC"

View File

@ -3029,8 +3029,16 @@ void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
ensurePen();
ensureState();
drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions,
textItem->fontEngine());
QRasterPaintEngineState *s = state();
QFontEngine *fontEngine = textItem->fontEngine();
const qreal pixelSize = fontEngine->fontDef.pixelSize;
if (pixelSize * pixelSize * qAbs(s->matrix.determinant()) < 64 * 64) {
drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions,
fontEngine);
} else {
QPaintEngineEx::drawStaticTextItem(textItem);
}
}
/*!

View File

@ -44,6 +44,8 @@
#include "qstroker_p.h"
#include "qbezier_p.h"
#include <private/qpainterpath_p.h>
#include <private/qfontengine_p.h>
#include <private/qstatictext_p.h>
#include <qvarlengtharray.h>
#include <qdebug.h>
@ -1057,5 +1059,38 @@ Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath(const QVectorPath &path)
return p;
}
void QPaintEngineEx::drawStaticTextItem(QStaticTextItem *staticTextItem)
{
QPainterPath path;
#ifndef Q_WS_MAC
path.setFillRule(Qt::WindingFill);
#endif
if (staticTextItem->numGlyphs == 0)
return;
QFontEngine *fontEngine = staticTextItem->fontEngine();
fontEngine->addGlyphsToPath(staticTextItem->glyphs, staticTextItem->glyphPositions,
staticTextItem->numGlyphs, &path, 0);
if (!path.isEmpty()) {
QPainterState *s = state();
QPainter::RenderHints oldHints = s->renderHints;
bool changedHints = false;
if (bool(oldHints & QPainter::TextAntialiasing)
&& !bool(fontEngine->fontDef.styleStrategy & QFont::NoAntialias)
&& !bool(oldHints & QPainter::Antialiasing)) {
s->renderHints |= QPainter::Antialiasing;
renderHintsChanged();
changedHints = true;
}
fill(qtVectorPathForPath(path), staticTextItem->color);
if (changedHints) {
s->renderHints = oldHints;
renderHintsChanged();
}
}
}
QT_END_NAMESPACE

View File

@ -202,7 +202,7 @@ public:
virtual void updateState(const QPaintEngineState &state);
virtual void drawStaticTextItem(QStaticTextItem *) = 0;
virtual void drawStaticTextItem(QStaticTextItem *);
virtual void setState(QPainterState *s);
inline QPainterState *state() { return static_cast<QPainterState *>(QPaintEngine::state); }

View File

@ -795,7 +795,7 @@ int QFontEngineFT::loadFlags(QGlyphSet *set, GlyphFormat format, int flags,
if (set && set->outline_drawing)
load_flags = FT_LOAD_NO_BITMAP;
if (default_hint_style == HintNone || (flags & HB_ShaperFlag_UseDesignMetrics))
if (default_hint_style == HintNone || (flags & HB_ShaperFlag_UseDesignMetrics) || set->outline_drawing)
load_flags |= FT_LOAD_NO_HINTING;
else
load_flags |= load_target;

View File

@ -1436,19 +1436,30 @@ void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem)
ensureActive();
QFontEngineGlyphCache::Type glyphType = textItem->fontEngine()->glyphFormat >= 0
? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat)
: d->glyphCacheType;
if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
if (d->device->alphaRequested() || state()->matrix.type() > QTransform::TxTranslate
|| (state()->composition_mode != QPainter::CompositionMode_Source
&& state()->composition_mode != QPainter::CompositionMode_SourceOver))
{
glyphType = QFontEngineGlyphCache::Raster_A8;
}
}
QPainterState *s = state();
float det = s->matrix.determinant();
d->drawCachedGlyphs(glyphType, textItem);
// don't try to cache huge fonts or vastly transformed fonts
QFontEngine *fontEngine = textItem->fontEngine();
const qreal pixelSize = fontEngine->fontDef.pixelSize;
if (pixelSize * pixelSize * qAbs(det) < QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE ||
det < 0.25f || det > 4.f) {
QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0
? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat)
: d->glyphCacheType;
if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
if (d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate
|| (s->composition_mode != QPainter::CompositionMode_Source
&& s->composition_mode != QPainter::CompositionMode_SourceOver))
{
glyphType = QFontEngineGlyphCache::Raster_A8;
}
}
d->drawCachedGlyphs(glyphType, textItem);
} else {
QPaintEngineEx::drawStaticTextItem(textItem);
}
}
bool QGL2PaintEngineEx::drawTexture(const QRectF &dest, GLuint textureId, const QSize &size, const QRectF &src)

View File

@ -362,17 +362,17 @@ QGLShader::ShaderType QGLShader::shaderType() const
// The precision qualifiers are useful on OpenGL/ES systems,
// but usually not present on desktop systems. Define the
// keywords to empty strings on desktop systems.
#ifndef QT_OPENGL_ES
#if !defined(QT_OPENGL_ES) || defined(QT_OPENGL_FORCE_SHADER_DEFINES)
#define QGL_DEFINE_QUALIFIERS 1
static const char qualifierDefines[] =
"#define lowp\n"
"#define mediump\n"
"#define highp\n";
#endif
#else
// The "highp" qualifier doesn't exist in fragment shaders
// on all ES platforms. When it doesn't exist, use "mediump".
#ifdef QT_OPENGL_ES
#define QGL_REDEFINE_HIGHP 1
static const char redefineHighp[] =
"#ifndef GL_FRAGMENT_PRECISION_HIGH\n"

View File

@ -6,3 +6,6 @@ contains(QT_CONFIG, wayland) {
SUBDIRS += wayland
}
contains(QT_CONFIG, xcb) {
SUBDIRS += xcb
}

View File

@ -653,7 +653,7 @@ QUiLoader::~QUiLoader()
Loads a form from the given \a device and creates a new widget with the
given \a parentWidget to hold its contents.
\sa createWidget()
\sa createWidget(), errorString()
*/
QWidget *QUiLoader::load(QIODevice *device, QWidget *parentWidget)
{
@ -936,6 +936,19 @@ bool QUiLoader::isTranslationEnabled() const
return d->builder.trEnabled;
}
/*!
Returns a human-readable description of the last error occurred in load().
\since 5.0
\sa load()
*/
QString QUiLoader::errorString() const
{
Q_D(const QUiLoader);
return d->builder.errorString();
}
QT_END_NAMESPACE
#include "quiloader.moc"

View File

@ -90,6 +90,8 @@ public:
void setTranslationEnabled(bool enabled);
bool isTranslationEnabled() const;
QString errorString() const;
private:
QScopedPointer<QUiLoaderPrivate> d_ptr;
Q_DECLARE_PRIVATE(QUiLoader)

View File

@ -100,10 +100,6 @@ void foo()
#include "qvector.h"
#include "qqueue.h"
#ifdef QT3_SUPPORT
#include "q3cleanuphandler.h"
#endif
template class QList<int>;
//TESTED_FILES=
@ -133,7 +129,6 @@ private slots:
void cache();
void regexp();
void pair();
void cleanupHandler();
void sharableQList();
void sharableQLinkedList();
void sharableQVector();
@ -2191,14 +2186,7 @@ void tst_Collections::qstring()
QVERIFY(s.toLatin1() == "first");
s = "second";
QVERIFY(s.toLatin1() == "second");
#ifdef QT3_SUPPORT
const char* cache = s.latin1();
QVERIFY(cache == s.latin1());
#endif
s.clear();
#ifdef QT3_SUPPORT
QVERIFY(*s.latin1() == '\0');
#endif
QVERIFY(s.isNull());
QVERIFY(s.toLatin1().size() == 0);
QVERIFY(s.toLatin1().isEmpty());
@ -2208,14 +2196,7 @@ void tst_Collections::qstring()
QVERIFY(s.toUtf8() == "first-utf8");
s = "second-utf8";
QVERIFY(s.toUtf8() == "second-utf8");
#ifdef QT3_SUPPORT
cache = s.utf8();
QVERIFY(cache == s.utf8());
#endif
s.clear();
#ifdef QT3_SUPPORT
QVERIFY(*s.utf8() == '\0');
#endif
QVERIFY(s.isNull());
QVERIFY(s.toUtf8().size() == 0);
QVERIFY(s.toUtf8().isEmpty());
@ -2225,14 +2206,7 @@ void tst_Collections::qstring()
QVERIFY(s.toUtf8() == "first-utf8");
s = "second-utf8";
QVERIFY(s.toUtf8() == "second-utf8");
#ifdef QT3_SUPPORT
cache = s.utf8();
QVERIFY(cache == s.utf8());
#endif
s.clear();
#ifdef QT3_SUPPORT
QVERIFY(*s.utf8() == '\0');
#endif
QVERIFY(s.isNull());
QVERIFY(s.toUtf8().size() == 0);
QVERIFY(s.toUtf8().isEmpty());
@ -2242,14 +2216,7 @@ void tst_Collections::qstring()
QVERIFY(s.toLocal8Bit() == "first-local8Bit");
s = "second-local8Bit";
QVERIFY(s.toLocal8Bit() == "second-local8Bit");
#ifdef QT3_SUPPORT
cache = s.local8Bit();
QVERIFY(cache == s.local8Bit());
#endif
s.clear();
#ifdef QT3_SUPPORT
QVERIFY(*s.local8Bit() == '\0');
#endif
QVERIFY(s.isNull());
QVERIFY(s.toLocal8Bit().size() == 0);
QVERIFY(s.toLocal8Bit().isEmpty());
@ -2258,14 +2225,7 @@ void tst_Collections::qstring()
QVERIFY(s.toAscii() == "first-ascii");
s = "second-ascii";
QVERIFY(s.toAscii() == "second-ascii");
#ifdef QT3_SUPPORT
cache = s.ascii();
QVERIFY(cache == s.ascii());
#endif
s.clear();
#ifdef QT3_SUPPORT
QVERIFY(*s.ascii() == '\0');
#endif
QVERIFY(s.isNull());
QVERIFY(s.toAscii().size() == 0);
QVERIFY(s.toAscii().isEmpty());
@ -2508,24 +2468,6 @@ void tst_Collections::pair()
QVERIFY(!(a > a || b > b || c > c || d > d || e > e));
}
void tst_Collections::cleanupHandler()
{
#ifdef QT3_SUPPORT
LargeStatic * f1 = 0;
LargeStatic * f2 = 0;
{
Q3CleanupHandler<LargeStatic> cleanup;
f1 = new LargeStatic;
f2 = new LargeStatic;
cleanup.add(&f1);
cleanup.add(&f2);
}
QVERIFY(f1 == 0 && f2 == 0);
#else
QSKIP("No Qt3 support", SkipAll);
#endif
}
/*
These test that Java-style mutable iterators don't trash shared
copy (the setSharable() mechanism).

View File

@ -52,9 +52,6 @@
#include <QtNetwork/QtNetwork>
#include <QtSql/QtSql>
//#include <QtSvg>
#if defined(QT3_SUPPORT)
#include <Qt3Support>
#endif
#if defined(WITH_DBUS)
#include <QtDBus>
#endif

View File

@ -185,8 +185,8 @@ void tst_QDBusType::isValidFixedType()
QFETCH(QString, data);
QFETCH(bool, result);
QFETCH(bool, isValid);
Q_ASSERT_X(data.length() == 1, "tst_QDBusType", "Test is malformed, this function must test only one-letter types");
Q_ASSERT(isValid || (!isValid && !result));
QVERIFY2(data.length() == 1, "Test is malformed, this function must test only one-letter types");
QVERIFY(isValid || (!isValid && !result));
int type = data.at(0).unicode();
if (isValid)
@ -207,8 +207,8 @@ void tst_QDBusType::isValidBasicType()
QFETCH(QString, data);
QFETCH(bool, result);
QFETCH(bool, isValid);
Q_ASSERT_X(data.length() == 1, "tst_QDBusType", "Test is malformed, this function must test only one-letter types");
Q_ASSERT(isValid || (!isValid && !result));
QVERIFY2(data.length() == 1, "Test is malformed, this function must test only one-letter types");
QVERIFY(isValid || (!isValid && !result));
int type = data.at(0).unicode();
if (isValid)

View File

@ -158,9 +158,6 @@ private slots:
void operator_eq();
void dotAndDotDot();
#ifdef QT3_SUPPORT
void matchAllDirs();
#endif
void homePath();
void tempPath();
void rootPath();
@ -193,10 +190,6 @@ private slots:
void arrayOperator();
#ifdef QT3_SUPPORT
void setNameFilter();
#endif
void equalityOperator_data();
void equalityOperator();
@ -553,17 +546,6 @@ void tst_QDir::entryList_data()
QTest::newRow("QDir::AllDirs | QDir::NoSymLinks") << SRCDIR "entrylist/" << QStringList("*")
<< int(QDir::AllDirs | QDir::NoSymLinks) << int(QDir::Name)
<< filterLinks(QString(".,..,directory").split(','));
#ifdef QT3_SUPPORT
QTest::newRow("QDir::All | QDir::Hidden | QDir::System") << SRCDIR "entrylist/" << QStringList("*")
<< int(QDir::All | QDir::Hidden | QDir::System) << int(QDir::Name)
<< filterLinks(QString(".,..,brokenlink.lnk,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(','));
QTest::newRow("QDir::All | QDir::Readable") << SRCDIR "entrylist/" << QStringList("*")
<< int(QDir::All | QDir::Readable) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(','));
QTest::newRow("QDir::All | QDir::Writable") << SRCDIR "entrylist/" << QStringList("*")
<< int(QDir::All | QDir::Writable) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,linktodirectory.lnk,writable").split(','));
#else
QTest::newRow("QDir::AllEntries | QDir::Hidden | QDir::System") << SRCDIR "entrylist/" << QStringList("*")
<< int(QDir::AllEntries | QDir::Hidden | QDir::System) << int(QDir::Name)
<< filterLinks(QString(".,..,brokenlink.lnk,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(','));
@ -573,7 +555,6 @@ void tst_QDir::entryList_data()
QTest::newRow("QDir::AllEntries | QDir::Writable") << SRCDIR "entrylist/" << QStringList("*")
<< int(QDir::AllEntries | QDir::Writable) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,linktodirectory.lnk,writable").split(','));
#endif
QTest::newRow("QDir::Files | QDir::Readable") << SRCDIR "entrylist/" << QStringList("*")
<< int(QDir::Files | QDir::Readable) << int(QDir::Name)
<< filterLinks(QString("file,linktofile.lnk,writable").split(','));
@ -1346,26 +1327,6 @@ void tst_QDir::dotAndDotDot()
#endif
}
#ifdef QT3_SUPPORT
/*
Tets that the setMatchAllDirs setting survies a call to setFilter.
*/
void tst_QDir::matchAllDirs()
{
QDir dir("/");
dir.setMatchAllDirs(true);
dir.setNameFilters(QStringList() << "*.foo");
dir.setFilter(QDir::Hidden);
QVERIFY(dir.matchAllDirs());
QVERIFY(dir.entryList().count() > 0);
dir.setMatchAllDirs(false);
dir.setFilter(QDir::Hidden);
QVERIFY(dir.matchAllDirs() == false);
QCOMPARE(dir.entryList().count(), 0);
}
#endif
void tst_QDir::homePath()
{
QDir homeDir = QDir::home();
@ -1890,32 +1851,6 @@ void tst_QDir::arrayOperator()
}
}
#ifdef QT3_SUPPORT
void tst_QDir::setNameFilter()
{
QStringList filters;
filters << "*.jpg" << "*.png" << "*.gif";
QStringList filters2;
filters2 << "*.cpp" << "*.h" << "*.c";
QDir dir(SRCDIR "entrylist/");
dir.setNameFilter(filters.join(";"));
QCOMPARE(filters, dir.nameFilters());
QCOMPARE(filters, dir.nameFilter().split(';'));
dir.setNameFilters(filters2);
QCOMPARE(filters2, dir.nameFilter().split(';'));
dir.setNameFilter(filters.join(" "));
QCOMPARE(filters, dir.nameFilters());
QCOMPARE(filters, dir.nameFilter().split(' '));
dir.setNameFilters(filters2);
QCOMPARE(filters2, dir.nameFilter().split(' '));
}
#endif
void tst_QDir::equalityOperator_data()
{
QTest::addColumn<QString>("leftPath");

View File

@ -42,7 +42,6 @@
#include <QtTest/QtTest>
#include <qfile.h>
#include <qdir.h>
#include <qcoreapplication.h>
@ -726,15 +725,9 @@ void tst_QFileInfo::dir()
if (absPath) {
QCOMPARE(fi.absolutePath(), expected);
QCOMPARE(fi.absoluteDir().path(), expected);
#ifdef QT3_SUPPORT
QCOMPARE(fi.dir(true).path(), expected);
#endif
} else {
QCOMPARE(fi.path(), expected);
QCOMPARE(fi.dir().path(), expected);
#ifdef QT3_SUPPORT
QCOMPARE(fi.dir(false).path(), expected);
#endif
}
}

View File

@ -43,13 +43,7 @@
#include <QtTest/QtTest>
#include <qapplication.h>
#include <qlineedit.h>
#if defined (QT3_SUPPORT)
#include <q3popupmenu.h>
#else
#include <qmenu.h>
#endif
#include <qlabel.h>
#include <qdialog.h>
#include <qevent.h>
@ -264,32 +258,6 @@ void tst_QFocusEvent::checkReason_Popup()
initWidget();
// Now test the popup reason
#if defined (QT3_SUPPORT)
Q3PopupMenu* popupMenu = new Q3PopupMenu( testFocusWidget );
popupMenu->insertItem( "Test" );
popupMenu->popup( QPoint(0,0) );
QTest::qWait(50);
QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus);
QVERIFY( childFocusWidgetOne->hasFocus() );
QVERIFY( !childFocusWidgetOne->focusInEventRecieved );
QVERIFY( childFocusWidgetOne->focusOutEventRecieved );
QVERIFY( !childFocusWidgetTwo->focusInEventRecieved );
QVERIFY( !childFocusWidgetTwo->focusOutEventRecieved );
QCOMPARE( childFocusWidgetOne->focusOutEventReason, int(Qt::PopupFocusReason));
popupMenu->hide();
QVERIFY(childFocusWidgetOne->focusInEventRecieved);
QVERIFY(childFocusWidgetOne->focusInEventGotFocus);
QVERIFY( childFocusWidgetOne->hasFocus() );
QVERIFY( childFocusWidgetOne->focusInEventRecieved );
QVERIFY( childFocusWidgetOne->focusOutEventRecieved );
QVERIFY( !childFocusWidgetTwo->focusInEventRecieved );
QVERIFY( !childFocusWidgetTwo->focusOutEventRecieved );
#else
QMenu* popupMenu = new QMenu( testFocusWidget );
popupMenu->addMenu( "Test" );
popupMenu->popup( QPoint(0,0) );
@ -314,7 +282,6 @@ void tst_QFocusEvent::checkReason_Popup()
QVERIFY( childFocusWidgetOne->focusOutEventRecieved );
QVERIFY( !childFocusWidgetTwo->focusInEventRecieved );
QVERIFY( !childFocusWidgetTwo->focusOutEventRecieved );
#endif
}
#ifdef Q_WS_MAC

View File

@ -73,7 +73,6 @@ private slots:
void create();
void createInvalidXPM();
void createFromUChar();
void convertBitOrder();
void formatHandlersInput_data();
void formatHandlersInput();
@ -265,32 +264,6 @@ void tst_QImage::createFromUChar()
QCOMPARE(i4.pixel(0,0), 6U);
}
void tst_QImage::convertBitOrder()
{
#if !defined(QT3_SUPPORT)
QSKIP("Qt compiled without Qt3Support", SkipAll);
#else
QImage i(9,5,1,2,QImage::LittleEndian);
qMemSet(i.bits(), 0, i.byteCount());
i.setDotsPerMeterX(9);
i.setDotsPerMeterY(5);
i.fill(0x12345678);
QVERIFY(!i.isNull());
QImage ni = i.convertBitOrder(QImage::BigEndian);
QVERIFY(!ni.isNull());
QVERIFY(ni.bitOrder() == QImage::BigEndian);
// A bunch of verifies to make sure that nothing was lost
QVERIFY(i.dotsPerMeterX() == ni.dotsPerMeterX());
QVERIFY(i.dotsPerMeterY() == ni.dotsPerMeterY());
QVERIFY(i.depth() == ni.depth());
QVERIFY(i.size() == ni.size());
QVERIFY(i.colorCount() == ni.colorCount());
#endif
}
void tst_QImage::formatHandlersInput_data()
{
QTest::addColumn<QString>("testFormat");

View File

@ -73,8 +73,6 @@ private slots:
void unget();
void peek();
void peekAndRead();
void getch();
void putch();
void readLine_data();
void readLine();
@ -382,47 +380,6 @@ void tst_QIODevice::peekAndRead()
QFile::remove("peektestfile");
}
void tst_QIODevice::getch()
{
#ifdef QT3_SUPPORT
QBuffer buffer;
buffer.open(QBuffer::ReadWrite);
buffer.write("\xff\x7f\x80\x00", 4);
buffer.reset();
QCOMPARE(buffer.getch(), 0xff);
QCOMPARE(buffer.getch(), 0x7f);
QCOMPARE(buffer.getch(), 0x80);
QCOMPARE(buffer.getch(), 0x00);
buffer.ungetch(0x00);
buffer.ungetch(0x80);
buffer.ungetch(0x7f);
buffer.ungetch(0xff);
QCOMPARE(buffer.getch(), 0xff);
QCOMPARE(buffer.getch(), 0x7f);
QCOMPARE(buffer.getch(), 0x80);
QCOMPARE(buffer.getch(), 0x00);
#endif
}
void tst_QIODevice::putch()
{
#ifdef QT3_SUPPORT
QBuffer buffer;
buffer.open(QBuffer::ReadWrite);
buffer.putch(0xff);
buffer.putch(0x7f);
buffer.putch(0x80);
buffer.putch(0x00);
buffer.reset();
QCOMPARE(buffer.getch(), 0xff);
QCOMPARE(buffer.getch(), 0x7f);
QCOMPARE(buffer.getch(), 0x80);
QCOMPARE(buffer.getch(), 0x00);
#endif
}
void tst_QIODevice::readLine_data()
{
QTest::addColumn<QByteArray>("data");

View File

@ -76,9 +76,6 @@ private slots:
void geometry();
void smartMaxSize();
void setLayoutBugs();
#ifdef QT3_SUPPORT
void task193350_sizeGrip();
#endif
void setContentsMargins();
void layoutItemRect();
void warnIfWrongParent();
@ -235,21 +232,6 @@ void tst_QLayout::setLayoutBugs()
QVERIFY(containerWidget.layout() == hBoxLayout);
}
#ifdef QT3_SUPPORT
void tst_QLayout::task193350_sizeGrip()
{
QDialog dialog;
dialog.setSizeGripEnabled(true);
QVBoxLayout* layout = new QVBoxLayout(&dialog);
layout->setAutoAdd(true);
new QLabel("Label", &dialog);
dialog.show();
QCOMPARE(layout->indexOf(qFindChild<QSizeGrip *>(&dialog)),-1);
}
#endif
class MyLayout : public QLayout
{
public:

View File

@ -277,11 +277,6 @@ private slots:
void QTBUG697_paletteCurrentColorGroup();
void QTBUG13520_textNotVisible();
#ifdef QT3_SUPPORT
void validateAndSet_data();
void validateAndSet();
#endif
void bidiVisualMovement_data();
void bidiVisualMovement();
@ -289,9 +284,6 @@ private slots:
void bidiLogicalMovement();
protected slots:
#ifdef QT3_SUPPORT
void lostFocus();
#endif
void editingFinished();
void onTextChanged( const QString &newString );
@ -360,9 +352,6 @@ void tst_QLineEdit::initTestCase()
connect(testWidget, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
connect(testWidget, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
connect(testWidget, SIGNAL(editingFinished()), this, SLOT(editingFinished()));
#ifdef QT3_SUPPORT
connect(testWidget, SIGNAL(lostFocus()), this, SLOT(lostFocus()));
#endif
testWidget->resize(200,50);
testWidget->show();
@ -1498,40 +1487,6 @@ void tst_QLineEdit::clear()
QCOMPARE(testWidget->text(), QString("I am Legend"));
}
#ifdef QT3_SUPPORT
void tst_QLineEdit::lostFocus()
{
editingFinished();
}
void tst_QLineEdit::validateAndSet_data()
{
QTest::addColumn<QString>("newText");
QTest::addColumn<int>("newPos");
QTest::addColumn<int>("newMarkAnchor");
QTest::addColumn<int>("newMarkDrag");
QTest::newRow("1") << QString("Hello World") << 3 << 3 << 5;
QTest::newRow("2") << QString("Hello World") << 5 << 3 << 5;
}
void tst_QLineEdit::validateAndSet()
{
QFETCH(QString, newText);
QFETCH(int, newPos);
QFETCH(int, newMarkAnchor);
QFETCH(int, newMarkDrag);
QLineEdit e;
e.validateAndSet(newText, newPos, newMarkAnchor, newMarkDrag);
QCOMPARE(e.text(), newText);
QCOMPARE(e.cursorPosition(), newPos);
QCOMPARE(e.selectedText(), newText.mid(newMarkAnchor, newMarkDrag-newMarkAnchor));
}
#endif
void tst_QLineEdit::editingFinished()
{
if (testWidget->hasAcceptableInput())
@ -2660,16 +2615,6 @@ void tst_QLineEdit::setAlignment()
#endif
QVERIFY(testWidget->alignment() == Qt::AlignLeft);
#ifdef QT3_SUPPORT
testWidget->setText("auto");
testWidget->setAlignment(Qt::AlignAuto);
#ifndef NO_PIXMAP_TESTS
#if defined Q_WS_WIN
QTEST(testWidget, "auto");
#endif
#endif
#endif
testWidget->setText("hcenter");
testWidget->setAlignment(Qt::AlignHCenter);
#ifndef NO_PIXMAP_TESTS
@ -2679,16 +2624,6 @@ void tst_QLineEdit::setAlignment()
#endif
QVERIFY(testWidget->alignment() == Qt::AlignHCenter);
#ifdef QT3_SUPPORT
testWidget->setText("auto");
testWidget->setAlignment(Qt::AlignAuto);
#ifndef NO_PIXMAP_TESTS
#if defined Q_WS_WIN
QTEST(testWidget, "auto");
#endif
#endif
#endif
testWidget->setText("right");
testWidget->setAlignment(Qt::AlignRight);
#ifndef NO_PIXMAP_TESTS
@ -2698,17 +2633,6 @@ void tst_QLineEdit::setAlignment()
#endif
QVERIFY(testWidget->alignment() == Qt::AlignRight);
#ifdef QT3_SUPPORT
testWidget->setText("auto");
testWidget->setAlignment(Qt::AlignAuto);
#ifndef NO_PIXMAP_TESTS
#if defined Q_WS_WIN
QTEST(testWidget, "auto");
#endif
#endif
QVERIFY(testWidget->alignment() == Qt::AlignAuto);
#endif
testWidget->setAlignment(Qt::AlignTop);
QVERIFY(testWidget->alignment() == Qt::AlignTop);

View File

@ -90,10 +90,6 @@ private slots:
void tearOff();
void layoutDirection();
#if defined(QT3_SUPPORT)
void indexBasedInsertion_data();
void indexBasedInsertion();
#endif
void task208001_stylesheet();
void activeSubMenuPosition();
void task242454_sizeHint();
@ -641,49 +637,6 @@ void tst_QMenu::layoutDirection()
QCOMPARE(menu.layoutDirection(), Qt::RightToLeft);
}
#if defined(QT3_SUPPORT)
void tst_QMenu::indexBasedInsertion_data()
{
QTest::addColumn<int>("indexForInsertion");
QTest::addColumn<int>("expectedIndex");
QTest::newRow("negative-index-appends") << -1 << 1;
QTest::newRow("prepend") << 0 << 0;
QTest::newRow("append") << 1 << 1;
}
void tst_QMenu::indexBasedInsertion()
{
// test the compat'ed index based insertion
QFETCH(int, indexForInsertion);
QFETCH(int, expectedIndex);
{
QMenu menu;
menu.addAction("Regular Item");
menu.insertItem("New Item", -1 /*id*/, indexForInsertion);
QAction *act = menu.actions().value(expectedIndex);
QVERIFY(act);
QCOMPARE(act->text(), QString("New Item"));
}
{
QMenu menu;
menu.addAction("Regular Item");
menu.insertSeparator(indexForInsertion);
QAction *act = menu.actions().value(expectedIndex);
QVERIFY(act);
QVERIFY(act->isSeparator());
}
}
#endif
void tst_QMenu::task208001_stylesheet()
{
//test if it crash

View File

@ -657,42 +657,6 @@ void tst_QMessageBox::testSymbols()
QSize sizeHint = mb1.sizeHint();
QVERIFY(sizeHint.width() > 20 && sizeHint.height() > 20);
#ifdef QT3_SUPPORT
//test QT3_SUPPORT stuff
QMessageBox mb4("title", "text", icon, QMessageBox::Yes, QMessageBox::No | QMessageBox::Default,
QMessageBox::Cancel, &mb1, "name", true, Qt::Dialog);
QMessageBox mb5(&mb1, "name");
QPixmap pm = QMessageBox::standardIcon(QMessageBox::Question, Qt::GUIStyle(1));
QPixmap pm2 = QMessageBox::standardIcon(QMessageBox::Question);
QVERIFY(pm.toImage() == iconPixmap.toImage());
QVERIFY(pm2.toImage() == iconPixmap.toImage());
int ret1 = QMessageBox::message("title", "text");
int ret2 = QMessageBox::message("title", "text", "OK");
int ret3 = QMessageBox::message("title", "text", "OK", &mb1);
int ret4 = QMessageBox::message("title", "text", "OK", &mb1, "name");
qDebug("%d %d %d %d", ret1, ret2, ret3, ret4);
bool ret5 = QMessageBox::query("title", "text");
bool ret6 = QMessageBox::query("title", "text", "Ja");
bool ret7 = QMessageBox::query("title", "text", "Ja", "Nein");
bool ret8 = QMessageBox::query("title", "text", "Ja", "Nein", &mb1);
bool ret9 = QMessageBox::query("title", "text", "Ja", "Nein", &mb1, "name");
qDebug("%d %d %d %d %d", ret5, ret6, ret7, ret8, ret9);
Q_UNUSED(ret1);
Q_UNUSED(ret5);
QPixmap pm3 = QMessageBox::standardIcon(QMessageBox::NoIcon);
QVERIFY(pm3.isNull());
pm3 = QMessageBox::standardIcon(QMessageBox::Information);
QVERIFY(!pm3.isNull());
#endif //QT3_SUPPORT
QMessageBox::about(&mb1, "title", "text");
QMessageBox::aboutQt(&mb1);
QMessageBox::aboutQt(&mb1, "title");

View File

@ -62,17 +62,9 @@ public:
}
bool mousePressEventRecieved;
bool mouseReleaseEventRecieved;
#ifdef QT3_SUPPORT
int mousePressStateBefore;
int mousePressStateAfter;
#endif
int mousePressButton;
int mousePressButtons;
int mousePressModifiers;
#ifdef QT3_SUPPORT
int mouseReleaseStateBefore;
int mouseReleaseStateAfter;
#endif
int mouseReleaseButton;
int mouseReleaseButtons;
int mouseReleaseModifiers;
@ -80,10 +72,6 @@ protected:
void mousePressEvent(QMouseEvent *e)
{
QWidget::mousePressEvent(e);
#ifdef QT3_SUPPORT
mousePressStateBefore = e->state();
mousePressStateAfter = e->stateAfter();
#endif
mousePressButton = e->button();
mousePressButtons = e->buttons();
mousePressModifiers = e->modifiers();
@ -93,10 +81,6 @@ protected:
void mouseReleaseEvent(QMouseEvent *e)
{
QWidget::mouseReleaseEvent(e);
#ifdef QT3_SUPPORT
mouseReleaseStateBefore = e->state();
mouseReleaseStateAfter = e->stateAfter();
#endif
mouseReleaseButton = e->button();
mouseReleaseButtons = e->buttons();
mouseReleaseModifiers = e->modifiers();
@ -125,8 +109,6 @@ private slots:
void checkMouseReleaseEvent_data();
void checkMouseReleaseEvent();
void qt3supportConstructors();
private:
MouseEventWidget* testMouseWidget;
};
@ -157,12 +139,6 @@ void tst_QMouseEvent::init()
{
testMouseWidget->mousePressEventRecieved = FALSE;
testMouseWidget->mouseReleaseEventRecieved = FALSE;
#ifdef QT3_SUPPORT
testMouseWidget->mousePressStateBefore = 0;
testMouseWidget->mousePressStateAfter = 0;
testMouseWidget->mouseReleaseStateBefore = 0;
testMouseWidget->mouseReleaseStateAfter = 0;
#endif
testMouseWidget->mousePressButton = 0;
testMouseWidget->mousePressButtons = 0;
testMouseWidget->mousePressModifiers = 0;
@ -210,13 +186,6 @@ void tst_QMouseEvent::checkMousePressEvent()
QCOMPARE(testMouseWidget->mousePressButton, button);
QCOMPARE(testMouseWidget->mousePressButtons, buttons);
QCOMPARE(testMouseWidget->mousePressModifiers, modifiers);
#ifdef QT3_SUPPORT
int stateAfter = buttons|modifiers;
int stateBefore = stateAfter & ~button;
QCOMPARE(testMouseWidget->mousePressStateBefore, stateBefore);
QCOMPARE(testMouseWidget->mousePressStateAfter, stateAfter);
#endif
QTest::mouseRelease(testMouseWidget, Qt::MouseButton(buttonPressed), Qt::KeyboardModifiers(keyPressed));
}
@ -256,35 +225,6 @@ void tst_QMouseEvent::checkMouseReleaseEvent()
QCOMPARE(testMouseWidget->mouseReleaseButton, button);
QCOMPARE(testMouseWidget->mouseReleaseButtons, buttons);
QCOMPARE(testMouseWidget->mouseReleaseModifiers, modifiers);
#ifdef QT3_SUPPORT
int stateAfter = buttons|modifiers;
int stateBefore = stateAfter|button;
QCOMPARE(testMouseWidget->mouseReleaseStateBefore, stateBefore);
QCOMPARE(testMouseWidget->mouseReleaseStateAfter, stateAfter);
#endif
}
void tst_QMouseEvent::qt3supportConstructors()
{
#if !defined(QT3_SUPPORT)
QSKIP( "No Qt3Support present", SkipAll);
#else
// make sure the state() and stateAfter() functions return the
// same thing they did in Qt 3 when using these constructors
{
QMouseEvent e(QEvent::MouseButtonPress, QPoint(0, 0), Qt::LeftButton, 0);
QCOMPARE(e.state(), Qt::ButtonState(Qt::NoButton));
QCOMPARE(e.stateAfter(), Qt::ButtonState(Qt::LeftButton));
}
{
QMouseEvent e(QEvent::MouseButtonPress, QPoint(0, 0), QPoint(0, 0), Qt::LeftButton, 0);
QCOMPARE(e.state(), Qt::ButtonState(Qt::NoButton));
QCOMPARE(e.stateAfter(), Qt::ButtonState(Qt::LeftButton));
}
#endif
}
QTEST_MAIN(tst_QMouseEvent)

View File

@ -39,7 +39,6 @@
**
****************************************************************************/
#include <QtTest/QtTest>
#include <qatomic.h>
@ -49,8 +48,6 @@
#include <qthread.h>
#include <qwaitcondition.h>
//TESTED_CLASS=
//TESTED_FILES=
@ -372,14 +369,6 @@ public:
}
};
#ifdef QT3_SUPPORT
#define VERIFY_LOCKED(x) QVERIFY((x).locked())
#define VERIFY_NLOCKED(x) QVERIFY(!(x).locked())
#else
#define VERIFY_LOCKED(x)
#define VERIFY_NLOCKED(x)
#endif // QT3_SUPPORT
void tst_QMutex::lock_unlock_locked_tryLock()
{
// normal mutex
@ -391,7 +380,6 @@ void tst_QMutex::lock_unlock_locked_tryLock()
for (int i = 0; i < iterations; ++i) {
// normal mutex
VERIFY_NLOCKED(mutex);
QVERIFY(mutex.tryLock());
mutex.unlock();
@ -400,7 +388,6 @@ void tst_QMutex::lock_unlock_locked_tryLock()
for (int j = 0; j < iterations; ++j) {
QVERIFY(thread.cond.wait(&thread.mutex, 10000));
VERIFY_LOCKED(mutex);
QVERIFY(!mutex.tryLock());
thread.cond.wakeOne();
@ -409,13 +396,11 @@ void tst_QMutex::lock_unlock_locked_tryLock()
thread.mutex.unlock();
QVERIFY(thread.wait(10000));
VERIFY_NLOCKED(mutex);
QVERIFY(mutex.tryLock());
mutex.unlock();
// recursive mutex
VERIFY_NLOCKED(rmutex);
QVERIFY(rmutex.tryLock());
QVERIFY(rmutex.tryLock());
QVERIFY(rmutex.tryLock());
@ -431,7 +416,6 @@ void tst_QMutex::lock_unlock_locked_tryLock()
for (int k = 0; k < iterations; ++k) {
QVERIFY(rthread.cond.wait(&rthread.mutex, 10000));
VERIFY_LOCKED(rmutex);
QVERIFY(!rmutex.tryLock());
rthread.cond.wakeOne();
@ -440,7 +424,6 @@ void tst_QMutex::lock_unlock_locked_tryLock()
rthread.mutex.unlock();
QVERIFY(rthread.wait(10000));
VERIFY_NLOCKED(rmutex);
QVERIFY(rmutex.tryLock());
QVERIFY(rmutex.tryLock());
QVERIFY(rmutex.tryLock());

View File

@ -40,10 +40,8 @@
****************************************************************************/
#define QT3_SUPPORT
#include <QtTest/QtTest>
#include <qcoreapplication.h>
#include <qpointer.h>
@ -2834,11 +2832,6 @@ void tst_QObject::compatibilityChildInsertedEvents()
expected =
EventSpy::EventList()
#ifdef QT_HAS_QT3SUPPORT
<< qMakePair(&object, QEvent::ChildInsertedRequest)
<< qMakePair(&object, QEvent::ChildInserted)
<< qMakePair(&object, QEvent::ChildInserted)
#endif
<< qMakePair(&object, QEvent::Type(QEvent::User + 1))
<< qMakePair(&object, QEvent::Type(QEvent::User + 2));
QCOMPARE(spy.eventList(), expected);
@ -2872,10 +2865,6 @@ void tst_QObject::compatibilityChildInsertedEvents()
expected =
EventSpy::EventList()
#ifdef QT_HAS_QT3SUPPORT
<< qMakePair(&object, QEvent::ChildInsertedRequest)
<< qMakePair(&object, QEvent::ChildInserted)
#endif
<< qMakePair(&object, QEvent::Type(QEvent::User + 1))
<< qMakePair(&object, QEvent::Type(QEvent::User + 2));
QCOMPARE(spy.eventList(), expected);

View File

@ -54,9 +54,6 @@
#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
#include <qprinter.h>
#include <math.h>
#ifdef QT3_SUPPORT
#include <q3painter.h>
#endif
#endif
#include <qpaintengine.h>
#include <qdesktopwidget.h>
@ -1271,24 +1268,6 @@ void tst_QPainter::drawRect()
QCOMPARE(painted.width(), rect.width() + increment);
QCOMPARE(painted.height(), rect.height() + increment);
}
#ifdef QT3_SUPPORT
{
if (usePen && (rect.width() < 2 || rect.height() < 2))
return;
pixmap.fill(Qt::white);
Q3Painter p(&pixmap);
p.setPen(usePen ? QPen(Qt::black) : QPen(Qt::NoPen));
p.setBrush(Qt::black);
p.drawRect(rect);
p.end();
const QRect painted = getPaintedSize(pixmap, Qt::white);
QCOMPARE(painted.width(), rect.width());
QCOMPARE(painted.height(), rect.height());
}
#endif
}
void tst_QPainter::drawRect2()
@ -1696,22 +1675,6 @@ void tst_QPainter::drawRoundRect()
QCOMPARE(painted.width(), rect.width() + increment);
QCOMPARE(painted.height(), rect.height() + increment);
}
#ifdef QT3_SUPPORT
{
pixmap.fill(Qt::white);
Q3Painter p(&pixmap);
p.setPen(usePen ? QPen(Qt::black) : QPen(Qt::NoPen));
p.setBrush(Qt::black);
p.drawRoundRect(rect);
p.end();
const QRect painted = getPaintedSize(pixmap, Qt::white);
QCOMPARE(painted.width(), rect.width());
QCOMPARE(painted.height(), rect.height());
}
#endif
}
Q_DECLARE_METATYPE(QImage::Format)

View File

@ -164,11 +164,6 @@ private slots:
void copy();
void depthOfNullObjects();
#ifdef QT3_SUPPORT
void resize();
void resizePreserveMask();
#endif
void transformed();
void transformed2();
@ -1427,53 +1422,6 @@ void tst_QPixmap::copy()
QVERIFY(pixmapsAreEqual(&trans, &transCopy));
}
#ifdef QT3_SUPPORT
void tst_QPixmap::resize()
{
QPixmap p1(10, 10);
p1.fill(Qt::red);
QPixmap p2 = p1;
QPixmap p3(50, 50);
p3.fill(Qt::red);
p1.resize(p3.size());
p1.resize(p2.size());
p3.resize(p2.size());
QCOMPARE(p1.toImage(), p2.toImage());
QCOMPARE(p1.toImage(), p3.toImage());
QBitmap b1;
b1.resize(10, 10);
QVERIFY(b1.depth() == 1);
QPixmap p4;
p4.resize(10, 10);
QVERIFY(p4.depth() != 0);
}
void tst_QPixmap::resizePreserveMask()
{
QPixmap pm(100, 100);
pm.fill(Qt::transparent);
QPainter p(&pm);
p.fillRect(10, 10, 80, 80, Qt::red);
p.drawRect(0, 0, 99, 99);
p.end();
QBitmap mask = pm.mask();
pm.resize(50, 50);
QCOMPARE(pm.mask().toImage(), mask.toImage().copy(0, 0, 50, 50));
pm = QPixmap(100, 100);
pm.fill(Qt::red);
pm.setMask(mask);
pm.resize(50, 50);
QCOMPARE(pm.mask().toImage(), mask.toImage().copy(0, 0, 50, 50));
}
#endif
void tst_QPixmap::depthOfNullObjects()
{
QBitmap b1;

View File

@ -39,19 +39,13 @@
**
****************************************************************************/
#include <QtTest/QtTest>
#include <qprinter.h>
#include <qpagesetupdialog.h>
#include <qpainter.h>
#include <qprintdialog.h>
#include <qprinterinfo.h>
#ifdef QT3_SUPPORT
#include <q3paintdevicemetrics.h>
#endif
#include <qvariant.h>
#include <qpainter.h>
#include <qprintengine.h>
@ -421,23 +415,6 @@ void tst_QPrinter::testMargins()
if (withPainter)
painter = new QPainter(&printer);
#ifdef QT3_SUPPORT
Q3PaintDeviceMetrics metrics(&printer);
int pwidth = metrics.width();
int pheight = metrics.height();
if (orientation == QPrinter::Portrait) {
QVERIFY(pheight >= pwidth);
} else {
QVERIFY(pwidth >= pheight);
}
if (fullpage) {
QCOMPARE(metrics.widthMM(), width);
QCOMPARE(metrics.heightMM(), height);
}
#endif
if (painter)
delete painter;
}

View File

@ -101,7 +101,6 @@ private slots:
void testArrays_data();
void testArrays();
void testEscapes();
void testCompatFunctions();
void testCaseSensitivity_data();
void testCaseSensitivity();
void testErrorHandling_data();
@ -136,52 +135,11 @@ private slots:
void qtbug_13249();
#endif
/*
These tests were developed for the Qt 3 QSettings class.
*/
#ifdef QT3_SUPPORT
void oldWriteEntryIni_data();
void oldWriteEntryIni();
void oldReadEntryIni_data();
void oldReadEntryIni();
void oldBeginGroup_data();
void oldBeginGroup();
void oldEndGroup_data();
void oldEndGroup();
void oldResetGroup_data();
void oldResetGroup();
void oldEntryList_data();
void oldEntryList();
void oldWriteEntry_QString_bool_data();
void oldWriteEntry_QString_bool();
void oldWriteEntry_QString_double_data();
void oldWriteEntry_QString_double();
void oldWriteEntry_QString_int_data();
void oldWriteEntry_QString_int();
void oldWriteEntry_QString_QString_data();
void oldWriteEntry_QString_QString();
void oldWriteEntry_QString_QStringList_data();
void oldWriteEntry_QString_QStringList();
void oldWriteEntry_QString_QStringList_QChar_data();
void oldWriteEntry_QString_QStringList_QChar();
void oldReadListEntry_QString();
void oldReadListEntry_QString_QChar();
void oldReadEntry();
void oldReadNumEntry();
void oldReadDoubleEntry();
void oldReadBoolEntry();
void oldGlobalVersusLocal();
void oldRemoveEntry();
#endif
void testVariantTypes_data();
void testVariantTypes();
void rainersSyncBugOnMac_data();
void rainersSyncBugOnMac();
void recursionBug();
#ifdef QT3_SUPPORT
void setPathBug();
#endif
void testByteArray_data();
void testByteArray();
@ -2529,104 +2487,6 @@ void tst_QSettings::testEscapes()
#endif
}
void tst_QSettings::testCompatFunctions()
{
#ifdef QT3_SUPPORT
QSettings settings1("software.org", "KillerAPP");
bool ok;
ok = settings1.writeEntry("/root/bool", true);
QVERIFY(ok);
ok = settings1.writeEntry("/root/double", 1.4);
QVERIFY(ok);
ok = settings1.writeEntry("/root/int", 66666);
QVERIFY(ok);
ok = settings1.writeEntry("/root/const char */1", "Hello");
QVERIFY(ok);
ok = settings1.writeEntry("/root/const char */2", "");
QVERIFY(ok);
ok = settings1.writeEntry("/root/const char */3", (const char *)0);
QVERIFY(ok);
ok = settings1.writeEntry("/root/QString/1", QString("Hello"));
QVERIFY(ok);
ok = settings1.writeEntry("/root/QString/2", QString(""));
QVERIFY(ok);
ok = settings1.writeEntry("/root/QString/3", QString());
QVERIFY(ok);
ok = settings1.writeEntry("/root/QStringList/1", QStringList());
QVERIFY(ok);
ok = settings1.writeEntry("/root/QStringList/2", QStringList() << "");
QVERIFY(ok);
ok = settings1.writeEntry("/root/QStringList/3", QStringList() << "a" << "" << "b");
QVERIFY(ok);
ok = settings1.writeEntry("/root/QStringList/4", QStringList() << "a" << "" << "b", ':');
QVERIFY(ok);
QCOMPARE(settings1.readBoolEntry("/root/bool"), true);
QCOMPARE(settings1.readDoubleEntry("/root/double"), 1.4);
QCOMPARE(settings1.readNumEntry("/root/int"), 66666);
QCOMPARE(settings1.readEntry("/root/const char */1"), QString("Hello"));
QCOMPARE(settings1.readEntry("/root/const char */2"), QString(""));
QCOMPARE(settings1.readEntry("/root/const char */3"), QString());
QCOMPARE(settings1.readEntry("/root/QString/1"), QString("Hello"));
QCOMPARE(settings1.readEntry("/root/QString/2"), QString(""));
QCOMPARE(settings1.readEntry("/root/QString/3"), QString());
QCOMPARE(settings1.readListEntry("/root/QStringList/1"), QStringList());
QCOMPARE(settings1.readListEntry("/root/QStringList/2"), QStringList() << "");
QCOMPARE(settings1.readListEntry("/root/QStringList/3"), QStringList() << "a" << "" << "b");
QCOMPARE(settings1.readListEntry("/root/QStringList/4", ':'), QStringList() << "a" << "" << "b");
QCOMPARE(settings1.readEntry("/root/QStringList/4"), QString("a::b"));
QStringList actual, expectedSubKey, expectedEntry;
settings1.clear();
QStringList initialKeys = settings1.allKeys();
settings1.setValue("/alpha/beta", 5);
settings1.setValue("/alpha/beta/gamma", 5);
settings1.setValue("/alpha/beta/delta", 5);
settings1.setValue("/alpha/epsilon/zeta/eta", 5);
settings1.setValue("/alpha/theta", 5);
settings1.beginGroup("/alpha");
QCOMPARE(settings1.group(), QString("alpha"));
actual = settings1.entryList("");
actual.sort();
expectedEntry = QStringList() << "beta" << "theta";
QCOMPARE(actual, expectedEntry);
actual = settings1.subkeyList("");
actual.sort();
expectedSubKey = QStringList() << "beta" << "epsilon";
QCOMPARE(actual, expectedSubKey);
settings1.endGroup();
actual = settings1.entryList("alpha");
actual.sort();
QCOMPARE(actual, expectedEntry);
actual = settings1.subkeyList("alpha");
actual.sort();
QCOMPARE(actual, expectedSubKey);
actual = settings1.entryList("");
QVERIFY(containsSubList(initialKeys, actual));
actual = settings1.subkeyList("");
QVERIFY(actual.contains("alpha"));
actual = settings1.subkeyList("foo/bar/baz");
QVERIFY(actual.isEmpty());
actual = settings1.subkeyList("alpha/epsilon");
expectedSubKey = QStringList() << "zeta";
QCOMPARE(actual, expectedSubKey);
#else
QSKIP("Compiled without Qt3Support", SkipAll);
#endif
}
void tst_QSettings::testCaseSensitivity_data()
{
populateWithFormats();
@ -2711,550 +2571,6 @@ void tst_QSettings::testCaseSensitivity()
}
}
#ifdef QT3_SUPPORT
void tst_QSettings::oldEntryList_data()
{
oldWriteEntry_data();
}
void tst_QSettings::oldReadEntryIni_data()
{
oldWriteEntry_data();
}
void tst_QSettings::oldWriteEntryIni_data()
{
oldWriteEntry_data();
}
void tst_QSettings::oldReadEntry_data()
{
oldWriteEntry_data();
}
void tst_QSettings::oldWriteEntry_data()
{
// define the test elements we're going to use
QTest::addColumn<QString>("string");
QTest::addColumn<QString>("empty");
QTest::addColumn<QString>("unicode");
QTest::addColumn<int>("integer");
QTest::addColumn<bool>("boolean");
QTest::addColumn<double>("floating");
QTest::addColumn<QStringList>("list");
QStringList list0;
list0 << "elem1";
list0 << "elem2";
list0 << "elem3";
list0 << "elem4";
QTest::newRow( "data0") << QString("blah") << QString("") << QString( QChar(0x0E12) ) << 99 << TRUE << 3.1415 << list0;
QStringList list1;
list1 << " elem1";
list1 << "elem2 ";
list1 << QString();
list1 << "";
list1 << "elem3";
QTest::newRow( "data1") << QString("foo") << QString("") << QString( QChar(0xFEFC) ) << -150 << FALSE << 0.0 << list1;
}
void tst_QSettings::oldWriteEntryHelper( QSettings &settings )
{
QFETCH( QString, string );
QFETCH( QString, empty );
QFETCH( QString, unicode );
QFETCH( int, integer );
QFETCH( bool, boolean );
QFETCH( double, floating );
QFETCH( QStringList, list );
QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting", string ) );
QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/String", string ) );
QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/Empty", empty ) );
QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/Unicode", unicode ) );
QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/Integer", integer ) );
QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/Boolean", boolean ) );
QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/Floating", floating ) );
QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/List", list ) );
}
void tst_QSettings::oldReadEntryHelper( QSettings &settings )
{
bool ok;
QFETCH( QString, string );
QFETCH( QString, empty );
QFETCH( QString, unicode );
QFETCH( int, integer );
QFETCH( bool, boolean );
QFETCH( double, floating );
QFETCH( QStringList, list );
QCOMPARE( settings.readEntry( "/Trolltech/QSettingsTesting", QString::null, &ok ), string );
QVERIFY( ok );
QCOMPARE( settings.readEntry( "/Trolltech/QSettingsTesting/String", QString::null, &ok ), string );
QVERIFY( ok );
QCOMPARE( settings.readEntry( "/Trolltech/QSettingsTesting/Empty", QString::null, &ok ), empty );
QVERIFY( ok );
QCOMPARE( settings.readEntry( "/Trolltech/QSettingsTesting/Unicode", QString::null, &ok ), unicode );
QVERIFY( ok );
QCOMPARE( settings.readNumEntry( "/Trolltech/QSettingsTesting/Integer", 0, &ok ), integer );
QVERIFY( ok );
QCOMPARE( settings.readBoolEntry( "/Trolltech/QSettingsTesting/Boolean", 0, &ok ), boolean );
QVERIFY( ok );
QCOMPARE( settings.readDoubleEntry( "/Trolltech/QSettingsTesting/Floating", 0, &ok ), floating );
QVERIFY( ok );
QCOMPARE( settings.readListEntry( "/Trolltech/QSettingsTesting/List", &ok ), list );
QVERIFY( ok );
settings.readListEntry( "/Trolltech/QSettingsTesting/NonExistingValue", &ok );
QVERIFY( !ok );
}
void tst_QSettings::oldWriteEntryIni()
{
QSettings settings(QSettings::IniFormat, QSettings::UserScope, "software.org", "KillerAPP");
oldWriteEntryHelper(settings);
}
void tst_QSettings::oldReadEntryIni()
{
{
QSettings writeSettings(QSettings::IniFormat, QSettings::UserScope, "software.org", "KillerAPP");
oldWriteEntryHelper( writeSettings );
}
{
QSettings readSettings(QSettings::IniFormat, QSettings::UserScope, "software.org", "KillerAPP");
oldReadEntryHelper( readSettings );
}
}
void tst_QSettings::oldEndGroup_data()
{
oldBeginGroup_data();
}
void tst_QSettings::oldResetGroup_data()
{
oldBeginGroup_data();
}
void tst_QSettings::oldBeginGroup_data()
{
// define the test elements we're going to use
QTest::addColumn<QString>("group");
QTest::addColumn<QString>("value");
QTest::newRow( "data0") << QString("blah") << "value";
QTest::newRow( "data1") << QString("") << "first/value";
QTest::newRow( "data2") << QString("first/second") << "value";
QTest::newRow( "data3") << QString("first/second/third") << "value";
QTest::newRow( "data4") << QString("first/second/third") << "value";
}
void tst_QSettings::oldBeginGroup()
{
bool ok;
QFETCH( QString, group );
QFETCH( QString, value );
QSettings settings("software.org", "KillerAPP");
QCOMPARE(settings.group(), QString());
settings.beginGroup( group );
QCOMPARE(settings.group(), group);
QVERIFY( settings.writeEntry( "/" + value, value ) );
QCOMPARE( settings.readEntry( "/" + value ), value );
settings.endGroup();
QCOMPARE( settings.readEntry( group + "/" + value, QString::null, &ok ), value );
QVERIFY( ok );
}
void tst_QSettings::oldEndGroup()
{
QFETCH( QString, group );
QSettings settings("software.org", "KillerAPP");
QCOMPARE( settings.group(), QString() );
settings.beginGroup( group );
settings.endGroup();
QCOMPARE( settings.group(), QString() );
settings.beginGroup( group );
settings.beginGroup( group );
settings.endGroup();
QCOMPARE( settings.group(), group );
settings.endGroup();
QCOMPARE( settings.group(), QString() );
QTest::ignoreMessage(QtWarningMsg, "QSettings::endGroup: No matching beginGroup()");
settings.endGroup();
QCOMPARE( settings.group(), QString() );
}
void tst_QSettings::oldResetGroup()
{
QFETCH( QString, group );
QSettings settings("software.org", "KillerAPP");
settings.beginGroup( group );
settings.resetGroup();
QCOMPARE( settings.group(), QString() );
}
void tst_QSettings::oldEntryList()
{
{
QSettings writeSettings("software.org", "KillerAPP");
oldWriteEntryHelper( writeSettings );
}
QStringList entryKeys;
entryKeys << "String" << "Empty" << "Unicode" << "Integer" << "Boolean" << "Floating" << "List";
QSettings readSettings("software.org", "KillerAPP");
QStringList entryList = readSettings.entryList( "/Trolltech/QSettingsTesting/" );
entryKeys.sort();
entryList.sort();
QCOMPARE( entryKeys, entryList );
}
void tst_QSettings::oldWriteEntry_QString_bool_data()
{
QTest::addColumn<bool>("b");
QTest::newRow( "false" ) << bool(FALSE);
QTest::newRow( "true" ) << bool(TRUE);
}
void tst_QSettings::oldWriteEntry_QString_bool()
{
{
QSettings writeSettings("software.org", "KillerAPP");
QFETCH( bool, b );
QVERIFY( writeSettings.writeEntry( "/Trolltech/QSettingsTesting/Boolean", b ) );
}
{
QSettings readSettings("software.org", "KillerAPP");
QFETCH( bool, b );
bool ok = FALSE;
QCOMPARE( readSettings.readBoolEntry( "/Trolltech/QSettingsTesting/Boolean", 0, &ok ), b );
QVERIFY( ok );
}
}
void tst_QSettings::oldWriteEntry_QString_double_data()
{
QTest::addColumn<double>("f");
QTest::newRow( "data0" ) << 3.1415;
QTest::newRow( "data1" ) << 0.0;
QTest::newRow( "data2" ) << 0.0000000000000000000000000001;
}
void tst_QSettings::oldWriteEntry_QString_double()
{
{
QSettings writeSettings("software.org", "KillerAPP");
QFETCH( double, f );
QVERIFY( writeSettings.writeEntry( "/Trolltech/QSettingsTesting/Floating", f ) );
}
{
QSettings readSettings("software.org", "KillerAPP");
QFETCH( double, f );
bool ok = FALSE;
QCOMPARE( readSettings.readDoubleEntry( "/Trolltech/QSettingsTesting/Floating", 0, &ok ), f );
QVERIFY( ok );
}
}
void tst_QSettings::oldWriteEntry_QString_int_data()
{
QTest::addColumn<int>("i");
QTest::newRow( "data0" ) << int(0);
QTest::newRow( "data1" ) << int(1);
QTest::newRow( "data2" ) << int(11);
QTest::newRow( "data3" ) << int(111);
QTest::newRow( "data4" ) << int(1111);
QTest::newRow( "data5" ) << int(11111);
QTest::newRow( "data6" ) << int(-1);
QTest::newRow( "data7" ) << int(-11);
QTest::newRow( "data8" ) << int(-111);
QTest::newRow( "data9" ) << int(-1111);
QTest::newRow( "data10" ) << int(-11111);
}
void tst_QSettings::oldWriteEntry_QString_int()
{
{
QSettings writeSettings("software.org", "KillerAPP");
QFETCH( int, i );
QVERIFY( writeSettings.writeEntry( "/Trolltech/QSettingsTesting/Integer", i ) );
}
{
QSettings readSettings("software.org", "KillerAPP");
QFETCH( int, i );
bool ok = FALSE;
QCOMPARE( readSettings.readNumEntry( "/Trolltech/QSettingsTesting/Integer", 0, &ok ), i );
QVERIFY( ok );
}
}
void tst_QSettings::oldWriteEntry_QString_QString_data()
{
QTest::addColumn<QString>("s");
QTest::newRow( "data0" ) << QString( "blah" );
QTest::newRow( "data1" ) << QString( "" );
QTest::newRow( "data2" ) << QString( QChar(0x0E12) ); // unicode
QTest::newRow( "data3" ) << QString("foo");
// QTest::newRow( "data4" ) << QString::null; // nul string (not supported on Windows!)
QTest::newRow( "data5" ) << QString( QChar(0xFEFC) ); // more unicode
QTest::newRow( "data6" ) << QString( "This is s short string" );
QTest::newRow( "data7" ) << QString( "This is a string with a cr\nand some text on the second line" );
QTest::newRow( "data8" ) << QString( "\n" );
QTest::newRow( "data9" ) << QString( "01234567890, abcdefghijklmnopqrestuvxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^&*()_+=-[{]}\\|'\":;/?.>,<" );
}
void tst_QSettings::oldWriteEntry_QString_QString()
{
{
QSettings writeSettings("software.org", "KillerAPP");
QFETCH( QString, s );
QVERIFY( writeSettings.writeEntry( "/Trolltech/QSettingsTesting/String", s ) );
}
{
QSettings readSettings("software.org", "KillerAPP");
QFETCH( QString, s );
bool ok = FALSE;
QCOMPARE( readSettings.readEntry( "/Trolltech/QSettingsTesting/String", QString::null, &ok ), s );
QVERIFY( ok );
}
}
void tst_QSettings::oldWriteEntry_QString_QStringList_data()
{
QTest::addColumn<QStringList>("l");
QStringList list0;
list0 << "elem1";
list0 << "elem2";
list0 << "elem3";
list0 << "elem4";
QTest::newRow( "data0") << list0;
QStringList list1;
list1 << " elem1";
list1 << "elem2 ";
list1 << QString();
list1 << "";
list1 << "elem3";
QTest::newRow( "data1") << list1;
QStringList list2;
list2 << " elem1";
list2 << "elem2 bla bla bla, yada yada, 01234567890, abcdefghijklmnopqrestuvxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^&*()_+=-[{]}\\|'\":;/?.>,<";
list1 << QString();
list2 << "\n";
list2 << "elem3\nand another line";
QTest::newRow( "data2") << list2;
}
void tst_QSettings::oldWriteEntry_QString_QStringList()
{
{
QSettings writeSettings("software.org", "KillerAPP");
QFETCH( QStringList, l );
QVERIFY( writeSettings.writeEntry( "/Trolltech/QSettingsTesting/List", l ) );
}
{
QSettings readSettings("software.org", "KillerAPP");
QFETCH( QStringList, l );
bool ok = FALSE;
QCOMPARE( readSettings.readListEntry( "/Trolltech/QSettingsTesting/List", &ok ), l );
QVERIFY( ok );
}
}
void tst_QSettings::oldWriteEntry_QString_QStringList_QChar_data()
{
QTest::addColumn<QStringList>("l");
QTest::addColumn<QString>("sep");
QStringList list0;
list0 << "elem1";
list0 << "elem2";
list0 << "elem3";
list0 << "elem4";
QTest::newRow( "data00") << list0 << "\\";
QTest::newRow( "data01") << list0 << "/";
QTest::newRow( "data02") << list0 << " ";
QStringList list1;
list1 << " elem1";
list1 << "elem2 ";
list1 << "elem3";
QTest::newRow( "data10") << list1 << "\\";
QTest::newRow( "data11") << list1 << "/";
QTest::newRow( "data12") << list1 << "&";
QStringList list2;
list2 << " elem1";
list2 << "elem2 bla bla bla, yada yada, 01234567890, abcdefghijklmnopqrestuvxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^*()_+=-[{]}\\|/'\":;?.>,<";
list2 << "\n";
list2 << "elem3\nand another line";
QTest::newRow( "data20") << list2 << "&";
// an empty stringlist should be stored as an empty string (and return an empty stringlist?)
QStringList list3;
QTest::newRow( "data30") << list3 << "/";
}
void tst_QSettings::oldWriteEntry_QString_QStringList_QChar()
{
// edba:
// data10, data11, data12, data20, data21 and data22 currently fail.
// This is because the list DOES contain the separator which is a fail IMO, so i
// expect the writeEntry to return FALSE (but it doesn't).
// If my interpretation of the doc is wrong, then the separators should be deleted from
// data10 .. data22.
{
QSettings writeSettings("software.org", "KillerAPP");
QFETCH( QStringList, l );
QFETCH( QString, sep );
QVERIFY( writeSettings.writeEntry( "/Trolltech/QSettingsTesting/List", l, QChar(sep[0]) ) );
}
{
QSettings readSettings("software.org", "KillerAPP");
QFETCH( QStringList, l );
QFETCH( QString, sep );
bool ok = FALSE;
QStringList actual;
actual = readSettings.readListEntry( "/Trolltech/QSettingsTesting/List", QChar(sep[0]), &ok );
QVERIFY2( ok, "Read the stringlist from the settings" );
QCOMPARE( actual, l );
}
}
void tst_QSettings::oldReadListEntry_QString()
{
DEPENDS_ON( "writeEntry_QString_QStringList" );
}
void tst_QSettings::oldReadListEntry_QString_QChar()
{
DEPENDS_ON( "writeEntry_QString_QStringList_QChar" );
}
void tst_QSettings::oldReadEntry()
{
DEPENDS_ON( "writeEntry_QString_QString" );
}
void tst_QSettings::oldReadNumEntry()
{
DEPENDS_ON( "writeEntry_QString_int" );
}
void tst_QSettings::oldReadDoubleEntry()
{
DEPENDS_ON( "writeEntry_QString_double" );
}
void tst_QSettings::oldReadBoolEntry()
{
DEPENDS_ON( "writeEntry_QString_bool" );
}
void tst_QSettings::oldRemoveEntry()
{
// we'll use this one later
QSettings firstSettings("software.org", "KillerAPP");
// first write a key
{
QSettings writeSettings("software.org", "KillerAPP");
writeSettings.writeEntry( "/Trolltech/QSettingsTesting/removeEntry", "foobar" );
}
// check that the key exists
{
QSettings readSettings("software.org", "KillerAPP");
bool ok = FALSE;
QString foo = readSettings.readEntry( "/Trolltech/QSettingsTesting/removeEntry", QString::null, &ok );
QVERIFY( ok );
QVERIFY( foo == "foobar" );
// and remove it
QVERIFY( readSettings.removeEntry( "/Trolltech/QSettingsTesting/removeEntry") );
// check that it is gone
QString foo2 = readSettings.readEntry( "/Trolltech/QSettingsTesting/removeEntry", QString::null, &ok );
QVERIFY( ok == FALSE );
QVERIFY( foo2 == "" );
}
// Take another chance with a fresh instance
{
QSettings readSettings("software.org", "KillerAPP");
bool ok = FALSE;
QString foo = readSettings.readEntry( "/Trolltech/QSettingsTesting/removeEntry", QString::null, &ok );
QVERIFY( ok == FALSE );
QVERIFY( foo == "" );
}
// and another chance with an instance that existed already
{
bool ok = FALSE;
QString foo = firstSettings.readEntry( "/Trolltech/QSettingsTesting/removeEntry", QString::null, &ok );
QVERIFY( ok == FALSE );
QVERIFY( foo == "" );
}
}
void tst_QSettings::oldGlobalVersusLocal()
{
{ //write global
QSettings settings("foo");
settings.setPath("software.org", "KillerAPP", QSettings::Global);
settings.writeEntry("/vs/just_global/", "from Global");
settings.writeEntry("/vs/local_and_global/", "from Global");
}
{ //write local
QSettings settings("bar");
settings.setPath("software.org", "KillerAPP", QSettings::User);
settings.writeEntry("/vs/local_and_global/", "from User");
}
bool ok;
{
QSettings settings("baz");
settings.setPath("software.org", "KillerAPP", QSettings::User);
QString just_global = settings.readEntry("/vs/just_global/", "not_available", &ok);
QVERIFY(ok);
QCOMPARE(just_global, QString("from Global"));
QString local_and_global = settings.readEntry("/vs/local_and_global/", "not_available", &ok);
QVERIFY(ok);
QCOMPARE(local_and_global, QString("from User"));
}
{
QSettings settings("bat");
settings.setPath("software.org", "KillerAPP", QSettings::Global);
QString just_global = settings.readEntry("/vs/just_global/", "not_available", &ok);
QVERIFY(ok);
QCOMPARE(just_global, QString("from Global"));
QString local_and_global = settings.readEntry("/vs/local_and_global/", "not_available", &ok);
QVERIFY(ok);
QCOMPARE(local_and_global, QString("from Global"));
}
}
#endif // QT3_SUPPORT
void tst_QSettings::fileName()
{
#ifdef Q_OS_MAC
@ -3792,19 +3108,6 @@ void tst_QSettings::recursionBug()
}
}
#ifdef QT3_SUPPORT
void tst_QSettings::setPathBug()
{
QSettings settings("software.org", "KillerAPP", this);
settings.setPath("foo.org", "Bar", QSettings::User);
QVERIFY(settings.parent() == this);
settings.setValue("blah", "BAZ");
settings.setPath("bar.org", "Baz", QSettings::User);
settings.setValue("blah", "BAZ");
QVERIFY(settings.parent() == this);
}
#endif
#if defined(Q_OS_WIN)
static DWORD readKeyType(HKEY handle, const QString &rSubKey)

View File

@ -45,9 +45,6 @@
#include <qsqldatabase.h>
#include <qsqlerror.h>
#include <qsqlquery.h>
#ifdef QT3_SUPPORT
#include <q3sqlcursor.h>
#endif
#include <qsqlrecord.h>
#include <qsql.h>
#include <qsqlresult.h>
@ -149,47 +146,6 @@ void tst_QSql::basicDriverTest()
QCOMPARE( rInf.count(), 2 );
QCOMPARE( rInf.fieldName( 0 ).toLower(), QString( "id" ) );
QCOMPARE( rInf.fieldName( 1 ).toLower(), QString( "name" ) );
#ifdef QT3_SUPPORT
QSqlRecord* rec = 0;
Q3SqlCursor cur( tableName, true, db );
QVERIFY_SQL( cur, select() );
QCOMPARE( cur.count(), 2 );
QCOMPARE( cur.fieldName( 0 ).lower(), QString( "id" ) );
QCOMPARE( cur.fieldName( 1 ).lower(), QString( "name" ) );
rec = cur.primeDelete();
rec->setGenerated( 0, false );
rec->setGenerated( 1, false );
QVERIFY_SQL( cur, del() );
QVERIFY_SQL( cur, select() );
QCOMPARE( cur.at(), int( QSql::BeforeFirst ) );
QVERIFY( !cur.next() );
rec = cur.primeInsert();
rec->setValue( 0, 1 );
rec->setValue( 1, QString( "Harry" ) );
QVERIFY_SQL( cur, insert( false ) );
rec = cur.primeInsert();
rec->setValue( 0, 2 );
rec->setValue( 1, QString( "Trond" ) );
QVERIFY_SQL( cur, insert( true ) );
QVERIFY_SQL( cur, select( cur.index( QString( "id" ) ) ) );
QVERIFY_SQL( cur, next() );
QCOMPARE( cur.value( 0 ).toInt(), 1 );
QCOMPARE( cur.value( 1 ).toString().stripWhiteSpace(), QString( "Harry" ) );
QVERIFY_SQL( cur, next() );
QCOMPARE( cur.value( 0 ).toInt(), 2 );
QCOMPARE( cur.value( 1 ).toString().stripWhiteSpace(), QString( "Trond" ) );
QVERIFY( !cur.next() );
QVERIFY_SQL( cur, first() );
rec = cur.primeUpdate();
rec->setValue( 1, QString( "Vohi" ) );
QVERIFY_SQL( cur, update( true ) );
QVERIFY_SQL( cur, select( "id = 1" ) );
QVERIFY_SQL( cur, next() );
QCOMPARE( cur.value( 0 ).toInt(), 1 );
QCOMPARE( cur.value( 1 ).toString().stripWhiteSpace(), QString( "Vohi" ) );
#endif
}
dbs.close();

View File

@ -44,11 +44,6 @@
#include <qsqldatabase.h>
#include <qsqlquery.h>
#include <qsqldriver.h>
#ifdef QT3_SUPPORT
#include <q3sqlcursor.h>
#include <q3sqlrecordinfo.h>
#include <q3cstring.h>
#endif
#include <qsqlrecord.h>
#include <qsqlfield.h>
#include <qsqlindex.h>
@ -130,8 +125,6 @@ private slots:
//problem specific tests
void alterTable_data() { generic_data(); }
void alterTable();
void recordNonSelect_data() { generic_data(); }
void recordNonSelect();
void caseSensivity_data() { generic_data(); }
void caseSensivity();
void noEscapedFieldNamesInRecord_data() { generic_data(); }
@ -211,13 +204,8 @@ private:
void populateTestTables(QSqlDatabase db);
void generic_data(const QString &engine=QString());
#ifdef QT3_SUPPORT
void testRecordInfo(const FieldDef fieldDefs[], const Q3SqlRecordInfo& inf);
#endif
void testRecord(const FieldDef fieldDefs[], const QSqlRecord& inf, QSqlDatabase db);
void commonFieldTest(const FieldDef fieldDefs[], QSqlDatabase, const int);
void checkValues(const FieldDef fieldDefs[], QSqlDatabase db);
void checkNullValues(const FieldDef fieldDefs[], QSqlDatabase db);
tst_Databases dbs;
};
@ -238,11 +226,7 @@ struct FieldDef {
{
QString rt = typeName;
rt.replace(QRegExp("\\s"), QString("_"));
#ifdef QT3_SUPPORT
int i = rt.find("(");
#else
int i = rt.indexOf("(");
#endif
if (i == -1)
i = rt.length();
if (i > 20)
@ -482,31 +466,6 @@ void tst_QSqlDatabase::open()
}
}
void tst_QSqlDatabase::recordNonSelect()
{
#ifdef QT3_SUPPORT
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
QSqlQuery q(db);
// nothing should happen on an empty query
QSqlRecord rec = db.record(q);
QVERIFY(rec.isEmpty());
Q3SqlRecordInfo rInf = db.recordInfo(q);
QVERIFY(rInf.isEmpty());
QVERIFY_SQL(q, exec("create table " + qTableName("qtest_temp", __FILE__) + " (id int)"));
// query without result set should return empty record
rec = db.record(q);
QVERIFY(rec.isEmpty());
rInf = db.recordInfo(q);
QVERIFY(rInf.isEmpty());
#endif
}
void tst_QSqlDatabase::tables()
{
QFETCH(QString, dbName);
@ -612,18 +571,10 @@ void tst_QSqlDatabase::alterTable()
QVERIFY_SQL(q, exec("create table " + qtestalter + " (F1 char(20), F2 char(20), F3 char(20))"));
QSqlRecord rec = db.record(qtestalter);
QCOMPARE((int)rec.count(), 3);
#ifdef QT3_SUPPORT
Q3SqlRecordInfo rinf = db.recordInfo(qtestalter);
QCOMPARE((int)rinf.count(), 3);
#endif
int i;
for (i = 0; i < 3; ++i) {
QCOMPARE(rec.field(i).name().toUpper(), QString("F%1").arg(i + 1));
#ifdef QT3_SUPPORT
QCOMPARE(rinf[ i ].name().upper(), QString("F%1").arg(i + 1));
#endif
}
if (!q.exec("alter table " + qtestalter + " drop column F2")) {
@ -631,36 +582,13 @@ void tst_QSqlDatabase::alterTable()
}
rec = db.record(qtestalter);
#ifdef QT3_SUPPORT
rinf = db.recordInfo(qtestalter);
#endif
QCOMPARE((int)rec.count(), 2);
#ifdef QT3_SUPPORT
QCOMPARE((int)rinf.count(), 2);
#endif
QCOMPARE(rec.field(0).name().toUpper(), QString("F1"));
QCOMPARE(rec.field(1).name().toUpper(), QString("F3"));
#ifdef QT3_SUPPORT
QCOMPARE(rinf[ 0 ].name().upper(), QString("F1"));
QCOMPARE(rinf[ 1 ].name().upper(), QString("F3"));
#endif
q.exec("select * from " + qtestalter);
#ifdef QT3_SUPPORT
rec = db.record(q);
rinf = db.recordInfo(q);
QCOMPARE((int)rec.count(), 2);
QCOMPARE((int)rinf.count(), 2);
QCOMPARE(rec.field(0).name().upper(), QString("F1"));
QCOMPARE(rec.field(1).name().upper(), QString("F3"));
QCOMPARE(rinf[ 0 ].name().upper(), QString("F1"));
QCOMPARE(rinf[ 1 ].name().upper(), QString("F3"));
#endif
}
#if 0
@ -684,27 +612,7 @@ void tst_QSqlDatabase::record()
const int fieldCount = createFieldTable(fieldDefs, db);
QVERIFY(fieldCount > 0);
// doesn't work with oracle: checkNullValues(fieldDefs, db);
commonFieldTest(fieldDefs, db, fieldCount);
for (int i = 0; i < ITERATION_COUNT; ++i) {
checkValues(fieldDefs, db);
}
}
#endif
#ifdef QT3_SUPPORT
void tst_QSqlDatabase::testRecordInfo(const FieldDef fieldDefs[], const Q3SqlRecordInfo& inf)
{
int i = 0;
for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) {
QCOMPARE(inf[i+1].name().upper(), fieldDefs[ i ].fieldName().upper());
if (inf[i+1].type() != fieldDefs[ i ].type) {
QFAIL(QString(" Expected: '%1' Received: '%2' for field %3 in testRecordInfo").arg(
QVariant::typeToName(fieldDefs[ i ].type)).arg(
QVariant::typeToName(inf[i+1].type())).arg(
fieldDefs[ i ].fieldName()));
}
}
}
#endif
@ -732,126 +640,12 @@ void tst_QSqlDatabase::commonFieldTest(const FieldDef fieldDefs[], QSqlDatabase
{
CHECK_DATABASE(db);
// check whether recordInfo returns the right types
#ifdef QT3_SUPPORT
Q3SqlRecordInfo inf = db.recordInfo(qTableName("qtestfields", __FILE__));
QCOMPARE((int)inf.count(), fieldCount+1);
testRecordInfo(fieldDefs, inf);
#endif
QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__));
QCOMPARE((int)rec.count(), fieldCount+1);
testRecord(fieldDefs, rec, db);
QSqlQuery q(db);
QVERIFY_SQL(q, exec("select * from " + qTableName("qtestfields", __FILE__)));
#ifdef QT3_SUPPORT
inf = db.recordInfo(q);
QCOMPARE((int)inf.count(), fieldCount+1);
testRecordInfo(fieldDefs, inf);
rec = db.record(q);
QCOMPARE((int)rec.count(), fieldCount+1);
testRecord(fieldDefs, rec, db);
#endif
}
// inserts testdata into the testtable, fetches and compares them
void tst_QSqlDatabase::checkValues(const FieldDef fieldDefs[], QSqlDatabase db)
{
Q_UNUSED(fieldDefs);
#ifdef QT3_SUPPORT
CHECK_DATABASE(db);
Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db);
QVERIFY_SQL(cur, select());
QSqlRecord* rec = cur.primeInsert();
QVERIFY(rec);
rec->setValue("id", pkey++);
int i = 0;
for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) {
rec->setValue(fieldDefs[ i ].fieldName(), fieldDefs[ i ].val);
// qDebug(QString("inserting %1 into %2").arg(fieldDefs[ i ].val.toString()).arg(fieldDefs[ i ].fieldName()));
}
QVERIFY_SQL(cur, insert());
cur.setForwardOnly(true);
QVERIFY_SQL(cur, select("id = " + QString::number(pkey - 1)));
QVERIFY_SQL(cur, next());
for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) {
bool ok = false;
QVariant val1 = cur.value(fieldDefs[ i ].fieldName());
QVariant val2 = fieldDefs[ i ].val;
if (val1.type() == QVariant::String)
//TDS Workaround
val1 = val1.toString().stripWhiteSpace();
if (fieldDefs[ i ].fieldName() == "t_real") {
// strip precision
val1 = (float)val1.toDouble();
val2 = (float)val2.toDouble();
}
if (val1.canCast(QVariant::Double) && val2.type() == QVariant::Double) {
// we don't care about precision here, we just want to know whether
// we can insert/fetch the right values
ok = (val1.toDouble() - val2.toDouble() < 0.00001);
} else if (val1.type() == val2.type()) {
ok = (val1 == val2);
} else {
ok = (val1.toString() == val2.toString());
}
if (!ok) {
if (val2.type() == QVariant::DateTime || val2.type() == QVariant::Time)
qDebug("Expected Time: " + val2.toTime().toString("hh:mm:ss.zzz"));
if (val1.type() == QVariant::DateTime || val1.type() == QVariant::Time)
qDebug("Received Time: " + val1.toTime().toString("hh:mm:ss.zzz"));
QFAIL(QString(" Expected: '%1' Received: '%2' for field %3 (etype %4 rtype %5) in checkValues").arg(
val2.type() == QVariant::ByteArray ? val2.toByteArray().toHex() : val2.toString()).arg(
val1.type() == QVariant::ByteArray ? val1.toByteArray().toHex() : val1.toString()).arg(
fieldDefs[ i ].fieldName()).arg(
val2.typeName()).arg(
val1.typeName())
);
}
}
#endif
}
// inserts a NULL value for each nullable field in testdata, fetches and checks whether
// we get back NULL
void tst_QSqlDatabase::checkNullValues(const FieldDef fieldDefs[], QSqlDatabase db)
{
Q_UNUSED(fieldDefs);
#ifdef QT3_SUPPORT
CHECK_DATABASE(db);
Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db);
QVERIFY_SQL(cur, select());
QSqlRecord* rec = cur.primeInsert();
QVERIFY(rec);
rec->setValue("id", pkey++);
int i = 0;
for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) {
if (fieldDefs[ i ].fieldName(), fieldDefs[ i ].nullable)
rec->setNull(fieldDefs[ i ].fieldName());
else
rec->setValue(fieldDefs[ i ].fieldName(), fieldDefs[ i ].val);
}
QVERIFY_SQL(cur, insert());
cur.setForwardOnly(true);
QVERIFY_SQL(cur, select("id = " + QString::number(pkey - 1)));
QVERIFY_SQL(cur, next());
for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) {
if (fieldDefs[ i ].nullable == false)
continue;
// multiple inheritance sucks so much
QVERIFY2(((QSqlQuery)cur).isNull(i + 1), "Check whether '" + fieldDefs[ i ].fieldName() + "' is null in QSqlQuery");
QVERIFY2(((QSqlRecord)cur).isNull(fieldDefs[ i ].fieldName()), "Check whether '" + fieldDefs[ i ].fieldName() + "' is null in QSqlRecord");
if (!cur.value(fieldDefs[ i ].fieldName()).isNull())
qDebug(QString("QVariant is not null for NULL-Value in Field '%1'").arg(fieldDefs[ i ].fieldName()));
}
#endif
}
void tst_QSqlDatabase::recordTDS()
@ -880,11 +674,6 @@ void tst_QSqlDatabase::recordTDS()
FieldDef("nchar(20)", QVariant::String, "blah3"),
FieldDef("nvarchar(20)", QVariant::String, "blah4"),
FieldDef("text", QVariant::String, "blah5"),
#ifdef QT3_SUPPORT
FieldDef("binary(20)", QVariant::ByteArray, Q3CString("blah6")),
FieldDef("varbinary(20)", QVariant::ByteArray, Q3CString("blah7")),
FieldDef("image", QVariant::ByteArray, Q3CString("blah8")),
#endif
FieldDef("bit", QVariant::Int, 1, false),
FieldDef()
@ -894,10 +683,6 @@ void tst_QSqlDatabase::recordTDS()
QVERIFY(fieldCount > 0);
commonFieldTest(fieldDefs, db, fieldCount);
checkNullValues(fieldDefs, db);
for (int i = 0; i < ITERATION_COUNT; ++i) {
checkValues(fieldDefs, db);
}
}
void tst_QSqlDatabase::recordOCI()
@ -954,9 +739,6 @@ void tst_QSqlDatabase::recordOCI()
QVERIFY(fieldCount > 0);
commonFieldTest(fieldDefs, db, fieldCount);
checkNullValues(fieldDefs, db);
for (int i = 0; i < ITERATION_COUNT; ++i)
checkValues(fieldDefs, db);
// some additional tests
QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__));
@ -978,18 +760,11 @@ void tst_QSqlDatabase::recordPSQL()
FieldDef byteadef;
if (db.driver()->hasFeature(QSqlDriver::BLOB))
#ifdef QT3_SUPPORT
byteadef = FieldDef("bytea", QVariant::ByteArray, QByteArray(Q3CString("bl\\ah")));
#else
byteadef = FieldDef("bytea", QVariant::ByteArray, QByteArray("bl\\ah"));
#endif
static FieldDef fieldDefs[] = {
FieldDef("bigint", QVariant::LongLong, Q_INT64_C(9223372036854775807)),
FieldDef("bigserial", QVariant::LongLong, 100, false),
FieldDef("bit", QVariant::String, "1"), // a bit in postgres is a bit-string
#ifdef QT3_SUPPORT
FieldDef("boolean", QVariant::Bool, QVariant(bool(true), 0)),
#endif
FieldDef("box", QVariant::String, "(5,6),(1,2)"),
FieldDef("char(20)", QVariant::String, "blah5678901234567890"),
FieldDef("varchar(20)", QVariant::String, "blah5678901234567890"),
@ -1038,7 +813,6 @@ void tst_QSqlDatabase::recordPSQL()
QVERIFY(fieldCount > 0);
commonFieldTest(fieldDefs, db, fieldCount);
checkNullValues(fieldDefs, db);
for (int i = 0; i < ITERATION_COUNT; ++i) {
// increase serial values
for (int i2 = 0; !fieldDefs[ i2 ].typeName.isNull(); ++i2) {
@ -1046,15 +820,10 @@ void tst_QSqlDatabase::recordPSQL()
fieldDefs[ i2 ].typeName == "bigserial") {
FieldDef def = fieldDefs[ i2 ];
#ifdef QT3_SUPPORT
def.val = def.val.asInt() + 1;
#else
def.val = def.val.toInt() + 1;
#endif
fieldDefs[ i2 ] = def;
}
}
checkValues(fieldDefs, db);
}
}
@ -1076,13 +845,8 @@ void tst_QSqlDatabase::recordMySQL()
with space on insert, and trailing spaces are removed on select.
*/
if( vernum >= ((5 << 16) + 15) ) {
#ifdef QT3_SUPPORT
bin10 = FieldDef("binary(10)", QVariant::ByteArray, QByteArray(Q3CString("123abc ")));
varbin10 = FieldDef("varbinary(10)", QVariant::ByteArray, QByteArray(Q3CString("123abcv ")));
#else
bin10 = FieldDef("binary(10)", QVariant::ByteArray, QString("123abc "));
varbin10 = FieldDef("varbinary(10)", QVariant::ByteArray, QString("123abcv "));
#endif
}
static QDateTime dt(QDate::currentDate(), QTime(1, 2, 3, 0));
@ -1108,20 +872,10 @@ void tst_QSqlDatabase::recordMySQL()
FieldDef("year", QVariant::Int, 2003),
FieldDef("char(20)", QVariant::String, "Blah"),
FieldDef("varchar(20)", QVariant::String, "BlahBlah"),
#ifdef QT3_SUPPORT
FieldDef("tinyblob", QVariant::ByteArray, QByteArray(Q3CString("blah1"))),
FieldDef("blob", QVariant::ByteArray, QByteArray(Q3CString("blah2"))),
FieldDef("mediumblob", QVariant::ByteArray,QByteArray(Q3CString("blah3"))),
FieldDef("longblob", QVariant::ByteArray, QByteArray(Q3CString("blah4"))),
#endif
FieldDef("tinytext", QVariant::String, QString("blah5")),
FieldDef("text", QVariant::String, QString("blah6")),
FieldDef("mediumtext", QVariant::String, QString("blah7")),
FieldDef("longtext", QVariant::String, QString("blah8")),
#ifdef QT3_SUPPORT
bin10,
varbin10,
#endif
// SET OF?
FieldDef()
@ -1131,10 +885,6 @@ void tst_QSqlDatabase::recordMySQL()
QVERIFY(fieldCount > 0);
commonFieldTest(fieldDefs, db, fieldCount);
checkNullValues(fieldDefs, db);
for (int i = 0; i < ITERATION_COUNT; ++i) {
checkValues(fieldDefs, db);
}
QSqlQuery q(db);
QVERIFY_SQL(q, exec("SELECT DATE_SUB(CURDATE(), INTERVAL 2 DAY)"));
@ -1168,11 +918,6 @@ void tst_QSqlDatabase::recordDB2()
// FieldDef("graphic(20)", QVariant::String, QString("Blah4")),
// FieldDef("vargraphic(20)", QVariant::String, QString("Blah5")),
// FieldDef("long vargraphic", QVariant::String, QString("Blah6")),
#ifdef QT3_SUPPORT
// FieldDef("clob(20)", QVariant::CString, QString("Blah7")),
// FieldDef("dbclob(20)", QVariant::CString, QString("Blah8")),
// FieldDef("blob(20)", QVariant::ByteArray, QByteArray(Q3CString("Blah9"))),
#endif
//X FieldDef("datalink", QVariant::String, QString("DLVALUE('Blah10')")),
FieldDef()
};
@ -1181,10 +926,6 @@ void tst_QSqlDatabase::recordDB2()
QVERIFY(fieldCount > 0);
commonFieldTest(fieldDefs, db, fieldCount);
checkNullValues(fieldDefs, db);
for (int i = 0; i < ITERATION_COUNT; ++i) {
checkValues(fieldDefs, db);
}
}
void tst_QSqlDatabase::recordIBase()
@ -1211,10 +952,6 @@ void tst_QSqlDatabase::recordIBase()
QVERIFY(fieldCount > 0);
commonFieldTest(fieldDefs, db, fieldCount);
checkNullValues(fieldDefs, db);
for (int i = 0; i < ITERATION_COUNT; ++i) {
checkValues(fieldDefs, db);
}
}
void tst_QSqlDatabase::recordSQLite()
@ -1241,10 +978,6 @@ void tst_QSqlDatabase::recordSQLite()
QVERIFY(fieldCount > 0);
commonFieldTest(fieldDefs, db, fieldCount);
checkNullValues(fieldDefs, db);
for (int i = 0; i < ITERATION_COUNT; ++i) {
checkValues(fieldDefs, db);
}
}
void tst_QSqlDatabase::recordSQLServer()
@ -1264,9 +997,6 @@ void tst_QSqlDatabase::recordSQLServer()
FieldDef("bigint", QVariant::LongLong, 12345),
FieldDef("int", QVariant::Int, 123456),
FieldDef("tinyint", QVariant::UInt, 255),
#ifdef QT3_SUPPORT
FieldDef("image", QVariant::ByteArray, Q3CString("Blah1")),
#endif
FieldDef("float", QVariant::Double, 1.12345),
FieldDef("numeric(5,2)", QVariant::Double, 123.45),
FieldDef("uniqueidentifier", QVariant::String,
@ -1279,10 +1009,6 @@ void tst_QSqlDatabase::recordSQLServer()
QVERIFY(fieldCount > 0);
commonFieldTest(fieldDefs, db, fieldCount);
checkNullValues(fieldDefs, db);
for (int i = 0; i < ITERATION_COUNT; ++i) {
checkValues(fieldDefs, db);
}
}
void tst_QSqlDatabase::recordAccess()
@ -1306,9 +1032,6 @@ void tst_QSqlDatabase::recordAccess()
FieldDef("single", QVariant::Double, 1.12345),
FieldDef("double", QVariant::Double, 1.123456),
FieldDef("byte", QVariant::UInt, 255),
#ifdef QT3_SUPPORT
FieldDef("binary(5)", QVariant::ByteArray, Q3CString("Blah2")),
#endif
FieldDef("long", QVariant::Int, 2147483647),
FieldDef("memo", QVariant::String, memo),
FieldDef()
@ -1318,10 +1041,6 @@ void tst_QSqlDatabase::recordAccess()
QVERIFY(fieldCount > 0);
commonFieldTest(fieldDefs, db, fieldCount);
checkNullValues(fieldDefs, db);
for (int i = 0; i < ITERATION_COUNT; ++i) {
checkValues(fieldDefs, db);
}
}
void tst_QSqlDatabase::transaction()
@ -1462,17 +1181,6 @@ void tst_QSqlDatabase::caseSensivity()
QVERIFY((int)rec.count() > 0);
}
#ifdef QT3_SUPPORT
Q3SqlRecordInfo rInf = db.recordInfo(qTableName("qtest", __FILE__));
QVERIFY((int)rInf.count() > 0);
if (!cs) {
rInf = db.recordInfo(qTableName("QTEST", __FILE__).upper());
QVERIFY((int)rInf.count() > 0);
rInf = db.recordInfo(qTableName("qTesT", __FILE__));
QVERIFY((int)rInf.count() > 0);
}
#endif
rec = db.primaryIndex(qTableName("qtest", __FILE__));
QVERIFY((int)rec.count() > 0);
if (!cs) {
@ -1526,12 +1234,6 @@ void tst_QSqlDatabase::psql_schemas()
QCOMPARE(rec.fieldName(0), QString("id"));
QCOMPARE(rec.fieldName(1), QString("name"));
#ifdef QT3_SUPPORT
rec = db.record(QSqlQuery("select * from " + table, db));
QCOMPARE(rec.count(), 2);
QCOMPARE(rec.fieldName(0), QString("id"));
QCOMPARE(rec.fieldName(1), QString("name"));
#endif
QSqlIndex idx = db.primaryIndex(table);
QCOMPARE(idx.count(), 1);
QCOMPARE(idx.fieldName(0), QString("id"));

View File

@ -70,12 +70,6 @@ public slots:
void cleanup();
private slots:
void value();
#ifdef QT3_SUPPORT
void toStringList_data();
void toStringList();
void toString_data();
void toString();
#endif // QT3_SUPPORT
void setValue_data();
void setValue();
void setNull();
@ -166,12 +160,6 @@ void tst_QSqlRecord::append()
QCOMPARE( rec->indexOf( "int" ), 1 );
QCOMPARE( rec->indexOf( "double" ), 2 );
QCOMPARE( rec->indexOf( "bool" ), 3 );
#ifdef QT3_SUPPORT
QCOMPARE( rec->position( "string" ), 0 );
QCOMPARE( rec->position( "int" ), 1 );
QCOMPARE( rec->position( "double" ), 2 );
QCOMPARE( rec->position( "bool" ), 3 );
#endif
}
void tst_QSqlRecord::clear()
@ -181,10 +169,6 @@ void tst_QSqlRecord::clear()
rec->clear();
QCOMPARE( (int)rec->count(), 0 );
QVERIFY( rec->isEmpty() );
#ifdef QT3_SUPPORT
QVERIFY( rec->fieldPtr( 0 ) == 0 );
QVERIFY( rec->fieldPtr( "_This should give a warning!_" ) == 0 );
#endif
QVERIFY( !rec->contains( fields[0]->name() ) );
}
@ -236,12 +220,6 @@ void tst_QSqlRecord::clearValues()
QCOMPARE( rec->indexOf( "int" ), 1 );
QCOMPARE( rec->indexOf( "double" ), 2 );
QCOMPARE( rec->indexOf( "bool" ), 3 );
#ifdef QT3_SUPPORT
QCOMPARE( rec->position( "string" ), 0 );
QCOMPARE( rec->position( "int" ), 1 );
QCOMPARE( rec->position( "double" ), 2 );
QCOMPARE( rec->position( "bool" ), 3 );
#endif
for ( i = 0; i < 4; ++i )
rec->setNull( i );
@ -287,9 +265,6 @@ void tst_QSqlRecord::field()
int i;
for ( i = 0; i < NUM_FIELDS; ++i )
QVERIFY( rec->field( i ) == *fields[ i ] );
#ifdef QT3_SUPPORT
QVERIFY( rec->fieldPtr( NUM_FIELDS ) == 0 );
#endif
for ( i = 0; i < NUM_FIELDS; ++i )
QVERIFY( rec->field( (fields[ i ] )->name() ) == *( fields[ i ] ) );
@ -438,9 +413,6 @@ void tst_QSqlRecord::position()
int i;
for ( i = 0; i < NUM_FIELDS; ++i ) {
QCOMPARE( rec->indexOf( fields[ i ]->name() ), i );
#ifdef QT3_SUPPORT
QCOMPARE( rec->position( fields[ i ]->name() ), i );
#endif
}
}
@ -499,12 +471,6 @@ void tst_QSqlRecord::setValue()
QCOMPARE( rec->indexOf( "int" ), 1 );
QCOMPARE( rec->indexOf( "double" ), 2 );
QCOMPARE( rec->indexOf( "bool" ), 3 );
#ifdef QT3_SUPPORT
QCOMPARE( rec->position( "string" ), 0 );
QCOMPARE( rec->position( "int" ), 1 );
QCOMPARE( rec->position( "double" ), 2 );
QCOMPARE( rec->position( "bool" ), 3 );
#endif
QFETCH( int, ival );
QFETCH( QString, sval );
@ -543,58 +509,6 @@ void tst_QSqlRecord::setValue()
QCOMPARE( rec->value( 3 ), QVariant(bval) );
}
#ifdef QT3_SUPPORT
void tst_QSqlRecord::toString_data()
{
clearValues_data( t );
}
void tst_QSqlRecord::toString()
{
createTestRecord();
QString result;
QFETCH( QString, prefix );
QFETCH( QString, sep );
rec->setGenerated( 1, false );
for (int i = 0; i < NUM_FIELDS; ++i ) {
if ( i == 1 )
continue;
if ( prefix.isEmpty() ) {
result += fields[ i ]->name();
} else {
result += prefix + '.' + fields[ i ]->name();
}
if ( i != NUM_FIELDS - 1 )
result += sep + ' ';
}
QCOMPARE( rec->toString( prefix, sep ), result );
}
void tst_QSqlRecord::toStringList_data()
{
clearValues_data( t );
}
void tst_QSqlRecord::toStringList()
{
createTestRecord();
QStringList result;
QFETCH( QString, prefix );
rec->setGenerated( 1, false );
for (int i = 0; i < NUM_FIELDS; ++i ) {
if ( i == 1 )
continue;
if ( prefix.isEmpty() ) {
result << fields[ i ]->name();
} else {
result << ( prefix + '.' + fields[ i ]->name() );
}
}
QCOMPARE(rec->toStringList( prefix ), result);
}
#endif // QT3_SUPPORT
void tst_QSqlRecord::value()
{
// this test is already covered in setValue()

View File

@ -151,7 +151,6 @@ private slots:
void indexOf3_data();
// void indexOf3();
void sprintf();
void copy();
void fill();
void truncate();
void constructor();
@ -904,19 +903,6 @@ void tst_QString::fill()
QCOMPARE(f,(QString)"FFF");
}
void tst_QString::copy()
{
#ifdef QT3_SUPPORT
QString e;
e = "String E";
QString ce = e.copy();
QCOMPARE(ce,(QString)"String E");
e = "XXX";
QCOMPARE(ce,(QString)"String E");
QCOMPARE(e,(QString)"XXX");
#endif
}
void tst_QString::sprintf()
{
QString a;
@ -3364,7 +3350,7 @@ void tst_QString::local8Bit_data()
/*
QString::local8Bit() called on a null QString returns an _empty_
QByteArray. This is the correct behavior since Qt 3.1.
QByteArray.
*/
QTest::newRow("nullString") << QString() << QByteArray("");
QTest::newRow("emptyString") << QString("") << QByteArray("");

View File

@ -337,9 +337,6 @@ void tst_QStyle::testAllFunctions(QStyle *style)
copt6.init(testWidget);
QStyleOptionToolButton copt7;
copt7.init(testWidget);
QStyleOptionQ3ListView copt8;
copt8.init(testWidget);
copt8.items << QStyleOptionQ3ListViewItem();
QStyleOptionComplex copt9;
copt9.initFrom(testWidget);
@ -351,10 +348,6 @@ void tst_QStyle::testAllFunctions(QStyle *style)
style->drawComplexControl(QStyle::CC_TitleBar, &copt6, &painter, 0);
style->drawComplexControl(QStyle::CC_GroupBox, &copt2, &painter, 0);
style->drawComplexControl(QStyle::CC_Dial, &copt4, &painter, 0);
#ifdef QT3_SUPPORT
style->drawComplexControl(QStyle::CC_Q3ListView, &copt8, &painter, 0);
style->drawComplexControl(QStyle::CC_MdiControls, &copt9, &painter, 0);
#endif
}
//Check standard pixmaps/icons

View File

@ -92,9 +92,6 @@ void tst_QStyleOption::qstyleoptioncast_data()
QTest::newRow("optionHeader") << stylePtr(new QStyleOptionHeader) << false << int(QStyleOption::SO_Header);
QTest::newRow("optionMenuItem") << stylePtr(new QStyleOptionMenuItem) << false << int(QStyleOption::SO_MenuItem);
QTest::newRow("optionProgressBar") << stylePtr(new QStyleOptionProgressBar) << false << int(QStyleOption::SO_ProgressBar);
QTest::newRow("optionQ3DockWindow") << stylePtr(new QStyleOptionQ3DockWindow) << false << int(QStyleOption::SO_Q3DockWindow);
QTest::newRow("optionQ3ListView") << stylePtr(new QStyleOptionQ3ListView) << true << int(QStyleOption::SO_Q3ListView);
QTest::newRow("optionQ3ListViewItem") << stylePtr(new QStyleOptionQ3ListViewItem) << false << int(QStyleOption::SO_Q3ListViewItem);
QTest::newRow("optionSlider") << stylePtr(new QStyleOptionSlider) << true << int(QStyleOption::SO_Slider);
QTest::newRow("optionSpinBox") << stylePtr(new QStyleOptionSpinBox) << true << int(QStyleOption::SO_SpinBox);
QTest::newRow("optionTab") << stylePtr(new QStyleOptionTab) << false << int(QStyleOption::SO_Tab);

View File

@ -43,9 +43,6 @@
#include <QtTest/QtTest>
#include <QtDebug>
#include <QMetaObject>
#ifdef QT3_SUPPORT
#include <Q3ProgressBar>
#endif
#include <private/qstylesheetstyle_p.h>
#include "../platformquirks.h"
@ -1291,9 +1288,6 @@ void tst_QStyleSheetStyle::emptyStyleSheet()
QWidget w;
QHBoxLayout layout(&w);
w.setLayout(&layout);
#ifdef QT3_SUPPORT
layout.addWidget(new Q3ProgressBar(&w)); //task 231137
#endif
layout.addWidget(new QPushButton("push", &w));
layout.addWidget(new QToolButton(&w));
QLabel label("toto", &w);

View File

@ -381,9 +381,6 @@ void tst_QTabWidget::currentIndex()
{
// Test bad arguments
QSignalSpy spy(tw, SIGNAL(currentChanged(int)));
#ifdef QT3_SUPPORT
QSignalSpy spySupport(tw, SIGNAL(currentChanged(QWidget *)));
#endif
QCOMPARE(tw->currentIndex(), -1);
tw->setCurrentIndex(-1);
QCOMPARE(tw->currentIndex(), -1);
@ -395,10 +392,7 @@ void tst_QTabWidget::currentIndex()
QCOMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
QVERIFY(arguments.at(0).toInt() == firstIndex);
#ifdef QT3_SUPPORT
QCOMPARE(spySupport.count(), 1);
#endif
int index = addPage();
QCOMPARE(tw->currentIndex(), firstIndex);
tw->setCurrentIndex(index);
@ -406,28 +400,18 @@ void tst_QTabWidget::currentIndex()
QCOMPARE(spy.count(), 1);
arguments = spy.takeFirst();
QVERIFY(arguments.at(0).toInt() == index);
#ifdef QT3_SUPPORT
QCOMPARE(spySupport.count(), 2);
#endif
removePage(index);
QCOMPARE(tw->currentIndex(), firstIndex);
QCOMPARE(spy.count(), 1);
arguments = spy.takeFirst();
QVERIFY(arguments.at(0).toInt() == firstIndex);
#ifdef QT3_SUPPORT
QCOMPARE(spySupport.count(), 3);
#endif
removePage(firstIndex);
QCOMPARE(tw->currentIndex(), -1);
QCOMPARE(spy.count(), 1);
arguments = spy.takeFirst();
QVERIFY(arguments.at(0).toInt() == -1);
#ifdef QT3_SUPPORT
QCOMPARE(spySupport.count(), 4);
#endif
}
void tst_QTabWidget::cornerWidget()

View File

@ -47,87 +47,6 @@
// Test
#include "Test.h"
#ifdef QT3_SUPPORT
//------------------------------------------------------------------------------
My3Socket::My3Socket(QObject *parent)
: Q3Socket(parent), safeShutDown(false)
{
connect(this, SIGNAL(readyRead()), this, SLOT(read()));
connect(this, SIGNAL(delayedCloseFinished()), this, SLOT(closed()));
connect(this, SIGNAL(connectionClosed()), this, SLOT(closed()));
}
//------------------------------------------------------------------------------
void My3Socket::read()
{
QDataStream in(this);
quint32 num, reply;
while (bytesAvailable()) {
in >> num;
if (num == 42) {
qDebug("SUCCESS");
safeShutDown = true;
QCoreApplication::instance()->quit();
return;
}
reply = num + 1;
if (reply == 42)
++reply;
}
// Reply with a bigger number
sendTest(reply);
}
//------------------------------------------------------------------------------
void My3Socket::closed()
{
if (!safeShutDown)
qDebug("FAILED");
QCoreApplication::instance()->quit();
}
//------------------------------------------------------------------------------
void My3Socket::sendTest(quint32 num)
{
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
out << num;
writeBlock(block, block.size());
}
//------------------------------------------------------------------------------
My3Server::My3Server(QObject *parent)
: Q3ServerSocket(7700, 1, parent), m_socket(0)
{
if (ok())
qDebug("qt3server");
QTimer::singleShot(5000, this, SLOT(stopServer()));
}
//------------------------------------------------------------------------------
void My3Server::newConnection(int socketId)
{
m_socket = new My3Socket(this);
m_socket->setSocket(socketId);
}
//------------------------------------------------------------------------------
void My3Server::stopServer()
{
if (m_socket) {
qDebug("SUCCESS");
m_socket->safeShutDown = true;
m_socket->sendTest(42);
} else {
QCoreApplication::instance()->quit();
}
}
#endif
//------------------------------------------------------------------------------
My4Socket::My4Socket(QObject *parent)
: QTcpSocket(parent), safeShutDown(false)
@ -210,19 +129,6 @@ void My4Server::stopServer()
Test::Test(Type type)
{
switch (type) {
#ifdef QT3_SUPPORT
case Qt3Server: {
new My3Server(this);
break;
}
case Qt3Client: {
qDebug("qt3client");
My3Socket *s = new My3Socket(this);
s->connectToHost("localhost", 7700);
s->sendTest(1);
break;
}
#endif
case Qt4Client: {
qDebug("qt4client");
My4Socket *s = new My4Socket(this);

View File

@ -42,48 +42,10 @@
#define TEST_H
//------------------------------------------------------------------------------
// Qt
#ifdef QT3_SUPPORT
#include <Q3ServerSocket>
#include <Q3Socket>
#endif
#include <QTcpServer>
#include <QTcpSocket>
//------------------------------------------------------------------------------
#ifdef QT3_SUPPORT
class My3Socket : public Q3Socket
{
Q_OBJECT
public:
My3Socket(QObject *parent);
void sendTest(Q_UINT32 num);
bool safeShutDown;
private slots:
void read();
void closed();
};
//------------------------------------------------------------------------------
class My3Server : public Q3ServerSocket
{
Q_OBJECT
public:
My3Server(QObject *parent = 0);
void newConnection(int socket);
private slots:
void stopServer();
private:
My3Socket *m_socket;
};
#endif
//------------------------------------------------------------------------------
class My4Socket : public QTcpSocket
{
@ -125,10 +87,6 @@ public:
enum Type {
Qt4Client,
Qt4Server,
#ifdef QT3_SUPPORT
Qt3Client,
Qt3Server
#endif
};
Test(Type type);
};

View File

@ -56,14 +56,8 @@ int main(int argc, char **argv)
type = Test::Qt4Client;
else if (arg == QLatin1String("qt4server"))
type = Test::Qt4Server;
#ifdef QT3_SUPPORT
else if (arg == QLatin1String("qt3client"))
type = Test::Qt3Client;
else if (arg == QLatin1String("qt3server"))
type = Test::Qt3Server;
#endif
else {
qDebug("usage: ./stressTest <qt3client|qt3server|qt4client|qt4server>");
qDebug("usage: ./stressTest <qt4client|qt4server>");
return 0;
}

View File

@ -2167,20 +2167,12 @@ void tst_QTcpSocket::suddenRemoteDisconnect_data()
QTest::addColumn<QString>("client");
QTest::addColumn<QString>("server");
#ifdef QT3_SUPPORT
QTest::newRow("Qt3 Client <-> Qt3 Server") << QString::fromLatin1("qt3client") << QString::fromLatin1("qt3server");
QTest::newRow("Qt3 Client <-> Qt4 Server") << QString::fromLatin1("qt3client") << QString::fromLatin1("qt4server");
QTest::newRow("Qt4 Client <-> Qt3 Server") << QString::fromLatin1("qt4client") << QString::fromLatin1("qt3server");
#endif
QTest::newRow("Qt4 Client <-> Qt4 Server") << QString::fromLatin1("qt4client") << QString::fromLatin1("qt4server");
}
void tst_QTcpSocket::suddenRemoteDisconnect()
{
#if defined(Q_OS_WINCE) || defined(Q_OS_VXWORKS)
QSKIP("stressTest subprocess needs Qt3Support", SkipAll);
#elif defined( Q_OS_SYMBIAN )
#if defined( Q_OS_SYMBIAN )
QSKIP("Symbian: QProcess IO is not yet supported, fix when supported", SkipAll);
#else
QFETCH(QString, client);

View File

@ -76,7 +76,6 @@ Q_DECLARE_METATYPE(QList<int>);
#if defined(Q_OS_SYMBIAN)
# define SRCDIR ""
#undef QT3_SUPPORT
#endif
@ -134,9 +133,6 @@ private slots:
void mergeCurrentBlockCharFormat();
void emptyAppend();
void appendOnEmptyDocumentShouldReuseInitialParagraph();
#ifdef QT3_SUPPORT
void textSemantics();
#endif
void cursorPositionChanged();
void setTextCursor();
#ifndef QT_NO_CLIPBOARD
@ -705,19 +701,6 @@ void tst_QTextEdit::appendOnEmptyDocumentShouldReuseInitialParagraph()
QCOMPARE(blockCount(), 1);
}
#ifdef QT3_SUPPORT
void tst_QTextEdit::textSemantics()
{
ed->setTextFormat(Qt::AutoText);
ed->setPlainText("Hello World");
QVERIFY(!Qt::mightBeRichText(ed->text()));
ed->setHtml("<b>Hey</b>");
QVERIFY(Qt::mightBeRichText(ed->text()));
}
#endif
class CursorPositionChangedRecorder : public QObject
{
Q_OBJECT

File diff suppressed because it is too large Load Diff

View File

@ -119,13 +119,6 @@ void tst_QToolButton::getSetCheck()
obj1.setDefaultAction((QAction *)0);
QCOMPARE((QAction *)0, obj1.defaultAction());
delete var4;
#ifdef QT_HAS_QT3SUPPORT
//ensure that popup delay is not reset on style change
obj1.setPopupDelay(5);
obj1.setStyle(new QWindowsStyle);
QCOMPARE(obj1.popupDelay(), 5);
#endif
}
Q_DECLARE_METATYPE(QAction*)

View File

@ -198,10 +198,6 @@ private slots:
void task_240612();
void taskQTBUG_6962();
void taskQTBUG_8701();
#ifdef QT3_SUPPORT
void dirPath();
#endif
};
// Testing get/set functions
@ -3933,13 +3929,6 @@ void tst_QUrl::task_240612()
QCOMPARE(url.toEncoded().constData(), "//example.com/test.txt");
}
#ifdef QT3_SUPPORT
void tst_QUrl::dirPath()
{
QCOMPARE(QUrl("http://www.vg.no/test/file.txt").dirPath(), QString("/test"));
}
#endif
void tst_QUrl::resolvedWithAbsoluteSchemes() const
{
QFETCH(QUrl, base);

View File

@ -50,9 +50,6 @@
#include <qiodevice.h>
#include <qurl.h>
#include <qlocale.h>
#ifdef QT3_SUPPORT
# include <q3cstring.h>
#endif
#include <qkeysequence.h>
#include <qbitmap.h>
#include <qcursor.h>
@ -141,18 +138,12 @@ private slots:
void toULongLong_data();
void toULongLong();
void asType_data();
void asType();
void toByteArray_data();
void toByteArray();
void toString_data();
void toString();
void toCString_data();
void toCString();
void toDate_data();
void toDate();
@ -231,8 +222,6 @@ private slots:
void podUserType();
void nullAsType();
void data_(); // data is virtual function in QtTestCase
void constData();
@ -243,7 +232,6 @@ private slots:
void variantMap();
void variantHash();
void invalidAsByteArray();
void convertToQUint8() const;
void invalidQColor() const;
void comparePointers() const;
@ -283,9 +271,6 @@ Q_DECLARE_METATYPE(QDate)
Q_DECLARE_METATYPE(QTime)
Q_DECLARE_METATYPE(QDateTime)
Q_DECLARE_METATYPE(QVariant)
#ifdef QT3_SUPPORT
Q_DECLARE_METATYPE(Q3CString)
#endif
const qlonglong intMax1 = (qlonglong)INT_MAX + 1;
const qulonglong uintMax1 = (qulonglong)UINT_MAX + 1;
@ -369,9 +354,6 @@ void tst_QVariant::isNull()
QVariant varLL( (qlonglong)0 );
QVERIFY( !varLL.isNull() );
QVariant var7(QString::null);
#ifdef QT3_SUPPORT
QCOMPARE(var7.asInt(), 0);
#endif
QVERIFY(var7.isNull());
}
@ -442,30 +424,15 @@ void tst_QVariant::canConvert_data()
var = qVariantFromValue(QBitmap());
QTest::newRow("Bitmap")
<< var << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N;
#ifdef QT3_SUPPORT
var = QVariant(true, 0);
QTest::newRow("Bool")
<< var << N << N << Y << N << Y << Y << N << N << N << N << N << Y << N << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
#endif
var = qVariantFromValue(QBrush());
QTest::newRow("Brush")
<< var << N << N << N << Y << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N;
var = QVariant(QByteArray());
QTest::newRow("ByteArray")
<< var << N << N << Y << N << Y << Y << Y << N << N << N << N << Y << N << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
#ifdef QT3_SUPPORT
var = QVariant(Q3CString("cstring"));
QTest::newRow("CString")
<< var << N << N << Y << N << Y << Y << Y << N << N << N << N << Y << N << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
#endif
var = qVariantFromValue(QColor());
QTest::newRow("Color")
<< var << N << N << N << Y << Y << Y << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N;
#ifdef QT3_SUPPORT
var = qVariantFromValue(QColorGroup());
QTest::newRow("ColorGroup")
<< var << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N;
#endif
#ifndef QT_NO_CURSOR
var = qVariantFromValue(QCursor());
QTest::newRow("Cursor")
@ -661,9 +628,6 @@ void tst_QVariant::toInt_data()
QTest::newRow( "double" ) << QVariant( 3.1415927 ) << 3 << true;
QTest::newRow( "float" ) << QVariant( 3.1415927f ) << 3 << true;
QTest::newRow( "uint" ) << QVariant( 123u ) << 123 << true;
#ifdef QT3_SUPPORT
QTest::newRow( "bool" ) << QVariant( true, 42 ) << 1 << true;
#endif
QTest::newRow( "int-string" ) << QVariant( QString("123") ) << 123 << true;
QTest::newRow( "string" ) << QVariant( QString("Unicode String") ) << 0 << false;
QTest::newRow( "longlong0" ) << QVariant( (qlonglong)34 ) << 34 << true;
@ -714,9 +678,6 @@ void tst_QVariant::toUInt_data()
QTest::newRow( "double" ) << QVariant( 3.1415927 ) << (uint)3 << true;
QTest::newRow( "float" ) << QVariant( 3.1415927f ) << (uint)3 << true;
QTest::newRow( "uint" ) << QVariant( 123u ) << (uint)123 << true;
#ifdef QT3_SUPPORT
QTest::newRow( "bool" ) << QVariant( true, 42 ) << (uint)1 << true;
#endif
QTest::newRow( "int-string" ) << QVariant( QString("123") ) << (uint)123 << true;
QTest::newRow( "string" ) << QVariant( QString("Unicode String") ) << (uint)0 << false;
QTest::newRow( "string2" ) << QVariant( QString("4") ) << (uint)4 << true;
@ -911,10 +872,6 @@ void tst_QVariant::toBool_data()
QTest::newRow( "float0" ) << QVariant( 0.0f ) << false;
QTest::newRow( "double1" ) << QVariant( 3.1415927 ) << true;
QTest::newRow( "float1" ) << QVariant( 3.1415927f ) << true;
#ifdef QT3_SUPPORT
QTest::newRow( "bool0" ) << QVariant( false, 42 ) << false;
QTest::newRow( "bool1" ) << QVariant( true, 42 ) << true;
#endif
QTest::newRow( "string0" ) << QVariant( QString("3") ) << true;
QTest::newRow( "string1" ) << QVariant( QString("true") ) << true;
QTest::newRow( "string2" ) << QVariant( QString("0") ) << false;
@ -1142,9 +1099,6 @@ void tst_QVariant::toLongLong_data()
QTest::newRow( "double" ) << QVariant( 3.1415927 ) << (qlonglong)3 << true;
QTest::newRow( "float" ) << QVariant( 3.1415927f ) << (qlonglong)3 << true;
QTest::newRow( "uint" ) << QVariant( 123u ) << (qlonglong)123 << true;
#ifdef QT3_SUPPORT
QTest::newRow( "bool" ) << QVariant( true, 42 ) << (qlonglong)1 << true;
#endif
QTest::newRow( "int-string" ) << QVariant( QString("123") )
<< (qlonglong)123 << true;
QTest::newRow( "string" ) << QVariant( QString("Unicode fun") ) << (qlonglong)0
@ -1183,9 +1137,6 @@ void tst_QVariant::toULongLong_data()
QTest::newRow( "double" ) << QVariant( 3.1415927 ) << (qulonglong)3 << true;
QTest::newRow( "float" ) << QVariant( 3.1415927f ) << (qulonglong)3 << true;
QTest::newRow( "uint" ) << QVariant( 123u ) << (qulonglong)123 << true;
#ifdef QT3_SUPPORT
QTest::newRow( "bool" ) << QVariant( true, 42 ) << (qulonglong)1 << true;
#endif
QTest::newRow( "int-string" ) << QVariant( QString("123") )
<< (qulonglong)123 << true;
QTest::newRow( "string" ) << QVariant( QString("Unicode fun") ) << (qulonglong)0
@ -1220,38 +1171,6 @@ void tst_QVariant::toULongLong()
QVERIFY( ok == valueOK );
}
void tst_QVariant::asType_data()
{
QTest::addColumn<QVariant>("value");
QTest::newRow( "string" ) << QVariant( QString( "1.0" ) );
}
void tst_QVariant::asType()
{
#ifndef QT3_SUPPORT
QSKIP("Qt compiled without Qt3Support", SkipAll);
#else
QFETCH( QVariant, value );
QVariant::Type type = value.type();
QVariant copy = value;
copy.asDouble();
QCOMPARE( value.type(), type );
copy = value;
copy.asList();
QCOMPARE( value.type(), type );
copy = value;
copy.asMap();
QCOMPARE( value.type(), type );
copy = value;
QCOMPARE( value.type(), type );
#endif
}
void tst_QVariant::toByteArray_data()
{
QTest::addColumn<QVariant>("value");
@ -1297,11 +1216,7 @@ void tst_QVariant::toString_data()
QTest::newRow( "uint" ) << QVariant( (uint)123 ) << QString( "123" );
QTest::newRow( "double" ) << QVariant( 123.456 ) << QString( "123.456" );
QTest::newRow( "float" ) << QVariant( 123.456f ) << QString( "123.456" );
#ifdef QT3_SUPPORT
QTest::newRow( "bool" ) << QVariant( true, 0 ) << QString( "true" );
#else
QTest::newRow( "bool" ) << QVariant( true ) << QString( "true" );
#endif
QTest::newRow( "qdate" ) << QVariant( QDate( 2002, 1, 1 ) ) << QString( "2002-01-01" );
QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56" );
QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56 ) ) ) << QString( "2002-01-01T12:34:56" );
@ -1329,32 +1244,6 @@ void tst_QVariant::toString()
QCOMPARE( str, result );
}
void tst_QVariant::toCString_data()
{
#ifdef QT3_SUPPORT
QTest::addColumn<QVariant>("value");
QTest::addColumn<Q3CString>("result");
QTest::newRow( "qstring" ) << QVariant( Q3CString( "Test" ) ) << Q3CString( "Test" );
QTest::newRow( "qcstring") << QVariant( Q3CString( "Test\0" ) ) << Q3CString( "Test" );
#endif
}
void tst_QVariant::toCString()
{
#ifdef QT3_SUPPORT
QFETCH( QVariant, value );
QFETCH( Q3CString, result );
QVERIFY( value.isValid() );
Q3CString str = value.toCString();
QCOMPARE( str, result );
#else
QSKIP("Qt not build with Qt3Support", SkipAll);
#endif
}
void tst_QVariant::toDate_data()
{
QTest::addColumn<QVariant>("value");
@ -1558,14 +1447,8 @@ void tst_QVariant::writeToReadFromDataStream_data()
QTest::newRow( "bitmap_valid" ) << qVariantFromValue( bitmap ) << false;
QTest::newRow( "brush_valid" ) << qVariantFromValue( QBrush( Qt::red ) ) << false;
QTest::newRow( "color_valid" ) << qVariantFromValue( QColor( Qt::red ) ) << false;
#ifdef QT3_SUPPORT
QTest::newRow( "colorgroup_valid" ) << qVariantFromValue(QPalette(QColor("turquoise")).active()) << false;
#endif
#ifndef QT_NO_CURSOR
QTest::newRow( "cursor_valid" ) << qVariantFromValue( QCursor( Qt::PointingHandCursor ) ) << false;
#endif
#ifdef QT3_SUPPORT
QTest::newRow( "bool_valid" ) << QVariant( true, 0 ) << false;
#endif
QTest::newRow( "date_invalid" ) << QVariant( QDate() ) << true;
QTest::newRow( "date_valid" ) << QVariant( QDate( 2002, 07, 06 ) ) << false;
@ -1578,16 +1461,8 @@ void tst_QVariant::writeToReadFromDataStream_data()
QPixmap pixmap( 10, 10 );
pixmap.fill( Qt::red );
QTest::newRow( "pixmap_valid" ) << qVariantFromValue( pixmap ) << false;
#ifdef QT3_SUPPORT
QTest::newRow( "iconset_invalid" ) << qVariantFromValue( QIcon() ) << true;
#endif
// QTest::newRow( "iconset_valid" ) << QVariant( QIcon( pixmap ) ) << false;
QTest::newRow( "image_invalid" ) << qVariantFromValue( QImage() ) << true;
#ifdef QT3_SUPPORT
QImage image( 10, 10, 32 );
image.fill( QColor( Qt::red ).pixel() );
QTest::newRow( "image_valid" ) << qVariantFromValue( image ) << false;
#endif
QTest::newRow( "keysequence_valid" ) << qVariantFromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) << false;
QTest::newRow( "int_valid" ) << QVariant( -123 ) << false;
typedef QList<QVariant> variantsList;
@ -1616,10 +1491,6 @@ void tst_QVariant::writeToReadFromDataStream_data()
QTest::newRow( "size_valid" ) << QVariant( QSize( 10, 10 ) ) << false;
QTest::newRow( "string_invalid" ) << QVariant( QString() ) << true;
QTest::newRow( "string_valid" ) << QVariant( QString( "Test" ) ) << false;
#ifdef QT3_SUPPORT
QTest::newRow( "cstring_invalid" ) << QVariant( Q3CString() ) << true;
QTest::newRow( "cstring_valid" ) << QVariant( Q3CString( "Test" ) ) << false;
#endif
QStringList stringlist;
stringlist << "One" << "Two" << "Three";
QTest::newRow( "stringlist_valid" ) << QVariant( stringlist ) << false;
@ -1674,13 +1545,8 @@ void tst_QVariant::writeToReadFromDataStream()
// Since only a few won't match since the serial numbers are different
// I won't bother adding another bool in the data test.
QVariant::Type writeType = writeVariant.type();
#ifdef QT3_SUPPORT
if ( writeType != QVariant::Invalid && writeType != QVariant::Bitmap && writeType != QVariant::Pixmap
&& writeType != QVariant::Image && writeType != QVariant::IconSet ) {
#else
if ( writeType != QVariant::Invalid && writeType != QVariant::Bitmap && writeType != QVariant::Pixmap
&& writeType != QVariant::Image) {
#endif
switch (writeType) {
default:
QCOMPARE( readVariant, writeVariant );
@ -1805,11 +1671,7 @@ void tst_QVariant::operator_eq_eq_data()
QVariant mULongLongString(QByteArray("42"));
QVariant mULongLongQString(QString("42"));
#ifdef QT3_SUPPORT
QVariant mBool(false, 0);
#else
QVariant mBool(false);
#endif
QVariant mBoolString(QByteArray("false"));
QVariant mBoolQString(QString("false"));
@ -2028,49 +1890,45 @@ void tst_QVariant::typeName_data()
QTest::newRow("9") << int(QVariant::Size) << QByteArray("QSize");
QTest::newRow("10") << int(QVariant::Color) << QByteArray("QColor");
QTest::newRow("11") << int(QVariant::Palette) << QByteArray("QPalette");
#ifdef QT3_SUPPORT
QTest::newRow("12") << int(QVariant::ColorGroup) << QByteArray("QColorGroup");
QTest::newRow("13") << int(QVariant::IconSet) << QByteArray("QIcon");
#endif
QTest::newRow("14") << int(QVariant::Point) << QByteArray("QPoint");
QTest::newRow("15") << int(QVariant::Image) << QByteArray("QImage");
QTest::newRow("16") << int(QVariant::Int) << QByteArray("int");
QTest::newRow("17") << int(QVariant::UInt) << QByteArray("uint");
QTest::newRow("18") << int(QVariant::Bool) << QByteArray("bool");
QTest::newRow("19") << int(QVariant::Double) << QByteArray("double");
QTest::newRow("20") << int(QMetaType::Float) << QByteArray("float");
QTest::newRow("21") << int(QVariant::Polygon) << QByteArray("QPolygon");
QTest::newRow("22") << int(QVariant::Region) << QByteArray("QRegion");
QTest::newRow("23") << int(QVariant::Bitmap) << QByteArray("QBitmap");
QTest::newRow("24") << int(QVariant::Cursor) << QByteArray("QCursor");
QTest::newRow("25") << int(QVariant::SizePolicy) << QByteArray("QSizePolicy");
QTest::newRow("26") << int(QVariant::Date) << QByteArray("QDate");
QTest::newRow("27") << int(QVariant::Time) << QByteArray("QTime");
QTest::newRow("28") << int(QVariant::DateTime) << QByteArray("QDateTime");
QTest::newRow("29") << int(QVariant::ByteArray) << QByteArray("QByteArray");
QTest::newRow("30") << int(QVariant::BitArray) << QByteArray("QBitArray");
QTest::newRow("31") << int(QVariant::KeySequence) << QByteArray("QKeySequence");
QTest::newRow("32") << int(QVariant::Pen) << QByteArray("QPen");
QTest::newRow("33") << int(QVariant::LongLong) << QByteArray("qlonglong");
QTest::newRow("34") << int(QVariant::ULongLong) << QByteArray("qulonglong");
QTest::newRow("35") << int(QVariant::Char) << QByteArray("QChar");
QTest::newRow("36") << int(QVariant::Url) << QByteArray("QUrl");
QTest::newRow("37") << int(QVariant::TextLength) << QByteArray("QTextLength");
QTest::newRow("38") << int(QVariant::TextFormat) << QByteArray("QTextFormat");
QTest::newRow("39") << int(QVariant::Locale) << QByteArray("QLocale");
QTest::newRow("40") << int(QVariant::LineF) << QByteArray("QLineF");
QTest::newRow("41") << int(QVariant::RectF) << QByteArray("QRectF");
QTest::newRow("42") << int(QVariant::PointF) << QByteArray("QPointF");
QTest::newRow("43") << int(QVariant::RegExp) << QByteArray("QRegExp");
QTest::newRow("44") << int(QVariant::UserType) << QByteArray("UserType");
QTest::newRow("45") << int(QVariant::Matrix) << QByteArray("QMatrix");
QTest::newRow("46") << int(QVariant::Transform) << QByteArray("QTransform");
QTest::newRow("47") << int(QVariant::Hash) << QByteArray("QVariantHash");
QTest::newRow("48") << int(QVariant::Matrix4x4) << QByteArray("QMatrix4x4");
QTest::newRow("49") << int(QVariant::Vector2D) << QByteArray("QVector2D");
QTest::newRow("50") << int(QVariant::Vector3D) << QByteArray("QVector3D");
QTest::newRow("51") << int(QVariant::Vector4D) << QByteArray("QVector4D");
QTest::newRow("52") << int(QVariant::Quaternion) << QByteArray("QQuaternion");
QTest::newRow("12") << int(QVariant::Point) << QByteArray("QPoint");
QTest::newRow("13") << int(QVariant::Image) << QByteArray("QImage");
QTest::newRow("14") << int(QVariant::Int) << QByteArray("int");
QTest::newRow("15") << int(QVariant::UInt) << QByteArray("uint");
QTest::newRow("16") << int(QVariant::Bool) << QByteArray("bool");
QTest::newRow("17") << int(QVariant::Double) << QByteArray("double");
QTest::newRow("18") << int(QMetaType::Float) << QByteArray("float");
QTest::newRow("19") << int(QVariant::Polygon) << QByteArray("QPolygon");
QTest::newRow("20") << int(QVariant::Region) << QByteArray("QRegion");
QTest::newRow("21") << int(QVariant::Bitmap) << QByteArray("QBitmap");
QTest::newRow("22") << int(QVariant::Cursor) << QByteArray("QCursor");
QTest::newRow("23") << int(QVariant::SizePolicy) << QByteArray("QSizePolicy");
QTest::newRow("24") << int(QVariant::Date) << QByteArray("QDate");
QTest::newRow("25") << int(QVariant::Time) << QByteArray("QTime");
QTest::newRow("26") << int(QVariant::DateTime) << QByteArray("QDateTime");
QTest::newRow("27") << int(QVariant::ByteArray) << QByteArray("QByteArray");
QTest::newRow("28") << int(QVariant::BitArray) << QByteArray("QBitArray");
QTest::newRow("29") << int(QVariant::KeySequence) << QByteArray("QKeySequence");
QTest::newRow("30") << int(QVariant::Pen) << QByteArray("QPen");
QTest::newRow("31") << int(QVariant::LongLong) << QByteArray("qlonglong");
QTest::newRow("32") << int(QVariant::ULongLong) << QByteArray("qulonglong");
QTest::newRow("33") << int(QVariant::Char) << QByteArray("QChar");
QTest::newRow("34") << int(QVariant::Url) << QByteArray("QUrl");
QTest::newRow("35") << int(QVariant::TextLength) << QByteArray("QTextLength");
QTest::newRow("36") << int(QVariant::TextFormat) << QByteArray("QTextFormat");
QTest::newRow("37") << int(QVariant::Locale) << QByteArray("QLocale");
QTest::newRow("38") << int(QVariant::LineF) << QByteArray("QLineF");
QTest::newRow("39") << int(QVariant::RectF) << QByteArray("QRectF");
QTest::newRow("40") << int(QVariant::PointF) << QByteArray("QPointF");
QTest::newRow("41") << int(QVariant::RegExp) << QByteArray("QRegExp");
QTest::newRow("42") << int(QVariant::UserType) << QByteArray("UserType");
QTest::newRow("43") << int(QVariant::Matrix) << QByteArray("QMatrix");
QTest::newRow("44") << int(QVariant::Transform) << QByteArray("QTransform");
QTest::newRow("45") << int(QVariant::Hash) << QByteArray("QVariantHash");
QTest::newRow("46") << int(QVariant::Matrix4x4) << QByteArray("QMatrix4x4");
QTest::newRow("47") << int(QVariant::Vector2D) << QByteArray("QVector2D");
QTest::newRow("48") << int(QVariant::Vector3D) << QByteArray("QVector3D");
QTest::newRow("49") << int(QVariant::Vector4D) << QByteArray("QVector4D");
QTest::newRow("50") << int(QVariant::Quaternion) << QByteArray("QQuaternion");
}
void tst_QVariant::typeName()
@ -2105,9 +1963,6 @@ void tst_QVariant::typeToName()
QVERIFY( QVariant::nameToType( "" ) == QVariant::Invalid );
QVERIFY( QVariant::nameToType( "foo" ) == QVariant::Invalid );
QCOMPARE(QVariant::nameToType("QIconSet"), QVariant::Icon);
#ifdef QT3_SUPPORT
QCOMPARE(QVariant::nameToType("Q3CString"), QVariant::ByteArray);
#endif
}
void tst_QVariant::streamInvalidVariant()
@ -2138,45 +1993,6 @@ void tst_QVariant::streamInvalidVariant()
QVERIFY( readY == writeY );
}
void tst_QVariant::nullAsType()
{
#ifdef QT3_SUPPORT
QVariant null;
QVERIFY(null.isNull());
null.asInt();
QVERIFY(null.isNull());
null = QVariant(QString::null);
QVERIFY(null.isNull());
null.asInt();
QVERIFY(null.isNull());
int type = QVariant::Invalid;
while (type < (int)QVariant::ULongLong) {
null = QVariant();
QVERIFY(null.isNull());
type++;
if (type == 20)
continue;
if (type == QVariant::Size)
// QSize has its own ideas of ::isNull
continue;
if (!null.convert((QVariant::Type)type))
continue;
QCOMPARE((int)null.type(), type);
QVERIFY2(null.isNull(), qPrintable(QString("'null.isNull()' failed for type: %1").arg(null.typeName())));
}
null = QVariant(QLatin1String(static_cast<const char *>(0)));
QVERIFY(null.isNull());
#endif
}
static int instanceCount = 0;
struct MyType
@ -2633,20 +2449,6 @@ void tst_QVariant::variantHash()
QCOMPARE(qvariant_cast<QVariantHash>(v3).value("test").toInt(), 42);
}
void tst_QVariant::invalidAsByteArray()
{
#ifdef QT3_SUPPORT
QVariant v;
QByteArray &a = v.asByteArray();
a.resize(2);
a[0] = 'a';
a[1] = 'b';
QCOMPARE(v, QVariant(QByteArray("ab")));
#else
QSKIP("Qt compiled without Qt3Support",SkipAll);
#endif
}
void tst_QVariant::invalidQColor() const
{
QVariant va("An invalid QColor::name() value.");

View File

@ -40,10 +40,6 @@
****************************************************************************/
#if defined(QT3_SUPPORT)
#include <q3hbox.h>
#include <q3textedit.h>
#endif
#include <qboxlayout.h>
#include <qapplication.h>
#include <qbitmap.h>
@ -169,7 +165,6 @@ public:
tst_QWidget();
virtual ~tst_QWidget();
public slots:
void initTestCase();
void cleanupTestCase();
@ -189,10 +184,8 @@ private slots:
void isVisibleTo();
void isHidden();
void fonts();
void mapToGlobal();
void mapFromAndTo_data();
void mapFromAndTo();
void checkFocus();
void focusChainOnHide();
void focusChainOnReparent();
void setTabOrder();
@ -650,9 +643,6 @@ void tst_QWidget::initTestCase()
// Create the test class
testWidget = new BezierViewer( 0, "testObject");
testWidget->resize(200,200);
#ifdef QT3_SUPPORT
qApp->setMainWidget(testWidget);
#endif
testWidget->show();
QTest::qWaitForWindowShown(testWidget);
QTest::qWait(50);
@ -1343,27 +1333,6 @@ void tst_QWidget::fonts()
QVERIFY( cleanTestWidget->font() == originalFont );
}
void tst_QWidget::mapToGlobal()
{
#if !defined(QT3_SUPPORT)
QSKIP("No Qt3 Support", SkipAll);
#else
QPoint vis = testWidget->mapToGlobal(QPoint(0,0));
testWidget->hide();
QCOMPARE(testWidget->mapToGlobal(QPoint(0,0)), vis);
testWidget->show();
// test in a layout and witha move
Q3HBox * qhb = new Q3HBox(testWidget);
QWidget * qw = new QWidget(qhb);
qw->move(6,12);
QPoint wVis = qw->mapToGlobal(QPoint(0,0));
qw->hide();
QCOMPARE(qw->mapToGlobal(QPoint(0,0)), wVis);
delete qhb;
#endif // QT3_SUPPORT
}
void tst_QWidget::mapFromAndTo_data()
{
QTest::addColumn<bool>("windowHidden");
@ -1654,36 +1623,6 @@ void tst_QWidget::focusChainOnHide()
testWidget->show(); //don't disturb later tests
}
void tst_QWidget::checkFocus()
{
#if !defined(QT3_SUPPORT)
QSKIP("No Qt3 Support", SkipAll);
#else
// This is a very specific test for a specific bug, the bug was
// that when setEnabled(FALSE) then setEnabled(TRUE) was called on
// the parent of a child widget which had focus while hidden, then
// when the widget was shown, the focus would be in the wrong place.
Q3HBox widget;
QLineEdit *focusWidget = new QLineEdit( &widget );
new QLineEdit( &widget );
new QPushButton( &widget );
focusWidget->setFocus();
widget.setEnabled( FALSE );
widget.setEnabled( TRUE );
widget.show();
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&widget);
#endif
QTest::qWait( 100 );
widget.activateWindow();
// next call is necessary since the window manager may not give the focus to the widget when
// it is shown, which causes the QVERIFY to fail
QApplication::setActiveWindow(&widget);
QVERIFY( qApp->focusWidget() == focusWidget );
#endif // QT3_SUPPORT
}
class Container : public QWidget
{
public:
@ -2014,28 +1953,6 @@ void tst_QWidget::showMaximized()
widget.showMaximized();
QTRY_VERIFY(widget.size().width() > 20 && widget.size().height() > 20);
}
#ifdef QT3_SUPPORT
#if !defined(Q_WS_QWS)
//embedded respects max/min sizes by design -- maybe wrong design, but that's the way it is now.
{
Q3HBox box;
QWidget widget(&box);
widget.setMinimumSize(500, 500);
box.showMaximized();
QVERIFY(box.isMaximized());
}
{
Q3HBox box;
QWidget widget(&box);
widget.setMaximumSize(500, 500);
box.showMaximized();
QVERIFY(box.isMaximized());
}
#endif
#endif // QT3_SUPPORT
}
void tst_QWidget::showFullScreen()
@ -2107,28 +2024,6 @@ void tst_QWidget::showFullScreen()
widget.showFullScreen();
QVERIFY(widget.isFullScreen());
}
#ifdef QT3_SUPPORT
#if !defined(Q_WS_QWS)
//embedded respects max/min sizes by design -- maybe wrong design, but that's the way it is now.
{
Q3HBox box;
QWidget widget(&box);
widget.setMinimumSize(500, 500);
box.showFullScreen();
QVERIFY(box.isFullScreen());
}
{
Q3HBox box;
QWidget widget(&box);
widget.setMaximumSize(500, 500);
box.showFullScreen();
QVERIFY(box.isFullScreen());
}
#endif
#endif // QT3_SUPPORT
}
class ResizeWidget : public QWidget {
@ -6374,11 +6269,6 @@ void tst_QWidget::compatibilityChildInsertedEvents()
QCoreApplication::sendPostedEvents();
expected =
EventRecorder::EventList()
#ifdef QT_HAS_QT3SUPPORT
<< qMakePair(&widget, QEvent::ChildInsertedRequest)
<< qMakePair(&widget, QEvent::ChildInserted)
<< qMakePair(&widget, QEvent::ChildInserted)
#endif
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Polish)
<< qMakePair(&widget, QEvent::ChildPolished)
@ -6414,10 +6304,6 @@ void tst_QWidget::compatibilityChildInsertedEvents()
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::WinIdChange)
<< qMakePair(&widget, QEvent::Polish)
#ifdef QT_HAS_QT3SUPPORT
<< qMakePair(&widget, QEvent::ChildInserted)
<< qMakePair(&widget, QEvent::ChildInserted)
#endif
<< qMakePair(&widget, QEvent::ChildPolished)
<< qMakePair(&widget, QEvent::ChildPolished)
<< qMakePair(&widget, QEvent::Move)
@ -6433,9 +6319,6 @@ void tst_QWidget::compatibilityChildInsertedEvents()
QCoreApplication::sendPostedEvents();
expected =
EventRecorder::EventList()
#ifdef QT_HAS_QT3SUPPORT
<< qMakePair(&widget, QEvent::ChildInsertedRequest)
#endif
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
<< qMakePair(&widget, QEvent::Type(QEvent::User + 2));
@ -6476,10 +6359,6 @@ void tst_QWidget::compatibilityChildInsertedEvents()
QCoreApplication::sendPostedEvents();
expected =
EventRecorder::EventList()
#ifdef QT_HAS_QT3SUPPORT
<< qMakePair(&widget, QEvent::ChildInsertedRequest)
<< qMakePair(&widget, QEvent::ChildInserted)
#endif
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Polish)
<< qMakePair(&widget, QEvent::ChildPolished)
@ -6516,9 +6395,6 @@ void tst_QWidget::compatibilityChildInsertedEvents()
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::WinIdChange)
<< qMakePair(&widget, QEvent::Polish)
#ifdef QT_HAS_QT3SUPPORT
<< qMakePair(&widget, QEvent::ChildInserted)
#endif
<< qMakePair(&widget, QEvent::ChildPolished)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
@ -6533,9 +6409,6 @@ void tst_QWidget::compatibilityChildInsertedEvents()
QCoreApplication::sendPostedEvents();
expected =
EventRecorder::EventList()
#ifdef QT_HAS_QT3SUPPORT
<< qMakePair(&widget, QEvent::ChildInsertedRequest)
#endif
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
<< qMakePair(&widget, QEvent::Type(QEvent::User + 2));
@ -6996,9 +6869,7 @@ void tst_QWidget::renderWithPainter()
void tst_QWidget::render_task188133()
{
QMainWindow mainWindow;
#if defined(QT3_SUPPORT)
mainWindow.setCentralWidget(new Q3TextEdit);
#endif
// Make sure QWidget::render does not trigger QWidget::repaint/update
// and asserts for Qt::WA_WState_Created.
QPixmap pixmap = QPixmap::grabWidget(&mainWindow);

View File

@ -45,10 +45,6 @@
#include <qmainwindow.h>
#include <qmenubar.h>
#include <qworkspace.h>
#if defined(QT3_SUPPORT)
#include <q3popupmenu.h>
#include <q3accel.h>
#endif
//TESTED_CLASS=
//TESTED_FILES=
@ -75,7 +71,6 @@ private slots:
void getSetCheck();
void windowActivated_data();
void windowActivated();
void accelPropagation();
void windowActivatedWithMinimize();
void showWindows();
void changeWindowTitle();
@ -314,59 +309,6 @@ void tst_QWorkspace::accelActivated()
accelPressed = TRUE;
}
void tst_QWorkspace::accelPropagation()
{
#if defined (QT3_SUPPORT)
QSKIP( "Until QTest::keyPress() sends the events via the OS, this will skip", SkipAll);
// See #13987 for details of bug report related to this
QMainWindow mw(0, Qt::X11BypassWindowManagerHint) ;
mw.menuBar();
QWorkspace *workspace = new QWorkspace(&mw);
workspace->setObjectName("testWidget");
mw.setCentralWidget(workspace);
connect( workspace, SIGNAL(windowActivated(QWidget*)), this, SLOT(activeChanged(QWidget*)) );
mw.show();
qApp->setActiveWindow(&mw);
QMainWindow* mainWindow = new QMainWindow( workspace );
// The popup menu has to have no parent, this is vital in the
// original case of reproducing the bug
Q3PopupMenu* popup = new Q3PopupMenu;
popup->insertItem("First");
mainWindow->menuBar()->insertItem("Menu", popup);
Q3Accel* accel = new Q3Accel(mainWindow);
accel->connectItem(accel->insertItem(Qt::Key_Escape), this, SLOT(accelActivated()) );
mainWindow->show();
QTest::keyPress( mainWindow, Qt::Key_Escape );
QVERIFY( accelPressed );
accelPressed = FALSE;
QTest::mousePress( mainWindow->menuBar(), Qt::LeftButton, 0, QPoint( 5, 5 ) );
// Check the popup menu did appear to be sure
QVERIFY( qApp->activePopupWidget() == popup );
QTest::mouseClick( popup, Qt::LeftButton, 0, QPoint( 5, 25 ) );
// Check we did actually cause the popup menu to be closed
QVERIFY( !popup->isVisible() );
// Now we check that the accelarator still works
QTest::keyPress( mainWindow, Qt::Key_Escape );
QVERIFY( accelPressed );
delete popup;
#else
QSKIP( "No Qt3Support. Skipping.", SkipAll);
#endif
}
void tst_QWorkspace::showWindows()
{
QWorkspace *ws = new QWorkspace( 0 );

View File

@ -52,6 +52,7 @@
#include <QtCore/QDir>
#include <QtCore/QQueue>
#include <QtCore/QHash>
#include <QtCore/QPair>
#include <QtCore/qdebug.h>
#include <QtCore/QCoreApplication>
@ -177,44 +178,97 @@ QAbstractFormBuilder::~QAbstractFormBuilder()
{
}
// Return UI file version from attribute 'version="4.0"'
static QPair<int, int> uiVersion(const QString &attr)
{
const QStringList versions = attr.split(QLatin1Char('.'), QString::SkipEmptyParts);
if (versions.size() >= 2) {
bool okMajor, okMinor;
const int majorVersion = versions.at(0).toInt(&okMajor);
const int minorVersion = versions.at(1).toInt(&okMinor);
if (okMajor && okMinor)
return QPair<int, int>(majorVersion, minorVersion);
}
return QPair<int, int>(-1, -1);
}
static inline QString msgXmlError(const QXmlStreamReader &reader)
{
return QCoreApplication::translate("QAbstractFormBuilder", "An error has occurred while reading the UI file at line %1, column %2: %3")
.arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString());
}
// Read and check the version and the (optional) language attribute
// of an <ui> element and leave reader positioned at <ui>.
static bool inline readUiAttributes(QXmlStreamReader &reader, const QString &language, QString *errorMessage)
{
const QString uiElement = QLatin1String("ui");
// Read up to first element
while (!reader.atEnd()) {
switch (reader.readNext()) {
case QXmlStreamReader::Invalid:
*errorMessage = msgXmlError(reader);
return false;
case QXmlStreamReader::StartElement:
if (reader.name().compare(uiElement, Qt::CaseInsensitive) == 0) {
const QString versionAttribute = QLatin1String("version");
const QString languageAttribute = QLatin1String("language");
const QXmlStreamAttributes attributes = reader.attributes();
if (attributes.hasAttribute(versionAttribute)) {
const QString versionString = attributes.value(versionAttribute).toString();
if (uiVersion(versionString).first < 4) {
*errorMessage = QCoreApplication::translate("QAbstractFormBuilder", "This file was created using Designer from Qt-%1 and cannot be read.")
.arg(versionString);
return false;
} // version error
} // has version
if (attributes.hasAttribute(languageAttribute)) {
// Check on optional language (Jambi)
const QString formLanguage = attributes.value(languageAttribute).toString();
if (!formLanguage.isEmpty() && formLanguage.compare(language, Qt::CaseInsensitive)) {
*errorMessage = QCoreApplication::translate("QAbstractFormBuilder", "This file cannot be read because it was created using %1.").arg(formLanguage);
return false;
} // language error
} // has language
return true;
} // <ui> matched
break;
default:
break;
}
}
// No <ui> found.
*errorMessage = QCoreApplication::translate("QAbstractFormBuilder", "Invalid UI file: The root element <ui> is missing.");
return false;
}
/*!
\fn QWidget *QAbstractFormBuilder::load(QIODevice *device, QWidget *parent)
Loads an XML representation of a widget from the given \a device,
and constructs a new widget with the specified \a parent.
\sa save()
\sa save(), errorString()
*/
QWidget *QAbstractFormBuilder::load(QIODevice *dev, QWidget *parentWidget)
{
QXmlStreamReader reader;
reader.setDevice(dev);
QXmlStreamReader reader(dev);
d->m_errorString.clear();
if (!readUiAttributes(reader, d->m_language, &d->m_errorString)) {
uiLibWarning(d->m_errorString);
return false;
}
DomUI ui;
bool initialized = false;
const QString uiElement = QLatin1String("ui");
while (!reader.atEnd()) {
if (reader.readNext() == QXmlStreamReader::StartElement) {
if (reader.name().compare(uiElement, Qt::CaseInsensitive) == 0) {
ui.read(reader);
initialized = true;
} else {
reader.raiseError(QCoreApplication::translate("QAbstractFormBuilder", "Unexpected element <%1>").arg(reader.name().toString()));
}
}
}
ui.read(reader);
if (reader.hasError()) {
uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "An error has occurred while reading the UI file at line %1, column %2: %3")
.arg(reader.lineNumber()).arg(reader.columnNumber())
.arg(reader.errorString()));
return 0;
}
if (!initialized) {
uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "Invalid UI file: The root element <ui> is missing."));
d->m_errorString = msgXmlError(reader);
uiLibWarning(d->m_errorString);
return 0;
}
QWidget *widget = create(&ui, parentWidget);
if (!widget && d->m_errorString.isEmpty())
d->m_errorString = QCoreApplication::translate("QAbstractFormBuilder", "Invalid UI file");
return widget;
}
@ -3119,4 +3173,16 @@ bool QAbstractFormBuilder::isScriptingEnabled() const
#endif
}
/*!
Returns a human-readable description of the last error occurred in load().
\since 5.0
\sa load()
*/
QString QAbstractFormBuilder::errorString() const
{
return d->m_errorString;
}
QT_END_NAMESPACE

View File

@ -127,6 +127,8 @@ public:
void setScriptingEnabled(bool enabled);
bool isScriptingEnabled() const;
QString errorString() const;
protected:
//
// load

View File

@ -87,6 +87,7 @@ QFormBuilderExtra::CustomWidgetData::CustomWidgetData(const DomCustomWidget *dcw
QFormBuilderExtra::QFormBuilderExtra() :
m_defaultMargin(INT_MIN),
m_defaultSpacing(INT_MIN),
m_language(QLatin1String("c++")),
m_layoutWidget(false),
m_resourceBuilder(0),
m_textBuilder(0)

View File

@ -180,6 +180,8 @@ public:
int m_defaultMargin;
int m_defaultSpacing;
QDir m_workingDirectory;
QString m_errorString;
QString m_language;
private:
void clearResourceBuilder();