CFG_DECORATION_PLUGIN=
CFG_XINPUT=runtime
CFG_XKB=auto
+CFG_XCB=no
CFG_NIS=auto
CFG_CUPS=auto
CFG_ICONV=auto
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
;;
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"
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>]
$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
[ "$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"
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"
--- /dev/null
+CONFIG += testcase
+
+!symbian {
+ INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtQuickTest
+} else {
+ load(data_caging_paths)
+
+ INCLUDEPATH+=$$MW_LAYER_PUBLIC_EXPORT_PATH(QtQuickTest)
+}
+
+QT += declarative
+
+win32:CONFIG(debug, debug|release) {
+ LIBS += -lQtQuickTest$${QT_LIBINFIX}d
+} else {
+ LIBS += -lQtQuickTest$${QT_LIBINFIX}
+}
+
+# If the .pro file specified an IMPORTPATH, then add that to
+# the command-line when the test is run.
+!isEmpty(IMPORTPATH) {
+ load(testcase)
+ for(import, IMPORTPATH): check.commands += -import \"$$import\"
+}
+DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$OUT_PWD\\\"\"
# Allow for custom arguments to tests
check.commands += $(TESTARGS)
+
+# If the test is marked as insignificant, discard the exit code
+insignificant_test:check.commands = -$${check.commands}
+
QMAKE_EXTRA_TARGETS *= check
!debug_and_release|build_pass {
} else {
// Qt controls everything (default)
- if (QApplication::testAttribute(Qt::AA_X11InitThreads))
- XInitThreads();
+ // With the threaded QML renderer, we always need this.
+ XInitThreads();
// Set application name and class
char *app_class = 0;
{
Q_D(const QWidget);
+ QPlatformWindowFormat format;
+
QTLWExtra *extra = d->maybeTopData();
if (extra){
- return extra->platformWindowFormat;
+ format = extra->platformWindowFormat;
} else {
- return QPlatformWindowFormat::defaultFormat();
+ format = QPlatformWindowFormat::defaultFormat();
}
+
+ if (testAttribute(Qt::WA_TranslucentBackground))
+ format.setAlpha(true);
+
+ return format;
}
void QWidgetPrivate::createSysExtra()
void QColor::setNamedColor(const QString &name)
{
- if (!setColorFromString(name))
- qWarning("QColor::setNamedColor: Unknown color name '%s'", name.toLatin1().constData());
+ setColorFromString(name);
}
/*!
static inline Int32x4 v_toInt(Float32x4 x) { return vcvtq_s32_f32(x); }
- static inline Int32x4 v_greaterOrEqual(Float32x4 a, Float32x4 b) { return vcge_f32(a, b); }
+ static inline Int32x4 v_greaterOrEqual(Float32x4 a, Float32x4 b) { return vreinterpretq_s32_u32(vcgeq_f32(a, b)); }
};
const uint * QT_FASTCALL qt_fetch_radial_gradient_neon(uint *buffer, const Operator *op, const QSpanData *data,
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);
+ }
}
/*!
#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>
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
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); }
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;
d->strikeOut = strikeOut;
}
+/*!
+ Returns the smallest rectangle that contains all glyphs in this QGlyphRun.
+
+ \since 5.0
+*/
+QRectF QGlyphRun::boundingRect() const
+{
+ qreal minX, minY, maxX, maxY;
+
+ for (int i=0; i<qMin(d->glyphPositions.size(), d->glyphIndexes.size()); ++i) {
+ QRectF glyphRect = d->rawFont.boundingRect(d->glyphIndexes.at(i));
+ glyphRect.translate(d->glyphPositions.at(i));
+
+ if (i == 0) {
+ minX = glyphRect.left();
+ minY = glyphRect.top();
+ maxX = glyphRect.right();
+ maxY = glyphRect.bottom();
+ } else {
+ minX = qMin(glyphRect.left(), minX);
+ minY = qMin(glyphRect.top(), minY);
+ maxX = qMax(glyphRect.right(),maxX);
+ maxY = qMax(glyphRect.bottom(), maxY);
+ }
+ }
+
+ return QRectF(QPointF(minX, minY), QPointF(maxX, maxY));
+}
+
QT_END_NAMESPACE
#endif // QT_NO_RAWFONT
void setStrikeOut(bool strikeOut);
bool strikeOut() const;
+ QRectF boundingRect() const;
+
private:
friend class QGlyphRunPrivate;
friend class QTextLine;
hintingPreference = QFont::PreferDefaultHinting;
}
+/*!
+ Returns the smallest rectangle containing the glyph with the given \a glyphIndex.
+
+ \since 5.0
+*/
+QRectF QRawFont::boundingRect(quint32 glyphIndex) const
+{
+ if (!isValid())
+ return QRectF();
+
+ glyph_metrics_t gm = d->fontEngine->boundingBox(glyphIndex);
+ return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
+}
+
#endif // QT_NO_RAWFONT
QT_END_NAMESPACE
AntialiasingType antialiasingType = SubPixelAntialiasing,
const QTransform &transform = QTransform()) const;
QPainterPath pathForGlyph(quint32 glyphIndex) const;
+ QRectF boundingRect(quint32 glyphIndex) const;
void setPixelSize(qreal pixelSize);
qreal pixelSize() const;
\sa draw(), QPainter::drawGlyphRun()
*/
#if !defined(QT_NO_RAWFONT)
-QList<QGlyphRun> QTextLayout::glyphRuns() const
-{
+QList<QGlyphRun> QTextLayout::glyphRuns(int from, int length) const
+{
+ if (from < 0)
+ from = 0;
+ if (length < 0)
+ length = text().length();
+
QList<QGlyphRun> glyphs;
- for (int i=0; i<d->lines.size(); ++i)
- glyphs += QTextLine(i, d).glyphs(-1, -1);
+ for (int i=0; i<d->lines.size(); ++i) {
+ if (d->lines[i].from > from + length)
+ break;
+ else if (d->lines[i].from + d->lines[i].length >= from)
+ glyphs += QTextLine(i, d).glyphRuns(from, length);
+ }
return glyphs;
}
}
/*!
- \internal
+ Returns the glyph indexes and positions for all glyphs in this QTextLine for characters
+ in the range defined by \a from and \a length. The \a from index is relative to the beginning
+ of the text in the containing QTextLayout, and the range must be within the range of QTextLine
+ as given by functions textStart() and textLength().
- Returns the glyph indexes and positions for all glyphs in this QTextLine which reside in
- QScriptItems that overlap with the range defined by \a from and \a length. The arguments
- specify characters, relative to the text in the layout. Note that it is not possible to
- use this function to retrieve a subset of the glyphs in a QScriptItem.
+ If \a from is negative, it will default to textStart(), and if \a length is negative it will
+ default to the return value of textLength().
- \since 4.8
+ \since 5.0
\sa QTextLayout::glyphRuns()
*/
#if !defined(QT_NO_RAWFONT)
-QList<QGlyphRun> QTextLine::glyphs(int from, int length) const
+QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
{
const QScriptLine &line = eng->lines[i];
if (line.length == 0)
return QList<QGlyphRun>();
+ if (from < 0)
+ from = textStart();
+
+ if (length < 0)
+ length = textLength();
+
QHash<QFontEngine *, GlyphInfo> glyphLayoutHash;
QTextLineItemIterator iterator(eng, i);
QPointF pos(iterator.x.toReal(), y);
if (from >= 0 && length >= 0 &&
- (from >= si.position + eng->length(&si) || from + length <= si.position))
+ (from >= si.position + eng->length(&si) || from + length <= si.position)) {
continue;
+ }
QFont font = eng->font(si);
flags |= QTextItem::Underline;
if (font.strikeOut())
flags |= QTextItem::StrikeOut;
- if (si.analysis.bidiLevel % 2)
+
+ bool rtl = false;
+ if (si.analysis.bidiLevel % 2) {
flags |= QTextItem::RightToLeft;
+ rtl = true;
+ }
- QGlyphLayout glyphLayout = eng->shapedGlyphs(&si).mid(iterator.glyphsStart,
- iterator.glyphsEnd - iterator.glyphsStart);
+ int relativeFrom = qMax(iterator.itemStart, from) - si.position;
+ int relativeTo = qMin(iterator.itemEnd, from + length - 1) - si.position;
+
+ unsigned short *logClusters = eng->logClusters(&si);
+ int glyphsStart = logClusters[relativeFrom];
+ int glyphsEnd = (relativeTo == eng->length(&si))
+ ? si.num_glyphs - 1
+ : logClusters[relativeTo];
+
+ QGlyphLayout glyphLayout = eng->shapedGlyphs(&si);
+
+ // Calculate new x position of glyph layout for a subset. This becomes somewhat complex
+ // when we're breaking a RTL script item, since the expected position passed into
+ // getGlyphPositions() is the left-most edge of the left-most glyph in an RTL run.
+ if (relativeFrom != (iterator.itemStart - si.position) && !rtl) {
+ for (int i=0; i<glyphsStart; ++i) {
+ QFixed justification = QFixed::fromFixed(glyphLayout.justifications[i].space_18d6);
+ pos += QPointF((glyphLayout.advances_x[i] + justification).toReal(),
+ glyphLayout.advances_y[i].toReal());
+ }
+ } else if (relativeTo != (iterator.itemEnd - si.position) && rtl) {
+ for (int i=glyphLayout.numGlyphs - 1; i>glyphsEnd; --i) {
+ QFixed justification = QFixed::fromFixed(glyphLayout.justifications[i].space_18d6);
+ pos += QPointF((glyphLayout.advances_x[i] + justification).toReal(),
+ glyphLayout.advances_y[i].toReal());
+ }
+ }
+
+ glyphLayout = glyphLayout.mid(glyphsStart, glyphsEnd - glyphsStart + 1);
if (glyphLayout.numGlyphs > 0) {
QFontEngine *mainFontEngine = font.d->engineForScript(si.analysis.script);
QGlyphLayout subLayout = glyphLayout.mid(start, end - start);
glyphLayoutHash.insertMulti(multiFontEngine->engine(which),
GlyphInfo(subLayout, pos, flags));
- for (int i = 0; i < subLayout.numGlyphs; i++)
+ for (int i = 0; i < subLayout.numGlyphs; i++) {
pos += QPointF(subLayout.advances_x[i].toReal(),
subLayout.advances_y[i].toReal());
+ }
start = end;
which = e;
pos = 0;
int glyph_pos = pos == l ? si->num_glyphs : logClusters[pos];
- if (edge == Trailing) {
+ if (edge == Trailing && glyph_pos < si->num_glyphs) {
// trailing edge is leading edge of next cluster
+ glyph_pos++;
while (glyph_pos < si->num_glyphs && !glyphs.attributes[glyph_pos].clusterStart)
glyph_pos++;
}
qreal maximumWidth() const;
#if !defined(QT_NO_RAWFONT)
- QList<QGlyphRun> glyphRuns() const;
+ QList<QGlyphRun> glyphRuns(int from = -1, int length = -1) const;
#endif
QTextEngine *engine() const { return d; }
void draw(QPainter *p, const QPointF &point, const QTextLayout::FormatRange *selection = 0) const;
+#if !defined(QT_NO_RAWFONT)
+ QList<QGlyphRun> glyphRuns(int from = -1, int length = -1) const;
+#endif
+
private:
QTextLine(int line, QTextEngine *e) : i(line), eng(e) {}
void layout_helper(int numGlyphs);
-#if !defined(QT_NO_RAWFONT)
- QList<QGlyphRun> glyphs(int from, int length) const;
-#endif
-
friend class QTextLayout;
friend class QTextFragment;
int i;
QList<QGlyphRun> ret;
for (int i=0; i<layout->lineCount(); ++i) {
QTextLine textLine = layout->lineAt(i);
- ret += textLine.glyphs(pos, len);
+ ret += textLine.glyphRuns(pos, len);
}
return ret;
void setCursorBlinkPeriod(int msec);
void resetCursorBlinkTimer();
+ bool cursorBlinkStatus() const { return m_blinkStatus; }
+
QString cancelText() const { return m_cancelText; }
void setCancelText(const QString &text) { m_cancelText = text; }
bool processEvent(QEvent *ev);
+ QTextLayout *textLayout()
+ {
+ return &m_textLayout;
+ }
+
private:
void init(const QString &txt);
void removeSelectedText();
Returns the address as a string.
For example, if the address is the IPv4 address 127.0.0.1, the
- returned string is "127.0.0.1".
+ returned string is "127.0.0.1". For IPv6 the string format will
+ follow the RFC5952 recommendation.
\sa toIPv4Address()
*/
ugle[i] = (quint16(d->a6[2*i]) << 8) | quint16(d->a6[2*i+1]);
}
QString s;
- s.sprintf("%X:%X:%X:%X:%X:%X:%X:%X",
- ugle[0], ugle[1], ugle[2], ugle[3], ugle[4], ugle[5], ugle[6], ugle[7]);
+ QString temp;
+ bool zeroDetected = false;
+ bool zeroShortened = false;
+ for (int i = 0; i < 8; i++) {
+ if ((ugle[i] != 0) || zeroShortened) {
+ temp.sprintf("%X", ugle[i]);
+ s.append(temp);
+ if (zeroDetected)
+ zeroShortened = true;
+ } else {
+ if (!zeroDetected) {
+ if (i<7 && (ugle[i+1] == 0)) {
+ s.append(QLatin1Char(':'));
+ zeroDetected = true;
+ } else {
+ temp.sprintf("%X", ugle[i]);
+ s.append(temp);
+ if (i<7)
+ s.append(QLatin1Char(':'));
+ }
+ }
+ }
+ if (i<7 && ((ugle[i] != 0) || zeroShortened || (i==0 && zeroDetected)))
+ s.append(QLatin1Char(':'));
+ }
+
if (!d->scopeId.isEmpty())
s.append(QLatin1Char('%') + d->scopeId);
return s;
#ifdef SIOCGIFHWADDR
// Get the HW address
if (qt_safe_ioctl(socket, SIOCGIFHWADDR, &req) >= 0) {
- uchar *addr = (uchar *)&req.ifr_addr;
+ uchar *addr = (uchar *)req.ifr_addr.sa_data;
iface->hardwareAddress = iface->makeHwAddress(6, addr);
}
#endif
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();
+
+ // 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);
+ d->drawCachedGlyphs(glyphType, textItem);
+ } else {
+ QPaintEngineEx::drawStaticTextItem(textItem);
+ }
}
bool QGL2PaintEngineEx::drawTexture(const QRectF &dest, GLuint textureId, const QSize &size, const QRectF &src)
if (shareContext) {
winFormat.setSharedContext(shareContext->d_func()->platformContext);
}
+ if (widget->testAttribute(Qt::WA_TranslucentBackground))
+ winFormat.setAlpha(true);
winFormat.setWindowApi(QPlatformWindowFormat::OpenGL);
winFormat.setWindowSurface(false);
widget->setPlatformWindowFormat(winFormat);
// 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"
d_ptr->did_paint = true;
updateGeometry();
- if (!context())
- return;
-
int clearFlags = 0;
- if (context()->d_func()->workaround_needsFullClearOnEveryFrame)
+ QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext);
+
+ if (!ctx)
+ return;
+
+ if (ctx->d_func()->workaround_needsFullClearOnEveryFrame)
clearFlags = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
- else if (context()->format().alpha())
+ else if (ctx->format().alpha())
clearFlags = GL_COLOR_BUFFER_BIT;
if (clearFlags) {
+ if (d_ptr->fbo)
+ d_ptr->fbo->bind();
+
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(clearFlags);
+
+ if (d_ptr->fbo)
+ d_ptr->fbo->release();
}
}
uchar ch = chars[i];
switch (nbuf) {
case 0:
- if (ch < 0x80 || IsKana(ch)) {
+ if (ch < 0x80) {
+ result += QValidChar(ch);
+ } else if (IsKana(ch)) {
// JIS X 0201 Latin or JIS X 0201 Kana
u = conv->jisx0201ToUnicode(ch);
result += QValidChar(u);
SOURCES += \
$$PWD/qglxconvenience.cpp
+
+CONFIG += xrender
+
+xrender {
+ LIBS += -lXrender
+} else {
+ DEFINES += QT_NO_XRENDER
+}
#include <QtCore/QVector>
+#ifndef QT_NO_XRENDER
+#include <X11/extensions/Xrender.h>
+#endif
+
enum {
XFocusOut = FocusOut,
XFocusIn = FocusIn,
spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize();
}
- spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
- spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
- spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ if (format.accum()) {
+ spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
- if (format.alpha()) {
- spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ if (format.alpha()) {
+ spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ }
}
-
} else {
spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works....
spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8;
if (reducedFormat.alpha()) {
int alphaSize;
glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize);
- if (alphaSize > 0)
- break;
+ if (alphaSize > 0) {
+ XVisualInfo *visual = glXGetVisualFromFBConfig(display, chosenConfig);
+#if !defined(QT_NO_XRENDER)
+ XRenderPictFormat *pictFormat = XRenderFindVisualFormat(display, visual->visual);
+ if (pictFormat->direct.alphaMask > 0)
+ break;
+#else
+ if (visual->depth == 32)
+ break;
+#endif
+ }
} else {
break; // Just choose the first in the list if there's no alpha requested
}
QMinimalScreen *mPrimaryScreen = new QMinimalScreen();
mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320);
- mPrimaryScreen->mDepth = 16;
- mPrimaryScreen->mFormat = QImage::Format_RGB16;
+ mPrimaryScreen->mDepth = 32;
+ mPrimaryScreen->mFormat = QImage::Format_ARGB32_Premultiplied;
mScreens.append(mPrimaryScreen);
}
{
public:
QMinimalScreen()
- : mDepth(16), mFormat(QImage::Format_RGB16) {}
+ : mDepth(32), mFormat(QImage::Format_ARGB32_Premultiplied) {}
QRect geometry() const { return mGeometry; }
int depth() const { return mDepth; }
SUBDIRS += wayland
}
+contains(QT_CONFIG, xcb) {
+ SUBDIRS += xcb
+}
Colormap cmap = XCreateColormap(mGlxIntegration->xDisplay(),mGlxIntegration->rootWindow(),visualInfo->visual,AllocNone);
XSetWindowAttributes a;
+ a.background_pixel = WhitePixel(mGlxIntegration->xDisplay(), mGlxIntegration->screen());
+ a.border_pixel = BlackPixel(mGlxIntegration->xDisplay(), mGlxIntegration->screen());
a.colormap = cmap;
mXWindow = XCreateWindow(mGlxIntegration->xDisplay(), mGlxIntegration->rootWindow(),0, 0, size.width(), size.height(),
0, visualInfo->depth, InputOutput, visualInfo->visual,
- CWColormap, &a);
+ CWBackPixel|CWBorderPixel|CWColormap, &a);
XCompositeRedirectWindow(mGlxIntegration->xDisplay(), mXWindow, CompositeRedirectManual);
XMapWindow(mGlxIntegration->xDisplay(), mXWindow);
#include "gl_integration/qwaylandglintegration.h"
#endif
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
+#endif
+
#include <QtCore/QAbstractEventDispatcher>
#include <QtGui/QApplication>
#include <QtGui/private/qapplication_p.h>
struct wl_visual *QWaylandDisplay::rgbVisual()
{
- return wl_display_get_rgb_visual(mDisplay);
+ return rgb_visual;
}
struct wl_visual *QWaylandDisplay::argbVisual()
{
- return wl_display_get_argb_visual(mDisplay);
+ return argb_visual;
}
struct wl_visual *QWaylandDisplay::argbPremultipliedVisual()
{
- return wl_display_get_premultiplied_argb_visual(mDisplay);
+ return premultiplied_argb_visual;
}
#ifdef QT_WAYLAND_GL_SUPPORT
}
#endif
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+QWaylandWindowManagerIntegration *QWaylandDisplay::windowManagerIntegration()
+{
+ return mWindowManagerIntegration;
+}
+#endif
+
void QWaylandDisplay::shellHandleConfigure(void *data, struct wl_shell *shell,
uint32_t time, uint32_t edges,
struct wl_surface *surface,
};
QWaylandDisplay::QWaylandDisplay(void)
+ : argb_visual(0), premultiplied_argb_visual(0), rgb_visual(0)
{
mDisplay = wl_display_connect(NULL);
if (mDisplay == NULL) {
mEglIntegration->initialize();
#endif
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+ mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this);
+#endif
+
connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests()));
mFd = wl_display_get_fd(mDisplay, sourceUpdate, this);
QWaylandDisplay::outputHandleGeometry
};
+const struct wl_compositor_listener QWaylandDisplay::compositorListener = {
+ QWaylandDisplay::handleVisual,
+};
+
+
void QWaylandDisplay::waitForScreens()
{
flushRequests();
wl_output_add_listener(output, &outputListener, this);
} else if (interface == "wl_compositor") {
mCompositor = wl_compositor_create(mDisplay, id, 1);
+ wl_compositor_add_listener(mCompositor,
+ &compositorListener, this);
} else if (interface == "wl_shm") {
mShm = wl_shm_create(mDisplay, id, 1);
} else if (interface == "wl_shell"){
clipboard->createSelectionOffer(id);
}
}
+
+void QWaylandDisplay::handleVisual(void *data,
+ struct wl_compositor *compositor,
+ uint32_t id, uint32_t token)
+{
+ QWaylandDisplay *self = static_cast<QWaylandDisplay *>(data);
+
+ switch (token) {
+ case WL_COMPOSITOR_VISUAL_ARGB32:
+ self->argb_visual = wl_visual_create(self->mDisplay, id, 1);
+ break;
+ case WL_COMPOSITOR_VISUAL_PREMULTIPLIED_ARGB32:
+ self->premultiplied_argb_visual =
+ wl_visual_create(self->mDisplay, id, 1);
+ break;
+ case WL_COMPOSITOR_VISUAL_XRGB32:
+ self->rgb_visual = wl_visual_create(self->mDisplay, id, 1);
+ break;
+ }
+}
class QPlatformScreen;
class QWaylandScreen;
class QWaylandGLIntegration;
+class QWaylandWindowManagerIntegration;
+
class QWaylandDisplay : public QObject {
Q_OBJECT
#ifdef QT_WAYLAND_GL_SUPPORT
QWaylandGLIntegration *eglIntegration();
#endif
+
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+ QWaylandWindowManagerIntegration *windowManagerIntegration();
+#endif
+
void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y);
void syncCallback(wl_display_sync_func_t func, void *data);
uint32_t mSocketMask;
+ struct wl_visual *argb_visual, *premultiplied_argb_visual, *rgb_visual;
+
static const struct wl_output_listener outputListener;
+ static const struct wl_compositor_listener compositorListener;
static int sourceUpdate(uint32_t mask, void *data);
static void displayHandleGlobal(struct wl_display *display,
uint32_t id,
int32_t x, int32_t y,
int32_t width, int32_t height);
+ static void handleVisual(void *data,
+ struct wl_compositor *compositor,
+ uint32_t id, uint32_t token);
#ifdef QT_WAYLAND_GL_SUPPORT
QWaylandGLIntegration *mEglIntegration;
#endif
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+ QWaylandWindowManagerIntegration *mWindowManagerIntegration;
+#endif
+
static void shellHandleConfigure(void *data, struct wl_shell *shell,
uint32_t time, uint32_t edges,
struct wl_surface *surface,
#include "qwaylandinputdevice.h"
#include "qwaylandscreen.h"
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
+#endif
+
+#include <QCoreApplication>
#include <QtGui/QWidget>
#include <QtGui/QWindowSystemInterface>
static WId id = 1;
mWindowId = id++;
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+ mDisplay->windowManagerIntegration()->mapClientToProcess(qApp->applicationPid());
+#endif
+
mSurface = mDisplay->createSurface(this);
}
}
}
-
void QWaylandWindow::damage(const QRegion ®ion)
{
//We have to do sync stuff before calling damage, or we might
INCLUDEPATH += $$PWD
include ($$PWD/gl_integration/gl_integration.pri)
+include ($$PWD/windowmanager_integration/windowmanager_integration.pri)
include (../fontdatabases/genericunix/genericunix.pri)
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target
+
--- /dev/null
+This version of the Qt Wayland plugin is checked against the following sha1
+from the Wayland repository:
+eff7fc0d99be2e51eaa351785030c8d374ac71de
--- /dev/null
+/*
+ * Copyright © 2010 Kristian Høgsberg
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+
+#ifndef WAYLAND_WINDOWMANAGER_CLIENT_PROTOCOL_H
+#define WAYLAND_WINDOWMANAGER_CLIENT_PROTOCOL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-util.h"
+
+struct wl_client;
+
+struct wl_windowmanager;
+
+extern const struct wl_interface wl_windowmanager_interface;
+
+#define WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0
+
+static inline struct wl_windowmanager *
+wl_windowmanager_create(struct wl_display *display, uint32_t id, uint32_t /*version*/)
+{
+ // ### does not run without latest wayland. must be enabled later
+ //wl_display_bind(display, id, "wl_windowmanager", version);
+
+ return (struct wl_windowmanager *)
+ wl_proxy_create_for_id(display, &wl_windowmanager_interface, id);
+}
+
+static inline void
+wl_windowmanager_set_user_data(struct wl_windowmanager *wl_windowmanager, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_windowmanager, user_data);
+}
+
+static inline void *
+wl_windowmanager_get_user_data(struct wl_windowmanager *wl_windowmanager)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_windowmanager);
+}
+
+static inline void
+wl_windowmanager_destroy(struct wl_windowmanager *wl_windowmanager)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_windowmanager);
+}
+
+static inline void
+wl_windowmanager_map_client_to_process(struct wl_windowmanager *wl_windowmanager, uint32_t processid)
+{
+ wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
+ WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandwindowmanagerintegration.h"
+#include "qwaylandwindowmanager-client-protocol.h"
+
+#include <stdint.h>
+
+QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegration(QWaylandDisplay *waylandDisplay)
+{
+ return new QWaylandWindowManagerIntegration(waylandDisplay);
+}
+
+QWaylandWindowManagerIntegration::QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay)
+ : mWaylandDisplay(waylandDisplay)
+ , mWaylandWindowManager(0)
+{
+ wl_display_add_global_listener(mWaylandDisplay->wl_display(),
+ QWaylandWindowManagerIntegration::wlHandleListenerGlobal,
+ this);
+}
+
+QWaylandWindowManagerIntegration::~QWaylandWindowManagerIntegration()
+{
+
+}
+
+struct wl_windowmanager *QWaylandWindowManagerIntegration::windowManager() const
+{
+ return mWaylandWindowManager;
+}
+
+void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface,
+ uint32_t version, void *data)
+{
+ if (strcmp(interface, "wl_windowmanager") == 0) {
+ QWaylandWindowManagerIntegration *integration = static_cast<QWaylandWindowManagerIntegration *>(data);
+ integration->mWaylandWindowManager = wl_windowmanager_create(display,id, version);
+ }
+}
+
+void QWaylandWindowManagerIntegration::mapClientToProcess(long long processId)
+{
+ if (mWaylandWindowManager)
+ wl_windowmanager_map_client_to_process(mWaylandWindowManager, (uint32_t) processId);
+}
+
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDWINDOWMANAGERINTEGRATION_H
+#define QWAYLANDWINDOWMANAGERINTEGRATION_H
+
+#include <QObject>
+#include "wayland-client.h"
+#include "qwaylanddisplay.h"
+
+class QWaylandWindowManagerIntegration
+{
+public:
+ explicit QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay);
+ virtual ~QWaylandWindowManagerIntegration();
+ static QWaylandWindowManagerIntegration *createIntegration(QWaylandDisplay *waylandDisplay);
+ struct wl_windowmanager *windowManager() const;
+
+ void mapSurfaceToProcess(struct wl_surface *surface, long long processId);
+ void mapClientToProcess(long long processId);
+
+private:
+ static void wlHandleListenerGlobal(wl_display *display, uint32_t id,
+ const char *interface, uint32_t version, void *data);
+
+private:
+ QWaylandDisplay *mWaylandDisplay;
+ struct wl_windowmanager *mWaylandWindowManager;
+};
+
+#endif // QWAYLANDWINDOWMANAGERINTEGRATION_H
--- /dev/null
+/*
+ * Copyright © 2010 Kristian Høgsberg
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+
+#include <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+static const struct wl_message wl_windowmanager_requests[] = {
+ { "map_client_to_process", "u", NULL },
+};
+
+WL_EXPORT const struct wl_interface wl_windowmanager_interface = {
+ "wl_windowmanager", 1,
+ ARRAY_LENGTH(wl_windowmanager_requests), wl_windowmanager_requests,
+ 0, NULL,
+};
--- /dev/null
+DEFINES += QT_WAYLAND_WINDOWMANAGER_SUPPORT
+
+contains(DEFINES, QT_WAYLAND_WINDOWMANAGER_SUPPORT) {
+
+ HEADERS += \
+ $$PWD/qwaylandwindowmanager-client-protocol.h \
+ $$PWD/qwaylandwindowmanagerintegration.h
+
+ SOURCES += \
+ $$PWD/qwaylandwindowmanagerintegration.cpp \
+ $$PWD/wayland-windowmanager-protocol.c
+
+}
+
+
+
#if defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
- && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
+ && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)
+ || tlw->platformWindowFormat().alpha())
{
#if defined(XCB_USE_GLX)
XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), tlw->platformWindowFormat());
visualInfo = XGetVisualInfo(DISPLAY_FROM_XCB(this), VisualIDMask, &visualInfoTemplate, &matchingCount);
#endif //XCB_USE_GLX
if (visualInfo) {
+ m_depth = visualInfo->depth;
+ m_format = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), m_screen->root(), visualInfo->visual, AllocNone);
XSetWindowAttributes a;
+ a.background_pixel = WhitePixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber());
+ a.border_pixel = BlackPixel(DISPLAY_FROM_XCB(this), m_screen->screenNumber());
a.colormap = cmap;
m_window = XCreateWindow(DISPLAY_FROM_XCB(this), m_screen->root(), tlw->x(), tlw->y(), tlw->width(), tlw->height(),
0, visualInfo->depth, InputOutput, visualInfo->visual,
- CWColormap, &a);
+ CWBackPixel|CWBorderPixel|CWColormap, &a);
printf("created GL window: %d\n", m_window);
} else {
#endif //defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
{
m_window = xcb_generate_id(xcb_connection());
+ m_depth = m_screen->screen()->root_depth;
+ m_format = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
Q_XCB_CALL(xcb_create_window(xcb_connection(),
XCB_COPY_FROM_PARENT, // depth -- same as root
#include <QtGui/QPlatformWindow>
#include <QtGui/QPlatformWindowFormat>
+#include <QtGui/QImage>
#include <xcb/xcb.h>
#include <xcb/sync.h>
QPlatformGLContext *glContext() const;
xcb_window_t window() const { return m_window; }
+ uint depth() const { return m_depth; }
+ QImage::Format format() const { return m_format; }
void handleExposeEvent(const xcb_expose_event_t *event);
void handleClientMessageEvent(const xcb_client_message_event_t *event);
xcb_window_t m_window;
QPlatformGLContext *m_context;
+ uint m_depth;
+ QImage::Format m_format;
+
xcb_sync_int64_t m_syncValue;
xcb_sync_counter_t m_syncCounter;
#include <stdio.h>
#include <qdebug.h>
+#include <qpainter.h>
class QXcbShmImage : public QXcbObject
{
public:
- QXcbShmImage(QXcbScreen *connection, const QSize &size);
+ QXcbShmImage(QXcbScreen *connection, const QSize &size, uint depth, QImage::Format format);
~QXcbShmImage() { destroy(); }
QImage *image() { return &m_qimage; }
QRegion m_dirty;
};
-QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size)
+QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QImage::Format format)
: QXcbObject(screen->connection())
, m_gc(0)
, m_gc_window(0)
size.width(),
size.height(),
XCB_IMAGE_FORMAT_Z_PIXMAP,
- screen->depth(),
+ depth,
0,
~0,
0);
if (shmctl(m_shm_info.shmid, IPC_RMID, 0) == -1)
qWarning() << "QXcbWindowSurface: Error while marking the shared memory segment to be destroyed";
- m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, screen->format());
+ m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, format);
}
void QXcbShmImage::destroy()
void QXcbWindowSurface::beginPaint(const QRegion ®ion)
{
m_image->preparePaint(region);
+
+ if (m_image->image()->hasAlphaChannel()) {
+ QPainter p(m_image->image());
+ p.setCompositionMode(QPainter::CompositionMode_Source);
+ const QVector<QRect> rects = region.rects();
+ const QColor blank = Qt::transparent;
+ for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
+ p.fillRect(*it, blank);
+ }
+ }
}
void QXcbWindowSurface::endPaint(const QRegion &)
QWindowSurface::resize(size);
QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(window()));
+ QXcbWindow* win = static_cast<QXcbWindow *>(window()->platformWindow());
delete m_image;
- m_image = new QXcbShmImage(screen, size);
+ m_image = new QXcbShmImage(screen, size, win->depth(), win->format());
Q_XCB_NOOP(connection());
m_syncingResize = true;
{
#if !defined(QT_NO_OPENGL)
#if !defined(QT_OPENGL_ES_2)
- QXlibScreen *screen = static_cast<const QXlibScreen *>(mScreens.at(0));
+ QXlibScreen *screen = static_cast<QXlibScreen *>(mScreens.at(0));
return glXQueryExtension(screen->display()->nativeDisplay(), 0, 0) != 0;
#else
static bool eglHasbeenInitialized = false;
#include "qxlibscreen.h"
+#include <X11/extensions/Xfixes.h>
+
#include "qxlibcursor.h"
#include "qxlibwindow.h"
#include "qxlibkeyboard.h"
#include <private/qapplication_p.h>
-#include <X11/extensions/Xfixes.h>
-
QT_BEGIN_NAMESPACE
static int (*original_x_errhandler)(Display *dpy, XErrorEvent *);
#ifndef DONT_USE_MIT_SHM
- Status MIT_SHM_extension_supported = XShmQueryExtension (mDisplay->nativeDisplay());
+ int MIT_SHM_extension_supported = XShmQueryExtension (mDisplay->nativeDisplay());
Q_ASSERT(MIT_SHM_extension_supported == True);
#endif
original_x_errhandler = XSetErrorHandler(qt_x_errhandler);
#include <QDebug>
-#ifndef QT_NO_XFIXES
-#include <X11/extensions/Xfixes.h>
-#endif // QT_NO_XFIXES
-
static const char * x11_atomnames = {
// window-manager <-> client protocols
"WM_PROTOCOLS\0"
#endif
#ifndef QT_NO_XFIXES
+#include <X11/extensions/Xfixes.h>
typedef Bool (*PtrXFixesQueryExtension)(Display *, int *, int *);
typedef Status (*PtrXFixesQueryVersion)(Display *, int *, int *);
typedef void (*PtrXFixesSetCursorName)(Display *dpy, Cursor cursor, const char *name);
#include "qxlibstatic.h"
#include "qxlibdisplay.h"
-#include <QtGui/QWindowSystemInterface>
-#include <QSocketNotifier>
-#include <QApplication>
-#include <QDebug>
-
-#include <QtGui/private/qwindowsurface_p.h>
-#include <QtGui/private/qapplication_p.h>
-
#if !defined(QT_NO_OPENGL)
#if !defined(QT_OPENGL_ES_2)
#include "qglxintegration.h"
#endif //QT_OPENGL_ES_2
#endif //QT_NO_OPENGL
+
+#include <QtGui/QWindowSystemInterface>
+#include <QSocketNotifier>
+#include <QApplication>
+#include <QDebug>
+
+#include <QtGui/private/qwindowsurface_p.h>
+#include <QtGui/private/qapplication_p.h>
+
//#define MYX11_DEBUG
QT_BEGIN_NAMESPACE
int w = window->width();
int h = window->height();
- if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
- && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL) ) {
#if !defined(QT_NO_OPENGL)
+ if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
+ && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)
+ || window->platformWindowFormat().alpha()) {
#if !defined(QT_OPENGL_ES_2)
XVisualInfo *visualInfo = qglx_findVisualInfo(mScreen->display()->nativeDisplay(),mScreen->xScreenNumber(),window->platformWindowFormat());
#else
visualInfo = XGetVisualInfo(mScreen->display()->nativeDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount);
#endif //!defined(QT_OPENGL_ES_2)
if (visualInfo) {
- Colormap cmap = XCreateColormap(mScreen->display()->nativeDisplay(),mScreen->rootWindow(),visualInfo->visual,AllocNone);
+ mDepth = visualInfo->depth;
+ mFormat = (mDepth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
+ mVisual = visualInfo->visual;
+ Colormap cmap = XCreateColormap(mScreen->display()->nativeDisplay(), mScreen->rootWindow(), visualInfo->visual, AllocNone);
XSetWindowAttributes a;
+ a.background_pixel = WhitePixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber());
+ a.border_pixel = BlackPixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber());
a.colormap = cmap;
x_window = XCreateWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),x, y, w, h,
0, visualInfo->depth, InputOutput, visualInfo->visual,
- CWColormap, &a);
+ CWBackPixel|CWBorderPixel|CWColormap, &a);
} else {
qFatal("no window!");
}
+ } else
#endif //!defined(QT_NO_OPENGL)
- } else {
+ {
+ mDepth = mScreen->depth();
+ mFormat = (mDepth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
+ mVisual = mScreen->defaultVisual();
+
x_window = XCreateSimpleWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),
x, y, w, h, 0 /*border_width*/,
mScreen->blackPixel(), mScreen->whitePixel());
Window xWindow() const;
GC graphicsContext() const;
+ inline uint depth() const { return mDepth; }
+ QImage::Format format() const { return mFormat; }
+ Visual* visual() const { return mVisual; }
+
protected:
QVector<Atom> getNetWmState() const;
void setMWMHints(const QXlibMWMHints &mwmhints);
Window x_window;
GC gc;
+ uint mDepth;
+ QImage::Format mFormat;
+ Visual* mVisual;
+
GC createGC();
QPlatformGLContext *mGLContext;
#include "qxlibscreen.h"
#include "qxlibdisplay.h"
+#include "qpainter.h"
+
# include <sys/ipc.h>
# include <sys/shm.h>
# include <X11/extensions/XShm.h>
void QXlibWindowSurface::resizeShmImage(int width, int height)
{
+ QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(window());
+ QXlibWindow *win = static_cast<QXlibWindow*>(window()->platformWindow());
#ifdef DONT_USE_MIT_SHM
- shm_img = QImage(width, height, QImage::Format_RGB32);
+ shm_img = QImage(width, height, win->format());
#else
- QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(window());
if (image_info)
image_info->destroy();
else
image_info = new QXlibShmImageInfo(screen->display()->nativeDisplay());
- Visual *visual = screen->defaultVisual();
-
- XImage *image = XShmCreateImage (screen->display()->nativeDisplay(), visual, 24, ZPixmap, 0,
+ XImage *image = XShmCreateImage (screen->display()->nativeDisplay(), win->visual(), win->depth(), ZPixmap, 0,
&image_info->shminfo, width, height);
Q_ASSERT(shm_attach_status == True);
- shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, QImage::Format_RGB32 );
+ shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, win->format() );
#endif
painted = false;
}
#ifdef DONT_USE_MIT_SHM
// just convert the image every time...
if (!shm_img.isNull()) {
- Visual *visual = DefaultVisual(screen->display(), screen->xScreenNumber());
+ QXlibWindow *win = static_cast<QXlibWindow*>(window()->platformWindow());
QImage image = shm_img;
//img.convertToFormat(
- XImage *xi = XCreateImage(screen->display(), visual, 24, ZPixmap,
+ XImage *xi = XCreateImage(screen->display(), win->visual(), win->depth(), ZPixmap,
0, (char *) image.scanLine(0), image.width(), image.height(),
32, image.bytesPerLine());
{
Q_UNUSED(region);
resizeBuffer(size());
+
+ if (shm_img.hasAlphaChannel()) {
+ QPainter p(&shm_img);
+ p.setCompositionMode(QPainter::CompositionMode_Source);
+ const QVector<QRect> rects = region.rects();
+ const QColor blank = Qt::transparent;
+ for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
+ p.fillRect(*it, blank);
+ }
+ }
}
void QXlibWindowSurface::endPaint(const QRegion ®ion)
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)
{
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"
void setTranslationEnabled(bool enabled);
bool isTranslationEnabled() const;
+ QString errorString() const;
+
private:
QScopedPointer<QUiLoaderPrivate> d_ptr;
Q_DECLARE_PRIVATE(QUiLoader)
#include(../arthurtester.pri)
#TEMPLATE = lib
#CONFIG += static
-#QT += xml opengl svg qt3support
+#QT += xml opengl svg
#build_all:!build_pass {
# CONFIG -= build_all
#include <qtextlayout.h>
#include <qdebug.h>
-#ifdef QT3_SUPPORT
-#include <q3painter.h>
-#endif
-
#ifndef QT_NO_OPENGL
#include <qglpixelbuffer.h>
#endif
"^gradient_setCoordinateMode\\s+(\\w*)$",
"gradient_setCoordinateMode <coordinate method enum>",
"gradient_setCoordinateMode ObjectBoundingMode");
-#ifdef QT3_SUPPORT
- DECL_PAINTCOMMANDSECTION("qt3 drawing ops");
- DECL_PAINTCOMMAND("qt3_drawArc", command_qt3_drawArc,
- "^qt3_drawArc\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)$",
- "qt3_drawArc <x> <y> <w> <h> <angleStart> <angleArc>\n - angles are expressed in 1/16th of degree",
- "qt3_drawArc 10 10 20 20 0 5760");
- DECL_PAINTCOMMAND("qt3_drawChord", command_qt3_drawChord,
- "^qt3_drawChord\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)$",
- "qt3_drawChord <x> <y> <w> <h> <angleStart> <angleArc>\n - angles are expressed in 1/16th of degree",
- "qt3_drawChord 10 10 20 20 0 5760");
- DECL_PAINTCOMMAND("qt3_drawEllipse", command_qt3_drawEllipse,
- "^qt3_drawEllipse\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)$",
- "qt3_drawEllipse <x> <y> <w> <h>",
- "qt3_drawEllipse 10 10 20 20");
- DECL_PAINTCOMMAND("qt3_drawPie", command_qt3_drawPie,
- "^qt3_drawPie\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)$",
- "qt3_drawPie <x> <y> <w> <h> <angleStart> <angleArc>\n - angles are expressed in 1/16th of degree",
- "qt3_drawPie 10 10 20 20 0 5760");
- DECL_PAINTCOMMAND("qt3_drawRect", command_qt3_drawRect,
- "^qt3_drawRect\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)$",
- "qt3_drawRect <x> <y> <w> <h>",
- "qt3_drawRect 10 10 20 20");
- DECL_PAINTCOMMAND("qt3_drawRoundRect", command_qt3_drawRoundRect,
- "^qt3_drawRoundRect\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s*(-?\\w)?\\s*(-?\\w)?$",
- "qt3_drawRoundRect <x> <y> <w> <h> [rx] [ry]",
- "qt3_drawRoundRect 10 10 20 20 3 3");
-#endif
DECL_PAINTCOMMANDSECTION("drawing ops");
DECL_PAINTCOMMAND("drawPoint", command_drawPoint,
"^drawPoint\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
m_painter->drawArc(x, y, w, h, angle, sweep);
}
-#ifdef QT3_SUPPORT
-/***************************************************************************************************/
-void PaintCommands::command_qt3_drawRect(QRegExp re)
-{
- Q_UNUSED(re);
-#ifdef QT3_SUPPORT
- QStringList caps = re.capturedTexts();
- int x = convertToInt(caps.at(1));
- int y = convertToInt(caps.at(2));
- int w = convertToInt(caps.at(3));
- int h = convertToInt(caps.at(4));
-
- if (m_verboseMode)
- printf(" -(lance) qt3_drawRect(%d, %d, %d, %d)\n", x, y, w, h);
-
- static_cast<Q3Painter*>(m_painter)->drawRect(x, y, w, h);
-#endif
-}
-
-/***************************************************************************************************/
-void PaintCommands::command_qt3_drawRoundRect(QRegExp re)
-{
- Q_UNUSED(re);
-#ifdef QT3_SUPPORT
- QStringList caps = re.capturedTexts();
- int x = convertToInt(caps.at(1));
- int y = convertToInt(caps.at(2));
- int w = convertToInt(caps.at(3));
- int h = convertToInt(caps.at(4));
- int xrnd = caps.at(5).isEmpty() ? 25 : convertToInt(caps.at(5));
- int yrnd = caps.at(6).isEmpty() ? 25 : convertToInt(caps.at(6));
-
- if (m_verboseMode)
- printf(" -(lance) qt3_drawRoundRect(%d, %d, %d, %d), %d, %d\n", x, y, w, h, xrnd, yrnd);
-
- static_cast<Q3Painter*>(m_painter)->drawRoundRect(x, y, w, h, xrnd, yrnd);
-#endif
-}
-
-/***************************************************************************************************/
-void PaintCommands::command_qt3_drawEllipse(QRegExp re)
-{
- Q_UNUSED(re);
-#ifdef QT3_SUPPORT
- QStringList caps = re.capturedTexts();
- int x = convertToInt(caps.at(1));
- int y = convertToInt(caps.at(2));
- int w = convertToInt(caps.at(3));
- int h = convertToInt(caps.at(4));
-
- if (m_verboseMode)
- printf(" -(lance) qt3_drawEllipse(%d, %d, %d, %d)\n", x, y, w, h);
-
- static_cast<Q3Painter*>(m_painter)->drawEllipse(x, y, w, h);
-#endif
-}
-
-/***************************************************************************************************/
-void PaintCommands::command_qt3_drawPie(QRegExp re)
-{
- Q_UNUSED(re);
-#ifdef QT3_SUPPORT
- QStringList caps = re.capturedTexts();
- int x = convertToInt(caps.at(1));
- int y = convertToInt(caps.at(2));
- int w = convertToInt(caps.at(3));
- int h = convertToInt(caps.at(4));
- int angle = convertToInt(caps.at(5));
- int sweep = convertToInt(caps.at(6));
-
- if (m_verboseMode)
- printf(" -(lance) qt3_drawPie(%d, %d, %d, %d, %d, %d)\n", x, y, w, h, angle, sweep);
-
- static_cast<Q3Painter*>(m_painter)->drawPie(x, y, w, h, angle, sweep);
-#endif
-}
-
-/***************************************************************************************************/
-void PaintCommands::command_qt3_drawChord(QRegExp re)
-{
- Q_UNUSED(re);
-#ifdef QT3_SUPPORT
- QStringList caps = re.capturedTexts();
- int x = convertToInt(caps.at(1));
- int y = convertToInt(caps.at(2));
- int w = convertToInt(caps.at(3));
- int h = convertToInt(caps.at(4));
- int angle = convertToInt(caps.at(5));
- int sweep = convertToInt(caps.at(6));
-
- if (m_verboseMode)
- printf(" -(lance) qt3_drawChord(%d, %d, %d, %d, %d, %d)\n", x, y, w, h, angle, sweep);
-
- static_cast<Q3Painter*>(m_painter)->drawChord(x, y, w, h, angle, sweep);
-#endif
-}
-
-/***************************************************************************************************/
-void PaintCommands::command_qt3_drawArc(QRegExp re)
-{
- Q_UNUSED(re);
-#ifdef QT3_SUPPORT
- QStringList caps = re.capturedTexts();
- int x = convertToInt(caps.at(1));
- int y = convertToInt(caps.at(2));
- int w = convertToInt(caps.at(3));
- int h = convertToInt(caps.at(4));
- int angle = convertToInt(caps.at(5));
- int sweep = convertToInt(caps.at(6));
-
- if (m_verboseMode)
- printf(" -(lance) qt3_drawArc(%d, %d, %d, %d, %d, %d)\n", x, y, w, h, angle, sweep);
-
- static_cast<Q3Painter*>(m_painter)->drawArc(x, y, w, h, angle, sweep);
-#endif
-}
-#endif //QT3_SUPPORT
/***************************************************************************************************/
void PaintCommands::command_drawText(QRegExp re)
{
void command_gradient_setCoordinateMode(QRegExp re);
// commands: drawing ops
-#ifdef QT3_SUPPORT
- void command_qt3_drawArc(QRegExp re);
- void command_qt3_drawChord(QRegExp re);
- void command_qt3_drawEllipse(QRegExp re);
- void command_qt3_drawPie(QRegExp re);
- void command_qt3_drawRect(QRegExp re);
- void command_qt3_drawRoundRect(QRegExp re);
-#endif
void command_drawArc(QRegExp re);
void command_drawChord(QRegExp re);
void command_drawConvexPolygon(QRegExp re);
drawRect 140 0 17 17
drawRect 160 0 18 18
drawRect 180 0 19 19
-qt3_drawRect 200 0 10 10
-qt3_drawRect 220 0 11 11
-qt3_drawRect 240 0 12 12
-qt3_drawRect 260 0 13 13
-qt3_drawRect 280 0 14 14
-qt3_drawRect 300 0 15 15
-qt3_drawRect 320 0 16 16
-qt3_drawRect 340 0 17 17
-qt3_drawRect 360 0 18 18
-qt3_drawRect 380 0 19 19
drawEllipse 0 20 10 10
drawEllipse 20 20 11 11
drawEllipse 140 20 17 17
drawEllipse 160 20 18 18
drawEllipse 180 20 19 19
-qt3_drawEllipse 200 20 10 10
-qt3_drawEllipse 220 20 11 11
-qt3_drawEllipse 240 20 12 12
-qt3_drawEllipse 260 20 13 13
-qt3_drawEllipse 280 20 14 14
-qt3_drawEllipse 300 20 15 15
-qt3_drawEllipse 320 20 16 16
-qt3_drawEllipse 340 20 17 17
-qt3_drawEllipse 360 20 18 18
-qt3_drawEllipse 380 20 19 19
drawRoundRect 0 40 10 10
drawRoundRect 20 40 11 11
drawRoundRect 140 40 17 17
drawRoundRect 160 40 18 18
drawRoundRect 180 40 19 19
-qt3_drawRoundRect 200 40 10 10
-qt3_drawRoundRect 220 40 11 11
-qt3_drawRoundRect 240 40 12 12
-qt3_drawRoundRect 260 40 13 13
-qt3_drawRoundRect 280 40 14 14
-qt3_drawRoundRect 300 40 15 15
-qt3_drawRoundRect 320 40 16 16
-qt3_drawRoundRect 340 40 17 17
-qt3_drawRoundRect 360 40 18 18
-qt3_drawRoundRect 380 40 19 19
drawPie 0 60 10 10 0 4320
drawPie 20 60 11 11 0 4320
drawPie 140 60 17 17 0 4320
drawPie 160 60 18 18 0 4320
drawPie 180 60 19 19 0 4320
-qt3_drawPie 200 60 10 10 0 4320
-qt3_drawPie 220 60 11 11 0 4320
-qt3_drawPie 240 60 12 12 0 4320
-qt3_drawPie 260 60 13 13 0 4320
-qt3_drawPie 280 60 14 14 0 4320
-qt3_drawPie 300 60 15 15 0 4320
-qt3_drawPie 320 60 16 16 0 4320
-qt3_drawPie 340 60 17 17 0 4320
-qt3_drawPie 360 60 18 18 0 4320
-qt3_drawPie 380 60 19 19 0 4320
drawArc 0 80 10 10 0 4320
drawArc 20 80 11 11 0 4320
drawArc 140 80 17 17 0 4320
drawArc 160 80 18 18 0 4320
drawArc 180 80 19 19 0 4320
-qt3_drawArc 200 80 10 10 0 4320
-qt3_drawArc 220 80 11 11 0 4320
-qt3_drawArc 240 80 12 12 0 4320
-qt3_drawArc 260 80 13 13 0 4320
-qt3_drawArc 280 80 14 14 0 4320
-qt3_drawArc 300 80 15 15 0 4320
-qt3_drawArc 320 80 16 16 0 4320
-qt3_drawArc 340 80 17 17 0 4320
-qt3_drawArc 360 80 18 18 0 4320
-qt3_drawArc 380 80 19 19 0 4320
drawChord 0 100 10 10 0 4320
drawChord 20 100 11 11 0 4320
drawChord 140 100 17 17 0 4320
drawChord 160 100 18 18 0 4320
drawChord 180 100 19 19 0 4320
-qt3_drawChord 200 100 10 10 0 4320
-qt3_drawChord 220 100 11 11 0 4320
-qt3_drawChord 240 100 12 12 0 4320
-qt3_drawChord 260 100 13 13 0 4320
-qt3_drawChord 280 100 14 14 0 4320
-qt3_drawChord 300 100 15 15 0 4320
-qt3_drawChord 320 100 16 16 0 4320
-qt3_drawChord 340 100 17 17 0 4320
-qt3_drawChord 360 100 18 18 0 4320
-qt3_drawChord 380 100 19 19 0 4320
end_block
INCLUDEPATH += .
DESTDIR = ../bin
-QT += svg xml
+QT += svg xml core-private gui-private
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2):QT += opengl
-contains(QT_CONFIG, qt3support):QT += qt3support
# Input
HEADERS += datagenerator.h \
CONFIG += console
-QT += svg xml
+QT += svg xml core-private gui-private
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2):QT += opengl
-contains(QT_CONFIG, qt3support):QT += qt3support
# Input
HEADERS += htmlgenerator.h
RESOURCES += icons.qrc
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2):QT += opengl
-contains(QT_CONFIG, qt3support):QT += qt3support
symbian*: {
testData.files = $$QT_BUILD_TREE/tests/arthur/data/qps
DEPLOYMENT += testData
}
-QT += xml svg
+QT += xml svg core-private gui-private
" drawText x y \"text\"\n"
" drawTiledPixmap pixmapfile x y width height sx sy\n"
"\n"
- "Compat functions for Qt 3:\n"
- " qt3_drawArc x y width height angle sweep\n"
- " qt3_drawChord x y width height angle sweep\n"
- " qt3_drawEllipse x y width height\n"
- " qt3_drawPie x y width height angle sweep\n"
- " qt3_drawRect x y width height\n"
- " qt3_drawRoundRect x y width height xfactor yfactor\n"
- "\n"
"Path commands:\n"
" path_addEllipse pathname x y width height\n"
" path_addPolygon pathname [ x1 y1 x2 y2 ... ] winding?\n"
CONFIG += console
-QT += xml svg
+QT += xml svg core-private gui-private
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2):QT += opengl
-contains(QT_CONFIG, qt3support):QT += qt3support
# Input
HEADERS += performancediff.h
INCLUDEPATH += .
DESTDIR = ../bin
-QT += xml svg
+QT += xml svg core-private gui-private
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2):QT += opengl
-contains(QT_CONFIG, qt3support):QT += qt3support
# Input
HEADERS += shower.h
#include "qvector.h"
#include "qqueue.h"
-#ifdef QT3_SUPPORT
-#include "q3cleanuphandler.h"
-#endif
-
template class QList<int>;
//TESTED_FILES=
void cache();
void regexp();
void pair();
- void cleanupHandler();
void sharableQList();
void sharableQLinkedList();
void sharableQVector();
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());
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());
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());
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());
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());
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).
uic \
qmake \
rcc \
- #atwrapper \ # These tests need significant updating,
- #uiloader \ # they have hardcoded machine names etc.
+ #atwrapper \ # QTBUG-19452: This test needs to be reworked or discarded
+ #uiloader \ # QTBUG-19453: this test has hardcoded machine names etc.
drawRect 140 0 17 17
drawRect 160 0 18 18
drawRect 180 0 19 19
-# qt3_drawRect 200 0 10 10
-# qt3_drawRect 220 0 11 11
-# qt3_drawRect 240 0 12 12
-# qt3_drawRect 260 0 13 13
-# qt3_drawRect 280 0 14 14
-# qt3_drawRect 300 0 15 15
-# qt3_drawRect 320 0 16 16
-# qt3_drawRect 340 0 17 17
-# qt3_drawRect 360 0 18 18
-# qt3_drawRect 380 0 19 19
drawEllipse 0 20 10 10
drawEllipse 20 20 11 11
drawEllipse 140 20 17 17
drawEllipse 160 20 18 18
drawEllipse 180 20 19 19
-# qt3_drawEllipse 200 20 10 10
-# qt3_drawEllipse 220 20 11 11
-# qt3_drawEllipse 240 20 12 12
-# qt3_drawEllipse 260 20 13 13
-# qt3_drawEllipse 280 20 14 14
-# qt3_drawEllipse 300 20 15 15
-# qt3_drawEllipse 320 20 16 16
-# qt3_drawEllipse 340 20 17 17
-# qt3_drawEllipse 360 20 18 18
-# qt3_drawEllipse 380 20 19 19
drawRoundRect 0 40 10 10
drawRoundRect 20 40 11 11
drawRoundRect 140 40 17 17
drawRoundRect 160 40 18 18
drawRoundRect 180 40 19 19
-# qt3_drawRoundRect 200 40 10 10
-# qt3_drawRoundRect 220 40 11 11
-# qt3_drawRoundRect 240 40 12 12
-# qt3_drawRoundRect 260 40 13 13
-# qt3_drawRoundRect 280 40 14 14
-# qt3_drawRoundRect 300 40 15 15
-# qt3_drawRoundRect 320 40 16 16
-# qt3_drawRoundRect 340 40 17 17
-# qt3_drawRoundRect 360 40 18 18
-# qt3_drawRoundRect 380 40 19 19
drawPie 0 60 10 10 0 4320
drawPie 20 60 11 11 0 4320
drawPie 140 60 17 17 0 4320
drawPie 160 60 18 18 0 4320
drawPie 180 60 19 19 0 4320
-# qt3_drawPie 200 60 10 10 0 4320
-# qt3_drawPie 220 60 11 11 0 4320
-# qt3_drawPie 240 60 12 12 0 4320
-# qt3_drawPie 260 60 13 13 0 4320
-# qt3_drawPie 280 60 14 14 0 4320
-# qt3_drawPie 300 60 15 15 0 4320
-# qt3_drawPie 320 60 16 16 0 4320
-# qt3_drawPie 340 60 17 17 0 4320
-# qt3_drawPie 360 60 18 18 0 4320
-# qt3_drawPie 380 60 19 19 0 4320
drawArc 0 80 10 10 0 4320
drawArc 20 80 11 11 0 4320
drawArc 140 80 17 17 0 4320
drawArc 160 80 18 18 0 4320
drawArc 180 80 19 19 0 4320
-# qt3_drawArc 200 80 10 10 0 4320
-# qt3_drawArc 220 80 11 11 0 4320
-# qt3_drawArc 240 80 12 12 0 4320
-# qt3_drawArc 260 80 13 13 0 4320
-# qt3_drawArc 280 80 14 14 0 4320
-# qt3_drawArc 300 80 15 15 0 4320
-# qt3_drawArc 320 80 16 16 0 4320
-# qt3_drawArc 340 80 17 17 0 4320
-# qt3_drawArc 360 80 18 18 0 4320
-# qt3_drawArc 380 80 19 19 0 4320
drawChord 0 100 10 10 0 4320
drawChord 20 100 11 11 0 4320
drawChord 140 100 17 17 0 4320
drawChord 160 100 18 18 0 4320
drawChord 180 100 19 19 0 4320
-# qt3_drawChord 200 100 10 10 0 4320
-# qt3_drawChord 220 100 11 11 0 4320
-# qt3_drawChord 240 100 12 12 0 4320
-# qt3_drawChord 260 100 13 13 0 4320
-# qt3_drawChord 280 100 14 14 0 4320
-# qt3_drawChord 300 100 15 15 0 4320
-# qt3_drawChord 320 100 16 16 0 4320
-# qt3_drawChord 340 100 17 17 0 4320
-# qt3_drawChord 360 100 18 18 0 4320
-# qt3_drawChord 380 100 19 19 0 4320
end_block
<< "QT_CONFIG+=phonon"
<< "QT_CONFIG+=private_tests"
<< "QT_CONFIG+=pulseaudio"
- << "QT_CONFIG+=qt3support"
<< "QT_CONFIG+=script"
<< "QT_CONFIG+=svg"
<< "QT_CONFIG+=webkit"
#include <QtNetwork/QtNetwork>
#include <QtSql/QtSql>
//#include <QtSvg>
-#if defined(QT3_SUPPORT)
-#include <Qt3Support>
-#endif
#if defined(WITH_DBUS)
#include <QtDBus>
#endif
\sa rowsInserted()
*/
-void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, int end )
+void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, int /* end */)
{
// Q_UNUSED(end);
// qDebug() << "rowsAboutToBeInserted" << "start=" << start << "end=" << end << "parent=" << model->data ( parent ).toString()
startTimer(2000);
}
- void timerEvent(QTimerEvent *event)
+ void timerEvent(QTimerEvent * /* event */)
{
// should not crash.
(void)new QScrollArea(this);
QSizeF documentSize() const { return QSizeF(); }
QRectF frameBoundingRect(QTextFrame *) const { return QRectF(); }
QRectF blockBoundingRect(const QTextBlock &) const { return QRectF(); }
- void documentChanged(int from, int oldLength, int length) {
+ void documentChanged(int from, int /* oldLength */, int length) {
++changeEvents;
QTextBlock last = document()->lastBlock();
****************************************************************************/
-#ifdef QT3_SUPPORT
-#include <Qt3Support/Qt3Support>
-#endif
#include <QtTest/QtTest>
#ifndef Q_OS_WINCE
#include "../../shared/util.h"
void customWidget();
void deletedWidget();
- void childCount();
- void childAt(); // also indexOfChild
- void relationTo();
void navigateGeometric();
void navigateHierarchy();
void navigateSlider();
void navigateCovered();
- void navigateControllers();
- void navigateLabels();
- void text();
- void setText();
void hideShowTest();
void userActionCount();
void applicationTest();
void mainWindowTest();
void buttonTest();
- void sliderTest();
void scrollBarTest();
void tabTest();
void tabWidgetTest();
void tableViewTest();
void calendarWidgetTest();
void dockWidgetTest();
- void pushButtonTest();
void comboBoxTest();
void accessibleName();
void treeWidgetTest();
void labelTest();
void accelerators();
-
-private:
- QWidget *createGUI();
};
const double Q_PI = 3.14159265358979323846;
delete iface;
}
-QWidget *tst_QAccessibility::createGUI()
-{
-#if !defined(QT3_SUPPORT)
- qWarning( "Should never get here without Qt3Support");
- return 0;
-#else
- QWidget *toplevel = new QWidget(0, Qt::X11BypassWindowManagerHint);
- QGridLayout *grid = new QGridLayout(toplevel, 2, 2);
-
- // topLeft - hierarchies
- Q3VBox *topLeft = new Q3VBox(toplevel, "topLeft");
- topLeft->setSpacing(2);
- grid->addWidget(topLeft, 0, 0);
-
- Q3VButtonGroup *group1 = new Q3VButtonGroup("Title1:", topLeft, "group1");
- /*QPushButton *pb1 = */ new QPushButton("Button&1", group1, "pb1");
- Q3VButtonGroup *group2 = new Q3VButtonGroup("Title2:", topLeft, "group2");
- /*QPushButton *pb2 = */ new QPushButton("Button2", group2, "pb2");
-
- Q3WidgetStack *stack = new Q3WidgetStack(topLeft, "stack");
- QLabel *page1 = new QLabel("Page 1", stack, "page1");
- stack->addWidget(page1);
- QLabel *page2 = new QLabel("Page 2", stack, "page2");
- stack->addWidget(page2);
- QLabel *page3 = new QLabel("Page 3", stack, "page3");
- stack->addWidget(page3);
-
- // topRight - controlling
- Q3VBox *topRight= new Q3VBox(toplevel, "topRight");
- grid->addWidget(topRight, 0, 1);
-
- QPushButton *pbOk = new QPushButton("Ok", topRight, "pbOk" );
- pbOk->setDefault(TRUE);
- QSlider *slider = new QSlider(Qt::Horizontal, topRight, "slider");
- QLCDNumber *sliderLcd = new QLCDNumber(topRight, "sliderLcd");
- QSpinBox *spinBox = new QSpinBox(topRight, "spinBox");
-
- connect(pbOk, SIGNAL(clicked()), toplevel, SLOT(close()) );
- connect(slider, SIGNAL(valueChanged(int)), sliderLcd, SLOT(display(int)));
- connect(spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
-
- spinBox->setValue(50);
-
- // bottomLeft - labeling and controlling
- Q3HBox *bottomLeft = new Q3HBox(toplevel, "bottomLeft");
- grid->addWidget(bottomLeft, 1, 0);
-
- QLabel *label = new QLabel("This is a &lineedit:", bottomLeft, "label");
- QLineEdit *lineedit = new QLineEdit(bottomLeft, "lineedit");
- label->setBuddy(lineedit);
- QLabel *label2 = new QLabel(bottomLeft, "label2");
-
- connect(lineedit, SIGNAL(textChanged(const QString&)), label2, SLOT(setText(const QString&)));
-
- Q3VButtonGroup *radiogroup = new Q3VButtonGroup("Exclusive &choices:", bottomLeft, "radiogroup");
- QLineEdit *frequency = new QLineEdit(radiogroup, "frequency");
- frequency->setText("100 Mhz");
- QRadioButton *radioAM = new QRadioButton("&AM", radiogroup, "radioAM");
- /* QRadioButton *radioFM = */ new QRadioButton("&FM", radiogroup, "radioFM");
- /* QRadioButton *radioSW = */ new QRadioButton("&Shortwave", radiogroup, "radioSW");
-
- // bottomRight - ### empty
- Q3HBox *bottomRight = new Q3HBox(toplevel, "bottomRight");
- grid->addWidget(bottomRight, 1, 1);
-
- toplevel->adjustSize(); // sends layout and child events
-
- // some tooltips
- QToolTip::add(label, "A label");
- QToolTip::add(lineedit, "A line edit");
- // some whatsthis
- QWhatsThis::add(label, "A label displays static text");
- QWhatsThis::add(frequency, "You can enter a single line of text here");
-
- radioAM->setFocus();
- QTestAccessibility::clearEvents();
- return toplevel;
-#endif // !QT3_SUPPORT
-}
-
-void tst_QAccessibility::childAt()
-{
-#if !defined(QT3_SUPPORT)
- QSKIP("This test needs Qt3Support", SkipAll);
-#else
- QWidget *toplevel = createGUI();
- QAccessibleInterface *acc_toplevel = QAccessible::queryAccessibleInterface(toplevel);
- QVERIFY(acc_toplevel);
- // this is necessary to have the layout setup correctly
- toplevel->show();
-
- QObjectList children = toplevel->queryList("QWidget", 0, 0, 0);
- for (int c = 1; c <= children.count(); ++c) {
- QWidget *child = qobject_cast<QWidget*>(children.at(c-1));
- QAccessibleInterface *acc_child = QAccessible::queryAccessibleInterface(child);
- QVERIFY(acc_child);
- QCOMPARE(acc_child->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask, QAccessible::Child);
-
- QPoint center(child->mapToGlobal(child->rect().center()));
- QRect childRect(child->geometry());
- childRect.moveCenter(center);
-
- QCOMPARE(acc_child->rect(0), childRect);
- QCOMPARE(acc_toplevel->childAt(childRect.center().x(), childRect.center().y()), c);
- QCOMPARE(acc_toplevel->childAt(childRect.left(), childRect.top()), c);
- QCOMPARE(acc_toplevel->childAt(childRect.left(), childRect.bottom()), c);
- QCOMPARE(acc_toplevel->childAt(childRect.right(), childRect.top()), c);
- QCOMPARE(acc_toplevel->childAt(childRect.right(), childRect.bottom()), c);
-
- QCOMPARE(acc_toplevel->indexOfChild(acc_child), c);
- delete acc_child;
- }
-
- delete acc_toplevel;
- delete toplevel;
- QTestAccessibility::clearEvents();
-#endif // !QT3_SUPPORT
-}
-
-void tst_QAccessibility::childCount()
-{
-#if !defined(QT3_SUPPORT)
- QSKIP("This test needs Qt3Support", SkipAll);
-#else
- QWidget *toplevel = createGUI();
- QObject *topLeft = toplevel->child("topLeft");
- QObject *topRight = toplevel->child("topRight");
- QObject *bottomLeft = toplevel->child("bottomLeft");
- QObject *bottomRight = toplevel->child("bottomRight");
-
- QAccessibleInterface* acc_toplevel = QAccessible::queryAccessibleInterface(toplevel);
- QAccessibleInterface* acc_topLeft = QAccessible::queryAccessibleInterface(topLeft);
- QAccessibleInterface* acc_topRight = QAccessible::queryAccessibleInterface(topRight);
- QAccessibleInterface* acc_bottomLeft = QAccessible::queryAccessibleInterface(bottomLeft);
- QAccessibleInterface* acc_bottomRight = QAccessible::queryAccessibleInterface(bottomRight);
-
- QVERIFY(acc_toplevel);
- QVERIFY(acc_topLeft);
- QVERIFY(acc_topRight);
- QVERIFY(acc_bottomLeft);
- QVERIFY(acc_bottomRight);
-
- toplevel->show();
- QCOMPARE(acc_toplevel->childCount(), toplevel->queryList("QWidget", 0, 0, 0).count());
- QCOMPARE(acc_topLeft->childCount(), topLeft->queryList("QWidget", 0, 0, 0).count());
- QCOMPARE(acc_topRight->childCount(), topRight->queryList("QWidget", 0, 0, 0).count());
- QCOMPARE(acc_bottomLeft->childCount(), bottomLeft->queryList("QWidget", 0, 0, 0).count());
- QCOMPARE(acc_bottomRight->childCount(), bottomRight->queryList("QWidget", 0, 0, 0).count());
-
- delete acc_toplevel;
- delete acc_topLeft;
- delete acc_topRight;
- delete acc_bottomLeft;
- delete acc_bottomRight;
- delete toplevel;
- QTestAccessibility::clearEvents();
-#endif // !QT3_SUPPORT
-}
-
-void tst_QAccessibility::relationTo()
-{
-#if !defined(QT3_SUPPORT)
- QSKIP("This test needs Qt3Support", SkipAll);
-#else
- QWidget *toplevel = createGUI();
- toplevel->resize(400,300);
- QObject *topLeft = toplevel->child("topLeft");
- QObject *topRight = toplevel->child("topRight");
- QObject *bottomLeft = toplevel->child("bottomLeft");
- QObject *bottomRight = toplevel->child("bottomRight");
-
- toplevel->show();
-
- QAccessibleInterface *acc_toplevel = QAccessible::queryAccessibleInterface(toplevel);
-
- QAccessibleInterface *acc_topLeft = QAccessible::queryAccessibleInterface(topLeft);
- QAccessibleInterface *acc_group1 = QAccessible::queryAccessibleInterface(topLeft->child("group1"));
- QVERIFY(topLeft->child("group1"));
- QAccessibleInterface *acc_pb1 = QAccessible::queryAccessibleInterface(topLeft->child("group1")->child("pb1"));
- QAccessibleInterface *acc_group2 = QAccessible::queryAccessibleInterface(topLeft->child("group2"));
- QAccessibleInterface *acc_pb2 = 0;
- QAccessibleInterface *acc_stack = QAccessible::queryAccessibleInterface(topLeft->child("stack"));
- QAccessibleInterface *acc_page1 = QAccessible::queryAccessibleInterface(topLeft->child("stack")->child("page1"));
- QAccessibleInterface *acc_page2 = QAccessible::queryAccessibleInterface(topLeft->child("stack")->child("page2"));
- QAccessibleInterface *acc_page3 = QAccessible::queryAccessibleInterface(topLeft->child("stack")->child("page3"));
- QAccessibleInterface *acc_topRight = QAccessible::queryAccessibleInterface(topRight);
- QAccessibleInterface *acc_pbOk = QAccessible::queryAccessibleInterface(topRight->child("pbOk"));
- QAccessibleInterface *acc_slider = QAccessible::queryAccessibleInterface(topRight->child("slider"));
- QAccessibleInterface *acc_spinBox = QAccessible::queryAccessibleInterface(topRight->child("spinBox"));
- QAccessibleInterface *acc_sliderLcd = QAccessible::queryAccessibleInterface(topRight->child("sliderLcd"));
-
- QAccessibleInterface *acc_bottomLeft = QAccessible::queryAccessibleInterface(bottomLeft);
- QAccessibleInterface *acc_label = QAccessible::queryAccessibleInterface(bottomLeft->child("label"));
- QAccessibleInterface *acc_lineedit = QAccessible::queryAccessibleInterface(bottomLeft->child("lineedit"));
- QAccessibleInterface *acc_label2 = QAccessible::queryAccessibleInterface(bottomLeft->child("label2"));
- QAccessibleInterface *acc_radiogroup = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup"));
- QAccessibleInterface *acc_radioAM = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("radioAM"));
- QAccessibleInterface *acc_radioFM = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("radioFM"));
- QAccessibleInterface *acc_radioSW = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("radioSW"));
- QAccessibleInterface *acc_frequency = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("frequency"));
-
- QAccessibleInterface *acc_bottomRight = QAccessible::queryAccessibleInterface(bottomRight);
-
- QVERIFY(acc_toplevel);
- QVERIFY(acc_topLeft);
- QVERIFY(acc_topRight);
- QVERIFY(acc_bottomLeft);
- QVERIFY(acc_bottomRight);
- QVERIFY(acc_group1);
- QVERIFY(acc_group2);
- QVERIFY(acc_stack);
- QVERIFY(acc_page1);
- QVERIFY(acc_page2);
- QVERIFY(acc_page3);
- QVERIFY(acc_pbOk);
- QVERIFY(acc_slider);
- QVERIFY(acc_spinBox);
- QVERIFY(acc_sliderLcd);
- QVERIFY(acc_label);
- QVERIFY(acc_lineedit);
- QVERIFY(acc_radiogroup);
- QVERIFY(acc_radioAM);
- QVERIFY(acc_radioFM);
- QVERIFY(acc_radioSW);
- QVERIFY(acc_frequency);
-
- // hierachy relations
- QCOMPARE(acc_toplevel->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Self);
- QCOMPARE(acc_toplevel->relationTo(1, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Child);
- QCOMPARE(acc_toplevel->relationTo(0, acc_toplevel, 1) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
-
- QCOMPARE(acc_toplevel->relationTo(0, acc_topLeft, 0) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
- QCOMPARE(acc_toplevel->relationTo(0, acc_topRight, 0) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
- QCOMPARE(acc_toplevel->relationTo(0, acc_bottomLeft, 0) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
- QCOMPARE(acc_toplevel->relationTo(0, acc_bottomRight, 0) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
-
- QCOMPARE(acc_toplevel->relationTo(0, acc_group1, 0) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
- QCOMPARE(acc_toplevel->relationTo(0, acc_page1, 0) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
- QCOMPARE(acc_group1->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Descendent);
- QCOMPARE(acc_stack->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Descendent);
- QCOMPARE(acc_page1->relationTo(0, acc_stack, 0) & QAccessible::HierarchyMask,
- QAccessible::Child);
- QCOMPARE(acc_page1->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Descendent);
-
- QCOMPARE(acc_topLeft->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Child);
- QCOMPARE(acc_topRight->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Child);
- QCOMPARE(acc_bottomLeft->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Child);
- QCOMPARE(acc_bottomRight->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Child);
-
- QCOMPARE(acc_topLeft->relationTo(0, acc_topRight, 0) & QAccessible::HierarchyMask,
- QAccessible::Sibling);
- QCOMPARE(acc_topLeft->relationTo(0, acc_bottomLeft, 0) & QAccessible::HierarchyMask,
- QAccessible::Sibling);
- QCOMPARE(acc_topLeft->relationTo(0, acc_bottomRight, 0) & QAccessible::HierarchyMask,
- QAccessible::Sibling);
-
- QCOMPARE(acc_pb1->relationTo(0, acc_pb2, 0), QAccessible::Unrelated);
-
- // geometrical relations - only valid for siblings
- QCOMPARE(acc_topLeft->relationTo(0, acc_topRight, 0), QAccessible::Sibling | QAccessible::Left);
- QCOMPARE(acc_topLeft->relationTo(0, acc_bottomLeft, 0), QAccessible::Sibling | QAccessible::Up);
- QCOMPARE(acc_topLeft->relationTo(0, acc_bottomRight, 0), QAccessible::Sibling | QAccessible::Left | QAccessible::Up);
-
- QCOMPARE(acc_bottomRight->relationTo(0, acc_topLeft, 0), QAccessible::Sibling | QAccessible::Right | QAccessible::Down);
- QCOMPARE(acc_bottomRight->relationTo(0, acc_topRight, 0), QAccessible::Sibling | QAccessible::Down);
- QCOMPARE(acc_bottomRight->relationTo(0, acc_bottomLeft, 0), QAccessible::Sibling | QAccessible::Right);
-#ifdef Q_WS_MAC
- QEXPECT_FAIL("", "Task 155501", Continue);
-#endif
- QCOMPARE(acc_group1->relationTo(0, acc_group2, 0), QAccessible::Sibling | QAccessible::Up);
-#ifdef Q_WS_MAC
- QEXPECT_FAIL("", "Task 155501", Continue);
-#endif
- QCOMPARE(acc_group2->relationTo(0, acc_group1, 0), QAccessible::Sibling | QAccessible::Down);
-
- // Covers/Covered tested in navigateCovered
-
- // logical relations - focus
- QCOMPARE(acc_radioAM->relationTo(0, acc_radioFM, 0) & QAccessible::FocusChild,
- QAccessible::Unrelated);
- QCOMPARE(acc_radioAM->relationTo(0, acc_radiogroup, 0) & QAccessible::FocusChild,
- QAccessible::FocusChild);
- QCOMPARE(acc_radioAM->relationTo(0, acc_bottomLeft, 0) & QAccessible::FocusChild,
- QAccessible::FocusChild);
- QCOMPARE(acc_radioAM->relationTo(0, acc_topLeft, 0) & QAccessible::FocusChild,
- QAccessible::Unrelated);
- QCOMPARE(acc_radioAM->relationTo(0, acc_toplevel, 0) & QAccessible::FocusChild,
- QAccessible::FocusChild);
-
- // logical relations - labels
- QCOMPARE(acc_label->relationTo(0, acc_lineedit, 0) & QAccessible::LogicalMask,
- QAccessible::Label);
- QCOMPARE(acc_lineedit->relationTo(0, acc_label, 0) & QAccessible::LogicalMask,
- QAccessible::Labelled);
- QCOMPARE(acc_label->relationTo(0, acc_radiogroup, 0) & QAccessible::LogicalMask,
- QAccessible::Unrelated);
- QCOMPARE(acc_lineedit->relationTo(0, acc_lineedit, 0) & QAccessible::LogicalMask,
- QAccessible::Unrelated);
-
- QEXPECT_FAIL("", "Make me accessible", Continue);
- QCOMPARE(acc_radiogroup->relationTo(0, acc_radioAM, 0) & QAccessible::LogicalMask,
- QAccessible::Label | QAccessible::Controlled);
- QEXPECT_FAIL("", "Make me accessible", Continue);
- QCOMPARE(acc_radiogroup->relationTo(0, acc_radioFM, 0) & QAccessible::LogicalMask,
- QAccessible::Label | QAccessible::Controlled);
- QEXPECT_FAIL("", "Make me accessible", Continue);
- QCOMPARE(acc_radiogroup->relationTo(0, acc_radioSW, 0) & QAccessible::LogicalMask,
- QAccessible::Label | QAccessible::Controlled);
- QCOMPARE(acc_radiogroup->relationTo(0, acc_frequency, 0) & QAccessible::LogicalMask,
- QAccessible::Label);
- QCOMPARE(acc_frequency->relationTo(0, acc_radiogroup, 0) & QAccessible::LogicalMask,
- QAccessible::Labelled);
- QCOMPARE(acc_radiogroup->relationTo(0, acc_lineedit, 0) & QAccessible::LogicalMask,
- QAccessible::Unrelated);
-
- // logical relations - controller
- QCOMPARE(acc_pbOk->relationTo(0, acc_toplevel, 0) & QAccessible::LogicalMask,
- QAccessible::Controller);
- QCOMPARE(acc_slider->relationTo(0, acc_sliderLcd, 0) & QAccessible::LogicalMask,
- QAccessible::Controller);
- QCOMPARE(acc_spinBox->relationTo(0, acc_slider, 0) & QAccessible::LogicalMask,
- QAccessible::Controller);
- QCOMPARE(acc_lineedit->relationTo(0, acc_label2, 0) & QAccessible::LogicalMask,
- QAccessible::Controller);
-
- delete acc_toplevel;
- delete acc_topLeft;
- delete acc_group1;
- delete acc_pb1;
- delete acc_group2;
- delete acc_stack;
- delete acc_page1;
- delete acc_page2;
- delete acc_page3;
- delete acc_topRight;
- delete acc_pbOk;
- delete acc_slider;
- delete acc_spinBox;
- delete acc_sliderLcd;
- delete acc_bottomLeft;
- delete acc_label;
- delete acc_lineedit;
- delete acc_label2;
- delete acc_radiogroup;
- delete acc_radioAM;
- delete acc_radioFM;
- delete acc_radioSW;
- delete acc_frequency;
- delete acc_bottomRight;
-
- delete toplevel;
-
- QTestAccessibility::clearEvents();
-#endif // !QT3_SUPPORT
-}
-
void tst_QAccessibility::navigateGeometric()
{
{
#define QSETCOMPARE(thetypename, elements, otherelements) \
QCOMPARE((QSet<thetypename>() << elements), (QSet<thetypename>() << otherelements))
-void tst_QAccessibility::navigateControllers()
-{
-#if !defined(QT3_SUPPORT)
- QSKIP("This test needs Qt3Support", SkipAll);
-#else
- {
- Q3VBox vbox;
- QSlider slider(&vbox);
- QSpinBox spinBox(&vbox);
- QLCDNumber lcd1(&vbox);
- QLCDNumber lcd2(&vbox);
- QLabel label(&vbox);
- vbox.show();
-
- slider.setObjectName("slider");
- spinBox.setObjectName("spinBox");
- lcd1.setObjectName("lcd1");
- lcd2.setObjectName("lcd2");
- label.setObjectName("label");
-
- QTestAccessibility::clearEvents();
-
- connect(&slider, SIGNAL(valueChanged(int)), &lcd1, SLOT(display(int)));
- connect(&slider, SIGNAL(valueChanged(int)), &lcd2, SLOT(display(int)));
- connect(&spinBox, SIGNAL(valueChanged(int)), &lcd2, SLOT(display(int)));
- connect(&spinBox, SIGNAL(valueChanged(int)), &lcd1, SLOT(display(int)));
- connect(&spinBox, SIGNAL(valueChanged(const QString&)), &label, SLOT(setText(const QString&)));
-
- QAccessibleInterface *acc_slider = QAccessible::queryAccessibleInterface(&slider);
- QAccessibleInterface *acc_spinBox = QAccessible::queryAccessibleInterface(&spinBox);
- QAccessibleInterface *acc_lcd1 = QAccessible::queryAccessibleInterface(&lcd1);
- QAccessibleInterface *acc_lcd2 = QAccessible::queryAccessibleInterface(&lcd2);
- QAccessibleInterface *acc_label = QAccessible::queryAccessibleInterface(&label);
-
- QVERIFY(acc_slider->relationTo(0, acc_lcd1, 0) & QAccessible::Controller);
- QVERIFY(acc_slider->relationTo(0, acc_lcd2, 0) & QAccessible::Controller);
- QVERIFY(acc_spinBox->relationTo(0, acc_lcd1, 0) & QAccessible::Controller);
- QVERIFY(acc_spinBox->relationTo(0, acc_lcd2, 0) & QAccessible::Controller);
- QVERIFY(acc_spinBox->relationTo(0, acc_label, 0) & QAccessible::Controller);
-
- QAccessibleInterface *acc_target1, *acc_target2, *acc_target3;
- // from controller
- QCOMPARE(acc_slider->navigate(QAccessible::Controlled, 0, &acc_target1), -1);
- QVERIFY(!acc_target1);
- QCOMPARE(acc_slider->navigate(QAccessible::Controlled, 1, &acc_target1), 0);
- QCOMPARE(acc_slider->navigate(QAccessible::Controlled, 2, &acc_target2), 0);
- QSETCOMPARE(QObject*, acc_lcd1->object() << acc_lcd2->object(),
- acc_target1->object() << acc_target2->object());
- delete acc_target1;
- delete acc_target2;
-
- QCOMPARE(acc_slider->navigate(QAccessible::Controlled, 3, &acc_target1), -1);
- QVERIFY(!acc_target1);
-
- QCOMPARE(acc_spinBox->navigate(QAccessible::Controlled, 0, &acc_target1), -1);
- QVERIFY(!acc_target1);
- QCOMPARE(acc_spinBox->navigate(QAccessible::Controlled, 1, &acc_target1), 0);
- QCOMPARE(acc_spinBox->navigate(QAccessible::Controlled, 2, &acc_target2), 0);
- QCOMPARE(acc_spinBox->navigate(QAccessible::Controlled, 3, &acc_target3), 0);
- QSETCOMPARE(QObject*, acc_lcd1->object() << acc_lcd2->object() << acc_label->object(),
- acc_target1->object() << acc_target2->object() << acc_target3->object());
- delete acc_target1;
- delete acc_target2;
- delete acc_target3;
-
- QCOMPARE(acc_spinBox->navigate(QAccessible::Controlled, 4, &acc_target1), -1);
- QVERIFY(!acc_target1);
-
- // to controller
- QCOMPARE(acc_lcd1->navigate(QAccessible::Controller, 0, &acc_target1), -1);
- QVERIFY(!acc_target1);
- QCOMPARE(acc_lcd1->navigate(QAccessible::Controller, 1, &acc_target1), 0);
- QCOMPARE(acc_lcd1->navigate(QAccessible::Controller, 2, &acc_target2), 0);
- QSETCOMPARE(QObject*, acc_slider->object() << acc_spinBox->object(),
- acc_target1->object() << acc_target2->object());
- delete acc_target1;
- delete acc_target2;
- QCOMPARE(acc_lcd1->navigate(QAccessible::Controller, 3, &acc_target1), -1);
- QVERIFY(!acc_target1);
-
- delete acc_label;
- delete acc_lcd2;
- delete acc_lcd1;
- delete acc_spinBox;
- delete acc_slider;
- }
- QTestAccessibility::clearEvents();
-#endif // !QT3_SUPPORT
-}
-
-void tst_QAccessibility::navigateLabels()
-{
-#if !defined(QT3_SUPPORT)
- QSKIP("This test needs Qt3Support", SkipAll);
-#else
- {
- Q3VBox vbox;
- Q3HBox hbox(&vbox);
-
- QLabel label(&hbox);
- label.setText("This is a lineedit:");
- QLineEdit lineedit(&hbox);
- label.setBuddy(&lineedit);
-
- Q3VButtonGroup groupbox(&vbox);
- groupbox.setTitle("Be my children!");
- QRadioButton radio(&groupbox);
- QLabel label2(&groupbox);
- label2.setText("Another lineedit:");
- QLineEdit lineedit2(&groupbox);
- label2.setBuddy(&lineedit2);
- Q3GroupBox groupbox2(&groupbox);
- groupbox2.setTitle("Some grand-children");
- QLineEdit grandchild(&groupbox2);
-
- Q3GroupBox border(&vbox);
- QLineEdit lineedit3(&border);
- vbox.show();
- QTestAccessibility::clearEvents();
-
- QAccessibleInterface *acc_label = QAccessible::queryAccessibleInterface(&label);
- QAccessibleInterface *acc_lineedit = QAccessible::queryAccessibleInterface(&lineedit);
- QAccessibleInterface *acc_groupbox = QAccessible::queryAccessibleInterface(&groupbox);
- QAccessibleInterface *acc_radio = QAccessible::queryAccessibleInterface(&radio);
- QAccessibleInterface *acc_label2 = QAccessible::queryAccessibleInterface(&label2);
- QAccessibleInterface *acc_lineedit2 = QAccessible::queryAccessibleInterface(&lineedit2);
- QAccessibleInterface *acc_groupbox2 = QAccessible::queryAccessibleInterface(&groupbox2);
- QAccessibleInterface *acc_grandchild = QAccessible::queryAccessibleInterface(&grandchild);
- QAccessibleInterface *acc_border = QAccessible::queryAccessibleInterface(&border);
- QAccessibleInterface *acc_lineedit3 = QAccessible::queryAccessibleInterface(&lineedit3);
-
- QVERIFY(acc_label->relationTo(0, acc_lineedit,0) & QAccessible::Label);
- QVERIFY(acc_groupbox->relationTo(0, acc_radio,0) & QAccessible::Label);
- QVERIFY(acc_groupbox->relationTo(0, acc_lineedit2,0) & QAccessible::Label);
- QVERIFY(acc_groupbox->relationTo(0, acc_groupbox2,0) & QAccessible::Label);
- QVERIFY(acc_groupbox2->relationTo(0, acc_grandchild,0) & QAccessible::Label);
- QVERIFY(!(acc_border->relationTo(0, acc_lineedit3,0) & QAccessible::Label));
-
- QAccessibleInterface *acc_target;
- // from label
- QCOMPARE(acc_label->navigate(QAccessible::Labelled, 0, &acc_target), -1);
- QVERIFY(!acc_target);
- QCOMPARE(acc_label->navigate(QAccessible::Labelled, 1, &acc_target), 0);
- QVERIFY(acc_target->object() == acc_lineedit->object());
- delete acc_target; acc_target = 0;
- QCOMPARE(acc_label->navigate(QAccessible::Labelled, 2, &acc_target), -1);
- QVERIFY(!acc_target);
-
- QCOMPARE(acc_groupbox->navigate(QAccessible::Labelled, 0, &acc_target), -1);
- QVERIFY(!acc_target);
- QCOMPARE(acc_groupbox->navigate(QAccessible::Labelled, 1, &acc_target), 0);
- QVERIFY(acc_target->object() == acc_radio->object());
- delete acc_target; acc_target = 0;
- QCOMPARE(acc_groupbox->navigate(QAccessible::Labelled, 2, &acc_target), 0);
- QVERIFY(acc_target->object() == acc_label2->object());
- delete acc_target; acc_target = 0;
- QCOMPARE(acc_groupbox->navigate(QAccessible::Labelled, 3, &acc_target), 0);
- QVERIFY(acc_target->object() == acc_lineedit2->object());
- delete acc_target; acc_target = 0;
- QCOMPARE(acc_groupbox->navigate(QAccessible::Labelled, 4, &acc_target), 0);
- QVERIFY(acc_target->object() == acc_groupbox2->object());
- delete acc_target; acc_target = 0;
- QCOMPARE(acc_groupbox->navigate(QAccessible::Labelled, 5, &acc_target), -1);
- QVERIFY(!acc_target);
-
- QCOMPARE(acc_border->navigate(QAccessible::Labelled, 0, &acc_target), -1);
- QVERIFY(!acc_target);
- QCOMPARE(acc_border->navigate(QAccessible::Labelled, 1, &acc_target), -1);
- QVERIFY(!acc_target);
-
- // to label
- QCOMPARE(acc_lineedit->navigate(QAccessible::Label, 0, &acc_target), -1);
- QVERIFY(!acc_target);
- QCOMPARE(acc_lineedit->navigate(QAccessible::Label, 1, &acc_target), 0);
- QVERIFY(acc_target->object() == acc_label->object());
- delete acc_target; acc_target = 0;
- QCOMPARE(acc_lineedit->navigate(QAccessible::Label, 2, &acc_target), -1);
- QVERIFY(!acc_target);
-
- QCOMPARE(acc_radio->navigate(QAccessible::Label, 0, &acc_target), -1);
- QVERIFY(!acc_target);
- QCOMPARE(acc_radio->navigate(QAccessible::Label, 1, &acc_target), 0);
- QVERIFY(acc_target->object() == acc_groupbox->object());
- delete acc_target; acc_target = 0;
- QCOMPARE(acc_radio->navigate(QAccessible::Label, 2, &acc_target), -1);
- QVERIFY(!acc_target);
-
- QCOMPARE(acc_lineedit2->navigate(QAccessible::Label, 1, &acc_target), 0);
- QVERIFY(acc_target->object() == acc_label2->object());
- delete acc_target; acc_target = 0;
- QCOMPARE(acc_lineedit2->navigate(QAccessible::Label, 2, &acc_target), 0);
- QVERIFY(acc_target->object() == acc_groupbox->object());
- delete acc_target; acc_target = 0;
- QCOMPARE(acc_lineedit2->navigate(QAccessible::Label, 3, &acc_target), -1);
- QVERIFY(!acc_target);
-
- QCOMPARE(acc_grandchild->navigate(QAccessible::Label, 1, &acc_target), 0);
- QVERIFY(acc_target->object() == acc_groupbox2->object());
- delete acc_target; acc_target = 0;
- QCOMPARE(acc_grandchild->navigate(QAccessible::Label, 2, &acc_target), -1);
- QVERIFY(!acc_target);
- QCOMPARE(acc_grandchild->navigate(QAccessible::Label, 3, &acc_target), -1);
- QVERIFY(!acc_target);
-
- delete acc_label;
- delete acc_lineedit;
- delete acc_groupbox;
- delete acc_radio;
- delete acc_label2;
- delete acc_lineedit2;
- delete acc_groupbox2;
- delete acc_grandchild;
- delete acc_border;
- delete acc_lineedit3;
- }
- QTestAccessibility::clearEvents();
-#endif // !QT3_SUPPORT
-}
-
static QWidget *createWidgets()
{
QWidget *w = new QWidget();
QTestAccessibility::clearEvents();
}
-void tst_QAccessibility::text()
-{
-#if !defined(QT3_SUPPORT)
- QSKIP("This test needs Qt3Support", SkipAll);
-#else
- QWidget *toplevel = createGUI();
- toplevel->show();
-#if defined(Q_WS_X11)
- qt_x11_wait_for_window_manager(toplevel);
- QTest::qWait(100);
-#endif
- QObject *topLeft = toplevel->child("topLeft");
- QObject *topRight = toplevel->child("topRight");
- QObject *bottomLeft = toplevel->child("bottomLeft");
-
- QAccessibleInterface *acc_pb1 = QAccessible::queryAccessibleInterface(topLeft->child("pb1"));
-
- QAccessibleInterface *acc_pbOk = QAccessible::queryAccessibleInterface(topRight->child("pbOk"));
- QAccessibleInterface *acc_slider = QAccessible::queryAccessibleInterface(topRight->child("slider"));
- QAccessibleInterface *acc_spinBox = QAccessible::queryAccessibleInterface(topRight->child("spinBox"));
- QAccessibleInterface *acc_sliderLcd = QAccessible::queryAccessibleInterface(topRight->child("sliderLcd"));
-
- QAccessibleInterface *acc_label = QAccessible::queryAccessibleInterface(bottomLeft->child("label"));
- QAccessibleInterface *acc_lineedit = QAccessible::queryAccessibleInterface(bottomLeft->child("lineedit"));
- QAccessibleInterface *acc_radiogroup = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup"));
- QVERIFY(bottomLeft->child("radiogroup"));
- QAccessibleInterface *acc_radioAM = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("radioAM"));
- QAccessibleInterface *acc_frequency = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("frequency"));
-
- QVERIFY(acc_pb1);
-
- QVERIFY(acc_pbOk);
- QVERIFY(acc_slider);
- QVERIFY(acc_spinBox);
- QVERIFY(acc_sliderLcd);
-
- QVERIFY(acc_label);
- QVERIFY(acc_lineedit);
- QVERIFY(acc_radiogroup);
- QVERIFY(acc_radioAM);
- QVERIFY(acc_frequency);
-
- QVERIFY(acc_label->relationTo(0, acc_lineedit, 0) & QAccessible::Label);
- QVERIFY(acc_radiogroup->relationTo(0, acc_frequency, 0) & QAccessible::Label);
- QVERIFY(acc_slider->relationTo(0, acc_sliderLcd, 0) & QAccessible::Controller);
- QVERIFY(acc_spinBox->relationTo(0, acc_slider, 0) & QAccessible::Controller);
-
- // Name
- QCOMPARE(acc_lineedit->text(QAccessible::Name, 0), acc_label->text(QAccessible::Name,0));
- QCOMPARE(acc_frequency->text(QAccessible::Name, 0), acc_radiogroup->text(QAccessible::Name,0));
- QCOMPARE(acc_sliderLcd->text(QAccessible::Name, 0), acc_slider->text(QAccessible::Value,0));
- QCOMPARE(acc_pbOk->text(QAccessible::Name, 0), QString("Ok"));
- QCOMPARE(acc_radioAM->text(QAccessible::Name, 0), QString("AM"));
- QCOMPARE(acc_pb1->text(QAccessible::Name, 0), QString("Button1"));
-
- // Description
- QString desc = qobject_cast<QWidget*>(acc_label->object())->toolTip();
- QVERIFY(!desc.isEmpty());
- QCOMPARE(acc_label->text(QAccessible::Description, 0), desc);
- desc = qobject_cast<QWidget*>(acc_lineedit->object())->toolTip();
- QVERIFY(!desc.isEmpty());
- QCOMPARE(acc_lineedit->text(QAccessible::Description, 0), desc);
-
- // Help
- QString help = qobject_cast<QWidget*>(acc_label->object())->whatsThis();
- QVERIFY(!help.isEmpty());
- QCOMPARE(acc_label->text(QAccessible::Help, 0), help);
- help = qobject_cast<QWidget*>(acc_frequency->object())->whatsThis();
- QVERIFY(!help.isEmpty());
- QCOMPARE(acc_frequency->text(QAccessible::Help, 0), help);
-
- // Value
- QString value = acc_frequency->object()->property("text").toString();
- QVERIFY(!value.isEmpty());
- QCOMPARE(acc_frequency->text(QAccessible::Value, 0), value);
- value = acc_slider->object()->property("value").toString();
- QVERIFY(!value.isEmpty());
- QCOMPARE(acc_slider->text(QAccessible::Value, 0), value);
- QCOMPARE(acc_spinBox->text(QAccessible::Value, 0), value);
-
- // Accelerator
- QCOMPARE(acc_pbOk->text(QAccessible::Accelerator, 0), Q3Accel::keyToString(Qt::Key_Enter));
- QCOMPARE(acc_pb1->text(QAccessible::Accelerator, 0), Q3Accel::keyToString(Qt::ALT + Qt::Key_1));
- QCOMPARE(acc_lineedit->text(QAccessible::Accelerator, 0), Q3Accel::keyToString(Qt::ALT) + "L");
- QCOMPARE(acc_frequency->text(QAccessible::Accelerator, 0), Q3Accel::keyToString(Qt::ALT) + "C");
-
- delete acc_pb1;
- delete acc_pbOk;
- delete acc_slider;
- delete acc_spinBox;
- delete acc_sliderLcd;
-
- delete acc_label;
- delete acc_lineedit;
- delete acc_radiogroup;
- delete acc_radioAM;
- delete acc_frequency;
-
- delete toplevel;
- QTestAccessibility::clearEvents();
-#endif // !QT3_SUPPORT
-}
-
-void tst_QAccessibility::setText()
-{
-#if !defined(QT3_SUPPORT)
- QSKIP("This test needs Qt3Support", SkipAll);
-#else
- QWidget *toplevel = createGUI();
- toplevel->show();
- QObject *bottomLeft = toplevel->findChild<QObject *>("bottomLeft");
-
- QAccessibleInterface *acc_lineedit = QAccessible::queryAccessibleInterface(bottomLeft->findChild<QLineEdit *>("lineedit"));
- // Value, read-write
- QString txt = acc_lineedit->text(QAccessible::Value, 0);
- QVERIFY(txt.isEmpty());
- txt = QLatin1String("Writable");
- acc_lineedit->setText(QAccessible::Value, 0, txt);
- QCOMPARE(acc_lineedit->text(QAccessible::Value, 0), txt);
-
- // Description, read-only
- txt = acc_lineedit->text(QAccessible::Description, 0);
- QVERIFY(!txt.isEmpty());
- acc_lineedit->setText(QAccessible::Description, 0, QLatin1String(""));
- QCOMPARE(acc_lineedit->text(QAccessible::Description, 0), txt);
-
- QVERIFY(acc_lineedit);
-
- delete acc_lineedit;
- delete toplevel;
- QTestAccessibility::clearEvents();
-#endif //QT3_SUPPORT
-}
-
void tst_QAccessibility::hideShowTest()
{
QWidget * const window = new QWidget();
toggletool.setText("Toggle");
toggletool.setMinimumSize(20,20);
-#if 0
- // QT3_SUPPORT
- // push button with a menu
- QPushButton menuButton("Menu", &window);
- Q3PopupMenu buttonMenu(&menuButton);
- buttonMenu.insertItem("Some item");
- menuButton.setPopup(&buttonMenu);
-
- // menu toolbutton
- QToolButton menuToolButton(&window);
- menuToolButton.setText("Menu Tool");
- Q3PopupMenu toolMenu(&menuToolButton);
- toolMenu.insertItem("Some item");
- menuToolButton.setPopup(&toolMenu);
- menuToolButton.setMinimumSize(20,20);
-
- // splitted menu toolbutton
- QToolButton splitToolButton(&window);
- splitToolButton.setTextLabel("Split Tool");
- Q3PopupMenu splitMenu(&splitToolButton);
- splitMenu.insertItem("Some item");
- splitToolButton.setPopup(&splitMenu);
- splitToolButton.setPopupDelay(0);
- splitToolButton.setMinimumSize(20,20);
-#endif
-
// test push button
QAccessibleInterface* interface = QAccessible::queryAccessibleInterface(&pushButton);
QAccessibleActionInterface* actionInterface = interface->actionInterface();
QTestAccessibility::clearEvents();
}
-void tst_QAccessibility::sliderTest()
-{
-#if !defined(QT3_SUPPORT)
- QSKIP("This test needs Qt3Support", SkipAll);
-#else
- QAccessibleInterface *test = 0;
- Q3VBox *vbox = new Q3VBox;
- QLabel *labelHorizontal = new QLabel("Horizontal", vbox);
- QSlider *sliderHorizontal = new QSlider(Qt::Horizontal, vbox);
- labelHorizontal->setBuddy(sliderHorizontal);
-
- QLabel *labelVertical = new QLabel("Vertical", vbox);
- QSlider *sliderVertical = new QSlider(Qt::Vertical, vbox);
- labelVertical->setBuddy(sliderVertical);
- vbox->show();
-
- // test horizontal slider
- test = QAccessible::queryAccessibleInterface(sliderHorizontal);
- QVERIFY(test);
- QCOMPARE(test->childCount(), 3);
- QCOMPARE(test->role(0), QAccessible::Slider);
- QCOMPARE(test->role(1), QAccessible::PushButton);
- QCOMPARE(test->role(2), QAccessible::Indicator);
- QCOMPARE(test->role(3), QAccessible::PushButton);
-
- QCOMPARE(test->text(QAccessible::Name, 0), labelHorizontal->text());
- QCOMPARE(test->text(QAccessible::Name, 1), QSlider::tr("Page left"));
- QCOMPARE(test->text(QAccessible::Name, 2), QSlider::tr("Position"));
- QCOMPARE(test->text(QAccessible::Name, 3), QSlider::tr("Page right"));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->value()));
- QCOMPARE(test->text(QAccessible::Value, 1), QString());
- QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderHorizontal->value()));
- QCOMPARE(test->text(QAccessible::Value, 3), QString());
-// Skip action tests.
-#if 0
- QCOMPARE(test->defaultAction(0), QAccessible::SetFocus);
- QCOMPARE(test->defaultAction(1), QAccessible::Press);
- QCOMPARE(test->defaultAction(2), QAccessible::NoAction);
- QCOMPARE(test->defaultAction(3), QAccessible::Press);
- QCOMPARE(test->actionText(QAccessible::SetFocus, QAccessible::Name, 0), QSlider::tr("Set Focus"));
- QCOMPARE(test->actionText(QAccessible::Press, QAccessible::Name, 1), QSlider::tr("Press"));
- QCOMPARE(test->actionText(QAccessible::Increase, QAccessible::Name, 2), QSlider::tr("Increase"));
- QCOMPARE(test->actionText(QAccessible::Decrease, QAccessible::Name, 2), QSlider::tr("Decrease"));
- QCOMPARE(test->actionText(QAccessible::Press, QAccessible::Name, 3), QSlider::tr("Press"));
- QVERIFY(test->doAction(QAccessible::Press, 3));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->pageStep()));
- QVERIFY(test->doAction(QAccessible::Press, 3));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal->pageStep()));
- QVERIFY(test->doAction(QAccessible::Press, 1));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->pageStep()));
- QVERIFY(test->doAction(QAccessible::Press, 1));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0));
- QVERIFY(test->doAction(QAccessible::Increase, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->lineStep()));
- QVERIFY(test->doAction(QAccessible::Increase, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal->lineStep()));
- QVERIFY(test->doAction(QAccessible::Decrease, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->lineStep()));
- QVERIFY(test->doAction(QAccessible::Decrease, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0));
-#endif
- delete test;
-
- // test vertical slider
- test = QAccessible::queryAccessibleInterface(sliderVertical);
- QVERIFY(test);
- QCOMPARE(test->childCount(), 3);
- QCOMPARE(test->role(0), QAccessible::Slider);
- QCOMPARE(test->role(1), QAccessible::PushButton);
- QCOMPARE(test->role(2), QAccessible::Indicator);
- QCOMPARE(test->role(3), QAccessible::PushButton);
-
- QCOMPARE(test->text(QAccessible::Name, 0), labelVertical->text());
- QCOMPARE(test->text(QAccessible::Name, 1), QSlider::tr("Page up"));
- QCOMPARE(test->text(QAccessible::Name, 2), QSlider::tr("Position"));
- QCOMPARE(test->text(QAccessible::Name, 3), QSlider::tr("Page down"));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->value()));
- QCOMPARE(test->text(QAccessible::Value, 1), QString());
- QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderVertical->value()));
- QCOMPARE(test->text(QAccessible::Value, 3), QString());
-// Skip action tests.
-#if 0
- QCOMPARE(test->defaultAction(0), QAccessible::SetFocus);
- QCOMPARE(test->defaultAction(1), QAccessible::Press);
- QCOMPARE(test->defaultAction(2), QAccessible::NoAction);
- QCOMPARE(test->defaultAction(3), QAccessible::Press);
- QCOMPARE(test->actionText(QAccessible::SetFocus, QAccessible::Name, 0), QSlider::tr("Set Focus"));
- QCOMPARE(test->actionText(QAccessible::Press, QAccessible::Name, 1), QSlider::tr("Press"));
- QCOMPARE(test->actionText(QAccessible::Increase, QAccessible::Name, 2), QSlider::tr("Increase"));
- QCOMPARE(test->actionText(QAccessible::Decrease, QAccessible::Name, 2), QSlider::tr("Decrease"));
- QCOMPARE(test->actionText(QAccessible::Press, QAccessible::Name, 3), QSlider::tr("Press"));
- QVERIFY(test->doAction(QAccessible::Press, 3));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->pageStep()));
- QVERIFY(test->doAction(QAccessible::Press, 3));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical->pageStep()));
- QVERIFY(test->doAction(QAccessible::Press, 1));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->pageStep()));
- QVERIFY(test->doAction(QAccessible::Press, 1));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0));
- QVERIFY(test->doAction(QAccessible::Increase, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->lineStep()));
- QVERIFY(test->doAction(QAccessible::Increase, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical->lineStep()));
- QVERIFY(test->doAction(QAccessible::Decrease, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->lineStep()));
- QVERIFY(test->doAction(QAccessible::Decrease, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0));
-#endif
- delete test;
- delete sliderHorizontal;
- delete sliderVertical;
- delete labelHorizontal;
- delete labelVertical;
- delete vbox;
-
- // Test that when we hide() a slider, the PageLeft, Indicator, and PageRight also gets the
- // Invisible state bit set.
- enum SubControls { PageLeft = 1, Position = 2, PageRight = 3 };
-
- QSlider *slider = new QSlider();
- QAccessibleInterface * const sliderInterface = QAccessible::queryAccessibleInterface(slider);
- QVERIFY(sliderInterface);
-
- QVERIFY(sliderInterface->state(0) & QAccessible::Invisible);
- QVERIFY(sliderInterface->state(PageLeft) & QAccessible::Invisible);
- QVERIFY(sliderInterface->state(Position) & QAccessible::Invisible);
- QVERIFY(sliderInterface->state(PageRight) & QAccessible::Invisible);
-
- slider->show();
- QVERIFY(sliderInterface->state(0) ^ QAccessible::Invisible);
- QVERIFY(sliderInterface->state(PageLeft) ^ QAccessible::Invisible);
- QVERIFY(sliderInterface->state(Position) ^ QAccessible::Invisible);
- QVERIFY(sliderInterface->state(PageRight) ^ QAccessible::Invisible);
- QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(slider, 0, QAccessible::ObjectShow)));
- QTestAccessibility::clearEvents();
-
- slider->hide();
- QVERIFY(sliderInterface->state(0) & QAccessible::Invisible);
- QVERIFY(sliderInterface->state(PageLeft) & QAccessible::Invisible);
- QVERIFY(sliderInterface->state(Position) & QAccessible::Invisible);
- QVERIFY(sliderInterface->state(PageRight) & QAccessible::Invisible);
- QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(slider, 0, QAccessible::ObjectHide)));
- QTestAccessibility::clearEvents();
-
- // Test that the left/right subcontrols are set to unavailable when the slider is at the minimum/maximum.
- slider->show();
- slider->setMinimum(0);
- slider->setMaximum(100);
-
- slider->setValue(50);
- QVERIFY(sliderInterface->state(PageLeft) ^ QAccessible::Unavailable);
- QVERIFY(sliderInterface->state(Position) ^ QAccessible::Unavailable);
- QVERIFY(sliderInterface->state(PageRight) ^ QAccessible::Unavailable);
-
- slider->setValue(0);
- QVERIFY(sliderInterface->state(PageLeft) & QAccessible::Unavailable);
- QVERIFY(sliderInterface->state(Position) ^ QAccessible::Unavailable);
- QVERIFY(sliderInterface->state(PageRight) ^ QAccessible::Unavailable);
-
- slider->setValue(100);
- QVERIFY(sliderInterface->state(PageLeft) ^ QAccessible::Unavailable);
- QVERIFY(sliderInterface->state(Position) ^ QAccessible::Unavailable);
- QVERIFY(sliderInterface->state(PageRight) & QAccessible::Unavailable);
-
- delete sliderInterface;
- delete slider;
-
- // Test that the rects are ok.
- {
- QSlider *slider = new QSlider(Qt::Horizontal);
- slider->show();
-#if defined(Q_WS_X11)
- qt_x11_wait_for_window_manager(slider);
- QTest::qWait(100);
-#endif
- QAccessibleInterface * const sliderInterface = QAccessible::queryAccessibleInterface(slider);
- QVERIFY(sliderInterface);
-
- slider->setMinimum(0);
- slider->setMaximum(100);
- slider->setValue(50);
-
- const QRect sliderRect = sliderInterface->rect(0);
- QVERIFY(sliderRect.isValid());
-
- // Verify that the sub-control rects are valid and inside the slider rect.
- for (int i = PageLeft; i <= PageRight; ++i) {
- const QRect testRect = sliderInterface->rect(i);
- QVERIFY(testRect.isValid());
- QVERIFY(sliderRect.contains(testRect));
- }
-
- delete slider;
- delete sliderInterface;
- }
-
- QTestAccessibility::clearEvents();
-#endif //!QT3_SUPPORT
-}
-
void tst_QAccessibility::scrollBarTest()
{
// Test that when we hide() a slider, the PageLeft, Indicator, and PageRight also gets the
#endif // QT_NO_DOCKWIDGET
}
-void tst_QAccessibility::pushButtonTest()
-{
-#if !defined(QT3_SUPPORT)
- QSKIP( "Should never get here without Qt3Support", SkipAll);
-#else
- // Set up a proper main window with two dock widgets
- QWidget *toplevel = createGUI();
- QObject *topRight = toplevel->findChild<QObject *>("topRight");
-
- toplevel->show();
-#if defined(Q_WS_X11)
- qt_x11_wait_for_window_manager(toplevel);
- QTest::qWait(100);
-#endif
- QPushButton *pb = qobject_cast<QPushButton*>(topRight->findChild<QPushButton *>("pbOk"));
- QPoint pt = pb->mapToGlobal(pb->geometry().topLeft());
- QRect rect(pt, pb->geometry().size());
- pt = rect.center();
-
- QAccessibleInterface *accToplevel = QAccessible::queryAccessibleInterface(toplevel);
- QAccessibleInterface *acc;
- QAccessibleInterface *acc2;
- int entry = accToplevel->childAt(pt.x(), pt.y());
- accToplevel->navigate(QAccessible::Child, entry, &acc);
- if (acc) {
- entry = acc->childAt(pt.x(), pt.y());
- acc->navigate(QAccessible::Child, entry, &acc2);
- delete acc;
- acc = acc2;
- }
- QCOMPARE(acc->role(0), QAccessible::PushButton);
- QCOMPARE(acc->rect(0), rect);
- QCOMPARE(acc->childAt(pt.x(), pt.y()), 0);
-
- delete acc;
- delete accToplevel;
- delete toplevel;
- QTestAccessibility::clearEvents();
-#endif //QT3_SUPPORT
-}
-
void tst_QAccessibility::comboBoxTest()
{
#if defined(Q_OS_WINCE)
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt3Support module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef Q3TL_H
-#define Q3TL_H
-
-#include <QtCore/qalgorithms.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3SupportLight)
-
-template <typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE void qHeapSortPushDown(T *heap, int first, int last, LessThan lessThan)
-{
- int r = first;
- while (r <= last / 2) {
- if (last == 2 * r) {
- // node r has only one child
- if (lessThan(heap[2 * r], heap[r]))
- qSwap(heap[r], heap[2 * r]);
- r = last;
- } else {
- // node r has two children
- if (lessThan(heap[2 * r], heap[r]) && !lessThan(heap[2 * r + 1], heap[2 * r])) {
- // swap with left child
- qSwap(heap[r], heap[2 * r]);
- r *= 2;
- } else if (lessThan(heap[2 * r + 1], heap[r])
- && lessThan(heap[2 * r + 1], heap[2 * r])) {
- // swap with right child
- qSwap(heap[r], heap[2 * r + 1]);
- r = 2 * r + 1;
- } else {
- r = last;
- }
- }
- }
-}
-
-template <typename BiIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE void qHeapSortHelper(BiIterator begin, BiIterator end, const T & /* dummy */, LessThan lessThan)
-{
- BiIterator it = begin;
- uint n = 0;
- while (it != end) {
- ++n;
- ++it;
- }
- if (n == 0)
- return;
-
- // Create the heap
- BiIterator insert = begin;
- T *realheap = new T[n];
- T *heap = realheap - 1;
- int size = 0;
- for(; insert != end; ++insert) {
- heap[++size] = *insert;
- int i = size;
- while (i > 1 && lessThan(heap[i], heap[i / 2])) {
- qSwap(heap[i], heap[i / 2]);
- i /= 2;
- }
- }
-
- // Now do the sorting
- for (int i = n; i > 0; i--) {
- *begin++ = heap[1];
- if (i > 1) {
- heap[1] = heap[i];
- qHeapSortPushDown(heap, 1, i - 1, lessThan);
- }
- }
-
- delete[] realheap;
-}
-
-template <typename BiIterator, typename T>
-inline void qHeapSortHelper(BiIterator begin, BiIterator end, const T &dummy)
-{
- qHeapSortHelper(begin, end, dummy, qLess<T>());
-}
-
-template <typename BiIterator, typename LessThan>
-inline void qHeapSort(BiIterator begin, BiIterator end, LessThan lessThan)
-{
- if (begin != end)
- qHeapSortHelper(begin, end, *begin, lessThan);
-}
-
-template <typename BiIterator>
-inline void qHeapSort(BiIterator begin, BiIterator end)
-{
- if (begin != end)
- qHeapSortHelper(begin, end, *begin);
-}
-
-template <typename Container>
-inline void qHeapSort(Container &c)
-{
-#ifdef Q_CC_BOR
- // Work around Borland 5.5 optimizer bug
- c.detach();
-#endif
- if (!c.empty())
- qHeapSortHelper(c.begin(), c.end(), *c.begin());
-}
-
-
-template <typename BiIterator, typename LessThan>
-void qBubbleSort(BiIterator begin, BiIterator end, LessThan lessThan)
-{
- // Goto last element;
- BiIterator last = end;
-
- // empty list
- if (begin == end)
- return;
-
- --last;
- // only one element ?
- if (last == begin)
- return;
-
- // So we have at least two elements in here
- while (begin != last) {
- bool swapped = false;
- BiIterator swapPos = begin;
- BiIterator x = end;
- BiIterator y = x;
- y--;
- do {
- --x;
- --y;
- if (lessThan(*x, *y)) {
- swapped = true;
- qSwap(*x, *y);
- swapPos = y;
- }
- } while (y != begin);
- if (!swapped)
- return;
- begin = swapPos;
- ++begin;
- }
-}
-
-template <typename BiIterator, typename T>
-void qBubbleSortHelper(BiIterator begin, BiIterator end, T)
-{
- qBubbleSort(begin, end, qLess<T>());
-}
-
-template <typename BiIterator>
-void qBubbleSort(BiIterator begin, BiIterator end)
-{
- if (begin != end)
- qBubbleSortHelper(begin, end, *begin);
-}
-
-template <typename Container>
-inline void qBubbleSort(Container &c)
-{
- qBubbleSort(c.begin(), c.end());
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // Q3TL_H
#include <sstream>
#include <algorithm>
#include <qalgorithms.h>
-#include "q3tl.h"
#include <QStringList>
#include <QString>
#include <QVector>
void cleanup();
private slots:
- void qBubbleSort();
- void qHeapSort();
void test_qLowerBound_data();
void test_qLowerBound();
void test_qUpperBound_data();
};
tst_QAlgorithms::tst_QAlgorithms()
-
{
}
tst_QAlgorithms::~tst_QAlgorithms()
{
-
}
void tst_QAlgorithms::init()
}
}
#endif
-static bool userFunction1(char ch1, char ch2)
-{
- return (ch1 ^ 1) < (ch2 ^ 1);
-}
-
-bool userFunction2(const char &ch1, char ch2)
-{
- return (ch1 ^ 1) < (ch2 ^ 1);
-}
-
-static inline bool userFunction3(char ch1, const char &ch2)
-{
- return (ch1 ^ 1) < (ch2 ^ 1);
-}
-
-inline bool userFunction4(const char &ch1, const char &ch2)
-{
- return (ch1 ^ 1) < (ch2 ^ 1);
-}
-
-class UserFunctor1
-{
-public:
- UserFunctor1(int x = 1) : y(x) {}
-
- bool operator()(char ch1, char ch2)
- {
- return (ch1 ^ y) < (ch2 ^ y);
- }
-
- char y;
-};
-
-void tst_QAlgorithms::qHeapSort()
-{
- char array1[] = "3141592";
- ::qHeapSort((char *)array1, array1 + strlen(array1));
- QVERIFY(strcmp(array1, "1123459") == 0);
-
- ::qHeapSort((char *)array1, array1 + strlen(array1), qGreater<char>());
- QVERIFY(strcmp(array1, "9543211") == 0);
-
- ::qHeapSort((char *)array1, array1 + strlen(array1), qLess<char>());
- QVERIFY(strcmp(array1, "1123459") == 0);
- {
- char array2[] = "0123456789@ABCDE";
- ::qHeapSort((char *)array2, array2 + strlen(array2), userFunction1);
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- }
-
- {
- char array2[] = "0123456789@ABCDE";
- ::qHeapSort((char *)array2, array2 + strlen(array2), userFunction2);
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- }
-
- {
- char array2[] = "0123456789@ABCDE";
- ::qHeapSort((char *)array2, array2 + strlen(array2), userFunction3);
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- }
-
- {
- char array2[] = "0123456789@ABCDE";
- ::qHeapSort((char *)array2, array2 + strlen(array2), userFunction4);
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- }
-
- {
- UserFunctor1 userFunctor1;
- char array2[] = "0123456789@ABCDE";
- ::qHeapSort((char *)array2, array2 + strlen(array2), userFunctor1);
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- }
-
- {
- char array2[] = "0123456789@ABCDE";
- ::qHeapSort((char *)array2, array2 + strlen(array2), UserFunctor1());
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- ::qHeapSort((char *)array2, array2 + strlen(array2), UserFunctor1(1));
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- ::qHeapSort((char *)array2, array2 + strlen(array2), UserFunctor1(3));
- QVERIFY(strcmp(array2, "3210765498CBA@ED") == 0);
- ::qHeapSort((char *)array2, array2 + strlen(array2), UserFunctor1(0));
- QVERIFY(strcmp(array2, "0123456789@ABCDE") == 0);
- }
-}
-
-void tst_QAlgorithms::qBubbleSort()
-{
- char array1[] = "3141592";
- ::qBubbleSort((char *)array1, array1 + strlen(array1));
- QVERIFY(strcmp(array1, "1123459") == 0);
-
- ::qBubbleSort((char *)array1, array1 + strlen(array1), qGreater<char>());
- QVERIFY(strcmp(array1, "9543211") == 0);
-
- ::qBubbleSort((char *)array1, array1 + strlen(array1), qLess<char>());
- QVERIFY(strcmp(array1, "1123459") == 0);
-
- {
- char array2[] = "0123456789@ABCDE";
- ::qBubbleSort((char *)array2, array2 + strlen(array2), userFunction1);
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- }
-
- {
- char array2[] = "0123456789@ABCDE";
- ::qBubbleSort((char *)array2, array2 + strlen(array2), userFunction2);
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- }
-
- {
- char array2[] = "0123456789@ABCDE";
- ::qBubbleSort((char *)array2, array2 + strlen(array2), userFunction3);
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- }
-
- {
- char array2[] = "0123456789@ABCDE";
- ::qBubbleSort((char *)array2, array2 + strlen(array2), userFunction4);
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- }
-
- {
- UserFunctor1 userFunctor1;
- char array2[] = "0123456789@ABCDE";
- ::qBubbleSort((char *)array2, array2 + strlen(array2), userFunctor1);
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- }
-
- {
- char array2[] = "0123456789@ABCDE";
- ::qBubbleSort((char *)array2, array2 + strlen(array2), UserFunctor1());
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- ::qBubbleSort((char *)array2, array2 + strlen(array2), UserFunctor1(1));
- QVERIFY(strcmp(array2, "1032547698A@CBED") == 0);
- ::qBubbleSort((char *)array2, array2 + strlen(array2), UserFunctor1(3));
- QVERIFY(strcmp(array2, "3210765498CBA@ED") == 0);
- ::qBubbleSort((char *)array2, array2 + strlen(array2), UserFunctor1(0));
- QVERIFY(strcmp(array2, "0123456789@ABCDE") == 0);
- }
-}
void tst_QAlgorithms::swap()
{
QList<int> list;
list << 4 << 3 << 6;
- ::qHeapSort(list.begin(), list.end());
+ ::qSort(list.begin(), list.end());
QCOMPARE(list.count(), 3);
QCOMPARE(list.at(0), 3);
}
template <typename DataType>
-class HeapSortHelper
-{
-public:
- void operator()(QVector<DataType> list)
- {
- ::qHeapSort(list);
- }
-};
-
-template <typename DataType>
-class BubbleSortHelper
-{
-public:
- void operator()(QVector<DataType> list)
- {
- ::qBubbleSort(list);
- }
-};
-
-template <typename DataType>
class QuickSortHelper
{
public:
testAlgorithm<StlSortHelper<TestInt>, TestInt>(StlSortHelper<TestInt>(), dataSetTypes);
cout << endl << "std::stable_sort" << endl;
testAlgorithm<StlStableSortHelper<TestInt>, TestInt>(StlStableSortHelper<TestInt>(), dataSetTypes);
- cout << "Heap sort" << endl;
- testAlgorithm<HeapSortHelper<TestInt>, TestInt>(HeapSortHelper<TestInt>(), dataSetTypes);
- cout << endl << "Bubble sort" << endl;
- testAlgorithm<BubbleSortHelper<TestInt>, TestInt>(BubbleSortHelper<TestInt>(), dataSetTypes);
/*
cout << endl << "Sorting lists of ints" << endl;
- cout << "Heap sort" << endl;
- testAlgorithm<HeapSortHelper<int>, int>(HeapSortHelper<int>(), dataSetTypes);
cout << endl << "Quick sort" << endl;
testAlgorithm<QuickSortHelper<int>, int>(QuickSortHelper<int>(), dataSetTypes);
cout << endl << "std::sort" << endl;
testAlgorithm<StlSortHelper<int>, int>(StlSortHelper<int>(), dataSetTypes);
cout << endl << "std::stable_sort" << endl;
testAlgorithm<StlStableSortHelper<int>, int>(StlStableSortHelper<int>(), dataSetTypes);
- cout << endl << "Bubble sort" << endl;
- testAlgorithm<BubbleSortHelper<int>, int>(BubbleSortHelper<int>(), dataSetTypes);
*/
}
#endif
QApplication app(argc, argv);
QApplication::setAttribute(Qt::AA_NativeWindows); //QTBUG-15774
base *b = new base();
+ Q_UNUSED(b);
return app.exec();
}
for (int i = 0; i < x11RgbTblSize; ++i) {
QString colorName = QLatin1String(x11RgbTbl[i].name);
QColor color;
- QTest::ignoreMessage(QtWarningMsg, QString("QColor::setNamedColor: Unknown color name '%1'").arg(colorName).toLatin1());
color.setNamedColor(colorName);
QVERIFY(!color.isValid());
}
for (int i = 0; i < x11RgbTblSize; ++i) {
QString colorName = QLatin1String(x11RgbTbl[i].name);
QColor color;
- QTest::ignoreMessage(QtWarningMsg, QString("QColor::setNamedColor: Unknown color name '%1'").arg(colorName).toLatin1());
color.setNamedColor(colorName);
QVERIFY(!color.isValid());
}
QTest::addColumn<int>("insertIndex");
QTest::addColumn<QString>("itemLabel");
QTest::addColumn<int>("expectedIndex");
- QTest::addColumn<bool>("testQt3Support");
QTest::addColumn<bool>("editable");
QStringList initialItems;
initialItems << "foo" << "bar";
for(int e = 0 ; e<2 ; e++) {
bool editable = (e==0);
- QTest::newRow("Insert less then 0") << initialItems << -1 << "inserted" << 0 << false << editable;
- QTest::newRow("Insert at 0") << initialItems << 0 << "inserted" << 0 << false << editable;
- QTest::newRow("Insert beyond count") << initialItems << 3 << "inserted" << 2 << false << editable;
- QTest::newRow("Insert at count") << initialItems << 2 << "inserted" << 2 << false << editable;
- QTest::newRow("Insert in the middle") << initialItems << 1 << "inserted" << 1 << false << editable;
-#if defined(QT3_SUPPORT)
- QTest::newRow("Qt3Support: Insert less then 0") << initialItems << -1 << "inserted" << 2 << true << editable;
-#endif
+ QTest::newRow("Insert less then 0") << initialItems << -1 << "inserted" << 0 << editable;
+ QTest::newRow("Insert at 0") << initialItems << 0 << "inserted" << 0 << editable;
+ QTest::newRow("Insert beyond count") << initialItems << 3 << "inserted" << 2 << editable;
+ QTest::newRow("Insert at count") << initialItems << 2 << "inserted" << 2 << editable;
+ QTest::newRow("Insert in the middle") << initialItems << 1 << "inserted" << 1 << editable;
}
}
QFETCH(int, insertIndex);
QFETCH(QString, itemLabel);
QFETCH(int, expectedIndex);
- QFETCH(bool, testQt3Support);
QFETCH(bool, editable);
testWidget->insertItems(0, initialItems);
testWidget->setEditable(true);
if (editable)
testWidget->setEditText("FOO");
-#if defined (QT3_SUPPORT)
- if (testQt3Support)
- testWidget->insertItem(itemLabel, insertIndex);
- else
- testWidget->insertItem(insertIndex, itemLabel);
-#else
- Q_UNUSED(testQt3Support);
testWidget->insertItem(insertIndex, itemLabel);
-#endif
-
QCOMPARE(testWidget->count(), initialItems.count() + 1);
QCOMPARE(testWidget->itemText(expectedIndex), itemLabel);
}
-static char *tokenName(QCss::TokenType t)
+static const char *tokenName(QCss::TokenType t)
{
switch (t) {
case QCss::NONE: return "NONE";
#include <QtTest/QtTest>
#include <QtGui/QtGui>
-#ifdef QT3_SUPPORT
-#include <Qt3Support/Qt3Support>
-#endif
#if defined(Q_OS_SYMBIAN)
# define STRINGIFY(x) #x
void stream_QImage_data();
void stream_QImage();
- void stream_QPalette_data();
- void stream_QPalette();
-
- void stream_QColorGroup_data();
- void stream_QColorGroup();
-
void stream_QPen_data();
void stream_QPen();
void stream_qint64_data();
void stream_qint64();
- void stream_QWMatrix_data();
- void stream_QWMatrix();
-
void stream_QIcon_data();
void stream_QIcon();
void floatingPointPrecision();
-#ifdef QT3_SUPPORT
- void task_224283();
-#endif
-
void compatibility_Qt3();
void compatibility_Qt2();
void writeQDateTime(QDataStream *s);
void writeQFont(QDataStream *s);
void writeQImage(QDataStream *s);
- void writeQPalette(QDataStream *s);
- void writeQColorGroup(QDataStream *s);
void writeQPen(QDataStream *s);
void writeQPixmap(QDataStream *s);
void writeQPoint(QDataStream *s);
void writeMap(QDataStream* dev);
void writeHash(QDataStream* dev);
void writeqint64(QDataStream *s);
- void writeQWMatrix(QDataStream *s);
void writeQIcon(QDataStream *s);
void writeQEasingCurve(QDataStream *s);
void readQDateTime(QDataStream *s);
void readQFont(QDataStream *s);
void readQImage(QDataStream *s);
- void readQPalette(QDataStream *s);
- void readQColorGroup(QDataStream *s);
void readQPen(QDataStream *s);
void readQPixmap(QDataStream *s);
void readQPoint(QDataStream *s);
void readMap(QDataStream *s);
void readHash(QDataStream *s);
void readqint64(QDataStream *s);
- void readQWMatrix(QDataStream *s);
void readQIcon(QDataStream *s);
void readQEasingCurve(QDataStream *s);
};
{
int pos = tag.lastIndexOf("_");
if (pos >= 0) {
- int ret = 0;
- QString count = tag.mid(pos + 1);
- bool ok;
- ret = count.toInt(&ok);
- if (ok)
- return ret;
+ int ret = 0;
+ QString count = tag.mid(pos + 1);
+ bool ok;
+ ret = count.toInt(&ok);
+ if (ok)
+ return ret;
}
return -1;
}
QTest::addColumn<QString>("byteOrder");
for (int d=0; devices[d] != 0; d++) {
- QString device = devices[d];
- for (int b=0; b<2; b++) {
- QString byte_order = b == 0 ? "BigEndian" : "LittleEndian";
-
- QString tag = device + "_" + byte_order;
- for (int e=0; e<noOfElements; e++) {
- QTest::newRow(qPrintable(tag + QString("_%1").arg(e))) << device << QString(byte_order);
- }
- }
+ QString device = devices[d];
+ for (int b=0; b<2; b++) {
+ QString byte_order = b == 0 ? "BigEndian" : "LittleEndian";
+
+ QString tag = device + "_" + byte_order;
+ for (int e=0; e<noOfElements; e++) {
+ QTest::newRow(qPrintable(tag + QString("_%1").arg(e))) << device << QString(byte_order);
+ }
+ }
}
}
#define STREAM_IMPL(TYPE) \
QFETCH(QString, device); \
if (device == "bytearray") { \
- QByteArray ba; \
- QDataStream sout(&ba, QIODevice::WriteOnly); \
- write##TYPE(&sout); \
- QDataStream sin(&ba, QIODevice::ReadOnly); \
- read##TYPE(&sin); \
+ QByteArray ba; \
+ QDataStream sout(&ba, QIODevice::WriteOnly); \
+ write##TYPE(&sout); \
+ QDataStream sin(&ba, QIODevice::ReadOnly); \
+ read##TYPE(&sin); \
} else if (device == "file") { \
- QString fileName = "qdatastream.out"; \
- QFile fOut(fileName); \
- QVERIFY(fOut.open(QIODevice::WriteOnly)); \
- QDataStream sout(&fOut); \
- write##TYPE(&sout); \
- fOut.close(); \
- QFile fIn(fileName); \
- QVERIFY(fIn.open(QIODevice::ReadOnly)); \
- QDataStream sin(&fIn); \
- read##TYPE(&sin); \
- fIn.close(); \
+ QString fileName = "qdatastream.out"; \
+ QFile fOut(fileName); \
+ QVERIFY(fOut.open(QIODevice::WriteOnly)); \
+ QDataStream sout(&fOut); \
+ write##TYPE(&sout); \
+ fOut.close(); \
+ QFile fIn(fileName); \
+ QVERIFY(fIn.open(QIODevice::ReadOnly)); \
+ QDataStream sin(&fIn); \
+ read##TYPE(&sin); \
+ fIn.close(); \
} else if (device == "buffer") { \
- QByteArray ba(10000, '\0'); \
- QBuffer bOut(&ba); \
- bOut.open(QIODevice::WriteOnly); \
- QDataStream sout(&bOut); \
- write##TYPE(&sout); \
- bOut.close(); \
- QBuffer bIn(&ba); \
- bIn.open(QIODevice::ReadOnly); \
- QDataStream sin(&bIn); \
- read##TYPE(&sin); \
- bIn.close(); \
+ QByteArray ba(10000, '\0'); \
+ QBuffer bOut(&ba); \
+ bOut.open(QIODevice::WriteOnly); \
+ QDataStream sout(&bOut); \
+ write##TYPE(&sout); \
+ bOut.close(); \
+ QBuffer bIn(&ba); \
+ bIn.open(QIODevice::ReadOnly); \
+ QDataStream sin(&bIn); \
+ read##TYPE(&sin); \
+ bIn.close(); \
}
// ************************************
static QString QStringData(int index)
{
- switch (index)
- {
- case 0: return QString();
- case 1: return QString("");
- case 2: return QString("A");
- case 3: return QString("ABCDE FGHI");
- case 4: return QString("This is a long string");
- case 5: return QString("And again a string with a \nCRLF");
- case 6: return QString("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRESTUVWXYZ 1234567890 ~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/");
+ switch (index) {
+ case 0: return QString();
+ case 1: return QString("");
+ case 2: return QString("A");
+ case 3: return QString("ABCDE FGHI");
+ case 4: return QString("This is a long string");
+ case 5: return QString("And again a string with a \nCRLF");
+ case 6: return QString("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRESTUVWXYZ 1234567890 ~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/");
}
return QString("foo");
}
static QRegExp QRegExpData(int index)
{
- switch (index)
- {
- case 0: return QRegExp();
- case 1: return QRegExp("");
- case 2: return QRegExp("A", Qt::CaseInsensitive);
- case 3: return QRegExp("ABCDE FGHI", Qt::CaseSensitive, QRegExp::Wildcard);
- case 4: return QRegExp("This is a long string", Qt::CaseInsensitive, QRegExp::FixedString);
- case 5: return QRegExp("And again a string with a \nCRLF", Qt::CaseInsensitive, QRegExp::RegExp);
- case 6: {
+ switch (index) {
+ case 0: return QRegExp();
+ case 1: return QRegExp("");
+ case 2: return QRegExp("A", Qt::CaseInsensitive);
+ case 3: return QRegExp("ABCDE FGHI", Qt::CaseSensitive, QRegExp::Wildcard);
+ case 4: return QRegExp("This is a long string", Qt::CaseInsensitive, QRegExp::FixedString);
+ case 5: return QRegExp("And again a string with a \nCRLF", Qt::CaseInsensitive, QRegExp::RegExp);
+ case 6:
+ {
QRegExp rx("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRESTUVWXYZ 1234567890 ~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/");
rx.setMinimal(true);
return rx;
{
Map map;
- switch (index)
- {
- case 0:
- default:
- break;
- case 1:
- map.insert(1, "a");
- map.insert(2, "bbb");
- map.insert(3, "cccccc");
- break;
- case 2:
- map.insert(1, "a");
- map.insert(2, "one");
- map.insertMulti(2, "two");
- map.insertMulti(2, "three");
- map.insert(3, "cccccc");
+ switch (index) {
+ case 0:
+ default:
+ break;
+ case 1:
+ map.insert(1, "a");
+ map.insert(2, "bbb");
+ map.insert(3, "cccccc");
+ break;
+ case 2:
+ map.insert(1, "a");
+ map.insert(2, "one");
+ map.insertMulti(2, "two");
+ map.insertMulti(2, "three");
+ map.insert(3, "cccccc");
}
return map;
}
{
Hash map;
- switch (index)
- {
- case 0:
- default:
- break;
- case 1:
- map.insert(1, "a");
- map.insert(2, "bbb");
- map.insert(3, "cccccc");
- break;
- case 2:
- map.insert(1, "a");
- map.insert(2, "one");
- map.insertMulti(2, "two");
- map.insertMulti(2, "three");
- map.insert(3, "cccccc");
+ switch (index) {
+ case 0:
+ default:
+ break;
+ case 1:
+ map.insert(1, "a");
+ map.insert(2, "bbb");
+ map.insert(3, "cccccc");
+ break;
+ case 2:
+ map.insert(1, "a");
+ map.insert(2, "one");
+ map.insertMulti(2, "two");
+ map.insertMulti(2, "three");
+ map.insert(3, "cccccc");
}
return map;
}
switch (index) {
case 0:
- default:
- break;
+ default:
+ break;
case 1:
- easing.setType(QEasingCurve::Linear);
- break;
+ easing.setType(QEasingCurve::Linear);
+ break;
case 2:
- easing.setType(QEasingCurve::OutCubic);
- break;
+ easing.setType(QEasingCurve::OutCubic);
+ break;
case 3:
- easing.setType(QEasingCurve::InOutSine);
- break;
+ easing.setType(QEasingCurve::InOutSine);
+ break;
case 4:
- easing.setType(QEasingCurve::InOutElastic);
- easing.setPeriod(1.5);
- easing.setAmplitude(2.0);
- break;
+ easing.setType(QEasingCurve::InOutElastic);
+ easing.setPeriod(1.5);
+ easing.setAmplitude(2.0);
+ break;
case 5:
- easing.setType(QEasingCurve::OutInBack);
- break;
+ easing.setType(QEasingCurve::OutInBack);
+ break;
case 6:
- easing.setType(QEasingCurve::OutCurve);
- break;
+ easing.setType(QEasingCurve::OutCurve);
+ break;
case 7:
- easing.setType(QEasingCurve::InOutBack);
- easing.setOvershoot(0.5);
- break;
+ easing.setType(QEasingCurve::InOutBack);
+ easing.setOvershoot(0.5);
+ break;
}
return easing;
}
static bool boolData(int index)
{
- switch (index)
- {
- case 0: return true;
- case 1: return false;
- case 2: return bool(2);
- case 3: return bool(-1);
- case 4: return bool(127);
+ switch (index) {
+ case 0: return true;
+ case 1: return false;
+ case 2: return bool(2);
+ case 3: return bool(-1);
+ case 4: return bool(127);
}
return false;
static QBool QBoolData(int index)
{
- switch (index)
- {
- case 0: return QBool(true);
- case 1: return QBool(false);
- case 2: return QBool(bool(2));
- case 3: return QBool(bool(-1));
- case 4: return QBool(bool(127));
+ switch (index) {
+ case 0: return QBool(true);
+ case 1: return QBool(false);
+ case 2: return QBool(bool(2));
+ case 3: return QBool(bool(-1));
+ case 4: return QBool(bool(127));
}
return QBool(false);
static void QBitArrayData(QBitArray *b, int index)
{
QString filler = "";
- switch (index)
- {
- case 0: filler = ""; break;
- case 1: filler = ""; break;
- case 2: filler = "0"; break;
- case 3: filler = "1"; break;
- case 4: filler = "0000"; break;
- case 5: filler = "0001"; break;
- case 6: filler = "0010"; break;
- case 7: filler = "0100"; break;
- case 8: filler = "1000"; break;
- case 9: filler = "1111"; break;
- case 10: filler = "00000000"; break;
- case 11: filler = "00000001"; break;
- case 12: filler = "11111111"; break;
- case 13: filler = "000000001"; break;
- case 14: filler = "000000000001"; break;
- case 15: filler = "0000000000000001"; break;
- case 16: filler = "0101010101010101010101010101010101010101010101010101010101010101"; break;
- case 17: filler = "1010101010101010101010101010101010101010101010101010101010101010"; break;
- case 18: filler = "1111111111111111111111111111111111111111111111111111111111111111"; break;
+ switch (index) {
+ case 0: filler = ""; break;
+ case 1: filler = ""; break;
+ case 2: filler = "0"; break;
+ case 3: filler = "1"; break;
+ case 4: filler = "0000"; break;
+ case 5: filler = "0001"; break;
+ case 6: filler = "0010"; break;
+ case 7: filler = "0100"; break;
+ case 8: filler = "1000"; break;
+ case 9: filler = "1111"; break;
+ case 10: filler = "00000000"; break;
+ case 11: filler = "00000001"; break;
+ case 12: filler = "11111111"; break;
+ case 13: filler = "000000001"; break;
+ case 14: filler = "000000000001"; break;
+ case 15: filler = "0000000000000001"; break;
+ case 16: filler = "0101010101010101010101010101010101010101010101010101010101010101"; break;
+ case 17: filler = "1010101010101010101010101010101010101010101010101010101010101010"; break;
+ case 18: filler = "1111111111111111111111111111111111111111111111111111111111111111"; break;
}
b->resize(filler.length());
b->fill(0); // reset all bits to zero
for (int i = 0; i < filler.length(); ++i) {
- if (filler.at(i) == '1')
- b->setBit(i, TRUE);
+ if (filler.at(i) == '1')
+ b->setBit(i, TRUE);
}
}
static QBrush qBrushData(int index)
{
- switch (index)
- {
- case 0: return QBrush(Qt::NoBrush);
- case 1: return QBrush(Qt::SolidPattern);
- case 2: return QBrush(Qt::Dense7Pattern);
- case 3: return QBrush(Qt::red, Qt::NoBrush);
- case 4: return QBrush(Qt::green, Qt::SolidPattern);
- case 5: return QBrush(Qt::blue, Qt::Dense7Pattern);
- case 6: {
- QPixmap pm(open_xpm);
- QBrush custom(Qt::black, pm);
- return custom;
- }
+ switch (index) {
+ case 0: return QBrush(Qt::NoBrush);
+ case 1: return QBrush(Qt::SolidPattern);
+ case 2: return QBrush(Qt::Dense7Pattern);
+ case 3: return QBrush(Qt::red, Qt::NoBrush);
+ case 4: return QBrush(Qt::green, Qt::SolidPattern);
+ case 5: return QBrush(Qt::blue, Qt::Dense7Pattern);
+ case 6:
+ {
+ QPixmap pm(open_xpm);
+ QBrush custom(Qt::black, pm);
+ return custom;
+ }
case 7:
QLinearGradient gradient(QPoint(2.718, 3.142), QPoint(3.1337, 42));
gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
void tst_QDataStream::stream_QBrush()
{
if (QString(QTest::currentDataTag()).endsWith("6"))
- QSKIP("Custom brushes don't seem to be supported with QDataStream", SkipSingle);
+ QSKIP("Custom brushes don't seem to be supported with QDataStream", SkipSingle);
STREAM_IMPL(QBrush);
}
static QColor QColorData(int index)
{
- switch (index)
- {
- case 0: return QColor(0,0,0);
- case 1: return QColor(0,0,0);
- case 2: return QColor(0,0,0);
- case 3: return QColor(0,0,0);
- case 4: return QColor(0,0,0);
- case 5: return QColor(0,0,0);
- case 6: return QColor(0,0,0);
- case 7: return QColor(0,0,0);
+ switch (index) {
+ case 0: return QColor(0,0,0);
+ case 1: return QColor(0,0,0);
+ case 2: return QColor(0,0,0);
+ case 3: return QColor(0,0,0);
+ case 4: return QColor(0,0,0);
+ case 5: return QColor(0,0,0);
+ case 6: return QColor(0,0,0);
+ case 7: return QColor(0,0,0);
}
return QColor(0,0,0);
static QByteArray qByteArrayData(int index)
{
- switch (index)
- {
- case 0: return QByteArray();
- case 1: return QByteArray("");
- case 2: return QByteArray("foo");
- case 3: return QByteArray("foo bar");
- case 4: return QByteArray("two\nlines");
- case 5: return QByteArray("ABCDEFG");
- case 6: return QByteArray("baec zxv 123"); // kept for nostalgic reasons
- case 7: return QByteArray("jbc;UBC;jd clhdbcahd vcbd vgdv dhvb laifv kadf jkhfbvljd khd lhvjh ");
+ switch (index) {
+ case 0: return QByteArray();
+ case 1: return QByteArray("");
+ case 2: return QByteArray("foo");
+ case 3: return QByteArray("foo bar");
+ case 4: return QByteArray("two\nlines");
+ case 5: return QByteArray("ABCDEFG");
+ case 6: return QByteArray("baec zxv 123"); // kept for nostalgic reasons
+ case 7: return QByteArray("jbc;UBC;jd clhdbcahd vcbd vgdv dhvb laifv kadf jkhfbvljd khd lhvjh ");
}
return QByteArray("foo");
#ifndef QT_NO_CURSOR
static QCursor qCursorData(int index)
{
- switch (index)
- {
-#ifdef QT3_SUPPORT
- case 0: return QCursor(Qt::arrowCursor);
- case 1: return QCursor(Qt::waitCursor);
-#else
+ switch (index) {
case 0: return QCursor(Qt::ArrowCursor);
case 1: return QCursor(Qt::WaitCursor);
-#endif
- case 2: return QCursor(Qt::BitmapCursor);
- case 3: return QCursor(Qt::BlankCursor);
- case 4: return QCursor(Qt::BlankCursor);
- case 5: return QCursor(QPixmap(open_xpm), 1, 1);
- case 6: { QPixmap pm(open_xpm); return QCursor(QBitmap(pm), pm.mask(), 3, 4); }
- case 7: return QCursor(QPixmap(open_xpm), -1, 5);
- case 8: return QCursor(QPixmap(open_xpm), 5, -1);
+ case 2: return QCursor(Qt::BitmapCursor);
+ case 3: return QCursor(Qt::BlankCursor);
+ case 4: return QCursor(Qt::BlankCursor);
+ case 5: return QCursor(QPixmap(open_xpm), 1, 1);
+ case 6: { QPixmap pm(open_xpm); return QCursor(QBitmap(pm), pm.mask(), 3, 4); }
+ case 7: return QCursor(QPixmap(open_xpm), -1, 5);
+ case 8: return QCursor(QPixmap(open_xpm), 5, -1);
}
return QCursor();
QVERIFY(d5.hotSpot() == test.hotSpot());
QVERIFY((d5.bitmap() != 0 && test.bitmap() != 0) || (d5.bitmap() == 0 && test.bitmap() == 0));
if (d5.bitmap() != 0)
- QVERIFY(pixmapsAreEqual(d5.bitmap(), test.bitmap()));
+ QVERIFY(pixmapsAreEqual(d5.bitmap(), test.bitmap()));
QVERIFY((d5.mask() != 0 && test.mask() != 0) || (d5.mask() == 0 && test.mask() == 0));
if (d5.mask() != 0)
- QVERIFY(pixmapsAreEqual(d5.mask(), test.mask()));
+ QVERIFY(pixmapsAreEqual(d5.mask(), test.mask()));
#endif
}
static QDate qDateData(int index)
{
- switch (index)
- {
- case 0: return QDate(1752, 9, 14); // the first valid date
- case 1: return QDate(1900, 1, 1);
- case 2: return QDate(1976, 4, 5);
- case 3: return QDate(1960, 5, 27);
- case 4: return QDate(1999, 12, 31); // w2k effects?
- case 5: return QDate(2000, 1, 1);
- case 6: return QDate(2050, 1, 1);// test some values far in the future too
- case 7: return QDate(3001, 12, 31);
- case 8: return QDate(4002, 1, 1);
- case 9: return QDate(4003, 12, 31);
- case 10: return QDate(5004, 1, 1);
- case 11: return QDate(5005, 12, 31);
- case 12: return QDate(6006, 1, 1);
- case 13: return QDate(6007, 12, 31);
- case 14: return QDate(7008, 1, 1);
- case 15: return QDate(7009, 12, 31);
+ switch (index) {
+ case 0: return QDate(1752, 9, 14); // the first valid date
+ case 1: return QDate(1900, 1, 1);
+ case 2: return QDate(1976, 4, 5);
+ case 3: return QDate(1960, 5, 27);
+ case 4: return QDate(1999, 12, 31); // w2k effects?
+ case 5: return QDate(2000, 1, 1);
+ case 6: return QDate(2050, 1, 1);// test some values far in the future too
+ case 7: return QDate(3001, 12, 31);
+ case 8: return QDate(4002, 1, 1);
+ case 9: return QDate(4003, 12, 31);
+ case 10: return QDate(5004, 1, 1);
+ case 11: return QDate(5005, 12, 31);
+ case 12: return QDate(6006, 1, 1);
+ case 13: return QDate(6007, 12, 31);
+ case 14: return QDate(7008, 1, 1);
+ case 15: return QDate(7009, 12, 31);
}
return QDate();
}
static QTime qTimeData(int index)
{
- switch (index)
- {
+ switch (index) {
case 0 : return QTime(0, 0, 0, 0);
case 1 : return QTime(0, 0, 0, 1);
case 2 : return QTime(0, 0, 0, 99);
static QDateTime qDateTimeData(int index)
{
- switch (index)
- {
- case 0: return QDateTime(QDate(1900, 1, 1), QTime(0,0,0,0));
- case 1: return QDateTime(QDate(1900, 1, 2), QTime(1,1,1,1));
- case 2: return QDateTime(QDate(1900, 1, 3), QTime(12,0,0,0));
- case 3: return QDateTime(QDate(1900, 1, 4), QTime(23,59,59,999));
- case 4: return QDateTime(QDate(1999, 1, 1), QTime(0,0,0,0));
- case 5: return QDateTime(QDate(1999, 1, 2), QTime(1,1,1,1));
- case 6: return QDateTime(QDate(1999, 1, 3), QTime(12,0,0,0));
- case 7: return QDateTime(QDate(1999, 1, 4), QTime(23,59,59,999));
- case 8: return QDateTime(QDate(2000, 1, 1), QTime(0,0,0,0));
- case 9: return QDateTime(QDate(2000, 1, 2), QTime(1,1,1,1));
- case 10: return QDateTime(QDate(2000, 1, 3), QTime(12,0,0,0));
- case 11: return QDateTime(QDate(2000, 1, 4), QTime(23,59,59,999));
- case 12: return QDateTime(QDate(2000, 12, 31), QTime(0,0,0,0));
- case 13: return QDateTime(QDate(2000, 12, 31), QTime(1,1,1,1));
- case 14: return QDateTime(QDate(2000, 12, 31), QTime(12,0,0,0));
- case 15: return QDateTime(QDate(2000, 12, 31), QTime(23,59,59,999));
+ switch (index) {
+ case 0: return QDateTime(QDate(1900, 1, 1), QTime(0,0,0,0));
+ case 1: return QDateTime(QDate(1900, 1, 2), QTime(1,1,1,1));
+ case 2: return QDateTime(QDate(1900, 1, 3), QTime(12,0,0,0));
+ case 3: return QDateTime(QDate(1900, 1, 4), QTime(23,59,59,999));
+ case 4: return QDateTime(QDate(1999, 1, 1), QTime(0,0,0,0));
+ case 5: return QDateTime(QDate(1999, 1, 2), QTime(1,1,1,1));
+ case 6: return QDateTime(QDate(1999, 1, 3), QTime(12,0,0,0));
+ case 7: return QDateTime(QDate(1999, 1, 4), QTime(23,59,59,999));
+ case 8: return QDateTime(QDate(2000, 1, 1), QTime(0,0,0,0));
+ case 9: return QDateTime(QDate(2000, 1, 2), QTime(1,1,1,1));
+ case 10: return QDateTime(QDate(2000, 1, 3), QTime(12,0,0,0));
+ case 11: return QDateTime(QDate(2000, 1, 4), QTime(23,59,59,999));
+ case 12: return QDateTime(QDate(2000, 12, 31), QTime(0,0,0,0));
+ case 13: return QDateTime(QDate(2000, 12, 31), QTime(1,1,1,1));
+ case 14: return QDateTime(QDate(2000, 12, 31), QTime(12,0,0,0));
+ case 15: return QDateTime(QDate(2000, 12, 31), QTime(23,59,59,999));
}
return QDateTime(QDate(1900, 1, 1), QTime(0,0,0));
}
static QFont qFontData(int index)
{
- switch (index)
- {
- case 0: return QFont("Courier", 20, QFont::Bold, TRUE);
- case 1: return QFont("Courier", 18, QFont::Bold, FALSE);
- case 2: return QFont("Courier", 16, QFont::Light, TRUE);
- case 3: return QFont("Courier", 14, QFont::Normal, FALSE);
- case 4: return QFont("Courier", 12, QFont::DemiBold, TRUE);
- case 5: return QFont("Courier", 10, QFont::Black, FALSE);
- case 6:
- {
- QFont f("Helvetica", 10, QFont::Normal, FALSE);
- f.setPixelSize(2);
- f.setUnderline(FALSE);
- f.setStrikeOut(FALSE);
- f.setFixedPitch(FALSE);
- return f;
- }
- case 7:
- {
- QFont f("Helvetica", 10, QFont::Bold, FALSE);
- f.setPixelSize(4);
- f.setUnderline(TRUE);
- f.setStrikeOut(FALSE);
- f.setFixedPitch(FALSE);
- return f;
- }
- case 8:
- {
- QFont f("Helvetica", 10, QFont::Light, FALSE);
- f.setPixelSize(6);
- f.setUnderline(FALSE);
- f.setStrikeOut(TRUE);
- f.setFixedPitch(FALSE);
- return f;
- }
- case 9:
- {
- QFont f("Helvetica", 10, QFont::DemiBold, FALSE);
- f.setPixelSize(8);
- f.setUnderline(FALSE);
- f.setStrikeOut(FALSE);
- f.setFixedPitch(TRUE);
- return f;
- }
- case 10:
- {
- QFont f("Helvetica", 10, QFont::Black, FALSE);
- f.setPixelSize(10);
- f.setUnderline(TRUE);
- f.setStrikeOut(TRUE);
- f.setFixedPitch(FALSE);
- return f;
- }
- case 11:
- {
- QFont f("Helvetica", 10, QFont::Normal, TRUE);
- f.setPixelSize(12);
- f.setUnderline(FALSE);
- f.setStrikeOut(TRUE);
- f.setFixedPitch(TRUE);
- return f;
- }
- case 12:
- {
- QFont f("Helvetica", 10, QFont::Bold, TRUE);
- f.setPixelSize(14);
- f.setUnderline(TRUE);
- f.setStrikeOut(TRUE);
- f.setFixedPitch(TRUE);
- return f;
- }
- case 13:
- {
- QFont f("Helvetica", 10, QFont::Bold, TRUE);
- f.setStretch(200);
- return f;
- }
+ switch (index) {
+ case 0: return QFont("Courier", 20, QFont::Bold, TRUE);
+ case 1: return QFont("Courier", 18, QFont::Bold, FALSE);
+ case 2: return QFont("Courier", 16, QFont::Light, TRUE);
+ case 3: return QFont("Courier", 14, QFont::Normal, FALSE);
+ case 4: return QFont("Courier", 12, QFont::DemiBold, TRUE);
+ case 5: return QFont("Courier", 10, QFont::Black, FALSE);
+ case 6:
+ {
+ QFont f("Helvetica", 10, QFont::Normal, FALSE);
+ f.setPixelSize(2);
+ f.setUnderline(FALSE);
+ f.setStrikeOut(FALSE);
+ f.setFixedPitch(FALSE);
+ return f;
+ }
+ case 7:
+ {
+ QFont f("Helvetica", 10, QFont::Bold, FALSE);
+ f.setPixelSize(4);
+ f.setUnderline(TRUE);
+ f.setStrikeOut(FALSE);
+ f.setFixedPitch(FALSE);
+ return f;
+ }
+ case 8:
+ {
+ QFont f("Helvetica", 10, QFont::Light, FALSE);
+ f.setPixelSize(6);
+ f.setUnderline(FALSE);
+ f.setStrikeOut(TRUE);
+ f.setFixedPitch(FALSE);
+ return f;
+ }
+ case 9:
+ {
+ QFont f("Helvetica", 10, QFont::DemiBold, FALSE);
+ f.setPixelSize(8);
+ f.setUnderline(FALSE);
+ f.setStrikeOut(FALSE);
+ f.setFixedPitch(TRUE);
+ return f;
+ }
+ case 10:
+ {
+ QFont f("Helvetica", 10, QFont::Black, FALSE);
+ f.setPixelSize(10);
+ f.setUnderline(TRUE);
+ f.setStrikeOut(TRUE);
+ f.setFixedPitch(FALSE);
+ return f;
+ }
+ case 11:
+ {
+ QFont f("Helvetica", 10, QFont::Normal, TRUE);
+ f.setPixelSize(12);
+ f.setUnderline(FALSE);
+ f.setStrikeOut(TRUE);
+ f.setFixedPitch(TRUE);
+ return f;
+ }
+ case 12:
+ {
+ QFont f("Helvetica", 10, QFont::Bold, TRUE);
+ f.setPixelSize(14);
+ f.setUnderline(TRUE);
+ f.setStrikeOut(TRUE);
+ f.setFixedPitch(TRUE);
+ return f;
+ }
+ case 13:
+ {
+ QFont f("Helvetica", 10, QFont::Bold, TRUE);
+ f.setStretch(200);
+ return f;
+ }
}
return QFont("Courier", 18, QFont::Bold, TRUE);
}
void tst_QDataStream::writeQImage(QDataStream *s)
{
QImage d12(open_xpm);
- //debug("Orig alpha: %i", (int)d12.hasAlphaBuffer());
*s << d12;
}
QVERIFY(d12.height() == ref.height());
QVERIFY(d12.depth() == ref.depth());
QVERIFY(d12.colorCount() == ref.colorCount());
-#ifdef QT3_SUPPORT
- QVERIFY(d12.hasAlphaBuffer() == ref.hasAlphaBuffer());
-#else
QVERIFY(d12.hasAlphaChannel() == ref.hasAlphaChannel());
-#endif
-// qDebug("Alpha: %i %i", (int)d12.hasAlphaBuffer(), ref.hasAlphaBuffer());
-// qDebug("Feil %i %i: %x != %x", 3, 0, d12.pixel(3, 0), ref.pixel(3, 0));
-//
// ################ Bug : ref and orig has ff in alpha; readback has 0
// ### (Was like this in 1.44 as well)
//
// for(int i = 0; i < d12.height(); i++)
-// for(int j = 0; j < d12.width(); j++)
-// if (d12.pixel(j, i) != ref.pixel(j, i))
-// qDebug("Feil %i %i", j, i);
+// for(int j = 0; j < d12.width(); j++)
+// if (d12.pixel(j, i) != ref.pixel(j, i))
+// qDebug("Feil %i %i", j, i);
//
}
// ************************************
-#ifdef QT3_SUPPORT
-static QPalette qPaletteData(int index)
-{
- QColorGroup g1(
- QBrush(Qt::red, Qt::SolidPattern),
- QBrush(Qt::blue, Qt::Dense1Pattern),
- QBrush(Qt::green, Qt::Dense2Pattern),
- QBrush(Qt::blue, Qt::Dense3Pattern),
- QBrush(Qt::cyan, Qt::Dense4Pattern),
- QBrush(Qt::magenta, Qt::Dense5Pattern),
- QBrush(Qt::black, Qt::Dense6Pattern),
- QBrush(Qt::darkGray, Qt::Dense7Pattern),
- QBrush(Qt::gray, Qt::CrossPattern));
- QColorGroup g2(
- QBrush(Qt::cyan, Qt::Dense3Pattern),
- QBrush(Qt::blue, Qt::Dense4Pattern),
- QBrush(Qt::magenta, Qt::Dense5Pattern),
- QBrush(Qt::black, Qt::Dense6Pattern),
- QBrush(Qt::darkGray, Qt::Dense7Pattern),
- QBrush(Qt::gray, Qt::CrossPattern),
- QBrush(Qt::green, Qt::SolidPattern),
- QBrush(Qt::blue, Qt::Dense1Pattern),
- QBrush(Qt::red, Qt::Dense2Pattern));
- QColorGroup g3(
- QBrush(Qt::black, Qt::Dense6Pattern),
- QBrush(Qt::darkGray, Qt::Dense7Pattern),
- QBrush(Qt::red, Qt::CrossPattern),
- QBrush(Qt::gray, Qt::SolidPattern),
- QBrush(Qt::blue, Qt::Dense1Pattern),
- QBrush(Qt::cyan, Qt::Dense2Pattern),
- QBrush(Qt::magenta, Qt::Dense3Pattern),
- QBrush(Qt::blue, Qt::Dense4Pattern),
- QBrush(Qt::magenta, Qt::Dense5Pattern));
-
- switch (index)
- {
- case 0: return QPalette(Qt::green);
- case 1: return QPalette(Qt::cyan, Qt::blue);
- case 2: return QPalette(Qt::red, Qt::yellow);
- case 3: return QPalette(g1, g2, g3);
- case 4: return QPalette(g2, g3, g1);
- case 5: return QPalette(g3, g1, g2);
- case 6: return QPalette(g3, g2, g1);
- }
- return QPalette(Qt::black);
-}
-#endif
-#define MAX_QPALETTE_DATA 7
-
-void tst_QDataStream::stream_QPalette_data()
-{
- stream_data(MAX_QPALETTE_DATA);
-}
-
-void tst_QDataStream::stream_QPalette()
-{
- STREAM_IMPL(QPalette);
-}
-
-void tst_QDataStream::writeQPalette(QDataStream *s)
-{
-#ifdef QT3_SUPPORT
- QPalette d13(qPaletteData(dataIndex(QTest::currentDataTag())));
- *s << d13;
-#else
- QSKIP("No Qt3 Support", SkipAll);
-#endif
-}
-
-void tst_QDataStream::readQPalette(QDataStream *s)
-{
-#ifdef QT3_SUPPORT
- QPalette test(qPaletteData(dataIndex(QTest::currentDataTag())));
- QPalette d13;
- *s >> d13;
- QVERIFY(d13 == test);
- QVERIFY(d13.active() == test.active());
- QVERIFY(d13.inactive() == test.inactive());
- QVERIFY(d13.disabled() == test.disabled());
-#else
- QSKIP("No Qt3 Support", SkipAll);
-#endif
-}
-
-// ************************************
-#ifdef QT3_SUPPORT
-static QColorGroup QColorGroupData(int index)
-{
- switch (index)
- {
- case 0: return QColorGroup(
- QBrush(Qt::red, Qt::SolidPattern),
- QBrush(Qt::blue, Qt::Dense1Pattern),
- QBrush(Qt::green, Qt::Dense2Pattern),
- QBrush(Qt::blue, Qt::Dense3Pattern),
- QBrush(Qt::cyan, Qt::Dense4Pattern),
- QBrush(Qt::magenta, Qt::Dense5Pattern),
- QBrush(Qt::black, Qt::Dense6Pattern),
- QBrush(Qt::darkGray, Qt::Dense7Pattern),
- QBrush(Qt::gray, Qt::CrossPattern));
- case 1: return QColorGroup(
- QBrush(Qt::cyan, Qt::Dense3Pattern),
- QBrush(Qt::blue, Qt::Dense4Pattern),
- QBrush(Qt::magenta, Qt::Dense5Pattern),
- QBrush(Qt::black, Qt::Dense6Pattern),
- QBrush(Qt::darkGray, Qt::Dense7Pattern),
- QBrush(Qt::gray, Qt::CrossPattern),
- QBrush(Qt::green, Qt::SolidPattern),
- QBrush(Qt::blue, Qt::Dense1Pattern),
- QBrush(Qt::red, Qt::Dense2Pattern));
- case 2: return QColorGroup(
- QBrush(Qt::black, Qt::Dense6Pattern),
- QBrush(Qt::darkGray, Qt::Dense7Pattern),
- QBrush(Qt::red, Qt::CrossPattern),
- QBrush(Qt::gray, Qt::SolidPattern),
- QBrush(Qt::blue, Qt::Dense1Pattern),
- QBrush(Qt::cyan, Qt::Dense2Pattern),
- QBrush(Qt::magenta, Qt::Dense3Pattern),
- QBrush(Qt::blue, Qt::Dense4Pattern),
- QBrush(Qt::magenta, Qt::Dense5Pattern));
- }
- return QColorGroup();
-}
-#endif
-
-#define MAX_QCOLORGROUP_DATA 3
-
-void tst_QDataStream::stream_QColorGroup_data()
-{
- stream_data(MAX_QCOLORGROUP_DATA);
-}
-
-void tst_QDataStream::stream_QColorGroup()
-{
- STREAM_IMPL(QColorGroup);
-}
-
-void tst_QDataStream::writeQColorGroup(QDataStream *s)
-{
-#ifdef QT3_SUPPORT
- QColorGroup d13(QColorGroupData(dataIndex(QTest::currentDataTag())));
- *s << d13;
-#else
- QSKIP("No Qt3 Support", SkipAll);
-#endif
-}
-
-void tst_QDataStream::readQColorGroup(QDataStream *s)
-{
-#ifdef QT3_SUPPORT
- QColorGroup test(QColorGroupData(dataIndex(QTest::currentDataTag())));
- QColorGroup d14;
- *s >> d14;
- QVERIFY(d14 == test);
-#else
- QSKIP("No Qt3 Support", SkipAll);
-#endif
-}
-
-// ************************************
static QPen qPenData(int index)
{
- switch (index)
- {
- case 0: {
- QPen p(Qt::blue, 0, Qt::NoPen);
- p.setCapStyle(Qt::FlatCap);
- p.setJoinStyle(Qt::MiterJoin);
- return p;
- }
- case 1: {
- QPen p(Qt::red, 1, Qt::SolidLine);
- p.setCapStyle(Qt::SquareCap);
- p.setJoinStyle(Qt::BevelJoin);
- return p;
- }
- case 2: {
- QPen p(Qt::red, 4, Qt::DashDotDotLine);
- p.setCapStyle(Qt::RoundCap);
- p.setJoinStyle(Qt::RoundJoin);
- return p;
- }
- case 3: {
- QPen p(Qt::blue, 12, Qt::NoPen);
- p.setCapStyle(Qt::FlatCap);
- p.setJoinStyle(Qt::RoundJoin);
- return p;
- }
- case 4: {
- QPen p(Qt::red, 99, Qt::SolidLine);
- p.setCapStyle(Qt::SquareCap);
- p.setJoinStyle(Qt::MiterJoin);
- return p;
- }
- case 5: {
- QPen p(Qt::red, 255, Qt::DashDotLine);
- p.setCapStyle(Qt::RoundCap);
- p.setJoinStyle(Qt::BevelJoin);
- return p;
- }
- case 6: {
- QPen p(Qt::red, 256, Qt::DashDotLine);
- p.setCapStyle(Qt::RoundCap);
- p.setJoinStyle(Qt::BevelJoin);
- return p;
- }
- case 7: {
- QPen p(Qt::red, 0.25, Qt::DashDotLine);
- p.setCapStyle(Qt::RoundCap);
- p.setJoinStyle(Qt::BevelJoin);
- return p;
- }
+ switch (index) {
+ case 0:
+ {
+ QPen p(Qt::blue, 0, Qt::NoPen);
+ p.setCapStyle(Qt::FlatCap);
+ p.setJoinStyle(Qt::MiterJoin);
+ return p;
+ }
+ case 1:
+ {
+ QPen p(Qt::red, 1, Qt::SolidLine);
+ p.setCapStyle(Qt::SquareCap);
+ p.setJoinStyle(Qt::BevelJoin);
+ return p;
+ }
+ case 2:
+ {
+ QPen p(Qt::red, 4, Qt::DashDotDotLine);
+ p.setCapStyle(Qt::RoundCap);
+ p.setJoinStyle(Qt::RoundJoin);
+ return p;
+ }
+ case 3:
+ {
+ QPen p(Qt::blue, 12, Qt::NoPen);
+ p.setCapStyle(Qt::FlatCap);
+ p.setJoinStyle(Qt::RoundJoin);
+ return p;
+ }
+ case 4:
+ {
+ QPen p(Qt::red, 99, Qt::SolidLine);
+ p.setCapStyle(Qt::SquareCap);
+ p.setJoinStyle(Qt::MiterJoin);
+ return p;
+ }
+ case 5:
+ {
+ QPen p(Qt::red, 255, Qt::DashDotLine);
+ p.setCapStyle(Qt::RoundCap);
+ p.setJoinStyle(Qt::BevelJoin);
+ return p;
+ }
+ case 6:
+ {
+ QPen p(Qt::red, 256, Qt::DashDotLine);
+ p.setCapStyle(Qt::RoundCap);
+ p.setJoinStyle(Qt::BevelJoin);
+ return p;
+ }
+ case 7:
+ {
+ QPen p(Qt::red, 0.25, Qt::DashDotLine);
+ p.setCapStyle(Qt::RoundCap);
+ p.setJoinStyle(Qt::BevelJoin);
+ return p;
+ }
}
return QPen();
QVERIFY(d16.size() == pm.size());
QVERIFY(d16.rect() == pm.rect());
QVERIFY(d16.depth() == pm.depth());
- // bit depth must be 24 or above for pixmap comparison
-#ifdef QT3_SUPPORT
- if (Q3PaintDeviceMetrics(&pm).depth() < 24)
- QSKIP("Don't do pixmap comparison when depth < 24", SkipAll);
- QCOMPARE(d16, QPixmap(pm));
-#endif
}
void tst_QDataStream::writeQIcon(QDataStream *s)
QPoint qPointData(int index)
{
- switch (index)
- {
- case 0: return QPoint(0, 0);
- case 1: return QPoint(-1, 0);
- case 2: return QPoint(0, -1);
- case 3: return QPoint(1, 0);
- case 4: return QPoint(0, 1);
- case 5: return QPoint(-1, -1);
- case 6: return QPoint(1, 1);
- case 7: return QPoint(255, 255);
- case 8: return QPoint(256, 256);
- case 9: return QPoint(-254, -254);
- case 10: return QPoint(-255, -255);
+ switch (index) {
+ case 0: return QPoint(0, 0);
+ case 1: return QPoint(-1, 0);
+ case 2: return QPoint(0, -1);
+ case 3: return QPoint(1, 0);
+ case 4: return QPoint(0, 1);
+ case 5: return QPoint(-1, -1);
+ case 6: return QPoint(1, 1);
+ case 7: return QPoint(255, 255);
+ case 8: return QPoint(256, 256);
+ case 9: return QPoint(-254, -254);
+ case 10: return QPoint(-255, -255);
}
return QPoint();
static QRect qRectData(int index)
{
- switch (index)
- {
- case 0: return QRect(0, 0, 0, 0);
- case 1: return QRect(1, 1, 1, 1);
- case 2: return QRect(1, 2, 3, 4);
- case 3: return QRect(-1, -1, -1, -1);
- case 4: return QRect(-1, -2, -3, -4);
- case 5: return QRect(255, -5, 256, -6);
- case 6: return QRect(-7, 255, -8, 256);
- case 7: return QRect(9, -255, 10, -255);
- case 8: return QRect(-255, 11, -255, 12);
- case 9: return QRect(256, 512, 1024, 2048);
- case 10: return QRect(-256, -512, -1024, -2048);
+ switch (index) {
+ case 0: return QRect(0, 0, 0, 0);
+ case 1: return QRect(1, 1, 1, 1);
+ case 2: return QRect(1, 2, 3, 4);
+ case 3: return QRect(-1, -1, -1, -1);
+ case 4: return QRect(-1, -2, -3, -4);
+ case 5: return QRect(255, -5, 256, -6);
+ case 6: return QRect(-7, 255, -8, 256);
+ case 7: return QRect(9, -255, 10, -255);
+ case 8: return QRect(-255, 11, -255, 12);
+ case 9: return QRect(256, 512, 1024, 2048);
+ case 10: return QRect(-256, -512, -1024, -2048);
}
return QRect();
}
QPoint p13(-99998, -34567);
QPoint p14(45678, -99999);
- switch (index)
- {
- case 0: return QPolygon(0);
- case 1: {
- QPolygon p(1);
- p.setPoint(0, p0);
- return p;
- }
- case 2: {
- QPolygon p(1);
- p.setPoint(0, p5);
- return p;
- }
- case 3: {
- QPolygon p(1);
- p.setPoint(0, p12);
- return p;
- }
- case 4: {
- QPolygon p(3);
- p.setPoint(0, p1);
- p.setPoint(1, p10);
- p.setPoint(2, p13);
- return p;
- }
- case 5: {
- QPolygon p(6);
- p.setPoint(0, p2);
- p.setPoint(1, p11);
- p.setPoint(2, p14);
- return p;
- }
- case 6: {
- QPolygon p(15);
- p.setPoint(0, p0);
- p.setPoint(1, p1);
- p.setPoint(2, p2);
- p.setPoint(3, p3);
- p.setPoint(4, p4);
- p.setPoint(5, p5);
- p.setPoint(6, p6);
- p.setPoint(7, p7);
- p.setPoint(8, p8);
- p.setPoint(9, p9);
- p.setPoint(10, p10);
- p.setPoint(11, p11);
- p.setPoint(12, p12);
- p.setPoint(13, p13);
- p.setPoint(14, p14);
- return p;
- }
+ switch (index) {
+ case 0:
+ return QPolygon(0);
+ case 1:
+ {
+ QPolygon p(1);
+ p.setPoint(0, p0);
+ return p;
+ }
+ case 2:
+ {
+ QPolygon p(1);
+ p.setPoint(0, p5);
+ return p;
+ }
+ case 3:
+ {
+ QPolygon p(1);
+ p.setPoint(0, p12);
+ return p;
+ }
+ case 4:
+ {
+ QPolygon p(3);
+ p.setPoint(0, p1);
+ p.setPoint(1, p10);
+ p.setPoint(2, p13);
+ return p;
+ }
+ case 5:
+ {
+ QPolygon p(6);
+ p.setPoint(0, p2);
+ p.setPoint(1, p11);
+ p.setPoint(2, p14);
+ return p;
+ }
+ case 6:
+ {
+ QPolygon p(15);
+ p.setPoint(0, p0);
+ p.setPoint(1, p1);
+ p.setPoint(2, p2);
+ p.setPoint(3, p3);
+ p.setPoint(4, p4);
+ p.setPoint(5, p5);
+ p.setPoint(6, p6);
+ p.setPoint(7, p7);
+ p.setPoint(8, p8);
+ p.setPoint(9, p9);
+ p.setPoint(10, p10);
+ p.setPoint(11, p11);
+ p.setPoint(12, p12);
+ p.setPoint(13, p13);
+ p.setPoint(14, p14);
+ return p;
+ }
}
return QRect();
}
static QRegion qRegionData(int index)
{
- switch (index)
- {
- case 0: return QRegion(0, 0, 0, 0, QRegion::Rectangle);
- case 1: {
- QRegion r(1, 2, 300, 400, QRegion::Rectangle);
- if (r != QRegion(1, 2, 300, 400, QRegion::Rectangle))
- qDebug("Error creating a region");
- return r;
- }
- case 2: return QRegion(100, 100, 1024, 768, QRegion::Rectangle);
- case 3: return QRegion(-100, -100, 1024, 1024, QRegion::Rectangle);
- case 4: return QRegion(100, -100, 2048, 4096, QRegion::Rectangle);
- case 5: return QRegion(-100, 100, 4096, 2048, QRegion::Rectangle);
- case 6: return QRegion(0, 0, 0, 0, QRegion::Ellipse);
+ switch (index) {
+ case 0: return QRegion(0, 0, 0, 0, QRegion::Rectangle);
+ case 1:
+ {
+ QRegion r(1, 2, 300, 400, QRegion::Rectangle);
+ if (r != QRegion(1, 2, 300, 400, QRegion::Rectangle))
+ qDebug("Error creating a region");
+ return r;
+ }
+ case 2: return QRegion(100, 100, 1024, 768, QRegion::Rectangle);
+ case 3: return QRegion(-100, -100, 1024, 1024, QRegion::Rectangle);
+ case 4: return QRegion(100, -100, 2048, 4096, QRegion::Rectangle);
+ case 5: return QRegion(-100, 100, 4096, 2048, QRegion::Rectangle);
+ case 6: return QRegion(0, 0, 0, 0, QRegion::Ellipse);
#if defined(Q_OS_SYMBIAN) || (!defined(Q_OS_UNIX) && !defined(Q_OS_WINCE)) // all our Unix platforms use X regions.
- case 7: return QRegion(1, 2, 300, 400, QRegion::Ellipse);
- case 8: return QRegion(100, 100, 1024, 768, QRegion::Ellipse);
- case 9: return QRegion(-100, -100, 1024, 1024, QRegion::Ellipse);
- case 10: return QRegion(100, -100, 2048, 4096, QRegion::Ellipse);
- case 11: return QRegion(-100, 100, 4096, 2048, QRegion::Ellipse);
- // simplest X11 case that fails:
- case 12: return QRegion(0, 0, 3, 3, QRegion::Ellipse);
+ case 7: return QRegion(1, 2, 300, 400, QRegion::Ellipse);
+ case 8: return QRegion(100, 100, 1024, 768, QRegion::Ellipse);
+ case 9: return QRegion(-100, -100, 1024, 1024, QRegion::Ellipse);
+ case 10: return QRegion(100, -100, 2048, 4096, QRegion::Ellipse);
+ case 11: return QRegion(-100, 100, 4096, 2048, QRegion::Ellipse);
+ // simplest X11 case that fails:
+ case 12: return QRegion(0, 0, 3, 3, QRegion::Ellipse);
#else
- case 7:
- qWarning("Skipping streaming of elliptical regions on embedded, Mac OS X, and X11;"
- " our pointarray stuff is not that great at approximating.");
+ case 7:
+ qWarning("Skipping streaming of elliptical regions on embedded, Mac OS X, and X11;"
+ " our pointarray stuff is not that great at approximating.");
#endif
}
return QRegion();
static QSize qSizeData(int index)
{
- switch (index)
- {
- case 0: return QSize(0, 0);
- case 1: return QSize(-1, 0);
- case 2: return QSize(0, -1);
- case 3: return QSize(1, 0);
- case 4: return QSize(0, 1);
- case 5: return QSize(-1, -1);
- case 6: return QSize(1, 1);
- case 7: return QSize(255, 255);
- case 8: return QSize(256, 256);
- case 9: return QSize(-254, -254);
- case 10: return QSize(-255, -255);
+ switch (index) {
+ case 0: return QSize(0, 0);
+ case 1: return QSize(-1, 0);
+ case 2: return QSize(0, -1);
+ case 3: return QSize(1, 0);
+ case 4: return QSize(0, 1);
+ case 5: return QSize(-1, -1);
+ case 6: return QSize(1, 1);
+ case 7: return QSize(255, 255);
+ case 8: return QSize(256, 256);
+ case 9: return QSize(-254, -254);
+ case 10: return QSize(-255, -255);
}
return QSize();
}
QVERIFY(d21f == QSizeF(ref));
}
-// ************************************
-
-void tst_QDataStream::stream_QWMatrix_data()
-{
- stream_data(1);
-}
-
-void tst_QDataStream::stream_QWMatrix()
-{
- STREAM_IMPL(QWMatrix);
-}
-
-void tst_QDataStream::writeQWMatrix(QDataStream *s)
-{
-#ifdef QT3_SUPPORT
- // QStringList: Qt 2.0 specific
- QWMatrix d23(1.2, 2.3, 3.4, 4.5, 5.6, 6.7);
- *s << d23;
-#else
- QSKIP("No Qt3 Support", SkipAll);
-#endif
-}
-
-void tst_QDataStream::readQWMatrix(QDataStream *s)
-{
-#ifdef QT3_SUPPORT
- // QStringList: Qt 2.0 specific
-
- QWMatrix d23;
- *s >> d23;
- // QVERIFY(d23 == QWMatrix(1.2, 2.3, 3.4, 4.5, 5.6, 6.7));
- QWMatrix m(1.2, 2.3, 3.4, 4.5, 5.6, 6.7);
- // Because of double vs. float rounding differences:
- QVERIFY(QABS(d23.m11() - m.m11()) < 1e-6);
- QVERIFY(QABS(d23.m12() - m.m12()) < 1e-6);
- QVERIFY(QABS(d23.m21() - m.m21()) < 1e-6);
- QVERIFY(QABS(d23.m22() - m.m22()) < 1e-6);
- QVERIFY(QABS(d23.dx() - m.dx()) < 1e-6);
- QVERIFY(QABS(d23.dy() - m.dy()) < 1e-6);
-#else
- QSKIP("No Qt3 Support", SkipAll);
-#endif
-}
-
// *********************** atEnd ******************************
void tst_QDataStream::stream_atEnd_data()
{
QFETCH(QString, device);
if (device == "bytearray") {
- QByteArray ba;
- QDataStream sout(&ba, QIODevice::WriteOnly);
- writeQString(&sout);
+ QByteArray ba;
+ QDataStream sout(&ba, QIODevice::WriteOnly);
+ writeQString(&sout);
- QDataStream sin(&ba, QIODevice::ReadOnly);
- readQString(&sin);
- QVERIFY(sin.atEnd());
+ QDataStream sin(&ba, QIODevice::ReadOnly);
+ readQString(&sin);
+ QVERIFY(sin.atEnd());
} else if (device == "file") {
- QString fileName = "qdatastream.out";
- QFile fOut(fileName);
- QVERIFY(fOut.open(QIODevice::WriteOnly));
- QDataStream sout(&fOut);
- writeQString(&sout);
- fOut.close();
-
- QFile fIn(fileName);
- QVERIFY(fIn.open(QIODevice::ReadOnly));
- QDataStream sin(&fIn);
- readQString(&sin);
- QVERIFY(sin.atEnd());
- fIn.close();
+ QString fileName = "qdatastream.out";
+ QFile fOut(fileName);
+ QVERIFY(fOut.open(QIODevice::WriteOnly));
+ QDataStream sout(&fOut);
+ writeQString(&sout);
+ fOut.close();
+
+ QFile fIn(fileName);
+ QVERIFY(fIn.open(QIODevice::ReadOnly));
+ QDataStream sin(&fIn);
+ readQString(&sin);
+ QVERIFY(sin.atEnd());
+ fIn.close();
} else if (device == "buffer") {
- {
- QByteArray ba(0);
- QBuffer bOut(&ba);
- bOut.open(QIODevice::WriteOnly);
- QDataStream sout(&bOut);
- writeQString(&sout);
- bOut.close();
-
- QBuffer bIn(&ba);
- bIn.open(QIODevice::ReadOnly);
- QDataStream sin(&bIn);
- readQString(&sin);
- QVERIFY(sin.atEnd());
- bIn.close();
- }
-
- // Do the same test again, but this time with an initial size for the bytearray.
- {
-#ifdef QT3_SUPPORT
- QByteArray ba(10000);
-#else
- QByteArray ba(10000, '\0');
-#endif
- QBuffer bOut(&ba);
- bOut.open(QIODevice::WriteOnly | QIODevice::Truncate);
- QDataStream sout(&bOut);
- writeQString(&sout);
- bOut.close();
-
- QBuffer bIn(&ba);
- bIn.open(QIODevice::ReadOnly);
- QDataStream sin(&bIn);
- readQString(&sin);
- QVERIFY(sin.atEnd());
- bIn.close();
- }
+ {
+ QByteArray ba(0);
+ QBuffer bOut(&ba);
+ bOut.open(QIODevice::WriteOnly);
+ QDataStream sout(&bOut);
+ writeQString(&sout);
+ bOut.close();
+
+ QBuffer bIn(&ba);
+ bIn.open(QIODevice::ReadOnly);
+ QDataStream sin(&bIn);
+ readQString(&sin);
+ QVERIFY(sin.atEnd());
+ bIn.close();
+ }
+
+ // Do the same test again, but this time with an initial size for the bytearray.
+ {
+ QByteArray ba(10000, '\0');
+ QBuffer bOut(&ba);
+ bOut.open(QIODevice::WriteOnly | QIODevice::Truncate);
+ QDataStream sout(&bOut);
+ writeQString(&sout);
+ bOut.close();
+
+ QBuffer bIn(&ba);
+ bIn.open(QIODevice::ReadOnly);
+ QDataStream sin(&bIn);
+ readQString(&sin);
+ QVERIFY(sin.atEnd());
+ bIn.close();
+ }
}
}
for (int vers = 1; vers <= latest.version(); ++vers)
QTest::newRow(qPrintable(QString("v_%1").arg(vers))) << vers;
-
-
}
void tst_QDataStream::setVersion()
QDataStream latest;
QFETCH(int, vers);
- /*
- Test QKeySequence.
+ /*
+ Test QKeySequence.
*/
QByteArray ba1;
{
QVERIFY(deadbeef == 0xDEADBEEF);
}
- /*
- Test QPalette.
+ /*
+ Test QPalette.
*/
-
- // revise the test if new color roles or color groups are added
+ // revise the test if new color roles or color groups are added
QVERIFY(QPalette::NColorRoles == QPalette::ToolTipText + 1);
QVERIFY(QPalette::NColorGroups == 3);
QPalette pal1, pal2;
for (int grp = 0; grp < (int)QPalette::NColorGroups; ++grp) {
for (int role = 0; role < (int)QPalette::NColorRoles; ++role) {
- // random stuff
+ // random stuff
pal1.setColor((QPalette::ColorGroup)grp, (QPalette::ColorRole)role,
QColor(grp * 13, 255 - grp, role));
pal2.setColor((QPalette::ColorGroup)grp, (QPalette::ColorRole)role,
QTest::addColumn<QByteArray>("expectedString");
#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
-#ifdef QT3_SUPPORT
- QByteArray oneMbMinus1(1024 * 1024 - 1);
-#else
QByteArray oneMbMinus1(1024 * 1024 - 1, '\0');
-#endif
for (int i = 0; i < oneMbMinus1.size(); ++i)
oneMbMinus1[i] = 0x1 | (8 * ((uchar)i / 9));
QByteArray threeMbMinus1 = oneMbMinus1 + 'j' + oneMbMinus1 + 'k' + oneMbMinus1;
static QByteArray qstring2qbytearray(const QString &str)
{
-#ifdef QT3_SUPPORT
- QByteArray ba(str.size() * 2);
-#else
QByteArray ba(str.size() * 2 , '\0');
-#endif
for (int i = 0; i < str.size(); ++i) {
// BigEndian
ba[2 * i] = str[i].row();
}
}
-#ifdef QT3_SUPPORT
-void tst_QDataStream::task_224283()
-{
- static const char sdata[] = "\0\0\0\12" "123456789";
- QByteArray expected = QByteArray::fromRawData(sdata, sizeof sdata); // includes the NUL
- Q3CString original = "123456789";
-
- QByteArray data;
- {
- QDataStream out(&data, QIODevice::WriteOnly);
- out.setVersion(QDataStream::Qt_3_3);
- out << original;
- }
- QCOMPARE(data, expected);
-
- {
- QDataStream in(data);
- in.setVersion(QDataStream::Qt_3_3);
- Q3CString s;
- in >> s;
- QVERIFY(s.length() == 9);
- QCOMPARE(s, original);
- }
-}
-#endif
-
void tst_QDataStream::compatibility_Qt3()
{
QByteArray ba("hello");
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)
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)
void operator_eq();
void dotAndDotDot();
-#ifdef QT3_SUPPORT
- void matchAllDirs();
-#endif
void homePath();
void tempPath();
void rootPath();
void arrayOperator();
-#ifdef QT3_SUPPORT
- void setNameFilter();
-#endif
-
void equalityOperator_data();
void equalityOperator();
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(','));
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(','));
QDir d = startDir;
bool notUsed = d.exists(); // make sure we cache this before so we can see if 'cd' fails to flush this
+ Q_UNUSED(notUsed);
QCOMPARE(d.cd(cdDir), successExpected);
if (successExpected)
QCOMPARE(d.absolutePath(), newDir);
#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();
}
}
-#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");
case OpenRFile:
return openRFile(file, mode, handleFlags);
#endif
+ case NumberOfFileTypes:
+ break;
}
return false;
#include <QtTest/QtTest>
-
#include <qfile.h>
#include <qdir.h>
#include <qcoreapplication.h>
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
}
}
#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>
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) );
QVERIFY( childFocusWidgetOne->focusOutEventRecieved );
QVERIFY( !childFocusWidgetTwo->focusInEventRecieved );
QVERIFY( !childFocusWidgetTwo->focusOutEventRecieved );
-#endif
}
#ifdef Q_WS_MAC
try {
MyClass m;
+ Q_UNUSED(m);
throw 0;
} catch (int) {}
}
static void sendMouseMove(QGraphicsScene *scene, const QPointF &point,
- Qt::MouseButton button = Qt::NoButton, Qt::MouseButtons buttons = 0)
+ Qt::MouseButton button = Qt::NoButton, Qt::MouseButtons /* buttons */ = 0)
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseMove);
event.setScenePos(point);
QGraphicsItem *child1 = new QGraphicsRectItem(rect);
QGraphicsItem *child2 = new QGraphicsRectItem(rect);
QGraphicsItem *child3 = new QGraphicsRectItem(rect);
+ Q_UNUSED(child3);
delete child1;
child2->setParentItem(0);
delete child2;
QGraphicsLayoutItem::setGeometry(geom);
}
-QSizeF AnimatedLayoutItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
+QSizeF AnimatedLayoutItem::sizeHint(Qt::SizeHint which, const QSizeF & /* constraint */) const
{
switch (which) {
case Qt::MinimumSize:
QSet<QGraphicsLayoutItem*> *m_destructedSet;
};
-QSizeF CustomLayoutItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
+QSizeF CustomLayoutItem::sizeHint(Qt::SizeHint which, const QSizeF & /* constraint */) const
{
switch (which) {
case Qt::MinimumSize:
QSet<QGraphicsLayoutItem*> *m_destructedSet;
};
-QSizeF CustomGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
+QSizeF CustomGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF & /* constraint */) const
{
switch (which) {
case Qt::MinimumSize:
}
}
-QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
+QSizeF sizeHint(Qt::SizeHint /* which */, const QSizeF & /* constraint */) const
{
return QSizeF(50,50);
}
int i;
bool addWidget = true;
- for (i = 0; i < sizeof(alignmentsToTest)/sizeof(Qt::Alignment); ++i) {
+ for (size_t i = 0; i < sizeof(alignmentsToTest)/sizeof(Qt::Alignment); ++i) {
QGraphicsLayoutItem *loutItem;
Qt::Alignment align = alignmentsToTest[i];
if (!align && i > 0)
{
QGraphicsScene scene;
QGraphicsView *view = new QGraphicsView(&scene);
+ Q_UNUSED(view);
QGraphicsWidget *form = new QGraphicsWidget(0, Qt::Window);
scene.addItem(form);
bool item2_wasDeleted = false;
DeleteTester *item1 = new DeleteTester(&item1_wasDeleted, &item1_parentWasDeleted);
DeleteTester *item2 = new DeleteTester(&item2_wasDeleted, &item2_parentWasDeleted, item1);
+ Q_UNUSED(item2);
delete item1;
QVERIFY(!item1_wasDeleted); // destructor not called yet
{
}
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem * /* option */, QWidget * /* widget */)
{
painter->setBrush(brush);
painter->drawRect(boundingRect());
int numPaints;
protected:
QRectF boundingRect() const { return QRectF(0, 0, 10, 10); }
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+ void paint(QPainter * /* painter */, const QStyleOptionGraphicsItem *, QWidget *)
{ ++numPaints; }
};
m_viewHasIMEnabledInFocusInEvent = false;
}
- void focusInEvent(QFocusEvent *event)
+ void focusInEvent(QFocusEvent * /* event */)
{
QGraphicsView *view = scene()->views().first();
m_viewHasIMEnabledInFocusInEvent = view->testAttribute(Qt::WA_InputMethodEnabled);
{
public:
CustomScene(const QRectF &rect) : QGraphicsScene(rect) { }
- void drawBackground(QPainter *painter, const QRectF &rect)
+ void drawBackground(QPainter * /* painter */, const QRectF &rect)
{ lastBackgroundExposedRect = rect; }
QRectF lastBackgroundExposedRect;
};
public:
CustomRectItem(const QRectF &rect) : QGraphicsRectItem(rect)
{ setFlag(QGraphicsItem::ItemUsesExtendedStyleOption); }
- void paint(QPainter * painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
+ void paint(QPainter * /* painter */, const QStyleOptionGraphicsItem *option, QWidget * /* widget */ = 0)
{ lastExposedRect = option->exposedRect; }
QRectF lastExposedRect;
};
setFlag(QGraphicsItem::ItemAcceptsInputMethod, true);
}
- QVariant inputMethodQuery(Qt::InputMethodQuery query) const
+ QVariant inputMethodQuery(Qt::InputMethodQuery) const
{
return mf;
}
QTest::newRow("ip4_04") << QString("255.3.2.1\r ") << (bool)TRUE << QString("255.3.2.1") << 4;
QTest::newRow("ip4_05") << QString("0.0.0.0") << (bool)TRUE << QString("0.0.0.0") << 4;
- // for the format of IPv6 addresses see also RFC 1884
+ // for the format of IPv6 addresses see also RFC 5952
QTest::newRow("ip6_00") << QString("FEDC:BA98:7654:3210:FEDC:BA98:7654:3210") << (bool)TRUE << QString("FEDC:BA98:7654:3210:FEDC:BA98:7654:3210") << 6;
- QTest::newRow("ip6_01") << QString("1080:0000:0000:0000:0008:0800:200C:417A") << (bool)TRUE << QString("1080:0:0:0:8:800:200C:417A") << 6;
- QTest::newRow("ip6_02") << QString("1080:0:0:0:8:800:200C:417A") << (bool)TRUE << QString("1080:0:0:0:8:800:200C:417A") << 6;
- QTest::newRow("ip6_03") << QString("1080::8:800:200C:417A") << (bool)TRUE << QString("1080:0:0:0:8:800:200C:417A") << 6;
- QTest::newRow("ip6_04") << QString("FF01::43") << (bool)TRUE << QString("FF01:0:0:0:0:0:0:43") << 6;
- QTest::newRow("ip6_05") << QString("::1") << (bool)TRUE << QString("0:0:0:0:0:0:0:1") << 6;
- QTest::newRow("ip6_06") << QString("1::") << (bool)TRUE << QString("1:0:0:0:0:0:0:0") << 6;
- QTest::newRow("ip6_07") << QString("::") << (bool)TRUE << QString("0:0:0:0:0:0:0:0") << 6;
- QTest::newRow("ip6_08") << QString("0:0:0:0:0:0:13.1.68.3") << (bool)TRUE << QString("0:0:0:0:0:0:D01:4403") << 6;
- QTest::newRow("ip6_09") << QString("::13.1.68.3") << (bool)TRUE << QString("0:0:0:0:0:0:D01:4403") << 6;
- QTest::newRow("ip6_10") << QString("0:0:0:0:0:FFFF:129.144.52.38") << (bool)TRUE << QString("0:0:0:0:0:FFFF:8190:3426") << 6;
- QTest::newRow("ip6_11") << QString("::FFFF:129.144.52.38") << (bool)TRUE << QString("0:0:0:0:0:FFFF:8190:3426") << 6;
- QTest::newRow("ip6_12") << QString("1::FFFF:129.144.52.38") << (bool)TRUE << QString("1:0:0:0:0:FFFF:8190:3426") << 6;
- QTest::newRow("ip6_13") << QString("A:B::D:E") << (bool)TRUE << QString("A:B:0:0:0:0:D:E") << 6;
+ QTest::newRow("ip6_01") << QString("1080:0000:0000:0000:0008:0800:200C:417A") << (bool)TRUE << QString("1080::8:800:200C:417A") << 6;
+ QTest::newRow("ip6_02") << QString("1080:0:0:0:8:800:200C:417A") << (bool)TRUE << QString("1080::8:800:200C:417A") << 6;
+ QTest::newRow("ip6_03") << QString("1080::8:800:200C:417A") << (bool)TRUE << QString("1080::8:800:200C:417A") << 6;
+ QTest::newRow("ip6_04") << QString("FF01::43") << (bool)TRUE << QString("FF01::43") << 6;
+ QTest::newRow("ip6_05") << QString("::1") << (bool)TRUE << QString("::1") << 6;
+ QTest::newRow("ip6_06") << QString("1::") << (bool)TRUE << QString("1::") << 6;
+ QTest::newRow("ip6_07") << QString("::") << (bool)TRUE << QString("::") << 6;
+ QTest::newRow("ip6_08") << QString("0:0:0:0:0:0:13.1.68.3") << (bool)TRUE << QString("::D01:4403") << 6;
+ QTest::newRow("ip6_09") << QString("::13.1.68.3") << (bool)TRUE << QString("::D01:4403") << 6;
+ QTest::newRow("ip6_10") << QString("0:0:0:0:0:FFFF:129.144.52.38") << (bool)TRUE << QString("::FFFF:8190:3426") << 6;
+ QTest::newRow("ip6_11") << QString("::FFFF:129.144.52.38") << (bool)TRUE << QString("::FFFF:8190:3426") << 6;
+ QTest::newRow("ip6_12") << QString("1::FFFF:129.144.52.38") << (bool)TRUE << QString("1::FFFF:8190:3426") << 6;
+ QTest::newRow("ip6_13") << QString("A:B::D:E") << (bool)TRUE << QString("A:B::D:E") << 6;
+ QTest::newRow("ip6_14") << QString("1080:0:1:0:8:800:200C:417A") << (bool)TRUE << QString("1080:0:1:0:8:800:200C:417A") << 6;
+ QTest::newRow("ip6_15") << QString("1080:0:1:0:8:800:200C:0") << (bool)TRUE << QString("1080:0:1:0:8:800:200C:0") << 6;
+ QTest::newRow("ip6_16") << QString("1080:0:1:0:8:800:0:0") << (bool)TRUE << QString("1080:0:1:0:8:800::") << 6;
+ QTest::newRow("ip6_17") << QString("1080:0:0:0:8:800:0:0") << (bool)TRUE << QString("1080::8:800:0:0") << 6;
+ QTest::newRow("ip6_18") << QString("0:1:1:1:8:800:0:0") << (bool)TRUE << QString("0:1:1:1:8:800::") << 6;
+ QTest::newRow("ip6_19") << QString("0:1:1:1:8:800:0:1") << (bool)TRUE << QString("0:1:1:1:8:800:0:1") << 6;
QTest::newRow("error_00") << QString("foobarcom") << (bool)FALSE << QString() << 0;
QTest::newRow("error_01") << QString("foo.bar.com") << (bool)FALSE << QString() << 0;
{
QHostAddress address("fe80::2e0:4cff:fefb:662a%eth0");
QCOMPARE(address.scopeId(), QString("eth0"));
- QCOMPARE(address.toString().toLower(), QString("fe80:0:0:0:2e0:4cff:fefb:662a%eth0"));
+ QCOMPARE(address.toString().toLower(), QString("fe80::2e0:4cff:fefb:662a%eth0"));
QHostAddress address2("fe80::2e0:4cff:fefb:662a");
QCOMPARE(address2.scopeId(), QString());
address2.setScopeId(QString("en0"));
- QCOMPARE(address2.toString().toLower(), QString("fe80:0:0:0:2e0:4cff:fefb:662a%en0"));
+ QCOMPARE(address2.toString().toLower(), QString("fe80::2e0:4cff:fefb:662a%en0"));
address2 = address;
QCOMPARE(address2.scopeId(), QString("eth0"));
- QCOMPARE(address2.toString().toLower(), QString("fe80:0:0:0:2e0:4cff:fefb:662a%eth0"));
+ QCOMPARE(address2.toString().toLower(), QString("fe80::2e0:4cff:fefb:662a%eth0"));
}
void tst_QHostAddress::hashKey()
#else
ipv6Available = false;
ipv6LookupsAvailable = false;
+
+ QTcpServer server;
+ if (server.listen(QHostAddress("::1"))) {
+ // We have IPv6 support
+ ipv6Available = true;
+ }
+
#if !defined(QT_NO_GETADDRINFO)
// check if the system getaddrinfo can do IPv6 lookups
struct addrinfo hint, *result = 0;
#endif
#endif
- QTcpServer server;
- if (server.listen(QHostAddress("::1"))) {
- // We have IPv6 support
- ipv6Available = true;
- }
-
-
// run each testcase with and without test enabled
QTest::addColumn<bool>("cache");
QTest::newRow("WithCache") << true;
http.setUser(user, pass);
http.setHost(host);
int id = http.get(path);
+ Q_UNUSED(id);
QTimer::singleShot(5000, &loop, SLOT(quit()));
loop.exec();
public Q_SLOTS:
void finishedSlot() {
QHttpNetworkReply *reply = (QHttpNetworkReply*) sender();
+ Q_UNUSED(reply);
receivedCount++;
if (receivedCount == requestCount)
public Q_SLOTS:
void finishedSlot() {
QHttpNetworkReply *reply = (QHttpNetworkReply*) sender();
+ Q_UNUSED(reply);
receivedCount++;
if (receivedCount == requestCount)
void create();
void createInvalidXPM();
void createFromUChar();
- void convertBitOrder();
void formatHandlersInput_data();
void formatHandlersInput();
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");
void unget();
void peek();
void peekAndRead();
- void getch();
- void putch();
void readLine_data();
void readLine();
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");
}
return maxlen;
}
- qint64 writeData(const char *data, qint64 maxlen) {
+ qint64 writeData(const char * /* data */, qint64 /* maxlen */) {
return -1;
}
struct MyFilterModel : public QSortFilterProxyModel
{ // Override sort filter proxy to remove even numbered rows.
bool filtering;
- virtual bool filterAcceptsRow( int source_row, const QModelIndex& source_parent ) const
+ virtual bool filterAcceptsRow( int source_row, const QModelIndex& /* source_parent */) const
{
return !filtering || !( source_row & 1 );
}
}
public slots:
- void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
+ void selectionChanged(const QItemSelection & /* selected */, const QItemSelection &deselected)
{
foreach(const QModelIndex &index, deselected.indexes()) {
QVERIFY(!m_itemSelectionModel->selection().contains(index));
void geometry();
void smartMaxSize();
void setLayoutBugs();
-#ifdef QT3_SUPPORT
- void task193350_sizeGrip();
-#endif
void setContentsMargins();
void layoutItemRect();
void warnIfWrongParent();
int expectedIndex = 0;
int regressionCount = 0;
- for (int p = 0; p < sizeof(policies)/sizeof(QSizePolicy::Policy); ++p) {
+ for (size_t p = 0; p < sizeof(policies)/sizeof(QSizePolicy::Policy); ++p) {
QSizePolicy sizePolicy;
sizePolicy.setHorizontalPolicy(policies[p]);
- for (int min = 0; min < sizeof(sizeCombinations)/sizeof(int); ++min) {
+ for (size_t min = 0; min < sizeof(sizeCombinations)/sizeof(int); ++min) {
int minSize = sizeCombinations[min];
- for (int max = 0; max < sizeof(sizeCombinations)/sizeof(int); ++max) {
+ for (size_t max = 0; max < sizeof(sizeCombinations)/sizeof(int); ++max) {
int maxSize = sizeCombinations[max];
- for (int sh = 0; sh < sizeof(sizeCombinations)/sizeof(int); ++sh) {
+ for (size_t sh = 0; sh < sizeof(sizeCombinations)/sizeof(int); ++sh) {
int sizeHint = sizeCombinations[sh];
- for (int a = 0; a < sizeof(alignments)/sizeof(int); ++a) {
+ for (size_t a = 0; a < sizeof(alignments)/sizeof(int); ++a) {
Qt::Alignment align = alignments[a];
QSize sz = qSmartMaxSize(QSize(sizeHint, 1), QSize(minSize, 1), QSize(maxSize, 1), sizePolicy, align);
int width = sz.width();
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:
void QTBUG697_paletteCurrentColorGroup();
void QTBUG13520_textNotVisible();
-#ifdef QT3_SUPPORT
- void validateAndSet_data();
- void validateAndSet();
-#endif
-
void bidiVisualMovement_data();
void bidiVisualMovement();
void bidiLogicalMovement();
protected slots:
-#ifdef QT3_SUPPORT
- void lostFocus();
-#endif
void editingFinished();
void onTextChanged( const QString &newString );
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();
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())
#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
#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
#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);
void tearOff();
void layoutDirection();
-#if defined(QT3_SUPPORT)
- void indexBasedInsertion_data();
- void indexBasedInsertion();
-#endif
void task208001_stylesheet();
void activeSubMenuPosition();
void task242454_sizeHint();
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
#include <qapplication.h>
#include <qmainwindow.h>
#include <qmenubar.h>
-#ifdef QT3_SUPPORT
-#include <q3popupmenu.h>
-#endif
#include <qstyle.h>
#include <qwindowsstyle.h>
#include <qdesktopwidget.h>
tst_QMenuBar();
virtual ~tst_QMenuBar();
-#ifdef QT3_SUPPORT
void initSimpleMenubar();
-#endif
- void initSimpleMenubar_noQt3();
-
-#ifdef QT3_SUPPORT
void initComplexMenubar();
-#endif
- void initComplexMenubar_noQt3();
public slots:
void initTestCase();
private slots:
void getSetCheck();
- void clear_noQt3();
- void removeItemAt_noQt3();
- void removeItemAt_noQt3_data();
- void removeItem_noQt3_data();
- void removeItem_noQt3();
- void count_noQt3();
- void insertItem_QString_QObject_noQt3();
- void accel_noQt3();
- void activatedCount_noQt3();
- void allowActiveAndDisabled();
-#ifdef QT3_SUPPORT
void clear();
- void removeItemAt_data();
void removeItemAt();
+ void removeItemAt_data();
void removeItem_data();
void removeItem();
void count();
void insertItem_QString_QObject();
void accel();
void activatedCount();
-#endif
+ void allowActiveAndDisabled();
void check_accelKeys();
void check_cursorKeys1();
void check_homeKey();
void check_endKey();
-#ifdef QT3_SUPPORT
void check_escKey();
-#endif
- void check_escKey_noQt3();
// void check_mouse1_data();
// void check_mouse1();
void taskQTBUG4965_escapeEaten();
void taskQTBUG11823_crashwithInvisibleActions();
-#if defined(QT3_SUPPORT)
- void indexBasedInsertion_data();
- void indexBasedInsertion();
-#endif
-
protected slots:
-#ifdef QT3_SUPPORT
- void onActivated( int );
-#endif
- void onActivated_noQt3( QAction*);
+ void onActivated( QAction*);
private:
-
- void initTestCase_noQt3();
-
QtTestSlot *menu1;
QtTestSlot *menu2;
QtTestSlot *menu3;
void reset() { resetSlots(); resetCount(); };
-#ifdef QT3_SUPPORT
- int last_accel_id;
-#endif
- QAction* last_accel_id_Qt4;
+ QAction* last_accel_id;
int activated_count;
-#ifdef QT3_SUPPORT
- int idAccel;
- int idAccel1;
-#endif
QAction *action;
QAction *action1;
QMainWindow *mw;
QMenuBar *mb;
-#ifdef QT3_SUPPORT
- Q3PopupMenu *pm1;
- Q3PopupMenu *pm2;
-#endif
- QMenu *pm1_Qt4;
- QMenu *pm2_Qt4;
+ QMenu *pm1;
+ QMenu *pm2;
};
// Testing get/set functions
delete var1;
}
-////
-
-
-
#include <qcursor.h>
const int RESET = 0;
activated_count = 0;
mb = 0;
-#ifdef QT3_SUPPORT
pm1 = 0;
pm2 = 0;
- last_accel_id = RESET;
-#endif
- pm1_Qt4 = 0;
- pm2_Qt4 = 0;
- last_accel_id_Qt4 = 0;
+ last_accel_id = 0;
}
tst_QMenuBar::~tst_QMenuBar()
void tst_QMenuBar::initTestCase()
{
-#ifdef QT3_SUPPORT
- // create a default mainwindow
- // If you run a widget test, this will be replaced in the testcase by the
- // widget under test
- mw = new QMainWindow(0, Qt::X11BypassWindowManagerHint);
- mb = new QMenuBar( mw, "menubar" );
- connect( mb, SIGNAL(activated(int)), this, SLOT(onActivated(int)) );
-
- initSimpleMenubar();
-
- qApp->setMainWidget( mw );
- mw->show();
- qApp->setActiveWindow(mw);
-
- menu1 = new QtTestSlot( mw );
- menu2 = new QtTestSlot( mw );
- menu3 = new QtTestSlot( mw );
- menu4 = new QtTestSlot( mw );
- item1_A = new QtTestSlot( mw );
- item1_B = new QtTestSlot( mw );
- item2_C = new QtTestSlot( mw );
- item2_D = new QtTestSlot( mw );
- item2_E = new QtTestSlot( mw );
- item2_F = new QtTestSlot( mw );
- item2_G = new QtTestSlot( mw );
- item2_H = new QtTestSlot( mw );
-#else
- initTestCase_noQt3();
-#endif
-}
-
-void tst_QMenuBar::initTestCase_noQt3()
-{
// create a default mainwindow
// If you run a widget test, this will be replaced in the testcase by the
// widget under test
mw = new QMainWindow(0, Qt::X11BypassWindowManagerHint);
mb = new QMenuBar( mw );
- connect( mb, SIGNAL(triggered(QAction *)), this, SLOT(onActivated_noQt3(QAction *)) );
+ connect( mb, SIGNAL(triggered(QAction *)), this, SLOT(onActivated(QAction *)) );
- initSimpleMenubar_noQt3();
+ initSimpleMenubar();
mw->show();
QTest::qWaitForWindowShown(mw);
mw->activateWindow();
delete mw;
}
-#if defined(QT3_SUPPORT)
void tst_QMenuBar::initSimpleMenubar()
{
mb->hide();
mb->clear();
delete pm1;
- pm1 = new Q3PopupMenu( mb );
- idAccel = pm1->insertItem( "menu1", 123 );
-// pm->setAccel( ALT + Key_A, idAccel );
- pm1->setAccel( Qt::CTRL + Qt::Key_A, idAccel );
- mb->insertItem( "&accel", pm1 );
- connect( pm1, SIGNAL(activated(int)), this, SLOT(onActivated(int)));
-
- delete pm2;
- pm2 = new Q3PopupMenu( mb );
-// idAccel1 = pm2->insertItem( "&Open...", this, SLOT(onActivated(int)), Qt::Key_O, 456 );
- idAccel1 = pm2->insertItem( "&Open...", 0, 0, Qt::Key_O, 456 );
- connect(pm2, SIGNAL(activated(int)), this, SLOT(onActivated(int)));
- mb->insertItem( "accel1", pm2 );
-
- mb->show();
- qApp->syncX();
- qApp->processEvents();
-}
-#endif
-
-void tst_QMenuBar::initSimpleMenubar_noQt3()
-{
- mb->hide();
- mb->clear();
-
- delete pm1_Qt4;
- pm1_Qt4 = mb->addMenu("&accel");
- action = pm1_Qt4->addAction( "menu1" );
- action->setShortcut(QKeySequence("ALT+A"));
- action->setShortcut(QKeySequence("CTRL+A"));
+ pm1 = mb->addMenu("&accel");
+ action = pm1->addAction( "menu1" );
+ action->setShortcut(QKeySequence("ALT+A"));
+ action->setShortcut(QKeySequence("CTRL+A"));
+ connect( pm1, SIGNAL(triggered(QAction*)), this, SLOT(onActivated(QAction*)));
- connect( pm1_Qt4, SIGNAL(triggered(QAction*)), this, SLOT(onActivated_noQt3(QAction*)));
-
- delete pm2_Qt4;
- pm2_Qt4 = mb->addMenu("accel1");
+ delete pm2;
+ pm2 = mb->addMenu("accel1");
- action1 = pm2_Qt4->addAction( "&Open..." );
+ action1 = pm2->addAction( "&Open..." );
action1->setShortcut(Qt::Key_O);
- connect(pm2_Qt4, SIGNAL(triggered(QAction*)), this, SLOT(onActivated_noQt3(QAction*)));
+ connect(pm2, SIGNAL(triggered(QAction*)), this, SLOT(onActivated(QAction*)));
mb->show();
qApp->syncX();
void tst_QMenuBar::resetCount()
{
-#ifdef QT3_SUPPORT
- last_accel_id = RESET;
-#endif
- last_accel_id_Qt4 = 0;
+ last_accel_id = 0;
activated_count = 0;
}
-#ifdef QT3_SUPPORT
-void tst_QMenuBar::onActivated( int i )
-{
- last_accel_id = i;
- activated_count++;
-// printf( QString("acceleratorId: %1, count: %1\n").arg( i ).arg(activated_count) );
-}
-#endif
-
-void tst_QMenuBar::onActivated_noQt3( QAction* action )
+void tst_QMenuBar::onActivated( QAction* action )
{
- last_accel_id_Qt4 = action;
+ last_accel_id = action;
activated_count++;
// printf( QString("acceleratorId: %1, count: %1\n").arg( i ).arg(activated_count) );
}
-#ifdef QT3_SUPPORT
void tst_QMenuBar::accel()
{
-#ifdef Q_WS_MAC
- QSKIP("On Mac, native key events are needed to test menu action activation", SkipAll);
-#endif
- // create a popup menu with menu items set the accelerators later...
- initSimpleMenubar();
-// QTest::keyClick( 0, Qt::Key_A, AltKey );
- QTest::keyClick( 0, Qt::Key_A, Qt::ControlModifier );
- QTest::qWait(300);
-
- QCOMPARE( last_accel_id, idAccel );
-}
-#endif //QT3_SUPPORT
-
-void tst_QMenuBar::accel_noQt3()
-{
#if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM)
QSKIP("On Mac/WinCE, native key events are needed to test menu action activation", SkipAll);
#endif
#endif
// create a popup menu with menu items set the accelerators later...
- initSimpleMenubar_noQt3();
+ initSimpleMenubar();
// QTest::keyClick( 0, Qt::Key_A, AltKey );
QTest::keyClick( 0, Qt::Key_A, Qt::ControlModifier );
QTest::qWait(300);
- QCOMPARE( last_accel_id_Qt4, action );
+ QCOMPARE( last_accel_id, action );
}
-#ifdef QT3_SUPPORT
void tst_QMenuBar::activatedCount()
{
-#ifdef Q_WS_MAC
- QSKIP("On Mac, native key events are needed to test menu action activation", SkipAll);
-#endif
- // create a popup menu with menu items set the accelerators later...
- initSimpleMenubar();
-
- QTest::keyClick( 0, Qt::Key_A, Qt::ControlModifier );
-//wait(5000);
- QCOMPARE( activated_count, 2 ); //1 from the popupmenu and 1 from the menubar
-}
-#endif //QT3_SUPPORT
-
-void tst_QMenuBar::activatedCount_noQt3()
-{
#if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM)
QSKIP("On Mac/WinCE, native key events are needed to test menu action activation", SkipAll);
#endif
// create a popup menu with menu items set the accelerators later...
- initSimpleMenubar_noQt3();
+ initSimpleMenubar();
QTest::keyClick( 0, Qt::Key_A, Qt::ControlModifier );
//wait(5000);
QCOMPARE( activated_count, 2 ); //1 from the popupmenu and 1 from the menubar
}
-void tst_QMenuBar::clear_noQt3()
+void tst_QMenuBar::clear()
{
mb->clear();
QVERIFY( (uint) mb->actions().size() == 0 );
QVERIFY( (uint) mb->actions().size() == 0 );
}
-void tst_QMenuBar::count_noQt3()
+void tst_QMenuBar::count()
{
mb->clear();
QVERIFY( mb->actions().size() == 0 );
}
}
-void tst_QMenuBar::removeItem_noQt3_data()
+void tst_QMenuBar::removeItem_data()
{
QTest::addColumn<int>("removeIndex");
QTest::newRow( "first" ) << 0;
}
// Basically the same test as removeItemAt, except that we remember and remove id's.
-void tst_QMenuBar::removeItem_noQt3()
+void tst_QMenuBar::removeItem()
{
mb->clear();
QVERIFY( menuBarActions2.size() == 2 );
}
-void tst_QMenuBar::removeItemAt_noQt3_data()
+void tst_QMenuBar::removeItemAt_data()
{
QTest::addColumn<int>("removeIndex");
QTest::newRow( "first" ) << 0;
QTest::newRow( "last" ) << 2;
}
-void tst_QMenuBar::removeItemAt_noQt3()
+void tst_QMenuBar::removeItemAt()
{
mb->clear();
QVERIFY( menuBarActions2.size() == 2 );
}
-#ifdef QT3_SUPPORT
-void tst_QMenuBar::clear()
-{
- mb->clear();
- QVERIFY( mb->count() == 0 );
-
- mb->clear();
- for (uint i=0; i<10; i++) {
- Q3PopupMenu *pm = new Q3PopupMenu( mb );
- for (uint k=0; k<i; k++)
- pm->insertItem( QString("Item %1").arg(i*10 + k) );
- mb->insertItem( QString("Menu %1").arg(i), pm );
- QCOMPARE( mb->count(), (uint)i+1 );
- }
- QCOMPARE( mb->count(), 10u );
-
- mb->clear();
- QVERIFY( mb->count() == 0 );
-}
-
-void tst_QMenuBar::count()
-{
- mb->clear();
- QVERIFY( mb->count() == 0 );
-
- for (uint i=0; i<10; i++) {
- Q3PopupMenu *pm = new Q3PopupMenu( mb );
- mb->insertItem( QString("Menu %1").arg(i), pm );
- QCOMPARE( mb->count(), i+1 );
- }
-}
-
-void tst_QMenuBar::removeItemAt_data()
-{
- QTest::addColumn<int>("removeIndex");
- QTest::newRow( "first" ) << 0;
- QTest::newRow( "middle" ) << 1;
- QTest::newRow( "last" ) << 2;
-}
-
-void tst_QMenuBar::removeItemAt()
-{
- mb->clear();
-
- Q3PopupMenu *pm;
- pm = new Q3PopupMenu( mb );
- pm->insertItem( QString("Item 10") );
- mb->insertItem( QString("Menu 1"), pm );
-
- pm = new Q3PopupMenu( mb );
- pm->insertItem( QString("Item 20") );
- pm->insertItem( QString("Item 21") );
- mb->insertItem( QString("Menu 2"), pm );
-
- pm = new Q3PopupMenu( mb );
- pm->insertItem( QString("Item 30") );
- pm->insertItem( QString("Item 31") );
- pm->insertItem( QString("Item 32") );
- mb->insertItem( QString("Menu 3"), pm );
-
- QCOMPARE( mb->text( mb->idAt(0) ), QString("Menu 1") );
- QCOMPARE( mb->text( mb->idAt(1) ), QString("Menu 2") );
- QCOMPARE( mb->text( mb->idAt(2) ), QString("Menu 3") );
-
- // Ok, now that we know we have created the menu we expect, lets remove an item...
- QFETCH( int, removeIndex );
- mb->removeItemAt( removeIndex );
- switch (removeIndex )
- {
- case 0:
- QCOMPARE( mb->text( mb->idAt(0) ), QString("Menu 2") );
- QCOMPARE( mb->text( mb->idAt(1) ), QString("Menu 3") );
- break;
- case 1:
- QCOMPARE( mb->text( mb->idAt(0) ), QString("Menu 1") );
- QCOMPARE( mb->text( mb->idAt(1) ), QString("Menu 3") );
- break;
- case 2:
- QCOMPARE( mb->text( mb->idAt(0) ), QString("Menu 1") );
- QCOMPARE( mb->text( mb->idAt(1) ), QString("Menu 2") );
- break;
- }
-
- QVERIFY( mb->count() == 2 );
-}
-
-void tst_QMenuBar::removeItem_data()
-{
- QTest::addColumn<int>("removeIndex");
- QTest::newRow( "first" ) << 0;
- QTest::newRow( "middle" ) << 1;
- QTest::newRow( "last" ) << 2;
-}
-
-// Basically the same test as removeItemAt, except that we remember and remove id's.
-void tst_QMenuBar::removeItem()
-{
- mb->clear();
-
- Q3PopupMenu *pm;
- pm = new Q3PopupMenu( mb );
- pm->insertItem( QString("Item 10") );
- int id1 = mb->insertItem( QString("Menu 1"), pm );
-
- pm = new Q3PopupMenu( mb );
- pm->insertItem( QString("Item 20") );
- pm->insertItem( QString("Item 21") );
- int id2 = mb->insertItem( QString("Menu 2"), pm );
-
- pm = new Q3PopupMenu( mb );
- pm->insertItem( QString("Item 30") );
- pm->insertItem( QString("Item 31") );
- pm->insertItem( QString("Item 32") );
- int id3 = mb->insertItem( QString("Menu 3"), pm );
-
- QCOMPARE( mb->text( id1 ), QString("Menu 1") );
- QCOMPARE( mb->text( id2 ), QString("Menu 2") );
- QCOMPARE( mb->text( id3 ), QString("Menu 3") );
-
- QVERIFY( mb->idAt(0) == id1 );
- QVERIFY( mb->idAt(1) == id2 );
- QVERIFY( mb->idAt(2) == id3 );
-
- // Ok, now that we know we have created the menu we expect, lets remove an item...
- QFETCH( int, removeIndex );
- switch (removeIndex )
- {
- case 0:
- mb->removeItem( id1 );
- QCOMPARE( mb->text( mb->idAt(0) ), QString("Menu 2") );
- QCOMPARE( mb->text( mb->idAt(1) ), QString("Menu 3") );
- break;
- case 1:
- mb->removeItem( id2 );
- QCOMPARE( mb->text( mb->idAt(0) ), QString("Menu 1") );
- QCOMPARE( mb->text( mb->idAt(1) ), QString("Menu 3") );
- break;
- case 2:
- mb->removeItem( id3 );
- QCOMPARE( mb->text( mb->idAt(0) ), QString("Menu 1") );
- QCOMPARE( mb->text( mb->idAt(1) ), QString("Menu 2") );
- break;
- }
-
- QVERIFY( mb->count() == 2 );
-}
-
void tst_QMenuBar::initComplexMenubar() // well, complex....
{
mb->hide();
mb->clear();
delete pm1;
- pm1 = new Q3PopupMenu( mb, "popup1" );
- pm1->insertItem( QString("Item A"), item1_A, SLOT(selected()), Qt::CTRL+Qt::Key_A );
- pm1->insertItem( QString("Item B"), item1_B, SLOT(selected()), Qt::CTRL+Qt::Key_B );
- // use the form insertItem( QString, Q3PopupMenu )
- mb->insertItem( "Menu &1", pm1 );
+ pm1 = mb->addMenu("Menu &1");
+ pm1->addAction( QString("Item A"), item1_A, SLOT(selected()), Qt::CTRL+Qt::Key_A );
+ pm1->addAction( QString("Item B"), item1_B, SLOT(selected()), Qt::CTRL+Qt::Key_B );
delete pm2;
- pm2 = new Q3PopupMenu( mb, "popup2" );
- pm2->insertItem( QString("Item C"), item2_C, SLOT(selected()), Qt::CTRL+Qt::Key_C );
- pm2->insertItem( QString("Item D"), item2_D, SLOT(selected()), Qt::CTRL+Qt::Key_D );
- pm2->insertItem( QString("Item E"), item2_E, SLOT(selected()), Qt::CTRL+Qt::Key_E );
- pm2->insertItem( QString("Item F"), item2_F, SLOT(selected()), Qt::CTRL+Qt::Key_F );
- pm2->insertSeparator();
- pm2->insertItem( QString("Item G"), item2_G, SLOT(selected()), Qt::CTRL+Qt::Key_G );
- pm2->insertItem( QString("Item H"), item2_H, SLOT(selected()), Qt::CTRL+Qt::Key_H );
- // use the form insertItem( QString, Q3PopupMenu )
- mb->insertItem( "Menu &2", pm2 );
-
- // use the form insertItem( QString, QObject, slot, keysequence )
- mb->insertItem( QString("M&enu 3"), menu3, SLOT(selected()), Qt::ALT+Qt::Key_J );
- mb->show();
-}
-#endif
-
-void tst_QMenuBar::initComplexMenubar_noQt3() // well, complex....
-{
- mb->hide();
- mb->clear();
-
- delete pm1_Qt4;
- pm1_Qt4 = mb->addMenu("Menu &1");
- pm1_Qt4->addAction( QString("Item A"), item1_A, SLOT(selected()), Qt::CTRL+Qt::Key_A );
- pm1_Qt4->addAction( QString("Item B"), item1_B, SLOT(selected()), Qt::CTRL+Qt::Key_B );
-
- delete pm2_Qt4;
- pm2_Qt4 = mb->addMenu("Menu &2");
- pm2_Qt4->addAction( QString("Item C"), item2_C, SLOT(selected()), Qt::CTRL+Qt::Key_C );
- pm2_Qt4->addAction( QString("Item D"), item2_D, SLOT(selected()), Qt::CTRL+Qt::Key_D );
- pm2_Qt4->addAction( QString("Item E"), item2_E, SLOT(selected()), Qt::CTRL+Qt::Key_E );
- pm2_Qt4->addAction( QString("Item F"), item2_F, SLOT(selected()), Qt::CTRL+Qt::Key_F );
- pm2_Qt4->addSeparator();
- pm2_Qt4->addAction( QString("Item G"), item2_G, SLOT(selected()), Qt::CTRL+Qt::Key_G );
- pm2_Qt4->addAction( QString("Item H"), item2_H, SLOT(selected()), Qt::CTRL+Qt::Key_H );
+ pm2 = mb->addMenu("Menu &2");
+ pm2->addAction( QString("Item C"), item2_C, SLOT(selected()), Qt::CTRL+Qt::Key_C );
+ pm2->addAction( QString("Item D"), item2_D, SLOT(selected()), Qt::CTRL+Qt::Key_D );
+ pm2->addAction( QString("Item E"), item2_E, SLOT(selected()), Qt::CTRL+Qt::Key_E );
+ pm2->addAction( QString("Item F"), item2_F, SLOT(selected()), Qt::CTRL+Qt::Key_F );
+ pm2->addSeparator();
+ pm2->addAction( QString("Item G"), item2_G, SLOT(selected()), Qt::CTRL+Qt::Key_G );
+ pm2->addAction( QString("Item H"), item2_H, SLOT(selected()), Qt::CTRL+Qt::Key_H );
QAction *ac = mb->addAction( QString("M&enu 3"), menu3, SLOT(selected()));
ac->setShortcut(Qt::ALT+Qt::Key_J);
used less frequently.
*/
-#ifdef QT3_SUPPORT
void tst_QMenuBar::insertItem_QString_QObject()
{
initComplexMenubar();
- QCOMPARE( mb->text( mb->idAt( 0 ) ), QString("Menu &1") );
- QCOMPARE( mb->text( mb->idAt( 1 ) ), QString("Menu &2") );
- QCOMPARE( mb->text( mb->idAt( 2 ) ), QString("M&enu 3") );
- QCOMPARE( mb->text( mb->idAt( 3 ) ), QString() ); // there is no menu 4!
-}
-#endif
-
-void tst_QMenuBar::insertItem_QString_QObject_noQt3()
-{
- initComplexMenubar_noQt3();
QList<QAction *> actions = mb->actions();
#if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM)
QSKIP("On Mac/WinCE, native key events are needed to test menu action activation", SkipAll);
#endif
-#ifdef QT3_SUPPORT
initComplexMenubar();
-#else
- initComplexMenubar_noQt3();
-#endif
// start with a bogus key that shouldn't trigger anything
QTest::keyClick(0, Qt::Key_I, Qt::ControlModifier);
QSKIP("Qt/Mac,WinCE does not use the native popups/menubar", SkipAll);
#endif
-#ifdef QT3_SUPPORT
initComplexMenubar();
-#else
- initComplexMenubar_noQt3();
-#endif
// start with a ALT + 1 that activates the first popupmenu
QTest::keyClick( 0, Qt::Key_1, Qt::AltModifier );
QSKIP("Qt/Mac,WinCE does not use the native popups/menubar", SkipAll);
#endif
-#ifdef QT3_SUPPORT
initComplexMenubar();
-#else
- initComplexMenubar_noQt3();
-#endif
// select popupmenu2
QTest::keyClick( 0, Qt::Key_2, Qt::AltModifier );
QSKIP("Qt/Mac,WinCE does not use the native popups/menubar", SkipAll);
#endif
-#ifdef QT3_SUPPORT
initComplexMenubar();
-#else
- initComplexMenubar_noQt3();
-#endif
// select Popupmenu 2
QTest::keyClick( 0, Qt::Key_2, Qt::AltModifier );
QEXPECT_FAIL( "0", "Popupmenu should respond to a Home key", Abort );
-#ifdef QT3_SUPPORT
initComplexMenubar();
-#else
- initComplexMenubar_noQt3();
-#endif
// select Popupmenu 2
QTest::keyClick( 0, Qt::Key_2, Qt::AltModifier );
QEXPECT_FAIL( "0", "Popupmenu should respond to an End key", Abort );
-#ifdef QT3_SUPPORT
initComplexMenubar();
-#else
- initComplexMenubar_noQt3();
-#endif
// select Popupmenu 2
QTest::keyClick( 0, Qt::Key_2, Qt::AltModifier );
If Down is pressed next the popup is activated again.
*/
-#ifdef QT3_SUPPORT
void tst_QMenuBar::check_escKey()
{
-#ifdef Q_WS_MAC
- QSKIP("Qt/Mac does not use the native popups/menubar", SkipAll);
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM)
+ QSKIP("Qt/Mac,WinCE does not use the native popups/menubar", SkipAll);
#endif
initComplexMenubar();
if (!QApplication::style()->inherits("QWindowsStyle"))
return;
- // but the menubar item should stay selected
- QVERIFY( mb->isItemActive(mb->idAt(1)) );
-
// If we press Down the popupmenu should be active again
QTest::keyClick( 0, Qt::Key_Down );
QVERIFY( !pm1->isActiveWindow() );
// Let's see if the correct slot is called...
QVERIFY2( item2_C->selCount() == 1, "Expected item 2C to be selected" );
}
-#endif
-
-void tst_QMenuBar::check_escKey_noQt3()
-{
-#if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM)
- QSKIP("Qt/Mac,WinCE does not use the native popups/menubar", SkipAll);
-#endif
-
- initComplexMenubar_noQt3();
-
- QVERIFY( !pm1_Qt4->isActiveWindow() );
- QVERIFY( !pm2_Qt4->isActiveWindow() );
-
- // select Popupmenu 2
- QTest::keyClick( 0, Qt::Key_2, Qt::AltModifier );
- QVERIFY( !pm1_Qt4->isActiveWindow() );
- QVERIFY( pm2_Qt4->isActiveWindow() );
-
- // If we press ESC, the popup should disappear
- QTest::keyClick( 0, Qt::Key_Escape );
- QVERIFY( !pm1_Qt4->isActiveWindow() );
- QVERIFY( !pm2_Qt4->isActiveWindow() );
-
- if (!QApplication::style()->inherits("QWindowsStyle"))
- return;
-
- // If we press Down the popupmenu should be active again
- QTest::keyClick( 0, Qt::Key_Down );
- QVERIFY( !pm1_Qt4->isActiveWindow() );
- QVERIFY( pm2_Qt4->isActiveWindow() );
-
- // and press ENTER
- QTest::keyClick( pm2_Qt4, Qt::Key_Enter );
- // Let's see if the correct slot is called...
- QVERIFY2( item2_C->selCount() == 1, "Expected item 2C to be selected" );
-}
// void tst_QMenuBar::check_mouse1_data()
arg( qApp->style()->objectName() ).toAscii(), SkipAll );
}
-#ifdef QT3_SUPPORT
initSimpleMenubar();
-#else
- initSimpleMenubar_noQt3();
-#endif
qApp->setActiveWindow(mw);
mw->setFocus();
QSKIP("Qt/Mac,WinCE does not use the native popups/menubar", SkipAll);
#endif
-#ifdef QT3_SUPPORT
initComplexMenubar();
-#else
- initComplexMenubar_noQt3();
-#endif
qApp->setActiveWindow(mw);
QCOMPARE(menu3->selCount(), 0u);
QVERIFY(!mb->activeAction());
QTest::keyClick(mw, Qt::Key_1, Qt::AltModifier );
-#ifdef QT3_SUPPORT
QVERIFY(pm1->isActiveWindow());
-#else
- QVERIFY(pm1_Qt4->isActiveWindow());
-#endif
QTest::keyClick(mb, Qt::Key_2);
-#ifdef QT3_SUPPORT
- QVERIFY(pm1->isActiveWindow()); // Should still be the active window
-#else
- QVERIFY(pm1_Qt4->isActiveWindow());
-#endif
+ QVERIFY(pm1->isActiveWindow());
}
void tst_QMenuBar::check_menuPosition()
QSKIP("Qt/CE uses native menubar", SkipAll);
#endif
Menu menu;
-#ifdef QT3_SUPPORT
initComplexMenubar();
-#else
- initComplexMenubar_noQt3();
-#endif
menu.setTitle("&menu");
QRect availRect = QApplication::desktop()->availableGeometry(mw);
QRect screenRect = QApplication::desktop()->screenGeometry(mw);
QCOMPARE(menubar.activeAction(), m); //the active action shouldn't have changed
}
-
-#if defined(QT3_SUPPORT)
-void tst_QMenuBar::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_QMenuBar::indexBasedInsertion()
-{
- // test the compat'ed index based insertion
-
- QFETCH(int, indexForInsertion);
- QFETCH(int, expectedIndex);
-
- {
- QMenuBar 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"));
- }
- {
- QMenuBar menu;
- menu.addAction("Regular Item");
-
- menu.insertSeparator(indexForInsertion);
-
- QAction *act = menu.actions().value(expectedIndex);
- QVERIFY(act);
- QVERIFY(act->isSeparator());
- }
-}
-#endif
-
QTEST_MAIN(tst_QMenuBar)
#include "tst_qmenubar.moc"
DEPENDPATH += .
INCLUDEPATH += .
-CONFIG += console qtestlib qt3support
-wince*: CONFIG -= qt3support
+CONFIG += console qtestlib
# Input
SOURCES += tst_qmessagebox.cpp
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");
}
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;
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();
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();
void checkMouseReleaseEvent_data();
void checkMouseReleaseEvent();
- void qt3supportConstructors();
-
private:
MouseEventWidget* testMouseWidget;
};
{
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;
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));
}
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)
**
****************************************************************************/
-
#include <QtTest/QtTest>
#include <qatomic.h>
#include <qthread.h>
#include <qwaitcondition.h>
-
-
//TESTED_CLASS=
//TESTED_FILES=
}
};
-#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
for (int i = 0; i < iterations; ++i) {
// normal mutex
- VERIFY_NLOCKED(mutex);
QVERIFY(mutex.tryLock());
mutex.unlock();
for (int j = 0; j < iterations; ++j) {
QVERIFY(thread.cond.wait(&thread.mutex, 10000));
- VERIFY_LOCKED(mutex);
QVERIFY(!mutex.tryLock());
thread.cond.wakeOne();
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());
for (int k = 0; k < iterations; ++k) {
QVERIFY(rthread.cond.wait(&rthread.mutex, 10000));
- VERIFY_LOCKED(rmutex);
QVERIFY(!rmutex.tryLock());
rthread.cond.wakeOne();
rthread.mutex.unlock();
QVERIFY(rthread.wait(10000));
- VERIFY_NLOCKED(rmutex);
QVERIFY(rmutex.tryLock());
QVERIFY(rmutex.tryLock());
QVERIFY(rmutex.tryLock());
{
Q_OBJECT
public:
- DownloadCheckWidget(QWidget *parent = 0) : QWidget(parent)
- , progressDlg(this), netmanager(this)
- , lateReadyRead(true)
+ DownloadCheckWidget(QWidget *parent = 0) :
+ QWidget(parent), lateReadyRead(true), zeroCopy(false),
+ progressDlg(this), netmanager(this)
{
progressDlg.setRange(1, 100);
QMetaObject::invokeMethod(this, "go", Qt::QueuedConnection);
void dataReadProgress(qint64 done, qint64 total)
{
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+ Q_UNUSED(reply);
progressDlg.setMaximum(total);
progressDlg.setValue(done);
}
void dataReadyRead()
{
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+ Q_UNUSED(reply);
lateReadyRead = true;
}
void finishedFromReply()
void putGetDeleteGetFromHttp();
void sendCustomRequestToHttp_data();
void sendCustomRequestToHttp();
+ void connectToIPv6Address_data();
+ void connectToIPv6Address();
void ioGetFromData_data();
void ioGetFromData();
QSemaphore ready;
bool doClose;
bool doSsl;
+ bool ipv6;
bool multiple;
int totalConnections;
- MiniHttpServer(const QByteArray &data, bool ssl = false, QThread *thread = 0)
- : client(0), dataToTransmit(data), doClose(true), doSsl(ssl),
+ MiniHttpServer(const QByteArray &data, bool ssl = false, QThread *thread = 0, bool useipv6 = false)
+ : client(0), dataToTransmit(data), doClose(true), doSsl(ssl), ipv6(useipv6),
multiple(false), totalConnections(0)
{
- listen();
+ if( useipv6 ){
+ listen(QHostAddress::AnyIPv6);
+ }else{
+ listen();
+ }
if (thread) {
connect(thread, SIGNAL(started()), this, SLOT(threadStartedSlot()));
moveToThread(thread);
protected:
void incomingConnection(int socketDescriptor)
{
- //qDebug() << "incomingConnection" << socketDescriptor;
+ //qDebug() << "incomingConnection" << socketDescriptor << "doSsl:" << doSsl << "ipv6:" << ipv6;
if (!doSsl) {
client = new QTcpSocket;
client->setSocketDescriptor(socketDescriptor);
}
+void tst_QNetworkReply::connectToIPv6Address_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QNetworkReply::NetworkError>("error");
+ QTest::addColumn<QByteArray>("dataToSend");
+ QTest::addColumn<QByteArray>("serverVerifyData");
+ QTest::newRow("localhost") << QUrl(QByteArray("http://[::1]")) << QNetworkReply::NoError<< QByteArray("localhost") << QByteArray("\r\nHost: [::1]\r\n");
+ //to add more test data here
+}
+
+void tst_QNetworkReply::connectToIPv6Address()
+{
+ QFETCH(QUrl, url);
+ QFETCH(QNetworkReply::NetworkError, error);
+ QFETCH(QByteArray, dataToSend);
+ QFETCH(QByteArray, serverVerifyData);
+
+ QByteArray httpResponse = QByteArray("HTTP/1.0 200 OK\r\nContent-Length: ");
+ httpResponse += QByteArray::number(dataToSend.size());
+ httpResponse += "\r\n\r\n";
+ httpResponse += dataToSend;
+
+ MiniHttpServer server(httpResponse, false, NULL/*thread*/, true/*useipv6*/);
+ server.doClose = true;
+
+ url.setPort(server.serverPort());
+ QNetworkRequest request(url);
+
+ QNetworkReplyPtr reply = manager.get(request);
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QByteArray content = reply->readAll();
+ if( !serverVerifyData.isEmpty()){
+ //qDebug() << server.receivedData;
+ //QVERIFY(server.receivedData.contains(serverVerifyData)); //got a bug here
+ }
+ QVERIFY(content == dataToSend);
+ QCOMPARE(reply->url(), request.url());
+ QVERIFY(reply->error() == error);
+}
+
void tst_QNetworkReply::sendCustomRequestToHttp_data()
{
QTest::addColumn<QUrl>("url");
****************************************************************************/
-#define QT3_SUPPORT
#include <QtTest/QtTest>
-
#include <qcoreapplication.h>
#include <qpointer.h>
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);
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);
#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>
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()
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)
// void QPictureIO::setPicture(const QPicture &)
// const char * QPictureIO::format()
// void QPictureIO::setFormat(const char *)
- char *var2 = "PNG";
+ const char var2[] = "PNG";
obj1.setFormat(var2);
QCOMPARE(var2, obj1.format());
obj1.setFormat((char *)0);
// const char * QPictureIO::parameters()
// void QPictureIO::setParameters(const char *)
- char *var3 = "Bogus data";
+ const char var3[] = "Bogus data";
obj1.setParameters(var3);
QCOMPARE(var3, obj1.parameters());
obj1.setParameters((char *)0);
void copy();
void depthOfNullObjects();
-#ifdef QT3_SUPPORT
- void resize();
- void resizePreserveMask();
-#endif
-
void transformed();
void transformed2();
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;
**
****************************************************************************/
-
#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>
QFETCH(int, width);
QFETCH(int, height);
QFETCH(bool, fullpage);
+ Q_UNUSED(width);
+ Q_UNUSED(height);
QPrinter printer;
QPainter *painter = 0;
printer.setOutputFileName("silly");
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;
}
label.show();
int c;
+ Q_UNUSED(c);
fgetc(stdin); // block until fed
qDebug("Process is running");
for (int i = 0; i < argc; ++i) {
if (i)
printf("|");
- printf(argv[i]);
+ printf("%s", argv[i]);
}
#endif
return 0;
void testArrays_data();
void testArrays();
void testEscapes();
- void testCompatFunctions();
void testCaseSensitivity_data();
void testCaseSensitivity();
void testErrorHandling_data();
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();
#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();
}
}
-#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
}
}
-#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)
sourceCode += "#include <QtOpenGL/QtOpenGL>\n";
if (qtModules & QExternalTest::QtSql)
sourceCode += "#include <QtSql/QtSql>\n";
- if (qtModules & QExternalTest::Qt3Support)
- sourceCode += "#include <Qt3Support/Qt3Support>\n";
if (qtModules & QExternalTest::QtSvg)
sourceCode += "#include <QtSvg/QtSvg>\n";
if (qtModules & QExternalTest::QtScript)
projectFile.write("QT += opengl\n");
if (qtModules & QExternalTest::QtSql)
projectFile.write("QT += sql\n");
- if (qtModules & QExternalTest::Qt3Support)
- projectFile.write("QT += qt3support\n");
if (qtModules & QExternalTest::QtSvg)
projectFile.write("QT += svg\n");
if (qtModules & QExternalTest::QtScript)
QtXmlPatterns=0x0010,
QtOpenGL = 0x0020,
QtSql = 0x0040,
- Qt3Support = 0x0080,
- QtSvg = 0x0100,
- QtScript = 0x0200,
- QtTest = 0x0400,
- QtDBus = 0x0800,
- QtWebKit = 0x1000,
- Phonon = 0x2000 // odd man out
+ QtSvg = 0x0080,
+ QtScript = 0x0100,
+ QtTest = 0x0200,
+ QtDBus = 0x0400,
+ QtWebKit = 0x0800,
+ Phonon = 0x1000 // odd man out
};
Q_DECLARE_FLAGS(QtModules, QtModule)
}
protected:
- bool filterAcceptsColumn(int column, const QModelIndex &source_parent) const
+ bool filterAcceptsColumn(int column, const QModelIndex & /* source_parent */) const
{
return column % 2 != 0;
}
private slots:
void getSetCheck();
void sizes(); // bare (as in empty)
- void setSizes3();
- void setSizes3_data();
void setSizes();
void setSizes_data();
void saveAndRestoreState();
w2 = new QWidget;
splitter->addWidget(w1);
splitter->addWidget(w2);
-#if defined(QT3_SUPPORT)
- qApp->setMainWidget(splitter);
-#endif
}
void tst_QSplitter::init()
void tst_QSplitter::cleanupTestCase()
{
-#if defined(QT3_SUPPORT)
- delete qApp->mainWidget();
-#endif
}
typedef QList<int> IntList;
Q_DECLARE_METATYPE(IntList)
-void tst_QSplitter::setSizes3()
+void tst_QSplitter::setSizes()
{
QFETCH(IntList, minimumSizes);
QFETCH(IntList, splitterSizes);
QTEST(splitter->sizes(), "expectedSizes");
}
-void tst_QSplitter::setSizes3_data()
+void tst_QSplitter::setSizes_data()
{
QTest::addColumn<IntList>("minimumSizes");
QTest::addColumn<IntList>("splitterSizes");
}
}
-void tst_QSplitter::setSizes()
-{
-#if !defined(QT3_SUPPORT)
- QSKIP("No Qt3Support", SkipAll);
-#else
- QFETCH(int, minSize1);
- QFETCH(int, minSize2);
- QFETCH(int, splitterSize1);
- QFETCH(int, splitterSize2);
- QFETCH(bool, collapse1);
- QFETCH(bool, collapse2);
- QFETCH(bool, childrencollapse);
- QFETCH(int, resizeMode1);
- QFETCH(int, resizeMode2);
- QList<int> mySizes;
- mySizes << splitterSize1 << splitterSize2;
- w1->setMinimumWidth(minSize1);
- w2->setMinimumWidth(minSize2);
- splitter->setCollapsible(w1, collapse1);
- splitter->setCollapsible(w2, collapse2);
- splitter->setChildrenCollapsible(childrencollapse);
- splitter->setResizeMode(w1, (QSplitter::ResizeMode)resizeMode1);
- splitter->setResizeMode(w2, (QSplitter::ResizeMode)resizeMode2);
- splitter->setSizes(mySizes);
- mySizes = splitter->sizes();
- QTEST(mySizes[0], "expected1");
- QTEST(mySizes[1], "expected2");
-#endif
-}
-
-void tst_QSplitter::setSizes_data()
-{
-#if defined(QT3_SUPPORT)
- QTest::addColumn<int>("minSize1");
- QTest::addColumn<int>("minSize2");
- QTest::addColumn<int>("splitterSize1");
- QTest::addColumn<int>("splitterSize2");
- QTest::addColumn<int>("expected1");
- QTest::addColumn<int>("expected2");
- QTest::addColumn<bool>("collapse1");
- QTest::addColumn<bool>("collapse2");
- QTest::addColumn<bool>("childrencollapse");
- QTest::addColumn<int>("resizeMode1");
- QTest::addColumn<int>("resizeMode2");
- QTest::newRow("ok00") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok01") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok02") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok03") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok04") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok05") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok06") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok07") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok08") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok09") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok10") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
-
- QTest::newRow("ok20") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok21") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok22") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok23") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok24") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok25") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok26") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok27") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok28") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok29") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok30") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Auto;
- QTest::newRow("ok40") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok41") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok42") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok43") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok44") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok45") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok46") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok47") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok48") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok49") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok50") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
-
- QTest::newRow("ok60") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok61") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok62") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok63") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok64") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok65") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok66") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok67") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok68") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok69") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
- QTest::newRow("ok70") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Auto;
-
- QTest::newRow("ok80") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok81") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok82") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok83") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok84") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok85") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok86") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok87") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok88") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok89") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok90") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
-
- QTest::newRow("ok100") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok101") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok102") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok103") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok104") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok105") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok106") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok107") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok108") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok109") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
- QTest::newRow("ok110") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::Stretch;
-
- QTest::newRow("ok120") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok121") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok122") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok123") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok124") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok125") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok126") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok127") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok128") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok129") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok130") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
-
- QTest::newRow("ok140") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok141") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok142") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok143") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok144") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok145") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok146") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok147") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok148") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok149") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok150") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
- QTest::newRow("ok160") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok161") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok162") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok163") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok164") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok165") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok166") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok167") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok168") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok169") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok170") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok180") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok181") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok182") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok183") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok184") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok185") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok186") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok187") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok188") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok189") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok190") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
- QTest::newRow("ok200") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok201") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok202") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok203") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok204") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok205") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok206") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok207") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok208") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok209") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok210") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok220") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok221") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok222") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok223") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok224") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok225") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok226") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok227") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok228") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok229") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok230") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
- QTest::newRow("ok240") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok241") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok242") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok243") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok244") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok245") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok246") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok247") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok248") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok249") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok250") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok260") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok261") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok262") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok263") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok264") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok265") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok266") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok267") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok268") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok269") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok270") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
- QTest::newRow("ok280") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok281") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok282") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok283") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok284") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok285") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok286") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok287") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok288") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok289") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok290") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok300") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok301") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok302") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok303") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok304") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok305") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok306") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok307") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok308") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok309") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok310") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
- QTest::newRow("ok320") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok321") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok322") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok323") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok324") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok325") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok326") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok327") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok328") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok329") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok330") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)true
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok340") << 100 << 50 << 100 << 300 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok341") << 100 << 100 << 50 << 350 << 100 << 300
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok342") << 100 << 100 << 350 << 50 << 300 << 100
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok343") << 200 << 200 << 350 << 50 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok344") << 200 << 200 << 200 << 200 << 200 << 200
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok345") << 200 << 200 << 0 << 350 << 0 << 400
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok346") << 200 << 200 << 350 << 0 << 400 << 0
- << (bool)true << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok347") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)true << (bool)false << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok348") << 200 << 200 << 350 << 0 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok349") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)true << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
- QTest::newRow("ok350") << 200 << 200 << 0 << 350 << 200 << 200
- << (bool)false << (bool)false << (bool)false
- << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
-#endif
-}
-
void tst_QSplitter::saveAndRestoreState_data()
{
saveState_data();
#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>
continue;
}
- qDebug( qPrintable( QLatin1String( "Testing: " ) + tst_Databases::dbToString( db ) ) );
+ qDebug("Testing: %s", qPrintable(tst_Databases::dbToString( db )));
QSqlRecord rInf = db.record( tableName );
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();
// force an open error
if ( db.open( "dummy130977", "doesnt_exist" ) ) {
- qDebug( qPrintable(QLatin1String("Promiscuous database server without access control - test skipped for ") +
- tst_Databases::dbToString( db )) );
+ qDebug("Promiscuous database server without access control - test skipped for %s",
+ qPrintable(tst_Databases::dbToString( db )) );
QVERIFY(1);
continue;
}
#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>
//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(); }
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;
};
// number of records to be inserted per testfunction
static const int ITERATION_COUNT = 2;
-static int pkey = 1;
//helper class for database specific tests
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)
}
}
-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);
if (!q.exec("CREATE VIEW " + qtest_view + " as select * from " + qtest)) {
- qDebug(QString("DBMS '%1' cannot handle VIEWs: %2").arg(
- tst_Databases::dbToString(db)).arg(QString(tst_Databases::printError(q.lastError()))).toLatin1());
+ qDebug("DBMS '%s' cannot handle VIEWs: %s",
+ qPrintable(tst_Databases::dbToString(db)),
+ qPrintable(tst_Databases::printError(q.lastError())));
views = false;
}
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")) {
}
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
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
{
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()
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()
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()
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__));
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"),
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) {
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);
}
}
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));
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()
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)"));
// 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()
};
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()
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()
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()
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,
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()
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()
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()
q.clear(); // for SQLite which does not allow any references on rows that shall be rolled back
if (!db.rollback()) {
if (db.driverName().startsWith("QMYSQL")) {
- qDebug("MySQL: " + tst_Databases::printError(db.lastError()));
+ qDebug("MySQL: %s", qPrintable(tst_Databases::printError(db.lastError())));
QSKIP("MySQL transaction failed ", SkipSingle); //non-fatal
} else {
QFAIL("Could not rollback transaction: " + tst_Databases::printError(db.lastError()));
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) {
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"));
}
}
if(!db.open())
- qFatal(tst_Databases::printError(db.lastError(), db));
+ qFatal("%s", qPrintable(tst_Databases::printError(db.lastError(), db)));
}
void tst_QSqlDatabase::oci_xmltypeSupport()
if ( !q.exec( "rollback" ) ) {
if ( db.driverName().startsWith( "QMYSQL" ) ) {
- qDebug( "MySQL: " + tst_Databases::printError( q.lastError() ) );
+ qDebug( "MySQL: %s", qPrintable(tst_Databases::printError( q.lastError() ) ));
QSKIP( "MySQL transaction failed ", SkipSingle ); //non-fatal
} else
QFAIL( "Could not rollback transaction: " + tst_Databases::printError( q.lastError() ) );
QVERIFY_SQL( q2, exec( "select * from" + qtest + " where id = 42" ) );
if ( q2.next() )
- qDebug( QString( "DBMS '%1' doesn't support query based transactions with concurrent access" ).arg(
- tst_Databases::dbToString( db ) ).toLatin1() );
+ qDebug("DBMS '%s' doesn't support query based transactions with concurrent access",
+ qPrintable(tst_Databases::dbToString( db )));
QVERIFY_SQL( q, exec( "commit" ) );
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();
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()
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() ) );
}
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 );
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 ] ) );
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
}
}
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 );
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()
#else
bool ret = server.waitForNewConnection(20000);
#endif
+ Q_UNUSED(ret);
// delayed start of encryption
QTest::qSleep(100);
QByteArray data;
data.resize(1024*1024*10); // 10 MB
// init with garbage. needed so ssl cannot compress it in an efficient way.
- for (int i = 0; i < data.size() / sizeof(int); i++) {
+ for (size_t i = 0; i < data.size() / sizeof(int); i++) {
int r = qrand();
data.data()[i*sizeof(int)] = r;
}
{
// make sure this links
QStateMachine::WrappedEvent *wrappedEvent = new QStateMachine::WrappedEvent(0, 0);
+ Q_UNUSED(wrappedEvent);
QStateMachine::SignalEvent *signalEvent = new QStateMachine::SignalEvent(0, 0, QList<QVariant>());
+ Q_UNUSED(signalEvent);
}
void tst_QStateMachine::stopInTransitionToFinalState()
void indexOf3_data();
// void indexOf3();
void sprintf();
- void copy();
void fill();
void truncate();
void constructor();
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;
/*
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("");
copt6.init(testWidget);
QStyleOptionToolButton copt7;
copt7.init(testWidget);
- QStyleOptionQ3ListView copt8;
- copt8.init(testWidget);
- copt8.items << QStyleOptionQ3ListViewItem();
QStyleOptionComplex copt9;
copt9.initFrom(testWidget);
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
#ifdef Q_OS_WINCE_WM
if (qobject_cast<QWindowsMobileStyle*>(style) && qt_wince_is_smartphone())
QSKIP("SmartPhone doesn't have scrollbar subcontrols.", SkipAll);
+#else
+ Q_UNUSED(style);
#endif
QScrollBar scrollBar;
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);
#include <QtTest/QtTest>
#include <QtDebug>
#include <QMetaObject>
-#ifdef QT3_SUPPORT
-#include <Q3ProgressBar>
-#endif
#include <private/qstylesheetstyle_p.h>
#include "../platformquirks.h"
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);
{
// 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);
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);
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()
// 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)
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);
#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
{
Q_OBJECT
enum Type {
Qt4Client,
Qt4Server,
-#ifdef QT3_SUPPORT
- Qt3Client,
- Qt3Server
-#endif
};
Test(Type type);
};
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;
}
earlyConstructedSockets->endPoints[1]->close();
}
-void tst_QTcpSocket::earlySocketBytesSent(qint64 bytes)
+void tst_QTcpSocket::earlySocketBytesSent(qint64 /* bytes */)
{
earlyBytesWrittenCount++;
}
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);
void moreToFromUnicode_data();
void moreToFromUnicode();
+
+ void shiftJis();
};
void tst_QTextCodec::toUnicode_data()
QCOMPARE(testData, cStr);
}
+void tst_QTextCodec::shiftJis()
+{
+ QByteArray backslashTilde("\\~");
+ QTextCodec* codec = QTextCodec::codecForName("shift_jis");
+ QString string = codec->toUnicode(backslashTilde);
+ QCOMPARE(string.length(), 2);
+ QCOMPARE(string.at(0), QChar(QLatin1Char('\\')));
+ QCOMPARE(string.at(1), QChar(QLatin1Char('~')));
+
+ QByteArray encoded = codec->fromUnicode(string);
+ QCOMPARE(encoded, backslashTilde);
+}
+
struct DontCrashAtExit {
~DontCrashAtExit() {
QTextCodec *c = QTextCodec::codecForName("utf8");
QTextTableFormat tableFormat;
tableFormat.setPosition(QTextFrameFormat::FloatLeft);
QTextTable *table = cursor.insertTable(50, 1, tableFormat);
+ Q_UNUSED(table);
// Make height of document 2/3 of the table, fitting the table into two pages
QSizeF documentSize = doc->size();
#if defined(Q_OS_SYMBIAN)
# define SRCDIR ""
-#undef QT3_SUPPORT
#endif
void mergeCurrentBlockCharFormat();
void emptyAppend();
void appendOnEmptyDocumentShouldReuseInitialParagraph();
-#ifdef QT3_SUPPORT
- void textSemantics();
-#endif
void cursorPositionChanged();
void setTextCursor();
#ifndef QT_NO_CLIPBOARD
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
QTextFrame *frame = table->insertFrame(1, 6, ffmt);
QTextFrame *childFrame = table->insertFrame(3, 5, ffmt);
+ Q_UNUSED(frame);
+ Q_UNUSED(childFrame);
// used to give a failing assertion
table->remove(2, 5);
+++ /dev/null
-foo
\ No newline at end of file
+++ /dev/null
-foo
-bar
\ No newline at end of file
+++ /dev/null
-cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv
\ No newline at end of file
+++ /dev/null
-foo
\ No newline at end of file
+++ /dev/null
-foo
-bar
\ No newline at end of file
+++ /dev/null
-cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv
\ No newline at end of file
+++ /dev/null
-foo
\ No newline at end of file
+++ /dev/null
-foo
-bar
\ No newline at end of file
+++ /dev/null
-cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv
\ No newline at end of file
+++ /dev/null
-A
\ No newline at end of file
+++ /dev/null
-B
\ No newline at end of file
+++ /dev/null
-Z
\ No newline at end of file
+++ /dev/null
-z
\ No newline at end of file
+++ /dev/null
-@
\ No newline at end of file
+++ /dev/null
-A
\ No newline at end of file
+++ /dev/null
-B
\ No newline at end of file
+++ /dev/null
-Z
\ No newline at end of file
+++ /dev/null
-z
\ No newline at end of file
+++ /dev/null
-@
\ No newline at end of file
+++ /dev/null
-A
\ No newline at end of file
+++ /dev/null
-B
\ No newline at end of file
+++ /dev/null
-Z
\ No newline at end of file
+++ /dev/null
-z
\ No newline at end of file
+++ /dev/null
-@
\ No newline at end of file
+++ /dev/null
-foo
\ No newline at end of file
+++ /dev/null
-foo
-bar
\ No newline at end of file
+++ /dev/null
-cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv
\ No newline at end of file
+++ /dev/null
-foo
\ No newline at end of file
+++ /dev/null
-foo
-bar
\ No newline at end of file
+++ /dev/null
-cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv
\ No newline at end of file
+++ /dev/null
-foo
\ No newline at end of file
+++ /dev/null
-foo
-bar
\ No newline at end of file
+++ /dev/null
-cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv
\ No newline at end of file
+++ /dev/null
-A
\ No newline at end of file
+++ /dev/null
-B
\ No newline at end of file
+++ /dev/null
-Z
\ No newline at end of file
+++ /dev/null
-\ e
\ No newline at end of file
+++ /dev/null
-0
\ No newline at end of file
+++ /dev/null
-A
\ No newline at end of file
+++ /dev/null
-B
\ No newline at end of file
+++ /dev/null
-Z
\ No newline at end of file
+++ /dev/null
-\ e
\ No newline at end of file
+++ /dev/null
-0
\ No newline at end of file
+++ /dev/null
-A
\ No newline at end of file
+++ /dev/null
-B
\ No newline at end of file
+++ /dev/null
-Z
\ No newline at end of file
+++ /dev/null
-\ e
\ No newline at end of file
+++ /dev/null
-0
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 0.0001 B
\ No newline at end of file
+++ /dev/null
- A -0.0001 B
\ No newline at end of file
+++ /dev/null
- A 3.45678 B
\ No newline at end of file
+++ /dev/null
- A -3.45678 B
\ No newline at end of file
+++ /dev/null
- A 1.23456789 B
\ No newline at end of file
+++ /dev/null
- A -1.23456789 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 0.0001 B
\ No newline at end of file
+++ /dev/null
- A -0.0001 B
\ No newline at end of file
+++ /dev/null
- A 3.45678 B
\ No newline at end of file
+++ /dev/null
- A -3.45678 B
\ No newline at end of file
+++ /dev/null
- A 1.23456789 B
\ No newline at end of file
+++ /dev/null
- A -1.23456789 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 0.0001 B
\ No newline at end of file
+++ /dev/null
- A -0.0001 B
\ No newline at end of file
+++ /dev/null
- A 3.45678 B
\ No newline at end of file
+++ /dev/null
- A -3.45678 B
\ No newline at end of file
+++ /dev/null
- A 1.23456789 B
\ No newline at end of file
+++ /dev/null
- A -1.23456789 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 0.0001 B
\ No newline at end of file
+++ /dev/null
- A -0.0001 B
\ No newline at end of file
+++ /dev/null
- A 3.45678 B
\ No newline at end of file
+++ /dev/null
- A -3.45678 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 0.0001 B
\ No newline at end of file
+++ /dev/null
- A -0.0001 B
\ No newline at end of file
+++ /dev/null
- A 3.45678 B
\ No newline at end of file
+++ /dev/null
- A -3.45678 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 0.0001 B
\ No newline at end of file
+++ /dev/null
- A -0.0001 B
\ No newline at end of file
+++ /dev/null
- A 3.45678 B
\ No newline at end of file
+++ /dev/null
- A -3.45678 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A -10 B
\ No newline at end of file
+++ /dev/null
- A -255 B
\ No newline at end of file
+++ /dev/null
- A -512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A -10 B
\ No newline at end of file
+++ /dev/null
- A -255 B
\ No newline at end of file
+++ /dev/null
- A -512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A -10 B
\ No newline at end of file
+++ /dev/null
- A -255 B
\ No newline at end of file
+++ /dev/null
- A -512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 65535 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A -10 B
\ No newline at end of file
+++ /dev/null
- A -255 B
\ No newline at end of file
+++ /dev/null
- A -65534 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 65535 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A -10 B
\ No newline at end of file
+++ /dev/null
- A -255 B
\ No newline at end of file
+++ /dev/null
- A -65534 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 65535 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A -10 B
\ No newline at end of file
+++ /dev/null
- A -255 B
\ No newline at end of file
+++ /dev/null
- A -65534 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A -254 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A -254 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A -254 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 65535 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 65535 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 65535 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
-foo
\ No newline at end of file
+++ /dev/null
-foo
-bar
\ No newline at end of file
+++ /dev/null
-cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv
\ No newline at end of file
+++ /dev/null
-foo
\ No newline at end of file
+++ /dev/null
-foo
-bar
\ No newline at end of file
+++ /dev/null
-cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv
\ No newline at end of file
+++ /dev/null
-foo
\ No newline at end of file
+++ /dev/null
-foo
-bar
\ No newline at end of file
+++ /dev/null
-cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv
\ No newline at end of file
+++ /dev/null
-A
\ No newline at end of file
+++ /dev/null
-B
\ No newline at end of file
+++ /dev/null
-Z
\ No newline at end of file
+++ /dev/null
-z
\ No newline at end of file
+++ /dev/null
-@
\ No newline at end of file
+++ /dev/null
-A
\ No newline at end of file
+++ /dev/null
-B
\ No newline at end of file
+++ /dev/null
-Z
\ No newline at end of file
+++ /dev/null
-z
\ No newline at end of file
+++ /dev/null
-@
\ No newline at end of file
+++ /dev/null
-A
\ No newline at end of file
+++ /dev/null
-B
\ No newline at end of file
+++ /dev/null
-Z
\ No newline at end of file
+++ /dev/null
-z
\ No newline at end of file
+++ /dev/null
-@
\ No newline at end of file
+++ /dev/null
-foo
\ No newline at end of file
+++ /dev/null
-foo
-bar
\ No newline at end of file
+++ /dev/null
-cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv
\ No newline at end of file
+++ /dev/null
-foo
\ No newline at end of file
+++ /dev/null
-foo
-bar
\ No newline at end of file
+++ /dev/null
-cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv
\ No newline at end of file
+++ /dev/null
-foo
\ No newline at end of file
+++ /dev/null
-foo
-bar
\ No newline at end of file
+++ /dev/null
-cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv
\ No newline at end of file
+++ /dev/null
-A
\ No newline at end of file
+++ /dev/null
-B
\ No newline at end of file
+++ /dev/null
-Z
\ No newline at end of file
+++ /dev/null
-\ e
\ No newline at end of file
+++ /dev/null
-0
\ No newline at end of file
+++ /dev/null
-A
\ No newline at end of file
+++ /dev/null
-B
\ No newline at end of file
+++ /dev/null
-Z
\ No newline at end of file
+++ /dev/null
-\ e
\ No newline at end of file
+++ /dev/null
-0
\ No newline at end of file
+++ /dev/null
-A
\ No newline at end of file
+++ /dev/null
-B
\ No newline at end of file
+++ /dev/null
-Z
\ No newline at end of file
+++ /dev/null
-\ e
\ No newline at end of file
+++ /dev/null
-0
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 0.0001 B
\ No newline at end of file
+++ /dev/null
- A -0.0001 B
\ No newline at end of file
+++ /dev/null
- A 3.45678 B
\ No newline at end of file
+++ /dev/null
- A -3.45678 B
\ No newline at end of file
+++ /dev/null
- A 1.23456789 B
\ No newline at end of file
+++ /dev/null
- A -1.23456789 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 0.0001 B
\ No newline at end of file
+++ /dev/null
- A -0.0001 B
\ No newline at end of file
+++ /dev/null
- A 3.45678 B
\ No newline at end of file
+++ /dev/null
- A -3.45678 B
\ No newline at end of file
+++ /dev/null
- A 1.23456789 B
\ No newline at end of file
+++ /dev/null
- A -1.23456789 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 0.0001 B
\ No newline at end of file
+++ /dev/null
- A -0.0001 B
\ No newline at end of file
+++ /dev/null
- A 3.45678 B
\ No newline at end of file
+++ /dev/null
- A -3.45678 B
\ No newline at end of file
+++ /dev/null
- A 1.23456789 B
\ No newline at end of file
+++ /dev/null
- A -1.23456789 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 0.0001 B
\ No newline at end of file
+++ /dev/null
- A -0.0001 B
\ No newline at end of file
+++ /dev/null
- A 3.45678 B
\ No newline at end of file
+++ /dev/null
- A -3.45678 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 0.0001 B
\ No newline at end of file
+++ /dev/null
- A -0.0001 B
\ No newline at end of file
+++ /dev/null
- A 3.45678 B
\ No newline at end of file
+++ /dev/null
- A -3.45678 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 0.0001 B
\ No newline at end of file
+++ /dev/null
- A -0.0001 B
\ No newline at end of file
+++ /dev/null
- A 3.45678 B
\ No newline at end of file
+++ /dev/null
- A -3.45678 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A -10 B
\ No newline at end of file
+++ /dev/null
- A -255 B
\ No newline at end of file
+++ /dev/null
- A -512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A -10 B
\ No newline at end of file
+++ /dev/null
- A -255 B
\ No newline at end of file
+++ /dev/null
- A -512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A -10 B
\ No newline at end of file
+++ /dev/null
- A -255 B
\ No newline at end of file
+++ /dev/null
- A -512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 65535 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A -10 B
\ No newline at end of file
+++ /dev/null
- A -255 B
\ No newline at end of file
+++ /dev/null
- A -65534 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 65535 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A -10 B
\ No newline at end of file
+++ /dev/null
- A -255 B
\ No newline at end of file
+++ /dev/null
- A -65534 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 65535 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A -10 B
\ No newline at end of file
+++ /dev/null
- A -255 B
\ No newline at end of file
+++ /dev/null
- A -65534 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A -254 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A -254 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A -1 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A -254 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 65535 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 65535 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 65535 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
+++ /dev/null
- A 0 B
\ No newline at end of file
+++ /dev/null
- A 1 B
\ No newline at end of file
+++ /dev/null
- A 10 B
\ No newline at end of file
+++ /dev/null
- A 255 B
\ No newline at end of file
+++ /dev/null
- A 512 B
\ No newline at end of file
void generateBOM();
void readBomSeekBackReadBomAgain();
- // old tests
-#ifdef QT3_SUPPORT
- void qt3_operator_shiftleft_data();
- void qt3_operator_shiftleft();
- void qt3_operator_shiftright_data();
- void qt3_operator_shiftright();
- void qt3_operator_shift_QChar_data();
- void qt3_operator_shift_QChar();
- void qt3_operator_shift_char_data();
- void qt3_operator_shift_char();
- void qt3_operator_shift_short_data();
- void qt3_operator_shift_short();
- void qt3_operator_shift_ushort_data();
- void qt3_operator_shift_ushort();
- void qt3_operator_shift_int_data();
- void qt3_operator_shift_int();
- void qt3_operator_shift_uint_data();
- void qt3_operator_shift_uint();
- void qt3_operator_shift_long_data();
- void qt3_operator_shift_long();
- void qt3_operator_shift_ulong_data();
- void qt3_operator_shift_ulong();
- void qt3_operator_shift_float_data();
- void qt3_operator_shift_float();
- void qt3_operator_shift_double_data();
- void qt3_operator_shift_double();
- void qt3_operator_shift_QString_data();
- void qt3_operator_shift_QString();
- void qt3_operator_shift_QByteArray_data();
- void qt3_operator_shift_QByteArray();
-
- void qt3_writeDataToFileReadAsLines_data();
- void qt3_writeDataToFileReadAsLines();
- void qt3_writeDataToQStringReadAsLines_data();
- void qt3_writeDataToQStringReadAsLines();
-
- void qt3_readLineFromString();
-#endif
-
// task-specific tests
void task180679_alignAccountingStyle();
void task178772_setCodec();
void generateRealNumbersData(bool for_QString);
void generateStringData(bool for_QString);
void generateRealNumbersDataWrite();
-
- // Qt 3 privates
-#ifdef QT3_SUPPORT
- void qt3_createWriteStream( QTextStream *&os );
- void qt3_closeWriteStream( QTextStream *os );
- void qt3_createReadStream( QTextStream *&is );
- void qt3_closeReadStream( QTextStream *is );
- void qt3_read_QChar( QTextStream *s );
- void qt3_write_QChar( QTextStream *s );
- void qt3_read_char( QTextStream *s );
- void qt3_write_char( QTextStream *s );
- void qt3_read_short( QTextStream *s );
- void qt3_write_short( QTextStream *s );
- void qt3_read_ushort( QTextStream *s );
- void qt3_write_ushort( QTextStream *s );
- void qt3_read_int( QTextStream *s );
- void qt3_write_int( QTextStream *s );
- void qt3_read_uint( QTextStream *s );
- void qt3_write_uint( QTextStream *s );
- void qt3_read_long( QTextStream *s );
- void qt3_write_long( QTextStream *s );
- void qt3_read_ulong( QTextStream *s );
- void qt3_write_ulong( QTextStream *s );
- void qt3_read_float( QTextStream *s );
- void qt3_write_float( QTextStream *s );
- void qt3_read_double( QTextStream *s );
- void qt3_write_double( QTextStream *s );
- void qt3_read_QString( QTextStream *s );
- void qt3_write_QString( QTextStream *s );
- void qt3_read_QByteArray( QTextStream *s );
- void qt3_write_QByteArray( QTextStream *s );
- void qt3_operatorShift_data( QIODevice::OpenMode );
- void qt3_do_shiftleft( QTextStream *ts );
- QTextStream::Encoding qt3_toEncoding( const QString& );
- QString qt3_decodeString( QByteArray array, const QString& encoding );
-#endif
-
- // Qt 3 data
- QTextStream *os;
- QTextStream *is;
- QTextStream *ts;
- QFile *inFile;
- QFile *inResource;
- QFile *outFile;
- QByteArray *inArray;
- QBuffer *inBuffer;
- QString *inString;
- bool file_is_empty;
};
// Testing get/set functions
tst_QTextStream::tst_QTextStream()
{
- // Initialize Qt 3 data
- ts = 0;
- os = 0;
- is = 0;
- outFile = 0;
- inFile = 0;
- inResource = 0;
- inArray = 0;
- inBuffer = 0;
- inString = 0;
- file_is_empty = FALSE;
-
Q_SET_DEFAULT_IAP
}
void tst_QTextStream::init()
{
- // Initialize Qt 3 data
- ts = 0;
- os = 0;
- is = 0;
- inFile = 0;
- inResource = 0;
- outFile = 0;
- inArray = 0;
- inBuffer = 0;
- inString = 0;
- file_is_empty = FALSE;
}
void tst_QTextStream::cleanup()
{
- // Clean up Qt 3 data
- delete ts;
- ts = 0;
- delete os;
- os = 0;
- delete is;
- is = 0;
- delete inResource;
- inResource = 0;
- delete inFile;
- inFile = 0;
- delete outFile;
- outFile = 0;
- delete inArray;
- inArray = 0;
- delete inBuffer;
- inBuffer = 0;
- delete inString;
- inString = 0;
-
QCoreApplication::instance()->processEvents();
}
QFile::remove("utf8bom");
QFile file("utf8bom");
QVERIFY(file.open(QFile::ReadWrite));
- file.write("\xef\xbb\xbf""Andreas");
+ file.write("\xef\xbb\xbf" "Andreas");
file.seek(0);
QCOMPARE(file.pos(), qint64(0));
}
// ------------------------------------------------------------------------------
-// QT 3 tests
-// ------------------------------------------------------------------------------
-#ifdef QT3_SUPPORT
-
-void tst_QTextStream::qt3_readLineFromString()
-{
- QString data = "line 1e\nline 2e\nline 3e";
- QStringList list;
- QTextStream stream(&data, QIODevice::ReadOnly);
- stream.setCodec(QTextCodec::codecForName("ISO-8859-1"));
- stream.setAutoDetectUnicode(true);
-
- while (!stream.atEnd()) {
- QString line = stream.readLine();
- QCOMPARE(QChar(line[line.size()-1]), QChar('e'));
- list << line;
- }
- QVERIFY(list.count() == 3);
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shiftright_data()
-{
- qt3_operatorShift_data( QIODevice::ReadOnly );
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shiftleft_data()
-{
- qt3_operatorShift_data( QIODevice::WriteOnly );
-}
-
-static const double doubleDummy = 567.89;
-static const int intDummy = 1234;
-static const QString stringDummy = "ABCD";
-
-struct tst_IODevice {
- char *n;
- QIODevice::OpenModeFlag modes;
- QString name() const { return QString::fromLatin1(n); }
-} devices[] = {
- { "file", QIODevice::ReadWrite },
- { "bytearray", QIODevice::ReadWrite },
- { "buffer", QIODevice::ReadWrite },
- { "string", QIODevice::ReadWrite },
- { "resource", QIODevice::ReadOnly }, //See discussion (resources) below
- { 0, (QIODevice::OpenModeFlag)0 }
-};
-
-/* Resources:
-
- This will test QTextStream's ability to interact with resources,
- however the trouble is the resources must be created correctly and
- built into the executable (but this executable also creates the
- resource files). So there is a chicken and egg problem, to create
- resources (if the file formats change at all):
-
- 1) p4 edit resources/...
-
- 2) Change QIODevice::ReadOnly above in the devices[] for "resource"
- to QIODevice::WriteOnly
-
- 3) run the test
-
- 4) revert this file, qmake, make, and run again.
-
- 5) Enjoy.
-*/
-
-static inline QString resourceDir()
-{
- QString ret = "resources/";
- if(QSysInfo::ByteOrder == QSysInfo::BigEndian)
- ret += "big_endian/";
- else
- ret += "little_endian/";
- return ret;
-}
-
-static const char *const encodings[] = {
- "Locale",
- "Latin1",
- "Unicode",
- "UnicodeNetworkOrder",
- "UnicodeReverse",
- "RawUnicode",
- "UnicodeUTF8",
- 0
-};
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operatorShift_data( QIODevice::OpenMode mode )
-{
- QTest::addColumn<QString>("device");
- QTest::addColumn<QString>("encoding");
- QTest::addColumn<QString>("type");
- QTest::addColumn<double>("doubleVal");
- QTest::addColumn<int>("intVal");
- QTest::addColumn<QString>("stringVal");
- QTest::addColumn<QByteArray>("encoded");
-
- for ( int i=0; !devices[i].name().isNull(); i++ ) {
- tst_IODevice *device = devices+i;
- if(!(device->modes & mode))
- continue;
-
- /*
- We first test each type at least once.
- */
- QTest::newRow( device->name() + "0" ) << device->name() << QString("UnicodeUTF8") << QString("QChar")
- << doubleDummy << (int) 'Z' << stringDummy
- << QByteArray( QByteArray("Z") );
- QTest::newRow( device->name() + "1" ) << device->name() << QString("UnicodeUTF8") << QString("char")
- << doubleDummy << (int) 'Z' << stringDummy
- << QByteArray( QByteArray("Z") );
- QTest::newRow( device->name() + "2" ) << device->name() << QString("UnicodeUTF8") << QString("signed short")
- << doubleDummy << 12345 << stringDummy
- << QByteArray( QByteArray("12345") );
- QTest::newRow( device->name() + "3" ) << device->name() << QString("UnicodeUTF8") << QString("unsigned short")
- << doubleDummy << 12345 << stringDummy
- << QByteArray( QByteArray("12345") );
- QTest::newRow( device->name() + "4" ) << device->name() << QString("UnicodeUTF8") << QString("signed int")
- << doubleDummy << 12345 << stringDummy
- << QByteArray( QByteArray("12345") );
- QTest::newRow( device->name() + "5" ) << device->name() << QString("UnicodeUTF8") << QString("unsigned int")
- << doubleDummy << 12345 << stringDummy
- << QByteArray( QByteArray("12345") );
- QTest::newRow( device->name() + "6" ) << device->name() << QString("UnicodeUTF8") << QString("signed long")
- << doubleDummy << 12345 << stringDummy
- << QByteArray( QByteArray("12345") );
- QTest::newRow( device->name() + "7" ) << device->name() << QString("UnicodeUTF8") << QString("unsigned long")
- << doubleDummy << 12345 << stringDummy
- << QByteArray( QByteArray("12345") );
- QTest::newRow( device->name() + "8" ) << device->name() << QString("UnicodeUTF8") << QString("float")
- << (double)3.1415f << intDummy << stringDummy
- << QByteArray( QByteArray("3.1415") );
- QTest::newRow( device->name() + "9" ) << device->name() << QString("UnicodeUTF8") << QString("double")
- << 3.1415 << intDummy << stringDummy
- << QByteArray( QByteArray("3.1415") );
- QTest::newRow( device->name() + "10" ) << device->name() << QString("UnicodeUTF8") << QString("char *")
- << doubleDummy << intDummy << QString("I-am-a-string")
- << QByteArray( QByteArray("I-am-a-string") );
- QTest::newRow( device->name() + "11" ) << device->name() << QString("UnicodeUTF8") << QString("QString")
- << doubleDummy << intDummy << QString("I-am-a-string")
- << QByteArray( QByteArray("I-am-a-string") );
- QTest::newRow( device->name() + "12" ) << device->name() << QString("UnicodeUTF8") << QString("QByteArray")
- << doubleDummy << intDummy << QString("I-am-a-string")
- << QByteArray( QByteArray("I-am-a-string") );
-
- /*
- Then we test some special cases that have caused problems in the past.
- */
- QTest::newRow( device->name() + "20" ) << device->name() << QString("UnicodeUTF8") << QString("QChar")
- << doubleDummy << 0xff8c << stringDummy
- << QByteArray( QByteArray("\xef\xbe\x8c") );
- QTest::newRow( device->name() + "21" ) << device->name() << QString("UnicodeUTF8") << QString("QChar")
- << doubleDummy << 0x8cff << stringDummy
- << QByteArray( QByteArray("\xe8\xb3\xbf") );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_do_shiftleft( QTextStream *ts )
-{
- QFETCH( QString, encoding );
- QFETCH( QString, type );
- QFETCH( double, doubleVal );
- QFETCH( int, intVal );
- QFETCH( QString, stringVal );
-
- ts->setEncoding( qt3_toEncoding(encoding) );
-
- if ( type == "QChar" ) {
- if ( intVal >= 0 && intVal <= 0xffff )
- *ts << QChar( intVal );
- } else if ( type == "char" ) {
- *ts << (char) intVal;
- } else if ( type == "signed short" ) {
- *ts << (signed short) intVal;
- } else if ( type == "unsigned short" ) {
- *ts << (unsigned short) intVal;
- } else if ( type == "signed int" ) {
- *ts << (signed int) intVal;
- } else if ( type == "unsigned int" ) {
- *ts << (unsigned int) intVal;
- } else if ( type == "signed long" ) {
- *ts << (signed long) intVal;
- } else if ( type == "unsigned long" ) {
- *ts << (unsigned long) intVal;
- } else if ( type == "float" ) {
- *ts << (float) doubleVal;
- } else if ( type == "double" ) {
- *ts << (double) doubleVal;
- } else if ( type == "char *" ) {
- *ts << stringVal.latin1();
- } else if ( type == "QString" ) {
- *ts << stringVal;
- } else if ( type == "QByteArray" ) {
- *ts << QByteArray( stringVal.latin1() );
- } else {
- QWARN( "Unknown type: %s" + type );
- }
-
- ts->flush();
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shiftleft()
-{
- QFETCH( QString, device );
- QFETCH( QString, encoding );
- QFETCH( QByteArray, encoded );
-
- if ( device == "file" ) {
- QFile outFile( "qtextstream.out" );
- QVERIFY( outFile.open( QIODevice::WriteOnly ) );
- QTextStream ts( &outFile );
-
- qt3_do_shiftleft( &ts );
- outFile.close();
-
- QFile inFile( "qtextstream.out" );
- QVERIFY( inFile.open( QIODevice::ReadOnly ) );
- QCOMPARE( inFile.readAll().constData(), encoded.constData() );
- } else if(device == "resource" ) { //ONLY TO CREATE THE RESOURCE!! NOT A TEST!
- QFile outFile( resourceDir() + "operator_shiftright_" + QTest::currentDataTag() + ".data" );
- QVERIFY( outFile.open( QIODevice::WriteOnly ) );
- QTextStream ts( &outFile );
- qt3_do_shiftleft( &ts );
- outFile.close();
- } else if ( device == "bytearray" ) {
- QByteArray outArray;
- QTextStream ts(&outArray, QIODevice::WriteOnly );
-
- qt3_do_shiftleft( &ts );
-
- QVERIFY( outArray == encoded );
- } else if ( device == "buffer" ) {
- QByteArray outArray;
- QBuffer outBuffer(&outArray);
- QVERIFY( outBuffer.open(QIODevice::WriteOnly) );
- QTextStream ts( &outBuffer );
-
- qt3_do_shiftleft( &ts );
-
- QCOMPARE( outArray, encoded );
- } else if ( device == "string" ) {
- QString outString;
- QTextStream ts( &outString, QIODevice::WriteOnly );
-
- qt3_do_shiftleft( &ts );
-
- QString decodedString = qt3_decodeString( encoded, encoding );
- QCOMPARE( outString, decodedString );
- } else {
- QWARN( "Unknown device type: " + device );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shiftright()
-{
- QFETCH( QString, device );
- QFETCH( QString, encoding );
- QFETCH( QString, type );
- QFETCH( double, doubleVal );
- QFETCH( int, intVal );
- QFETCH( QString, stringVal );
- QFETCH( QByteArray, encoded );
-
- if ( device == "file" ) {
- QFile outFile( "qtextstream.out" );
- QVERIFY( outFile.open( QIODevice::WriteOnly ) );
- QVERIFY( (int) outFile.write(encoded) == (int) encoded.size() );
- outFile.close();
-
- inFile = new QFile( "qtextstream.out" );
- QVERIFY( inFile->open( QIODevice::ReadOnly ) );
- ts = new QTextStream( inFile );
- } else if(device == "resource" ) {
- inResource = new QFile( ":/tst_textstream/" + resourceDir() + "operator_shiftright_" + QTest::currentDataTag() + ".data" );
- QVERIFY( inResource->open( QIODevice::ReadOnly ) );
- ts = new QTextStream( inResource );
- } else if ( device == "bytearray" ) {
- ts = new QTextStream(&encoded, QIODevice::ReadOnly);
- } else if ( device == "buffer" ) {
- inBuffer = new QBuffer(&encoded);
- QVERIFY( inBuffer->open(QIODevice::ReadOnly) );
- ts = new QTextStream( inBuffer );
- } else if ( device == "string" ) {
- inString = new QString( qt3_decodeString(encoded, encoding) );
- ts = new QTextStream(inString, QIODevice::ReadOnly);
- } else {
- QWARN( "Unknown device type: " + device );
- }
-
- ts->setEncoding( qt3_toEncoding(encoding) );
-
- if ( type == "QChar" ) {
- QChar c;
- if ( intVal >= 0 && intVal <= 0xffff )
- *ts >> c;
- QCOMPARE( c.toLatin1(), QChar(intVal).toLatin1() );
- } else if ( type == "char" ) {
- char c;
- *ts >> c;
- QCOMPARE( c, (char) intVal );
- } else if ( type == "signed short" ) {
- signed short h;
- *ts >> h;
- QCOMPARE( h, (signed short) intVal );
- } else if ( type == "unsigned short" ) {
- unsigned short h;
- *ts >> h;
- QCOMPARE( h, (unsigned short) intVal );
- } else if ( type == "signed int" ) {
- signed int i;
- *ts >> i;
- QCOMPARE( i, (signed int) intVal );
- } else if ( type == "unsigned int" ) {
- unsigned int i;
- *ts >> i;
- QCOMPARE( i, (unsigned int) intVal );
- } else if ( type == "signed long" ) {
- signed long ell;
- *ts >> ell;
- QCOMPARE( ell, (signed long) intVal );
- } else if ( type == "unsigned long" ) {
- unsigned long ell;
- *ts >> ell;
- QCOMPARE( ell, (unsigned long) intVal );
- } else if ( type == "float" ) {
- float f;
- *ts >> f;
- QCOMPARE( f, (float) doubleVal );
- } else if ( type == "double" ) {
- double d;
- *ts >> d;
- QCOMPARE( d, (double) doubleVal );
- } else if ( type == "char *" ) {
- char *cp = new char[2048];
- *ts >> cp;
- QVERIFY( qstrcmp(cp, stringVal.latin1()) == 0 );
- delete[] cp;
- } else if ( type == "QString" ) {
- QString s;
- *ts >> s;
- QCOMPARE( s, stringVal );
- } else if ( type == "QByteArray" ) {
- QByteArray s;
- *ts >> s;
- QCOMPARE( QString::fromLatin1(s), stringVal );
- } else {
- QWARN( "Unknown type: %s" + type );
- }
-}
-
-// ------------------------------------------------------------------------------
-QTextStream::Encoding tst_QTextStream::qt3_toEncoding( const QString &str )
-{
- if ( str == "Locale" )
- return QTextStream::Locale;
- else if ( str == "Latin1" )
- return QTextStream::Latin1;
- else if ( str == "Unicode" )
- return QTextStream::Unicode;
- else if ( str == "UnicodeNetworkOrder" )
- return QTextStream::UnicodeNetworkOrder;
- else if ( str == "UnicodeReverse" )
- return QTextStream::UnicodeReverse;
- else if ( str == "RawUnicode" )
- return QTextStream::RawUnicode;
- else if ( str == "UnicodeUTF8" )
- return QTextStream::UnicodeUTF8;
-
- QWARN( "No such encoding " + str );
- return QTextStream::Latin1;
-}
-
-// ------------------------------------------------------------------------------
-QString tst_QTextStream::qt3_decodeString( QByteArray array, const QString& encoding )
-{
- switch ( qt3_toEncoding(encoding) ) {
- case QTextStream::Locale:
- return QString::fromLocal8Bit( array.data(), array.size() );
- case QTextStream::Latin1:
- return QString::fromLatin1( array.data(), array.size() );
- case QTextStream::Unicode:
- case QTextStream::UnicodeNetworkOrder:
- case QTextStream::UnicodeReverse:
- case QTextStream::RawUnicode:
- QWARN( "Unicode not implemented ###" );
- return QString();
- case QTextStream::UnicodeUTF8:
- return QString::fromUtf8( array.data(), array.size() );
- default:
- QWARN( "Unhandled encoding" );
- return QString();
- }
-}
-
-// ************************************************
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_createWriteStream( QTextStream *&os )
-{
- QFETCH( QString, device );
-
- if ( device == "file" ) {
- outFile = new QFile( "qtextstream.out" );
- QVERIFY( outFile->open( QIODevice::WriteOnly ) );
- os = new QTextStream( outFile );
- os->setCodec(QTextCodec::codecForName("ISO-8859-1"));
- os->setAutoDetectUnicode(true);
- } else if(device == "resource" ) { //ONLY TO CREATE THE RESOURCE!! NOT A TEST!
- outFile = new QFile( resourceDir() +
- QTest::currentTestFunction() +
- "_" + QTest::currentDataTag() + ".data" );
- QVERIFY( outFile->open( QIODevice::WriteOnly ) );
- os = new QTextStream( outFile );
- os->setCodec(QTextCodec::codecForName("ISO-8859-1"));
- os->setAutoDetectUnicode(true);
- } else if ( device == "bytearray" ) {
- inArray = new QByteArray;
- os = new QTextStream(inArray, QIODevice::WriteOnly);
- os->setCodec(QTextCodec::codecForName("ISO-8859-1"));
- os->setAutoDetectUnicode(true);
- } else if ( device == "buffer" ) {
- inBuffer = new QBuffer;
- QVERIFY( inBuffer->open(QIODevice::WriteOnly) );
- os = new QTextStream( inBuffer );
- os->setCodec(QTextCodec::codecForName("ISO-8859-1"));
- os->setAutoDetectUnicode(true);
- } else if ( device == "string" ) {
- inString = new QString;
- os = new QTextStream( inString, QIODevice::WriteOnly );
- os->setCodec(QTextCodec::codecForName("ISO-8859-1"));
- os->setAutoDetectUnicode(true);
- } else {
- QWARN( "Error creating write stream: Unknown device type '" + device + "'" );
- }
-
- QFETCH( QString, encoding );
- os->setEncoding( qt3_toEncoding( encoding ));
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_closeWriteStream( QTextStream *os )
-{
- QFETCH( QString, device );
-
- os->flush();
- if ( os->device() )
- os->device()->close();
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_createReadStream( QTextStream *&is )
-{
- QFETCH( QString, device );
-
- if ( device == "file" ) {
- inFile = new QFile( "qtextstream.out" );
- is = new QTextStream( inFile );
- is->setCodec(QTextCodec::codecForName("ISO-8859-1"));
- is->setAutoDetectUnicode(true);
- QVERIFY( inFile->open( QIODevice::ReadOnly ) );
- } else if(device == "resource") {
- inResource = new QFile( ":/tst_textstream/" + resourceDir() +
- QTest::currentTestFunction() +
- "_" + QTest::currentDataTag() + ".data" );
- is = new QTextStream( inResource );
- is->setCodec(QTextCodec::codecForName("ISO-8859-1"));
- is->setAutoDetectUnicode(true);
- QVERIFY( inResource->open( QIODevice::ReadOnly ) );
- } else if ( device == "bytearray" ) {
- is = new QTextStream(inArray, QIODevice::ReadOnly);
- is->setCodec(QTextCodec::codecForName("ISO-8859-1"));
- is->setAutoDetectUnicode(true);
- } else if ( device == "buffer" ) {
- QVERIFY( inBuffer->open(QIODevice::ReadOnly) );
- is = new QTextStream( inBuffer );
- is->setCodec(QTextCodec::codecForName("ISO-8859-1"));
- is->setAutoDetectUnicode(true);
- } else if ( device == "string" ) {
- is = new QTextStream( inString, QIODevice::ReadOnly );
- is->setCodec(QTextCodec::codecForName("ISO-8859-1"));
- is->setAutoDetectUnicode(true);
- } else {
- QWARN( "Error creating read stream: Unknown device type '" + device + "'" );
- }
-
- QFETCH( QString, encoding );
- is->setEncoding( qt3_toEncoding( encoding ));
-
- if (!file_is_empty) {
- QVERIFY( !is->atEnd() );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_closeReadStream( QTextStream *is )
-{
- QVERIFY( is->atEnd() );
-
- if ( is->device() )
- is->device()->close();
-}
-
-// **************** QChar ****************
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_QChar_data()
-{
- QTest::addColumn<int>("modes");
- QTest::addColumn<QString>("device");
- QTest::addColumn<QString>("encoding");
- QTest::addColumn<ushort>("qchar");
-
- for ( int i=0; !devices[i].name().isNull(); i++ ) {
- tst_IODevice *device = devices+i;
- for ( int e=0; encodings[e] != 0; e++ ) {
- QString encoding = encodings[e];
-
- QString tag = device->name() + "_" + encoding + "_";
- QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << QChar( 'A' ).unicode();
- QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << QChar( 'B' ).unicode();
- QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << QChar( 'Z' ).unicode();
- QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << QChar( 'z' ).unicode();
- QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << QChar( '@' ).unicode();
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_QChar()
-{
- QFETCH( int, modes );
- if(modes & QIODevice::WriteOnly) {
- qt3_createWriteStream( os );
- qt3_write_QChar( os );
- qt3_closeWriteStream( os );
- }
- if(modes & QIODevice::ReadOnly) {
- qt3_createReadStream( is );
- qt3_read_QChar( is );
- qt3_closeReadStream( is );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_read_QChar( QTextStream *s )
-{
- QFETCH( ushort, qchar );
- QChar expected( qchar );
- QChar actual;
- *s >> actual;
- QCOMPARE( actual, expected );
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_write_QChar( QTextStream *s )
-{
- QFETCH( ushort, qchar );
- QChar actual( qchar );
- *s << actual;
-}
-
-// **************** char ****************
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_char_data()
-{
- QTest::addColumn<int>("modes");
- QTest::addColumn<QString>("device");
- QTest::addColumn<QString>("encoding");
- QTest::addColumn<int>("ch");
-
- for ( int i=0; !devices[i].name().isNull(); i++ ) {
- tst_IODevice *device = devices+i;
- for ( int e=0; encodings[e] != 0; e++ ) {
- QString encoding = encodings[e];
-
- QString tag = device->name() + "_" + encoding + "_";
- QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << int('A');
- QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << int('B');
- QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << int('Z');
- QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << int(14);
- QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << int('0');
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_char()
-{
- QFETCH( int, modes );
- if(modes & QIODevice::WriteOnly) {
- qt3_createWriteStream( os );
- qt3_write_char( os );
- qt3_closeWriteStream( os );
- }
- if(modes & QIODevice::ReadOnly) {
- qt3_createReadStream( is );
- qt3_read_char( is );
- qt3_closeReadStream( is );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_read_char( QTextStream *s )
-{
- QFETCH( int, ch );
- char c(ch);
- char exp;
- *s >> exp;
- QCOMPARE( exp, c );
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_write_char( QTextStream *s )
-{
- QFETCH( int, ch );
- char c(ch);
- *s << c;
-}
-
-// **************** short ****************
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_short_data()
-{
- QTest::addColumn<int>("modes");
- QTest::addColumn<QString>("device");
- QTest::addColumn<QString>("encoding");
- QTest::addColumn<short>("ss");
-
- for ( int i=0; !devices[i].name().isNull(); i++ ) {
- tst_IODevice *device = devices+i;
- for ( int e=0; encodings[e] != 0; e++ ) {
- QString encoding = encodings[e];
-
- QString tag = device->name() + "_" + encoding + "_";
- QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << short(0);
- QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << short(-1);
- QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << short(1);
- QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << short(255);
- QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << short(-254);
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_short()
-{
- QFETCH( int, modes );
- if(modes & QIODevice::WriteOnly) {
- qt3_createWriteStream( os );
- qt3_write_short( os );
- qt3_closeWriteStream( os );
- }
- if(modes & QIODevice::ReadOnly) {
- qt3_createReadStream( is );
- qt3_read_short( is );
- qt3_closeReadStream( is );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_read_short( QTextStream *s )
-{
- QFETCH( short, ss );
- short exp;
- QString A, B;
- *s >> A >> exp >> B;
- QCOMPARE( A, QString("A") );
- QCOMPARE( B, QString("B") );
- QCOMPARE( exp, ss );
- s->skipWhiteSpace();
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_write_short( QTextStream *s )
-{
- QFETCH( short, ss );
- *s << " A " << ss << " B ";
-}
-
-// **************** ushort ****************
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_ushort_data()
-{
- QTest::addColumn<int>("modes");
- QTest::addColumn<QString>("device");
- QTest::addColumn<QString>("encoding");
- QTest::addColumn<ushort>("us");
-
- for ( int i=0; !devices[i].name().isNull(); i++ ) {
- tst_IODevice *device = devices+i;
- for ( int e=0; encodings[e] != 0; e++ ) {
- QString encoding = encodings[e];
-
- QString tag = device->name() + "_" + encoding + "_";
- QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << ushort(0);
- QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << ushort(1);
- QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << ushort(10);
- QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << ushort(255);
- QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << ushort(512);
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_ushort()
-{
- QFETCH( int, modes );
- if(modes & QIODevice::WriteOnly) {
- qt3_createWriteStream( os );
- qt3_write_ushort( os );
- qt3_closeWriteStream( os );
- }
- if(modes & QIODevice::ReadOnly) {
- qt3_createReadStream( is );
- qt3_read_ushort( is );
- qt3_closeReadStream( is );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_read_ushort( QTextStream *s )
-{
- QFETCH( ushort, us );
- ushort exp;
- QString A, B;
- *s >> A >> exp >> B;
- QCOMPARE( A, QString("A") );
- QCOMPARE( B, QString("B") );
- QCOMPARE( exp, us );
- s->skipWhiteSpace();
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_write_ushort( QTextStream *s )
-{
- QFETCH( ushort, us );
- *s << " A " << us << " B ";
-}
-
-// **************** int ****************
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_int_data()
-{
- QTest::addColumn<int>("modes");
- QTest::addColumn<QString>("device");
- QTest::addColumn<QString>("encoding");
- QTest::addColumn<int>("si");
-
- for ( int i=0; !devices[i].name().isNull(); i++ ) {
- tst_IODevice *device = devices+i;
- for ( int e=0; encodings[e] != 0; e++ ) {
- QString encoding = encodings[e];
-
- QString tag = device->name() + "_" + encoding + "_";
- QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << int(0);
- QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << int(1);
- QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << int(10);
- QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << int(255);
- QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << int(512);
- QTest::newRow( tag + "5" ) << device->modes << device->name() << encoding << int(-1);
- QTest::newRow( tag + "6" ) << device->modes << device->name() << encoding << int(-10);
- QTest::newRow( tag + "7" ) << device->modes << device->name() << encoding << int(-255);
- QTest::newRow( tag + "8" ) << device->modes << device->name() << encoding << int(-512);
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_int()
-{
- QFETCH( int, modes );
- if(modes & QIODevice::WriteOnly) {
- qt3_createWriteStream( os );
- qt3_write_int( os );
- qt3_closeWriteStream( os );
- }
- if(modes & QIODevice::ReadOnly) {
- qt3_createReadStream( is );
- qt3_read_int( is );
- qt3_closeReadStream( is );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_read_int( QTextStream *s )
-{
- QFETCH( int, si );
- int exp;
- QString A, B;
- *s >> A >> exp >> B;
- QCOMPARE( A, QString("A") );
- QCOMPARE( B, QString("B") );
- QCOMPARE( exp, si );
- s->skipWhiteSpace();
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_write_int( QTextStream *s )
-{
- QFETCH( int, si );
- *s << " A " << si << " B ";
-}
-
-// **************** uint ****************
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_uint_data()
-{
- QTest::addColumn<int>("modes");
- QTest::addColumn<QString>("device");
- QTest::addColumn<QString>("encoding");
- QTest::addColumn<uint>("ui");
-
- for ( int i=0; !devices[i].name().isNull(); i++ ) {
- tst_IODevice *device = devices+i;
- for ( int e=0; encodings[e] != 0; e++ ) {
- QString encoding = encodings[e];
-
- QString tag = device->name() + "_" + encoding + "_";
- QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << uint(0);
- QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << uint(1);
- QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << uint(10);
- QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << uint(255);
- QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << uint(512);
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_uint()
-{
- QFETCH( int, modes );
- if(modes & QIODevice::WriteOnly) {
- qt3_createWriteStream( os );
- qt3_write_uint( os );
- qt3_closeWriteStream( os );
- }
- if(modes & QIODevice::ReadOnly) {
- qt3_createReadStream( is );
- qt3_read_uint( is );
- qt3_closeReadStream( is );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_read_uint( QTextStream *s )
-{
- QFETCH( uint, ui );
- uint exp;
- QString A, B;
- *s >> A >> exp >> B;
- QCOMPARE( A, QString("A") );
- QCOMPARE( B, QString("B") );
- QCOMPARE( exp, ui );
- s->skipWhiteSpace();
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_write_uint( QTextStream *s )
-{
- QFETCH( uint, ui );
- *s << " A " << ui << " B ";
-}
-
-// **************** long ****************
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_long_data()
-{
- QTest::addColumn<int>("modes");
- QTest::addColumn<QString>("device");
- QTest::addColumn<QString>("encoding");
- QTest::addColumn<long>("sl");
-
- for ( int i=0; !devices[i].name().isNull(); i++ ) {
- tst_IODevice *device = devices+i;
- for ( int e=0; encodings[e] != 0; e++ ) {
- QString encoding = encodings[e];
-
- QString tag = device->name() + "_" + encoding + "_";
- QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << long(0);
- QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << long(1);
- QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << long(10);
- QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << long(255);
- QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << long(65535);
- QTest::newRow( tag + "5" ) << device->modes << device->name() << encoding << long(-1);
- QTest::newRow( tag + "6" ) << device->modes << device->name() << encoding << long(-10);
- QTest::newRow( tag + "7" ) << device->modes << device->name() << encoding << long(-255);
- QTest::newRow( tag + "8" ) << device->modes << device->name() << encoding << long(-65534);
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_long()
-{
- QFETCH( int, modes );
- if(modes & QIODevice::WriteOnly) {
- qt3_createWriteStream( os );
- qt3_write_long( os );
- qt3_closeWriteStream( os );
- }
- if(modes & QIODevice::ReadOnly) {
- qt3_createReadStream( is );
- qt3_read_long( is );
- qt3_closeReadStream( is );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_read_long( QTextStream *s )
-{
- QFETCH( long, sl );
- long exp;
- QString A, B;
- *s >> A >> exp >> B;
- QCOMPARE( A, QString("A") );
- QCOMPARE( B, QString("B") );
- QCOMPARE( exp, sl );
- s->skipWhiteSpace();
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_write_long( QTextStream *s )
-{
- QFETCH( long, sl );
- *s << " A " << sl << " B ";
-}
-
-// **************** long ****************
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_ulong_data()
-{
- QTest::addColumn<int>("modes");
- QTest::addColumn<QString>("device");
- QTest::addColumn<QString>("encoding");
- QTest::addColumn<ulong>("ul");
-
- for ( int i=0; !devices[i].name().isNull(); i++ ) {
- tst_IODevice *device = devices+i;
- for ( int e=0; encodings[e] != 0; e++ ) {
- QString encoding = encodings[e];
-
- QString tag = device->name() + "_" + encoding + "_";
- QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << ulong(0);
- QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << ulong(1);
- QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << ulong(10);
- QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << ulong(255);
- QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << ulong(65535);
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_ulong()
-{
- QFETCH( int, modes );
- if(modes & QIODevice::WriteOnly) {
- qt3_createWriteStream( os );
- qt3_write_ulong( os );
- qt3_closeWriteStream( os );
- }
- if(modes & QIODevice::ReadOnly) {
- qt3_createReadStream( is );
- qt3_read_ulong( is );
- qt3_closeReadStream( is );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_read_ulong( QTextStream *s )
-{
- QFETCH( ulong, ul );
- ulong exp;
- QString A, B;
- *s >> A >> exp >> B;
- QCOMPARE( A, QString("A") );
- QCOMPARE( B, QString("B") );
- QCOMPARE( exp, ul );
- s->skipWhiteSpace();
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_write_ulong( QTextStream *s )
-{
- QFETCH( ulong, ul );
- *s << " A " << ul << " B ";
-}
-
-// **************** float ****************
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_float_data()
-{
- QTest::addColumn<int>("modes");
- QTest::addColumn<QString>("device");
- QTest::addColumn<QString>("encoding");
- QTest::addColumn<float>("f");
-
- for ( int i=0; !devices[i].name().isNull(); i++ ) {
- tst_IODevice *device = devices+i;
- for ( int e=0; encodings[e] != 0; e++ ) {
- QString encoding = encodings[e];
-
- QString tag = device->name() + "_" + encoding + "_";
- QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << float(0.0);
- QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << float(0.0001);
- QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << float(-0.0001);
- QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << float(3.45678);
- QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << float(-3.45678);
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_float()
-{
- QFETCH( int, modes );
- if(modes & QIODevice::WriteOnly) {
- qt3_createWriteStream( os );
- qt3_write_float( os );
- qt3_closeWriteStream( os );
- }
- if(modes & QIODevice::ReadOnly) {
- qt3_createReadStream( is );
- qt3_read_float( is );
- qt3_closeReadStream( is );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_read_float( QTextStream *s )
-{
- QFETCH( float, f );
- float exp;
- QString A, B;
- *s >> A >> exp >> B;
- QCOMPARE( A, QString("A") );
- QCOMPARE( B, QString("B") );
- QCOMPARE( exp, f );
- s->skipWhiteSpace();
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_write_float( QTextStream *s )
-{
- QFETCH( float, f );
- *s << " A " << f << " B ";
-}
-
-// **************** double ****************
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_double_data()
-{
- QTest::addColumn<int>("modes");
- QTest::addColumn<QString>("device");
- QTest::addColumn<QString>("encoding");
- QTest::addColumn<double>("d");
-
- for ( int i=0; !devices[i].name().isNull(); i++ ) {
- tst_IODevice *device = devices+i;
- for ( int e=0; encodings[e] != 0; e++ ) {
- QString encoding = encodings[e];
-
- QString tag = device->name() + "_" + encoding + "_";
- QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << double(0.0);
- QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << double(0.0001);
- QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << double(-0.0001);
- QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << double(3.45678);
- QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << double(-3.45678);
- QTest::newRow( tag + "5" ) << device->modes << device->name() << encoding << double(1.23456789);
- QTest::newRow( tag + "6" ) << device->modes << device->name() << encoding << double(-1.23456789);
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_double()
-{
- QFETCH( int, modes );
- if(modes & QIODevice::WriteOnly) {
- qt3_createWriteStream( os );
- os->precision( 10 );
- qt3_write_double( os );
- qt3_closeWriteStream( os );
- }
- if(modes & QIODevice::ReadOnly) {
- qt3_createReadStream( is );
- is->precision( 10 );
- qt3_read_double( is );
- qt3_closeReadStream( is );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_read_double( QTextStream *s )
-{
- QFETCH( double, d );
- double exp;
- QString A, B;
- *s >> A >> exp >> B;
- QCOMPARE( A, QString("A") );
- QCOMPARE( B, QString("B") );
- QCOMPARE( exp, d );
- s->skipWhiteSpace();
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_write_double( QTextStream *s )
-{
- QFETCH( double, d );
- *s << " A " << d << " B ";
-}
-
-// **************** QString ****************
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_QString_data()
-{
- QTest::addColumn<int>("modes");
- QTest::addColumn<QString>("device");
- QTest::addColumn<QString>("encoding");
- QTest::addColumn<QString>("str");
- QTest::addColumn<bool>("multi_str");
- QTest::addColumn<bool>("zero_length");
-
- for ( int i=0; !devices[i].name().isNull(); i++ ) {
- tst_IODevice *device = devices+i;
- for ( int e=0; encodings[e] != 0; e++ ) {
- QString encoding = encodings[e];
-
- QString tag = device->name() + "_" + encoding + "_";
- QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << QString("") << bool(FALSE) << bool(TRUE);
- QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << QString() << bool(FALSE) << bool(TRUE);
- QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << QString("foo") << bool(FALSE) << bool(FALSE);
- QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << QString("foo\nbar") << bool(TRUE) << bool(FALSE);
- QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << QString("cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv") << bool(TRUE) << bool(FALSE);
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_QString()
-{
- QFETCH( bool, zero_length );
- file_is_empty = zero_length;
-
- QFETCH( int, modes );
- if(modes & QIODevice::WriteOnly) {
- qt3_createWriteStream( os );
- qt3_write_QString( os );
- qt3_closeWriteStream( os );
- }
- if(modes & QIODevice::ReadOnly) {
- qt3_createReadStream( is );
- qt3_read_QString( is );
- qt3_closeReadStream( is );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_read_QString( QTextStream *s )
-{
- QString exp;
- QFETCH( QString, str );
- if (str.isNull())
- str = "";
-
- QFETCH( bool, multi_str );
- if (!multi_str) {
- *s >> exp;
- QCOMPARE( exp, str );
- } else {
- QStringList l;
- l = QStringList::split( " ", str );
- if (l.count() < 2)
- l = QStringList::split( "\n", str );
- for (int i=0; i<l.count(); i++) {
- *s >> exp;
- QCOMPARE( exp, l[i] );
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_write_QString( QTextStream *s )
-{
- QFETCH( QString, str );
- *s << str;
-}
-
-// **************** QByteArray ****************
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_QByteArray_data()
-{
- QTest::addColumn<int>("modes");
- QTest::addColumn<QString>("device");
- QTest::addColumn<QString>("encoding");
- QTest::addColumn<QByteArray>("cs");
- QTest::addColumn<bool>("multi_str");
- QTest::addColumn<bool>("zero_length");
-
- for ( int i=0; !devices[i].name().isNull(); i++ ) {
- tst_IODevice *device = devices+i;
- for ( int e=0; encodings[e] != 0; e++ ) {
- QString encoding = encodings[e];
-
- QString tag = device->name() + "_" + encoding + "_";
- QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << QByteArray("") << bool(FALSE) << bool(TRUE);
- QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << QByteArray(0) << bool(FALSE) << bool(TRUE);
- QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << QByteArray("foo") << bool(FALSE) << bool(FALSE);
- QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << QByteArray("foo\nbar") << bool(TRUE) << bool(FALSE);
- QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << QByteArray("cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv") << bool(TRUE) << bool(FALSE);
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_operator_shift_QByteArray()
-{
- QFETCH( bool, zero_length );
- file_is_empty = zero_length;
-
- QFETCH( int, modes );
- if(modes & QIODevice::WriteOnly) {
- qt3_createWriteStream( os );
- qt3_write_QByteArray( os );
- qt3_closeWriteStream( os );
- }
- if(modes & QIODevice::ReadOnly) {
- qt3_createReadStream( is );
- qt3_read_QByteArray( is );
- qt3_closeReadStream( is );
- }
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_read_QByteArray( QTextStream *s )
-{
-/*
- QFETCH( QByteArray, cs );
- QByteArray exp;
- *s >> exp;
- QCOMPARE( exp, cs );
-*/
- QByteArray exp;
- QFETCH( QByteArray, cs );
- if (cs.isNull())
- cs = "";
-
- QFETCH( bool, multi_str );
- if (!multi_str) {
- *s >> exp;
- QCOMPARE( exp.constData(), cs.constData() );
- } else {
- QStringList l;
- l = QStringList::split( " ", cs );
- if (l.count() < 2)
- l = QStringList::split( "\n", cs );
- for (int i=0; i<l.count(); i++) {
- *s >> exp;
- QCOMPARE( exp, QByteArray(l[i].toAscii()) );
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-static void qt3_generateLineData( bool for_QString )
-{
- QTest::addColumn<QByteArray>("input");
- QTest::addColumn<QStringList>("output");
-
- QTest::newRow("emptyer") << QByteArray() << QStringList();
- QTest::newRow("lf") << QByteArray("\n") << (QStringList() << "");
- QTest::newRow("crlf") << QByteArray("\r\n") << (QStringList() << "");
- QTest::newRow("oneline/nothing") << QByteArray("ole") << (QStringList() << "ole");
- QTest::newRow("oneline/lf") << QByteArray("ole\n") << (QStringList() << "ole");
- QTest::newRow("oneline/crlf") << QByteArray("ole\r\n") << (QStringList() << "ole");
- QTest::newRow("twolines/lf/lf") << QByteArray("ole\ndole\n") << (QStringList() << "ole" << "dole");
- QTest::newRow("twolines/crlf/crlf") << QByteArray("ole\r\ndole\r\n") << (QStringList() << "ole" << "dole");
- QTest::newRow("twolines/lf/crlf") << QByteArray("ole\ndole\r\n") << (QStringList() << "ole" << "dole");
- QTest::newRow("twolines/lf/nothing") << QByteArray("ole\ndole") << (QStringList() << "ole" << "dole");
- QTest::newRow("twolines/crlf/nothing") << QByteArray("ole\r\ndole") << (QStringList() << "ole" << "dole");
- QTest::newRow("threelines/lf/lf/lf") << QByteArray("ole\ndole\ndoffen\n") << (QStringList() << "ole" << "dole" << "doffen");
- QTest::newRow("threelines/crlf/crlf/crlf") << QByteArray("ole\r\ndole\r\ndoffen\r\n") << (QStringList() << "ole" << "dole" << "doffen");
- QTest::newRow("threelines/crlf/crlf/nothing") << QByteArray("ole\r\ndole\r\ndoffen") << (QStringList() << "ole" << "dole" << "doffen");
-
- if (!for_QString) {
- QTest::newRow("unicode/nothing") << QByteArray("\xfe\xff\x00\xe5\x00\x67\x00\x65", 8) << (QStringList() << "\345ge");
- QTest::newRow("unicode-little/nothing") << QByteArray("\xff\xfe\xe5\x00\x67\x00\x65\x00", 8) << (QStringList() << "\345ge");
- QTest::newRow("unicode/lf") << QByteArray("\xfe\xff\x00\xe5\x00\x67\x00\x65\x00\x0a", 10) << (QStringList() << "\345ge");
- QTest::newRow("unicode-little/lf") << QByteArray("\xff\xfe\xe5\x00\x67\x00\x65\x00\x0a\x00", 10) << (QStringList() << "\345ge");
-
- QTest::newRow("unicode/twolines") << QByteArray("\xfe\xff\x00\xe5\x00\x67\x00\x65\x00\x0a\x00\xe5\x00\x67\x00\x65\x00\x0a", 18) << (QStringList() << "\345ge" << "\345ge");
- QTest::newRow("unicode-little/twolines") << QByteArray("\xff\xfe\xe5\x00\x67\x00\x65\x00\x0a\x00\xe5\x00\x67\x00\x65\x00\x0a\x00", 18) << (QStringList() << "\345ge" << "\345ge");
-
- QTest::newRow("unicode/threelines")
- << QByteArray("\xfe\xff"
- "\x00\xe5\x00\x67\x00\x65\x00\x0a"
- "\x00\xe5\x00\x67\x00\x65\x00\x0a"
- "\x00\xe5\x00\x67\x00\x65\x00\x0a", 26)
- << (QStringList() << "\345ge" << "\345ge" << "\345ge");
- QTest::newRow("unicode-little/threelines")
- << QByteArray("\xff\xfe"
- "\xe5\x00\x67\x00\x65\x00\x0a\x00"
- "\xe5\x00\x67\x00\x65\x00\x0a\x00"
- "\xe5\x00\x67\x00\x65\x00\x0a\x00", 26)
- << (QStringList() << "\345ge" << "\345ge" << "\345ge");
- }
-
- // partials
- QTest::newRow("cr") << QByteArray("\r") << (QStringList() << "");
- QTest::newRow("oneline/cr") << QByteArray("ole\r") << (QStringList() << "ole");
- if (!for_QString)
- QTest::newRow("unicode/cr") << QByteArray("\xfe\xff\x00\xe5\x00\x67\x00\x65\x00\x0d", 10) << (QStringList() << "\345ge");
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_writeDataToFileReadAsLines_data()
-{
- qt3_generateLineData(false);
-}
-
-// ------------------------------------------------------------------------------
-QByteArray pretty(const QString &input)
-{
- QByteArray data;
-
- QByteArray arr = input.toLatin1();
- for (int i = 0; i < arr.size(); ++i) {
- char buf[64];
- memset(buf, 0, sizeof(buf));
- char ch = arr.at(i);
- sprintf(buf, "\\%2hhx", ch);
- data += buf;
- }
-
- return data;
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_writeDataToFileReadAsLines()
-{
- QFETCH(QByteArray, input);
- QFETCH(QStringList, output);
-
- QFile::remove("eoltest");
-
- // Create the file
- QFile writer("eoltest");
- QVERIFY2(writer.open(QFile::WriteOnly | QFile::Truncate), ("When creating a file: " + writer.errorString()).latin1());
- QCOMPARE(writer.write(input), qlonglong(input.size()));
- writer.close();
-
- // Read from it using QTextStream
- QVERIFY2(writer.open(QFile::ReadOnly), ("When reading a file: " + writer.errorString()).latin1());
- QTextStream stream(&writer);
- QStringList tmp;
-
- while (!stream.atEnd())
- tmp << stream.readLine();
-
- QCOMPARE(tmp, output);
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_writeDataToQStringReadAsLines_data()
-{
- qt3_generateLineData(true);
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_writeDataToQStringReadAsLines()
-{
- QFETCH(QByteArray, input);
- QFETCH(QStringList, output);
-
- QString s = input;
- QTextStream stream(&s, QIODevice::ReadOnly);
-
- QStringList tmp;
- while (!stream.atEnd())
- tmp << stream.readLine();
-
- QCOMPARE(tmp, output);
-}
-
-// ------------------------------------------------------------------------------
-void tst_QTextStream::qt3_write_QByteArray( QTextStream *s )
-{
- QFETCH( QByteArray, cs );
- *s << cs;
-}
-#endif
-
-// ------------------------------------------------------------------------------
void tst_QTextStream::status_real_read_data()
{
QTest::addColumn<QString>("input");
static QBasicAtomicInt count;
inline SPointer() { count.ref(); }
inline ~SPointer() { count.deref(); }
- inline SPointer(const SPointer &other) { count.ref(); }
+ inline SPointer(const SPointer & /* other */) { count.ref(); }
};
QBasicAtomicInt SPointer::count = Q_BASIC_ATOMIC_INITIALIZER(0);
include(../qsharedmemory/src/src.pri)
QT = core script
+QT += core-private
CONFIG += qtestlib
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*)
{
Q_OBJECT
public:
- Model_11466(QObject *parent) :
+ Model_11466(QObject * /* parent */) :
m_block(false)
{
// set up the model to have two top level items and a few others
return 2; // two top level items
}
- int columnCount(const QModelIndex &parent) const
+ int columnCount(const QModelIndex & /* parent */) const
{
return 2;
}
void task_240612();
void taskQTBUG_6962();
void taskQTBUG_8701();
-
-#ifdef QT3_SUPPORT
- void dirPath();
-#endif
};
// Testing get/set functions
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);
#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>
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();
void podUserType();
- void nullAsType();
-
void data_(); // data is virtual function in QtTestCase
void constData();
void variantMap();
void variantHash();
- void invalidAsByteArray();
void convertToQUint8() const;
void invalidQColor() const;
void comparePointers() const;
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;
QVariant varLL( (qlonglong)0 );
QVERIFY( !varLL.isNull() );
QVariant var7(QString::null);
-#ifdef QT3_SUPPORT
- QCOMPARE(var7.asInt(), 0);
-#endif
QVERIFY(var7.isNull());
}
QTest::addColumn<bool>("BoolCast");
QTest::addColumn<bool>("BrushCast");
QTest::addColumn<bool>("ByteArrayCast");
- QTest::addColumn<bool>("CStringCast");
QTest::addColumn<bool>("ColorCast");
- QTest::addColumn<bool>("ColorGroupCast");
QTest::addColumn<bool>("CursorCast");
QTest::addColumn<bool>("DateCast");
QTest::addColumn<bool>("DateTimeCast");
QTest::addColumn<bool>("DoubleCast");
QTest::addColumn<bool>("FontCast");
- QTest::addColumn<bool>("IconSetCast");
QTest::addColumn<bool>("ImageCast");
QTest::addColumn<bool>("IntCast");
QTest::addColumn<bool>("InvalidCast");
QTest::addColumn<bool>("PaletteCast");
QTest::addColumn<bool>("PenCast");
QTest::addColumn<bool>("PixmapCast");
- QTest::addColumn<bool>("PointArrayCast");
QTest::addColumn<bool>("PointCast");
QTest::addColumn<bool>("RectCast");
QTest::addColumn<bool>("RegionCast");
#endif
#define Y true
#define N false
- // bita bitm bool brsh byta cstr col colg curs date dt dbl font icon img int inv kseq list ll map pal pen pix pnta pnt rect reg size sp str strl time uint ull
+ // bita bitm bool brsh byta col curs date dt dbl font img int inv kseq list ll map pal pen pix pnt rect reg size sp str strl time uint ull
QVariant var(QBitArray(0));
QTest::newRow("BitArray")
- << var << 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 << N << N << N << N << N << N << N;
+ << var << 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 << N << N << N;
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 << N << Y << 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;
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 << N << N << N << Y << N << Y << 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;
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 << N << N << Y << N << Y << Y << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
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
+ << var << N << N << N << Y << Y << Y << 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;
#ifndef QT_NO_CURSOR
var = qVariantFromValue(QCursor());
QTest::newRow("Cursor")
- << var << N << 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;
+ << var << 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;
#endif
var = QVariant(QDate());
QTest::newRow("Date")
- << var << N << N << N << N << N << N << N << N << N << Y << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N;
+ << var << N << N << N << N << N << N << N << Y << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N;
var = QVariant(QDateTime());
QTest::newRow("DateTime")
- << var << N << N << N << N << N << N << N << N << N << Y << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << Y << N << N;
+ << var << N << N << N << N << N << N << N << Y << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << Y << N << N;
var = QVariant((double)0.1);
QTest::newRow("Double")
- << 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;
+ << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
var = QVariant(0.1f);
QTest::newRow("Float")
- << 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;
+ << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
var = qVariantFromValue(QFont());
QTest::newRow("Font")
- << var << N << N << N << N << N << 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 << Y << N << N << N << N;
+ << var << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N;
var = qVariantFromValue(QIcon());
QTest::newRow("Icon")
- << var << 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 << N << N << N << N << N << N << N << N << N << N;
+ << var << 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 << N << N << N << N;
var = qVariantFromValue(QImage());
QTest::newRow("Image")
- << 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;
+ << var << N << Y << 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;
var = QVariant((int)1);
QTest::newRow("Int")
- << var << N << N << Y << N << Y << Y << N << N << N << N << N << Y << N << N << N << Y << N << Y << N << Y << N << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
+ << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << Y << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
var = QVariant();
QTest::newRow("Invalid")
- << var << 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 << N << N << N << N << N << N << N;
+ << var << 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 << N << N << N << N << N << N;
var = qVariantFromValue(QKeySequence());
QTest::newRow("KeySequence")
- << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N;
+ << var << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << Y << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N;
var = QVariant(QList<QVariant>());
QTest::newRow("List")
- << var << N << N << 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 << N << Y << N << N << N;
+ << var << 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 << Y << N << N << N;
var = QVariant((qlonglong)1);
QTest::newRow("LongLong")
- << 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;
+ << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
var = QVariant(QMap<QString,QVariant>());
QTest::newRow("Map")
- << var << 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 << N << N << N << N << N << N << N << N << N << N;
+ << var << N << 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 << N << N;
var = qVariantFromValue(QPalette());
QTest::newRow("Palette")
- << var << 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 << N << N << N << N << N << N << N << N << N;
+ << var << N << N << 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 << N;
var = qVariantFromValue(QPen());
QTest::newRow("Pen")
- << var << 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 << N << N << N << N << N << N << N << N;
+ << var << N << N << N << 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 = qVariantFromValue(QPixmap());
QTest::newRow("Pixmap")
- << var << N << Y << N << Y << 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;
+ << var << N << Y << N << Y << 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;
var = qVariantFromValue(QPolygon());
QTest::newRow("PointArray")
- << var << N << 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 << N << N << N << N << N << N;
+ << var << 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 << N << N << N << N;
var = QVariant(QPoint());
QTest::newRow("Point")
- << var << 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 << Y << N << N << N << N << N << N << N << N << N;
+ << var << 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 << N << N << N << N << N;
var = QVariant(QRect());
QTest::newRow("Rect")
- << var << 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 << Y << N << N << N << N << N << N << N << N;
+ << var << 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 << N << N << N << N;
var = qVariantFromValue(QRegion());
QTest::newRow("Region")
- << var << 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 << Y << N << N << N << N << N << N << N;
+ << var << 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 << N << N << N;
var = QVariant(QSize());
QTest::newRow("Size")
- << var << 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 << N << Y << N << N << N << N << N << N;
+ << var << N << 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 << N << N;
var = qVariantFromValue(QSizePolicy());
QTest::newRow("SizePolicy")
- << var << 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 << N << N << Y << N << N << N << N << N;
+ << var << 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 << Y << N << N << N << N << N;
var = QVariant(QString());
QTest::newRow("String")
- << var << N << N << Y << N << Y << Y << Y << N << N << Y << Y << Y << Y << N << N << Y << N << Y << N << Y << N << N << N << N << N << N << N << N << N << N << Y << Y << Y << Y << Y;
+ << var << N << N << Y << N << Y << Y << N << Y << Y << Y << Y << N << Y << N << Y << N << Y << N << N << N << N << N << N << N << N << N << Y << Y << Y << Y << Y;
var = QVariant(QStringList("entry"));
QTest::newRow("StringList")
- << var << N << N << 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 << Y << Y << N << N << N;
+ << var << 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 << Y << Y << N << N << N;
var = QVariant(QTime());
QTest::newRow("Time")
- << var << 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 << N << N << N << Y << N << Y << N << N;
+ << var << 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 << Y << N << Y << N << N;
var = QVariant((uint)1);
QTest::newRow("UInt")
- << 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;
+ << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
var = QVariant((qulonglong)1);
QTest::newRow("ULongLong")
- << 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;
+ << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
#undef N
#undef Y
QFETCH(bool, BoolCast);
QFETCH(bool, BrushCast);
QFETCH(bool, ByteArrayCast);
- QFETCH(bool, CStringCast);
QFETCH(bool, ColorCast);
- QFETCH(bool, ColorGroupCast);
QFETCH(bool, CursorCast);
QFETCH(bool, DateCast);
QFETCH(bool, DateTimeCast);
QFETCH(bool, DoubleCast);
QFETCH(bool, FontCast);
- QFETCH(bool, IconSetCast);
QFETCH(bool, ImageCast);
QFETCH(bool, IntCast);
QFETCH(bool, InvalidCast);
QFETCH(bool, PaletteCast);
QFETCH(bool, PenCast);
QFETCH(bool, PixmapCast);
- QFETCH(bool, PointArrayCast);
QFETCH(bool, PointCast);
QFETCH(bool, RectCast);
QFETCH(bool, RegionCast);
QCOMPARE(val.canConvert(QVariant::Bool), BoolCast);
QCOMPARE(val.canConvert(QVariant::Brush), BrushCast);
QCOMPARE(val.canConvert(QVariant::ByteArray), ByteArrayCast);
-#ifdef QT3_SUPPORT
- QCOMPARE(val.canConvert(QVariant::CString), CStringCast);
-#else
- Q_UNUSED(CStringCast);
-#endif
QCOMPARE(val.canConvert(QVariant::Color), ColorCast);
-#ifdef QT3_SUPPORT
- QCOMPARE(val.canConvert(QVariant::ColorGroup), ColorGroupCast);
-#else
- Q_UNUSED(ColorGroupCast);
-#endif
QCOMPARE(val.canConvert(QVariant::Cursor), CursorCast);
QCOMPARE(val.canConvert(QVariant::Date), DateCast);
QCOMPARE(val.canConvert(QVariant::DateTime), DateTimeCast);
QCOMPARE(val.canConvert(QVariant::Double), DoubleCast);
QCOMPARE(val.canConvert(QVariant::Type(QMetaType::Float)), DoubleCast);
QCOMPARE(val.canConvert(QVariant::Font), FontCast);
-#ifdef QT3_SUPPORT
- QCOMPARE(val.canConvert(QVariant::IconSet), IconSetCast);
-#else
- Q_UNUSED(IconSetCast);
-#endif
QCOMPARE(val.canConvert(QVariant::Image), ImageCast);
QCOMPARE(val.canConvert(QVariant::Int), IntCast);
QCOMPARE(val.canConvert(QVariant::Invalid), InvalidCast);
QCOMPARE(val.canConvert(QVariant::Palette), PaletteCast);
QCOMPARE(val.canConvert(QVariant::Pen), PenCast);
QCOMPARE(val.canConvert(QVariant::Pixmap), PixmapCast);
-#ifdef QT3_SUPPORT
- QCOMPARE(val.canConvert(QVariant::PointArray), PointArrayCast);
-#else
- Q_UNUSED(PointArrayCast);
-#endif
QCOMPARE(val.canConvert(QVariant::Point), PointCast);
QCOMPARE(val.canConvert(QVariant::Rect), RectCast);
QCOMPARE(val.canConvert(QVariant::Region), RegionCast);
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;
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;
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;
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
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
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");
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" );
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");
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;
QTest::newRow( "datetime_invalid" ) << QVariant( QDateTime() ) << true;
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;
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;
// 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 );
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"));
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()
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()
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
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.");
****************************************************************************/
-#if defined(QT3_SUPPORT)
-#include <q3hbox.h>
-#include <q3textedit.h>
-#endif
#include <qboxlayout.h>
#include <qapplication.h>
#include <qbitmap.h>
tst_QWidget();
virtual ~tst_QWidget();
-
public slots:
void initTestCase();
void cleanupTestCase();
void isVisibleTo();
void isHidden();
void fonts();
- void mapToGlobal();
void mapFromAndTo_data();
void mapFromAndTo();
- void checkFocus();
void focusChainOnHide();
void focusChainOnReparent();
void setTabOrder();
// 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);
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");
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:
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()
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 {
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)
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)
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));
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)
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)
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));
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);
#include <qmainwindow.h>
#include <qmenubar.h>
#include <qworkspace.h>
-#if defined(QT3_SUPPORT)
-#include <q3popupmenu.h>
-#include <q3accel.h>
-#endif
//TESTED_CLASS=
//TESTED_FILES=
void getSetCheck();
void windowActivated_data();
void windowActivated();
- void accelPropagation();
void windowActivatedWithMinimize();
void showWindows();
void changeWindowTitle();
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 );
return 0;
}
-static inline int bsf_nonzero(register long val)
+static inline int bsf_nonzero(register int val)
{
int result;
# ifdef Q_CC_GNU
bool AbstractItemContainer::eventFilter(QObject *obj, QEvent *event)
{
if (event->type()==QEvent::GraphicsSceneResize && m_itemView) {
-#if (QT_VERSION >= 0x040600)
const bool caching = m_itemView->listItemCaching();
m_itemView->setListItemCaching(false);
-#endif
QSizeF s = m_itemView->size();
s.setWidth(s.width()-m_itemView->verticalScrollBar()->size().width());
m_itemView->updateViewContent();
updateItemBuffer();
-#if (QT_VERSION >= 0x040600)
m_itemView->setListItemCaching(caching);
-#endif
}
return QGraphicsWidget::eventFilter(obj, event);
m_items.at(i)->updateItemContents();
}
-#if (QT_VERSION >= 0x040600)
void AbstractItemContainer::setSubtreeCacheEnabled(bool enabled)
{
for (int i = 0; i <m_items.count(); ++i)
if (m_prototype)
m_prototype->setSubtreeCacheEnabled(enabled);
}
-#endif
void AbstractItemContainer::setTwoColumns(const bool enabled)
{
virtual void setTwoColumns(const bool enabled);
bool twoColumns();
-#if (QT_VERSION >= 0x040600)
void setSubtreeCacheEnabled(const bool enabled);
virtual void setListItemCaching(const bool enabled, const int index) = 0;
-#endif
protected:
virtual void adjustVisibleContainerSize(const QSizeF &size) = 0;
for (int i = 0; i<itemsInContainer; ++i) {
AbstractViewItem *changedItem = m_container->itemAt(i);
- changedItem->setModelIndex(m_model->index(startRow+i,0));
-#if (QT_VERSION >= 0x040600)
+ changedItem->setModelIndex(m_model->index(startRow+i,0));
m_container->setListItemCaching(listItemCaching(), i);
-#endif
}
qreal diff = vPos-startRow*itemH;
void updateViewContent();
virtual void scrollContentsBy(qreal dx, qreal dy);
-#if (QT_VERSION >= 0x040600)
virtual bool listItemCaching() const = 0;
virtual void setListItemCaching(bool enabled) = 0;
-#endif
protected:
virtual bool event(QEvent *e);
; // No impl yet
}
-#if (QT_VERSION >= 0x040600)
/*virtual*/
void AbstractViewItem::setSubtreeCacheEnabled(bool enabled)
{
Q_UNUSED(enabled)
; // No impl
}
-#endif
virtual void updateItemContents();
virtual void themeChange();
-#if (QT_VERSION >= 0x040600)
virtual void setSubtreeCacheEnabled(bool enabled);
-#endif
virtual QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
#include <QtGui>
#include <QSvgRenderer>
-
-#if (QT_VERSION >= 0x040600)
#include <QGraphicsEffect>
-#endif
#include "iconitem.h"
: GvbWidget(parent)
, m_filename(filename)
, m_rotation(0.0)
-#if (QT_VERSION >= 0x040600)
, m_opacityEffect(0)
-#endif
, m_smoothTransformation(false)
{
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
}
}
-#if (QT_VERSION >= 0x040600)
void IconItem::setOpacityEffectEnabled(const bool enable)
{
if (!m_opacityEffect)
return false;
}
-#endif
#include "gvbwidget.h"
-#if (QT_VERSION >= 0x040600)
class QGraphicsOpacityEffect;
-#endif
class QPainter;
class IconItem : public GvbWidget
QString fileName() const;
void setFileName(const QString &filename);
-#if (QT_VERSION >= 0x040600)
void setOpacityEffectEnabled(const bool enable);
bool isOpacityEffectEnabled() const;
-#endif
+
void setRotation(const qreal rotation) { m_rotation = rotation; }
qreal rotation() const { return m_rotation; }
QString m_filename;
QPixmap m_pixmap;
qreal m_rotation;
-#if (QT_VERSION >= 0x040600)
QGraphicsOpacityEffect *m_opacityEffect;
-#endif
bool m_smoothTransformation;
};
// Update icons
item->icon(ListItem::LeftIcon)->setRotation(Theme::p()->iconRotation(ListItem::LeftIcon));
item->icon(ListItem::RightIcon)->setRotation(Theme::p()->iconRotation(ListItem::RightIcon));
-#if (QT_VERSION >= 0x040600)
item->icon(ListItem::LeftIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::LeftIcon));
item->icon(ListItem::RightIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::RightIcon));
-#endif
item->icon(ListItem::LeftIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::LeftIcon));
item->icon(ListItem::RightIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::RightIcon));
}
bool ItemRecyclingList::listItemCaching() const
{
-#if (QT_VERSION >= 0x040600)
ListItemContainer *container =
static_cast<ListItemContainer *>(m_container);
return container->listItemCaching();
-#else
- return false;
-#endif
}
void ItemRecyclingList::setListItemCaching(bool enabled)
{
-#if (QT_VERSION >= 0x040600)
ListItemContainer *container =
static_cast<ListItemContainer *>(m_container);
container->setListItemCaching(enabled);
-#else
- Q_UNUSED(enabled)
-#endif
}
void ItemRecyclingList::updateListItemBackgrounds(int index)
if (twoColumns() == enabled)
return;
-#if (QT_VERSION >= 0x040600)
const bool caching = listItemCaching();
setListItemCaching(false);
-#endif
m_container->setTwoColumns(enabled);
refreshContainerGeometry();
-#if (QT_VERSION >= 0x040600)
setListItemCaching(caching);
-#endif
}
bool ItemRecyclingList::twoColumns()
virtual ~ItemRecyclingListView();
void setCurrentRow(const int row);
int rows() const;
-#if (QT_VERSION >= 0x040600)
virtual bool listItemCaching() const = 0;
virtual void setListItemCaching(bool enabled) = 0;
-#endif
protected:
void rowsInserted(const QModelIndex &parent, int start, int end);
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
setContentsMargins(0, 0, 0, 0);
setText(text);
-#if QT_VERSION >= 0x040600
// This flag was introduced in Qt 4.6.
setFlag(QGraphicsItem::ItemHasNoContents, true);
-#endif
}
Label::~Label()
data.icons[ListItem::LeftIcon] = icon(ListItem::LeftIcon)->fileName();
data.iconRotations[ListItem::LeftIcon] = icon(ListItem::LeftIcon)->rotation();
data.iconSmoothTransformations[ListItem::LeftIcon] = icon(ListItem::LeftIcon)->isSmoothTransformationEnabled();
-#if (QT_VERSION >= 0x040600)
data.iconOpacityEffets[ListItem::LeftIcon] = icon(ListItem::LeftIcon)->isOpacityEffectEnabled();
-#endif
}
if (icon(ListItem::RightIcon)) {
data.icons[ListItem::RightIcon] = icon(ListItem::RightIcon)->fileName();
data.iconRotations[ListItem::RightIcon] = icon(ListItem::RightIcon)->rotation();
data.iconSmoothTransformations[ListItem::RightIcon] = icon(ListItem::RightIcon)->isSmoothTransformationEnabled();
-#if (QT_VERSION >= 0x040600)
data.iconOpacityEffets[ListItem::RightIcon] = icon(ListItem::RightIcon)->isOpacityEffectEnabled();
-#endif
}
data.borderPen = m_borderPen;
if (icon(ListItem::LeftIcon)) {
icon(ListItem::LeftIcon)->setRotation(data.iconRotations[ListItem::LeftIcon]);
icon(ListItem::LeftIcon)->setSmoothTransformationEnabled(data.iconSmoothTransformations[ListItem::LeftIcon]);
-#if (QT_VERSION >= 0x040600)
icon(ListItem::LeftIcon)->setOpacityEffectEnabled(data.iconOpacityEffets[ListItem::LeftIcon]);
-#endif
}
if (icon(ListItem::RightIcon)) {
icon(ListItem::RightIcon)->setRotation(data.iconRotations[ListItem::RightIcon]);
icon(ListItem::RightIcon)->setSmoothTransformationEnabled(data.iconSmoothTransformations[ListItem::RightIcon]);
-#if (QT_VERSION >= 0x040600)
icon(ListItem::RightIcon)->setOpacityEffectEnabled(data.iconOpacityEffets[ListItem::RightIcon]);
-#endif
}
m_borderPen = data.borderPen;
#include "abstractviewitem.h"
#include "recycledlistitem.h"
-
-#if (QT_VERSION >= 0x040600)
#include "listitemcache.h"
#include "itemrecyclinglist.h"
-#endif
ListItemContainer::ListItemContainer(int bufferSize, ItemRecyclingList *view, QGraphicsWidget *parent)
: AbstractItemContainer(bufferSize, parent)
, m_view(view)
, m_layout(new QGraphicsLinearLayout(Qt::Vertical))
-#if (QT_VERSION >= 0x040600)
, m_listItemCaching(false)
-#endif
{
setContentsMargins(0,0,0,0);
m_layout->setContentsMargins(0,0,0,0);
/*virtual*/
ListItemContainer::~ListItemContainer()
{
-#if (QT_VERSION >= 0x040600)
setListItemCaching(false);
-#endif
for (int i = 0; i < m_items.count(); ++i) {
m_layout->removeItem(m_items.at(i));
m_items.at(i)->setParentItem(0);
m_items.clear();
}
-#if (QT_VERSION >= 0x040600)
bool ListItemContainer::listItemCaching() const
{
return m_listItemCaching;
for (int i = 0; i < itemCount; ++i)
setListItemCaching(enabled, i);
}
-#endif
/*virtual*/
void ListItemContainer::adjustVisibleContainerSize(const QSizeF &size)
{
m_layout->insertItem(index,item);
-#if (QT_VERSION >= 0x040600)
setListItemCaching(m_listItemCaching, index);
-#endif
}
/*virtual*/
{
m_layout->removeItem(item);
-#if (QT_VERSION >= 0x040600)
RecycledListItem *recycledItem = static_cast<RecycledListItem*>(item);
if (!recycledItem)
ListItem *listItem = recycledItem->item();
setListItemCaching(false, listItem);
-#endif
}
/*virtual*/
return count;
}
-#if (QT_VERSION >= 0x040600)
void ListItemContainer::setListItemCaching(const bool enabled, const int index)
{
RecycledListItem *recycledItem = static_cast<RecycledListItem*>(m_layout->itemAt(index));
listItem->setGraphicsEffect(cache);
}
}
-#endif
-
void ListItemContainer::setTwoColumns(const bool twoColumns)
{
virtual void setTwoColumns(const bool twoColumns);
-#if (QT_VERSION >= 0x040600)
bool listItemCaching() const;
void setListItemCaching(const bool enabled);
virtual void setListItemCaching(const bool enabled, const int index);
-#endif
protected:
ItemRecyclingList *m_view;
QGraphicsLinearLayout *m_layout;
-#if (QT_VERSION >= 0x040600)
+
void setListItemCaching(const bool enabled, ListItem *listItem);
bool m_listItemCaching;
-#endif
};
-
#endif // LISTITEMCONTAINER_H
return 0;
}
-#if (QT_VERSION >= 0x040600)
bool ListWidget::listItemCaching() const
{
return m_listView->listItemCaching();
{
m_listView->setListItemCaching(enable);
}
-#endif
void ListWidget::setTwoColumns(const bool twoColumns)
{
QGraphicsWidget* takeItem(int row);
QGraphicsWidget* itemAt(int row);
int itemCount() const;
-#if (QT_VERSION >= 0x040600)
bool listItemCaching() const;
void setListItemCaching(bool enable);
-#endif
ScrollBar* verticalScrollBar() const;
void setTwoColumns(const bool twoColumns);
bool SimpleList::listItemCaching() const
{
-#if (QT_VERSION >= 0x040600)
return m_list->listItemCaching();
-#else
- return false;
-#endif
}
void SimpleList::setListItemCaching(bool enable)
{
-#if (QT_VERSION >= 0x040600)
m_list->setListItemCaching(enable);
-#else
- Q_UNUSED(enable)
-#endif
}
void SimpleList::keyPressEvent(QKeyEvent *event)
#include "simplelistview.h"
#include "scrollbar.h"
#include "listitem.h"
-#if (QT_VERSION >= 0x040600)
#include "listitemcache.h"
-#endif
#include "theme.h"
class SimpleListViewPrivate
, m_layout(0)
, m_twoColumns(false)
, q_ptr(button)
-#if (QT_VERSION >= 0x040600)
, m_listItemCaching(false)
-#endif
{
Q_Q(SimpleListView);
if (!m_content)
return;
-#if (QT_VERSION >= 0x040600)
const bool caching = q->listItemCaching();
q->setListItemCaching(false);
-#endif
+
m_content->resize(q->viewport()->size().width(),
m_layout->preferredHeight());
const bool clip =
q->viewport()->setFlag(
QGraphicsItem::ItemClipsChildrenToShape, clip);
-#if (QT_VERSION >= 0x040600)
q->setListItemCaching(caching);
-#endif
}
void resizeScrollBars()
void updateListContents()
{
-#if (QT_VERSION >= 0x040600)
Q_Q(SimpleListView);
const bool caching = q->listItemCaching();
q->setListItemCaching(false);
-#endif
+
const QString defaultIcon = Theme::p()->pixmapPath()+"contact_default_icon.svg";
const int itemCount = m_layout->count();
// Update icons
item->icon(ListItem::LeftIcon)->setRotation(Theme::p()->iconRotation(ListItem::LeftIcon));
item->icon(ListItem::RightIcon)->setRotation(Theme::p()->iconRotation(ListItem::RightIcon));
-#if (QT_VERSION >= 0x040600)
item->icon(ListItem::LeftIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::LeftIcon));
item->icon(ListItem::RightIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::RightIcon));
-#endif
item->icon(ListItem::LeftIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::LeftIcon));
item->icon(ListItem::RightIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::RightIcon));
}
-#if (QT_VERSION >= 0x040600)
q->setListItemCaching(caching);
-#endif
}
void updateListItemBackgrounds(int index)
{
-#if (QT_VERSION >= 0x040600)
Q_Q(SimpleListView);
const bool caching = q->listItemCaching();
q->setListItemCaching(false);
-#endif
+
const int itemCount = m_layout->count();
for (int i=index; i<itemCount; ++i) {
}
}
-#if (QT_VERSION >= 0x040600)
q->setListItemCaching(caching);
-#endif
}
void setTwoColumns(const bool twoColumns)
Q_Q(SimpleListView);
m_twoColumns = twoColumns;
-#if (QT_VERSION >= 0x040600)
bool cache = q->listItemCaching();
q->setListItemCaching(false);
-#endif
+
QList<QGraphicsLayoutItem *> moveditems;
if(twoColumns) {
int half = m_layout->count()/2;
resizeContents(q->size());
resizeScrollBars();
-#if (QT_VERSION >= 0x040600)
q->setListItemCaching(cache);
-#endif
}
bool twoColumns()
QGraphicsGridLayout *m_layout;
bool m_twoColumns;
SimpleListView *q_ptr;
-#if (QT_VERSION >= 0x040600)
bool m_listItemCaching;
-#endif
};
SimpleListView::SimpleListView(QGraphicsWidget *parent)
d->m_layout->addItem(moveditems.at(i), d->m_layout->count(), 0);
}
-#if (QT_VERSION >= 0x040600)
ListItemCache *cache = new ListItemCache;
item->setGraphicsEffect(cache);
cache->setEnabled(listItemCaching());
-#endif
d->resizeScrollBars();
d->updateListItemBackgrounds(index);
return d->m_layout->count();
}
-#if (QT_VERSION >= 0x040600)
bool SimpleListView::listItemCaching() const
{
Q_D(const SimpleListView);
cache->setEnabled(enabled);
}
}
-#endif
void SimpleListView::scrollContentsBy(qreal dx, qreal dy)
{
public slots:
void themeChange();
-#if (QT_VERSION >= 0x040600)
bool listItemCaching() const;
void setListItemCaching(bool enabled);
-#endif
protected:
, m_listItemBackgroundOpacityOdd()
, m_listItemBorderPen(QPen())
, m_listItemRounding()
-#if (QT_VERSION >= 0x040600)
, m_iconOpacityEffectEnabled()
-#endif
, m_iconRotation()
, m_iconSmoothTransformation()
{
m_listItemBorderPen = QPen(Qt::NoPen);
m_listItemRounding = QSize(0.0, 0.0);
-#if (QT_VERSION >= 0x040600)
m_iconOpacityEffectEnabled[ListItem::LeftIcon] = false;
m_iconOpacityEffectEnabled[ListItem::RightIcon] = false;
-#endif
+
m_iconRotation[ListItem::LeftIcon] = 0.0;
m_iconRotation[ListItem::RightIcon] = 0.0;
m_listItemBorderPen = QPen(QColor(0,0,0,55), 3, Qt::SolidLine);
m_listItemRounding = QSize(12.0, 12.0);
-#if (QT_VERSION >= 0x040600)
m_iconOpacityEffectEnabled[ListItem::LeftIcon] = true;
m_iconOpacityEffectEnabled[ListItem::RightIcon] = false;
-#endif
+
m_iconRotation[ListItem::LeftIcon] = -4.0;
m_iconRotation[ListItem::RightIcon] = 0.0;
QPen listItemBorderPen() const { return m_listItemBorderPen; }
QSize listItemRounding() const { return m_listItemRounding; }
-#if (QT_VERSION >= 0x040600)
bool isIconOpacityEffectEnabled(const ListItem::IconItemPos iconPos) const { return m_iconOpacityEffectEnabled[iconPos]; }
-#endif
+
qreal iconRotation(const ListItem::IconItemPos iconPos) const { return m_iconRotation[iconPos]; }
bool isIconSmoothTransformationEnabled(const ListItem::IconItemPos iconPos) const { return m_iconSmoothTransformation[iconPos]; }
QPen m_listItemBorderPen;
QSize m_listItemRounding;
-#if (QT_VERSION >= 0x040600)
QHash<ListItem::IconItemPos, bool> m_iconOpacityEffectEnabled;
-#endif
QHash<ListItem::IconItemPos, qreal> m_iconRotation;
QHash<ListItem::IconItemPos, bool> m_iconSmoothTransformation;
};
case Primitive_Float_RectPath: QBENCHMARK { p->drawPath(s->f_path_rect); } break;
case Primitive_Float_2RectPath: QBENCHMARK { p->drawPath(s->f_path_2rects); } break;
case Primitive_Float_EllipsePath: QBENCHMARK { p->drawPath(s->f_path_ellipse); } break;
+ case Primitive_Last_Primitive: break;
}
}
#include <QTextLayout>
#include <QFontMetrics>
#include <QDebug>
-
-#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
-# include <QStaticText>
-#endif
+#include <QStaticText>
class Benchmark
{
PainterQPointMode,
LayoutMode,
DocumentMode,
- PixmapMode
-
-#if QT_VERSION >= 0x040700
- , StaticTextMode,
+ PixmapMode,
+ StaticTextMode,
StaticTextWithMaximumSizeMode,
StaticTextBackendOptimizations
-#endif
};
DrawText(const QString &text, Mode mode)
}
virtual void begin(QPainter *p, int iterations) {
-#if QT_VERSION >= 0x040700
m_staticTexts.clear();
m_currentStaticText = 0;
-#else
- Q_UNUSED(iterations);
-#endif
m_pixmaps.clear();
m_currentPixmap = 0;
QRect m_bounds = QRect(0,0,p->device()->width(), p->device()->height());
m_size = m_layout.boundingRect().toRect().size();
break; }
-#if QT_VERSION >= 0x040700
case StaticTextWithMaximumSizeMode: {
QStaticText staticText;
m_size = (p->boundingRect(m_bounds, 0, m_text)).size();
break;
}
-#endif
-
case PainterQPointMode: {
QFontMetrics fm(p->font());
m_size = QSize(fm.width(m_text, m_text.length()), fm.height());
case LayoutMode:
m_layout.draw(p, rect.topLeft());
break;
-
-#if QT_VERSION >= 0x040700
case StaticTextWithMaximumSizeMode:
case StaticTextMode:
p->drawStaticText(rect.topLeft(), m_staticTexts.at(0));
p->drawStaticText(rect.topLeft(), m_staticTexts.at(m_currentStaticText));
m_currentStaticText = (m_currentStaticText + 1) % m_staticTexts.size();
break;
-#endif
}
}
case LayoutMode: type = "layout.draw()"; break;
case DocumentMode: type = "doc.drawContents()"; break;
case PixmapMode: type = "pixmap cached text"; break;
-
-#if QT_VERSION >= 0x040700
case StaticTextMode: type = "drawStaticText()"; break;
case StaticTextWithMaximumSizeMode: type = "drawStaticText() w/ maxsize"; break;
case StaticTextBackendOptimizations: type = "drawStaticText() w/ backend optimizations"; break;
-#endif
}
return QString::fromLatin1("%3, len=%1, lines=%2")
QList<QPixmap> m_pixmaps;
int m_currentPixmap;
-#if QT_VERSION >= 0x040700
int m_currentStaticText;
QList<QStaticText> m_staticTexts;
-#endif
};
-
-
-
class ClippedDrawRectBenchmark : public Benchmark
{
public:
benchmarks << (new DrawText(longString, DrawText::PixmapMode));
benchmarks << (new DrawText(superLongString, DrawText::PixmapMode));
-#if QT_VERSION >= 0x040700
benchmarks << (new DrawText(shortString, DrawText::StaticTextMode));
benchmarks << (new DrawText(middleString, DrawText::StaticTextMode));
benchmarks << (new DrawText(longString, DrawText::StaticTextMode));
benchmarks << (new DrawText(middleString, DrawText::StaticTextBackendOptimizations));
benchmarks << (new DrawText(longString, DrawText::StaticTextBackendOptimizations));
benchmarks << (new DrawText(superLongString, DrawText::StaticTextBackendOptimizations));
-#endif
foreach (Benchmark *benchmark, benchmarks)
QTest::newRow(qPrintable(benchmark->name())) << reinterpret_cast<void *>(benchmark);
}
}
-void ReplayWidget::resizeEvent(QResizeEvent *event)
+void ReplayWidget::resizeEvent(QResizeEvent * /* event */)
{
visibleUpdates.clear();
void tst_QText::document()
{
QTextDocument *doc = new QTextDocument;
+ Q_UNUSED(doc)
QBENCHMARK {
QTextDocument *doc = new QTextDocument;
void tst_QText::control()
{
QTextControl *control = new QTextControl(m_shortLorem);
+ Q_UNUSED(control);
QBENCHMARK {
QTextControl *control = new QTextControl;
QByteArray data;
data.resize(1024*1024*10); // 10 MB
// init with garbage. needed so ssl cannot compress it in an efficient way.
- for (int i = 0; i < data.size() / sizeof(int); i++) {
+ for (size_t i = 0; i < data.size() / sizeof(int); i++) {
int r = qrand();
data.data()[i*sizeof(int)] = r;
}
#include <QtCore/QDir>
#include <QtCore/QQueue>
#include <QtCore/QHash>
+#include <QtCore/QPair>
#include <QtCore/qdebug.h>
#include <QtCore/QCoreApplication>
{
}
+// 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);
- 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()));
- }
- }
+ QXmlStreamReader reader(dev);
+ d->m_errorString.clear();
+ if (!readUiAttributes(reader, d->m_language, &d->m_errorString)) {
+ uiLibWarning(d->m_errorString);
+ return false;
}
+ DomUI ui;
+ 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;
}
#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
void setScriptingEnabled(bool enabled);
bool isScriptingEnabled() const;
+ QString errorString() const;
+
protected:
//
// load
virtual void addWidget(QWidget *widget) = 0;
virtual void insertWidget(int index, QWidget *widget) = 0;
virtual void remove(int index) = 0;
+
+ virtual bool canAddWidget() const
+ // ### Qt6 remove body, provided in Qt5 for source compatibility to Qt4.
+ { return true; }
+ virtual bool canRemove(int index) const
+ // ### Qt6 remove body, provided in Qt5 for source compatibility to Qt4.
+ { Q_UNUSED(index); return true; }
};
Q_DECLARE_EXTENSION_INTERFACE(QDesignerContainerExtension, "com.trolltech.Qt.Designer.Container")
\sa addWidget(), insertWidget()
*/
+
+/*!
+ \fn bool QDesignerContainerExtension::canAddWidget() const
+
+ Returns whether a widget can be added. This determines whether
+ the context menu options to add or insert pages are enabled.
+
+ This should return false for containers that have a single, fixed
+ page, for example QScrollArea or QDockWidget.
+
+ \since 5.0
+ \sa addWidget(), canRemove()
+*/
+
+/*!
+ \fn bool QDesignerContainerExtension::canRemove(int index) const
+
+ Returns whether the widget at the given \a index can be removed.
+ This determines whether the context menu option to remove the current
+ page is enabled.
+
+ This should return false for containers that have a single, fixed
+ page, for example QScrollArea or QDockWidget.
+
+ \since 5.0
+ \sa remove(), canAddWidget()
+*/
QFormBuilderExtra::QFormBuilderExtra() :
m_defaultMargin(INT_MIN),
m_defaultSpacing(INT_MIN),
+ m_language(QLatin1String("c++")),
m_layoutWidget(false),
m_resourceBuilder(0),
m_textBuilder(0)
int m_defaultMargin;
int m_defaultSpacing;
QDir m_workingDirectory;
+ QString m_errorString;
+ QString m_language;
private:
void clearResourceBuilder();