summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@nokia.com>2009-11-19 09:58:03 +0100
committerPaul Olav Tvete <paul.tvete@nokia.com>2009-11-19 09:58:03 +0100
commit879e2ea7d15510ec5f94d6d7a005b157b115f69f (patch)
tree73aedd0bffe7ab39387229a9417aa50cecbbf0aa /tests
parent8fc2eec5b3282665f76f1e0313a03608bf4e7bc1 (diff)
parent80cd617b05ad3e647c87dc063d40cde0617344ca (diff)
Merge remote branch 'origin/4.6' into lighthouse
Conflicts: configure src/plugins/graphicssystems/graphicssystems.pro
Diffstat (limited to 'tests')
-rw-r--r--tests/arthur/common/paintcommands.cpp20
-rw-r--r--tests/arthur/common/paintcommands.h2
-rw-r--r--tests/auto/auto.pro7
-rw-r--r--tests/auto/bic/tst_bic.cpp4
-rw-r--r--tests/auto/checkxmlfiles/checkxmlfiles.pro2
-rw-r--r--tests/auto/collections/tst_collections.cpp109
-rw-r--r--tests/auto/gestures/tst_gestures.cpp973
-rw-r--r--tests/auto/guiapplauncher/README.txt14
-rw-r--r--tests/auto/guiapplauncher/guiapplauncher.pro20
-rw-r--r--tests/auto/guiapplauncher/test.ts973
-rw-r--r--tests/auto/guiapplauncher/test.ui66
-rw-r--r--tests/auto/guiapplauncher/tst_guiapplauncher.cpp526
-rw-r--r--tests/auto/guiapplauncher/windowmanager.cpp508
-rw-r--r--tests/auto/guiapplauncher/windowmanager.h (renamed from tests/benchmarks/qnetworkreply/main.cpp)58
-rw-r--r--tests/auto/headers/tst_headers.cpp2
-rw-r--r--tests/auto/linguist/lconvert/tst_lconvert.cpp8
-rw-r--r--tests/auto/linguist/lrelease/testdata/idbased.ts7
-rw-r--r--tests/auto/linguist/lrelease/tst_lrelease.cpp21
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp17
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before22
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result25
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before13
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result8
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before13
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result12
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp24
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result14
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp49
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.h (renamed from tests/auto/qstringbuilder1/stringbuilder.h)16
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result24
-rw-r--r--tests/auto/linguist/lupdate/testlupdate.cpp4
-rw-r--r--tests/auto/linguist/lupdate/tst_lupdate.cpp12
-rw-r--r--tests/auto/networkselftest/tst_networkselftest.cpp17
-rw-r--r--tests/auto/q3filedialog/tst_q3filedialog.cpp4
-rw-r--r--tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp7
-rw-r--r--tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp63
-rw-r--r--tests/auto/qabstractitemview/tst_qabstractitemview.cpp45
-rw-r--r--tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp97
-rw-r--r--tests/auto/qabstractslider/tst_qabstractslider.cpp20
-rw-r--r--tests/auto/qabstractvideosurface/tst_qabstractvideosurface.cpp38
-rw-r--r--tests/auto/qaccessibility/tst_qaccessibility.cpp21
-rw-r--r--tests/auto/qactiongroup/tst_qactiongroup.cpp21
-rw-r--r--tests/auto/qalgorithms/tst_qalgorithms.cpp17
-rw-r--r--tests/auto/qanimationgroup/tst_qanimationgroup.cpp84
-rw-r--r--tests/auto/qapplication/tst_qapplication.cpp85
-rw-r--r--tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp6
-rw-r--r--tests/auto/qaudioformat/tst_qaudioformat.cpp15
-rw-r--r--tests/auto/qaudioinput/tst_qaudioinput.cpp14
-rw-r--r--tests/auto/qaudiooutput/tst_qaudiooutput.cpp18
-rw-r--r--tests/auto/qboxlayout/tst_qboxlayout.cpp1
-rw-r--r--tests/auto/qbuttongroup/tst_qbuttongroup.cpp11
-rw-r--r--tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp70
-rw-r--r--tests/auto/qclipboard/test/test.pro15
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp138
-rw-r--r--tests/auto/qcompleter/tst_qcompleter.cpp2
-rw-r--r--tests/auto/qcoreapplication/tst_qcoreapplication.cpp36
-rw-r--r--tests/auto/qcssparser/tst_qcssparser.cpp3
-rw-r--r--tests/auto/qdatastream/qdatastream.pro2
-rw-r--r--tests/auto/qdatastream/tst_qdatastream.cpp86
-rw-r--r--tests/auto/qdatawidgetmapper/tst_qdatawidgetmapper.cpp2
-rw-r--r--tests/auto/qdatetime/tst_qdatetime.cpp8
-rw-r--r--tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp60
-rw-r--r--tests/auto/qdbusinterface/tst_qdbusinterface.cpp37
-rw-r--r--tests/auto/qdbusperformance/tst_qdbusperformance.cpp22
-rw-r--r--tests/auto/qdbusservicewatcher/qdbusservicewatcher.pro8
-rw-r--r--tests/auto/qdbusservicewatcher/tst_qdbusservicewatcher.cpp273
-rw-r--r--tests/auto/qdockwidget/tst_qdockwidget.cpp64
-rw-r--r--tests/auto/qfile/largefile/largefile.pro6
-rw-r--r--tests/auto/qfile/largefile/tst_largefile.cpp540
-rw-r--r--tests/auto/qfile/qfile.pro2
-rw-r--r--tests/auto/qfile/test/test.pro1
-rw-r--r--tests/auto/qfile/tst_qfile.cpp301
-rw-r--r--tests/auto/qfiledialog/tst_qfiledialog.cpp867
-rw-r--r--tests/auto/qfiledialog2/qfiledialog2.pro27
-rw-r--r--tests/auto/qfiledialog2/tst_qfiledialog2.cpp1044
-rw-r--r--tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp22
-rw-r--r--tests/auto/qfont/tst_qfont.cpp7
-rw-r--r--tests/auto/qfontcombobox/tst_qfontcombobox.cpp6
-rw-r--r--tests/auto/qfontmetrics/tst_qfontmetrics.cpp14
-rw-r--r--tests/auto/qgl/tst_qgl.cpp339
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp681
-rw-r--r--tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp68
-rw-r--r--tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp12
-rw-r--r--tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp129
-rw-r--r--tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp27
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp393
-rw-r--r--tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp20
-rw-r--r--tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp42
-rw-r--r--tests/auto/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp2
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp69
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp270
-rw-r--r--tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp62
-rw-r--r--tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp69
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp74
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview_2.cpp212
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp27
-rw-r--r--tests/auto/qgridlayout/tst_qgridlayout.cpp40
-rw-r--r--tests/auto/qheaderview/tst_qheaderview.cpp7
-rw-r--r--tests/auto/qhttp/tst_qhttp.cpp43
-rw-r--r--tests/auto/qimage/tst_qimage.cpp24
-rw-r--r--tests/auto/qimagereader/images/grayscale-ref.tifbin0 -> 256182 bytes
-rw-r--r--tests/auto/qimagereader/images/grayscale.tifbin0 -> 64162 bytes
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp9
-rw-r--r--tests/auto/qimagewriter/tst_qimagewriter.cpp19
-rw-r--r--tests/auto/qitemdelegate/tst_qitemdelegate.cpp2
-rw-r--r--tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp65
-rw-r--r--tests/auto/qkeysequence/tst_qkeysequence.cpp45
-rw-r--r--tests/auto/qlabel/qlabel.pro21
-rw-r--r--tests/auto/qlabel/tst_qlabel.cpp117
-rw-r--r--tests/auto/qlayout/tst_qlayout.cpp28
-rw-r--r--tests/auto/qlcdnumber/tst_qlcdnumber.cpp16
-rw-r--r--tests/auto/qlibrary/lib2/lib2.pro6
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp40
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp123
-rw-r--r--tests/auto/qlistwidget/tst_qlistwidget.cpp59
-rw-r--r--tests/auto/qlocalsocket/tst_qlocalsocket.cpp12
-rw-r--r--tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp168
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp27
-rw-r--r--tests/auto/qmenubar/tst_qmenubar.cpp29
-rw-r--r--tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp39
-rw-r--r--tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp18
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp520
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp103
-rw-r--r--tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp153
-rw-r--r--tests/auto/qpauseanimation/tst_qpauseanimation.cpp56
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp31
-rw-r--r--tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp4
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp48
-rw-r--r--tests/auto/qregexp/tst_qregexp.cpp28
-rw-r--r--tests/auto/qregion/tst_qregion.cpp20
-rw-r--r--tests/auto/qscopedpointer/tst_qscopedpointer.cpp132
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp151
-rw-r--r--tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp124
-rw-r--r--tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp24
-rw-r--r--tests/auto/qscriptstring/tst_qscriptstring.cpp37
-rw-r--r--tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp517
-rw-r--r--tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp71
-rw-r--r--tests/auto/qsound/tst_qsound.cpp26
-rw-r--r--tests/auto/qsplitter/tst_qsplitter.cpp34
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp10
-rw-r--r--tests/auto/qsqlquery/tst_qsqlquery.cpp102
-rw-r--r--tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp18
-rw-r--r--tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp36
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp110
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp199
-rw-r--r--tests/auto/qstring/tst_qstring.cpp9
-rw-r--r--tests/auto/qstringbuilder1/qstringbuilder1.pro3
-rw-r--r--tests/auto/qstringbuilder1/stringbuilder.cpp82
-rw-r--r--tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp33
-rw-r--r--tests/auto/qstringbuilder2/qstringbuilder2.pro3
-rw-r--r--tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp32
-rw-r--r--tests/auto/qstringbuilder3/qstringbuilder3.pro3
-rw-r--r--tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp31
-rw-r--r--tests/auto/qstringbuilder4/qstringbuilder4.pro3
-rw-r--r--tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp34
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp171
-rw-r--r--tests/auto/qtablewidget/tst_qtablewidget.cpp21
-rw-r--r--tests/auto/qtabwidget/tst_qtabwidget.cpp6
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp57
-rw-r--r--tests/auto/qtextdocument/qtextdocument.pro1
-rw-r--r--tests/auto/qtextdocument/tst_qtextdocument.cpp77
-rw-r--r--tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp10
-rw-r--r--tests/auto/qtextedit/fullWidthSelection/centered-fully-selected.pngbin1232 -> 1232 bytes
-rw-r--r--tests/auto/qtextedit/fullWidthSelection/centered-partly-selected.pngbin1231 -> 1231 bytes
-rw-r--r--tests/auto/qtextedit/fullWidthSelection/last-char-on-line.pngbin1220 -> 1226 bytes
-rw-r--r--tests/auto/qtextedit/fullWidthSelection/last-char-on-parag.pngbin1222 -> 1223 bytes
-rw-r--r--tests/auto/qtextedit/fullWidthSelection/multiple-full-width-lines.pngbin1236 -> 1236 bytes
-rw-r--r--tests/auto/qtextedit/fullWidthSelection/nowrap_long.pngbin1199 -> 1199 bytes
-rw-r--r--tests/auto/qtextedit/fullWidthSelection/single-full-width-line.pngbin1235 -> 1225 bytes
-rw-r--r--tests/auto/qtextedit/tst_qtextedit.cpp4
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp13
-rw-r--r--tests/auto/qtextscriptengine/generate/generate.pro1
-rw-r--r--tests/auto/qtextscriptengine/generate/main.cpp4
-rw-r--r--tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp87
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp189
-rw-r--r--tests/auto/qtreewidget/tst_qtreewidget.cpp67
-rw-r--r--tests/auto/qudpsocket/tst_qudpsocket.cpp10
-rw-r--r--tests/auto/qurl/tst_qurl.cpp63
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp263
-rw-r--r--tests/auto/qvideoframe/tst_qvideoframe.cpp18
-rw-r--r--tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp116
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp330
-rw-r--r--tests/auto/qwidgetaction/tst_qwidgetaction.cpp2
-rw-r--r--tests/auto/qworkspace/tst_qworkspace.cpp3
-rw-r--r--tests/auto/qxmlnodemodelindex/tst_qxmlnodemodelindex.cpp2
-rw-r--r--tests/auto/qxmlquery/tst_qxmlquery.cpp14
-rw-r--r--tests/auto/qxmlschema/tst_qxmlschema.cpp4
-rw-r--r--tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp12
-rw-r--r--tests/auto/qxmlserializer/tst_qxmlserializer.cpp4
-rw-r--r--tests/auto/uic/baseline/mainwindowbase.ui.h1
-rw-r--r--tests/auto/uiloader/baseline/css_itemview_task258382.ui179
-rw-r--r--tests/auto/xmlpatterns.pri5
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt2
-rw-r--r--tests/auto/xmlpatterns/tst_xmlpatterns.cpp14
-rw-r--r--tests/auto/xmlpatterns/xmlpatterns.pro6
-rw-r--r--tests/auto/xmlpatternsdiagnosticsts/test/test.pro4
-rw-r--r--tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro5
-rw-r--r--tests/auto/xmlpatternsxqts/lib/Global.h2
-rw-r--r--tests/auto/xmlpatternsxqts/lib/lib.pro6
-rw-r--r--tests/auto/xmlpatternsxqts/test/test.pro2
-rw-r--r--tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro2
-rw-r--r--tests/benchmarks/benchmarks.pro4
-rw-r--r--tests/benchmarks/qanimation/rectanimation.cpp5
-rw-r--r--tests/benchmarks/qanimation/rectanimation.h1
-rw-r--r--tests/benchmarks/qapplication/main.cpp30
-rw-r--r--tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp236
-rw-r--r--tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp4
-rw-r--r--tests/benchmarks/qnetworkreply/qnetworkreply.pro2
-rw-r--r--tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp642
-rw-r--r--tests/benchmarks/qscriptengine/tst_qscriptengine.cpp19
-rw-r--r--tests/manual/gestures/graphicsview/gestures.cpp24
-rw-r--r--tests/manual/gestures/graphicsview/gestures.h8
-rw-r--r--tests/manual/gestures/graphicsview/main.cpp12
-rw-r--r--tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp50
-rw-r--r--tests/manual/gestures/graphicsview/mousepangesturerecognizer.h4
-rw-r--r--tests/manual/gestures/scrollarea/main.cpp70
-rw-r--r--tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp41
-rw-r--r--tests/manual/gestures/scrollarea/mousepangesturerecognizer.h4
-rw-r--r--tests/manual/textrendering/glyphshaping/glyphshaping.pro5
-rw-r--r--tests/manual/textrendering/glyphshaping/glyphshaping_data.xml251
-rw-r--r--tests/manual/textrendering/glyphshaping/main.cpp269
-rw-r--r--tests/manual/textrendering/textperformance/main.cpp231
-rw-r--r--tests/manual/textrendering/textperformance/textperformance.pro1
-rw-r--r--tests/manual/windowflags/previewwindow.cpp20
-rw-r--r--tests/manual/windowflags/previewwindow.h6
227 files changed, 14271 insertions, 3511 deletions
diff --git a/tests/arthur/common/paintcommands.cpp b/tests/arthur/common/paintcommands.cpp
index 475f07d9cf..feabaed3c7 100644
--- a/tests/arthur/common/paintcommands.cpp
+++ b/tests/arthur/common/paintcommands.cpp
@@ -587,10 +587,10 @@ void PaintCommands::staticInit()
"^image_setColor\\s+([\\w.:\\/]*)\\s+([0-9]*)\\s+#([0-9]*)$",
"image_setColor <imageName> <index> <color>",
"image_setColor myImage 0 black");
- DECL_PAINTCOMMAND("image_setNumColors", command_image_setNumColors,
- "^image_setNumColors\\s+([\\w.:\\/]*)\\s+([0-9]*)$",
- "image_setNumColors <imageName> <nbColors>",
- "image_setNumColors myImage 128");
+ DECL_PAINTCOMMAND("image_setColorCount", command_image_setColorCount,
+ "^image_setColorCount\\s+([\\w.:\\/]*)\\s+([0-9]*)$",
+ "image_setColorCount <imageName> <nbColors>",
+ "image_setColorCount myImage 128");
DECL_PAINTCOMMANDSECTION("transformations");
DECL_PAINTCOMMAND("resetMatrix", command_resetMatrix,
@@ -974,7 +974,7 @@ void PaintCommands::command_drawPixmap(QRegExp re)
if (sh == 0) sh = -1;
if (m_verboseMode)
- printf(" -(lance) drawPixmap('%s' dim=(%d, %d), depth=%d, (%d, %d, %d, %d), (%d, %d, %d, %d)\n",
+ printf(" -(lance) drawPixmap('%s' dim=(%d, %d), depth=%d, (%f, %f, %f, %f), (%f, %f, %f, %f)\n",
qPrintable(re.cap(1)), pm.width(), pm.height(), pm.depth(),
tx, ty, tw, th, sx, sy, sw, sh);
@@ -1022,7 +1022,7 @@ void PaintCommands::command_drawImage(QRegExp re)
if (sh == 0) sh = -1;
if (m_verboseMode)
- printf(" -(lance) drawImage('%s' dim=(%d, %d), (%d, %d, %d, %d), (%d, %d, %d, %d)\n",
+ printf(" -(lance) drawImage('%s' dim=(%d, %d), (%f, %f, %f, %f), (%f, %f, %f, %f)\n",
qPrintable(re.cap(1)), im.width(), im.height(), tx, ty, tw, th, sx, sy, sw, sh);
m_painter->drawImage(QRectF(tx, ty, tw, th), im, QRectF(sx, sy, sw, sh), Qt::OrderedDither | Qt::OrderedAlphaDither);
@@ -2245,7 +2245,7 @@ void PaintCommands::command_image_load(QRegExp re)
}
/***************************************************************************************************/
-void PaintCommands::command_image_setNumColors(QRegExp re)
+void PaintCommands::command_image_setColorCount(QRegExp re)
{
QStringList caps = re.capturedTexts();
@@ -2253,10 +2253,10 @@ void PaintCommands::command_image_setNumColors(QRegExp re)
int count = convertToInt(caps.at(2));
if (m_verboseMode)
- printf(" -(lance) image_setNumColors(%s), %d -> %d\n",
- qPrintable(name), m_imageMap[name].numColors(), count);
+ printf(" -(lance) image_setColorCount(%s), %d -> %d\n",
+ qPrintable(name), m_imageMap[name].colorCount(), count);
- m_imageMap[name].setNumColors(count);
+ m_imageMap[name].setColorCount(count);
}
/***************************************************************************************************/
diff --git a/tests/arthur/common/paintcommands.h b/tests/arthur/common/paintcommands.h
index ba91a9266a..e2c4d67af7 100644
--- a/tests/arthur/common/paintcommands.h
+++ b/tests/arthur/common/paintcommands.h
@@ -239,7 +239,7 @@ private:
void command_image_convertToFormat(QRegExp re);
void command_image_load(QRegExp re);
void command_image_setColor(QRegExp re);
- void command_image_setNumColors(QRegExp re);
+ void command_image_setColorCount(QRegExp re);
// commands: transformation
void command_resetMatrix(QRegExp re);
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 8e3ce8149b..da1f7ca937 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -10,7 +10,8 @@ TEMPLATE = subdirs
linguist \
moc \
uic \
- uic3
+ uic3 \
+ guiapplauncher
Q3SUBDIRS += \
q3accel \
q3action \
@@ -127,6 +128,7 @@ SUBDIRS += \
qexplicitlyshareddatapointer \
qfile \
qfiledialog \
+ qfiledialog2 \
qfileinfo \
qfilesystemwatcher \
qfilesystemmodel \
@@ -134,6 +136,7 @@ SUBDIRS += \
qfocusevent \
qfocusframe \
qfont \
+ qfontcombobox \
qfontdatabase \
qfontdialog \
qfontmetrics \
@@ -500,3 +503,5 @@ contains(QT_CONFIG, webkit): SUBDIRS += \
qwebhistoryinterface \
qwebelement \
qwebhistory
+
+contains(QT_CONFIG, declarative): SUBDIRS += declarative
diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp
index 8c6056e8c6..b7c79cfbd3 100644
--- a/tests/auto/bic/tst_bic.cpp
+++ b/tests/auto/bic/tst_bic.cpp
@@ -96,6 +96,9 @@ tst_Bic::tst_Bic()
/* QtOpenGL includes qt_windows.h, and some SDKs dont have these structs present */
bic.addBlacklistedClass(QLatin1String("tagTITLEBARINFO"));
+ bic.addBlacklistedClass(QLatin1String("tagMENUITEMINFOA"));
+ bic.addBlacklistedClass(QLatin1String("tagMENUITEMINFOW"));
+ bic.addBlacklistedClass(QLatin1String("tagENHMETAHEADER"));
/* some bug in gcc also reported template instanciations */
bic.addBlacklistedClass(QLatin1String("QTypeInfo<*>"));
@@ -115,6 +118,7 @@ tst_Bic::tst_Bic()
bic.addBlacklistedClass(QLatin1String("QObjectData"));
bic.addBlacklistedClass(QLatin1String("QAtomic"));
bic.addBlacklistedClass(QLatin1String("QBasicAtomic"));
+ bic.addBlacklistedClass(QLatin1String("QRegion::QRegionData"));
/* Jambi-related classes in Designer */
bic.addBlacklistedClass(QLatin1String("QDesignerLanguageExtension"));
diff --git a/tests/auto/checkxmlfiles/checkxmlfiles.pro b/tests/auto/checkxmlfiles/checkxmlfiles.pro
index c368c02114..d53c11cedc 100644
--- a/tests/auto/checkxmlfiles/checkxmlfiles.pro
+++ b/tests/auto/checkxmlfiles/checkxmlfiles.pro
@@ -12,7 +12,7 @@ addFiles.sources = \
$$QT_SOURCE_TREE/examples/sql/masterdetail/albumdetails.xml \
$$QT_SOURCE_TREE/examples/xmlpatterns/xquery/globalVariables/globals.gccxml \
$$QT_SOURCE_TREE/doc/src/diagrams/stylesheet/treeview.svg \
- $$QT_SOURCE_TREE/doc/src/diagrams/designer-mainwindow-actions.ui \
+ $$QT_SOURCE_TREE/doc/src/diagrams/designer-manual/designer-mainwindow-actions.ui \
$$QT_SOURCE_TREE/demos/undo/undo.qrc
addFiles.path = xmlfiles
DEPLOYMENT += addFiles
diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp
index 670cff0377..84f466be93 100644
--- a/tests/auto/collections/tst_collections.cpp
+++ b/tests/auto/collections/tst_collections.cpp
@@ -164,6 +164,7 @@ private slots:
void qtimerList();
void containerTypedefs();
void forwardDeclared();
+ void alignment();
};
struct LargeStatic {
@@ -3481,5 +3482,113 @@ void tst_Collections::forwardDeclared()
{ typedef QSet<T1> C; C *x = 0; /* C::iterator i; */ C::const_iterator j; Q_UNUSED(x) }
}
+#if defined(Q_ALIGNOF) && defined(Q_DECL_ALIGN)
+
+class Q_DECL_ALIGN(4) Aligned4
+{
+ char i;
+public:
+ Aligned4(int i = 0) : i(i) {}
+ bool checkAligned() const
+ {
+ return (quintptr(this) & 3) == 0;
+ }
+
+ inline bool operator==(const Aligned4 &other) const { return i == other.i; }
+ inline bool operator<(const Aligned4 &other) const { return i < other.i; }
+ friend inline int qHash(const Aligned4 &a) { return qHash(a.i); }
+};
+
+class Q_DECL_ALIGN(128) Aligned128
+{
+ char i;
+public:
+ Aligned128(int i = 0) : i(i) {}
+ bool checkAligned() const
+ {
+ return (quintptr(this) & 127) == 0;
+ }
+
+ inline bool operator==(const Aligned128 &other) const { return i == other.i; }
+ inline bool operator<(const Aligned128 &other) const { return i < other.i; }
+ friend inline int qHash(const Aligned128 &a) { return qHash(a.i); }
+};
+
+template<typename C>
+void testVectorAlignment()
+{
+ typedef typename C::value_type Aligned;
+ C container;
+ container.append(Aligned());
+ QVERIFY(container[0].checkAligned());
+
+ for (int i = 0; i < 200; ++i)
+ container.append(Aligned());
+
+ for (int i = 0; i < container.size(); ++i)
+ QVERIFY(container.at(i).checkAligned());
+}
+
+template<typename C>
+void testContiguousCacheAlignment()
+{
+ typedef typename C::value_type Aligned;
+ C container(150);
+ container.append(Aligned());
+ QVERIFY(container[container.firstIndex()].checkAligned());
+
+ for (int i = 0; i < 200; ++i)
+ container.append(Aligned());
+
+ for (int i = container.firstIndex(); i < container.lastIndex(); ++i)
+ QVERIFY(container.at(i).checkAligned());
+}
+
+template<typename C>
+void testAssociativeContainerAlignment()
+{
+ typedef typename C::key_type Key;
+ typedef typename C::mapped_type Value;
+ C container;
+ container.insert(Key(), Value());
+
+ typename C::const_iterator it = container.constBegin();
+ QVERIFY(it.key().checkAligned());
+ QVERIFY(it.value().checkAligned());
+
+ // add some more elements
+ for (int i = 0; i < 200; ++i)
+ container.insert(Key(i), Value(i));
+
+ it = container.constBegin();
+ for ( ; it != container.constEnd(); ++it) {
+ QVERIFY(it.key().checkAligned());
+ QVERIFY(it.value().checkAligned());
+ }
+}
+
+void tst_Collections::alignment()
+{
+ testVectorAlignment<QVector<Aligned4> >();
+ testVectorAlignment<QVector<Aligned128> >();
+ testContiguousCacheAlignment<QContiguousCache<Aligned4> >();
+ testContiguousCacheAlignment<QContiguousCache<Aligned128> >();
+ testAssociativeContainerAlignment<QMap<Aligned4, Aligned4> >();
+ testAssociativeContainerAlignment<QMap<Aligned4, Aligned128> >();
+ testAssociativeContainerAlignment<QMap<Aligned128, Aligned4> >();
+ testAssociativeContainerAlignment<QMap<Aligned128, Aligned128> >();
+ testAssociativeContainerAlignment<QHash<Aligned4, Aligned4> >();
+ testAssociativeContainerAlignment<QHash<Aligned4, Aligned128> >();
+ testAssociativeContainerAlignment<QHash<Aligned128, Aligned4> >();
+ testAssociativeContainerAlignment<QHash<Aligned128, Aligned128> >();
+}
+
+#else
+void tst_Collections::alignment()
+{
+ QSKIP("Compiler doesn't support necessary extension keywords", SkipAll);
+}
+#endif
+
QTEST_APPLESS_MAIN(tst_Collections)
#include "tst_collections.moc"
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
index 46ed45e5ad..20b53f2d34 100644
--- a/tests/auto/gestures/tst_gestures.cpp
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -56,6 +56,11 @@
//TESTED_CLASS=
//TESTED_FILES=
+static QPointF mapToGlobal(const QPointF &pt, QGraphicsItem *item, QGraphicsView *view)
+{
+ return view->mapToGlobal(view->mapFromScene(item->mapToScene(pt)));
+}
+
class CustomGesture : public QGesture
{
Q_OBJECT
@@ -63,11 +68,10 @@ public:
static Qt::GestureType GestureType;
CustomGesture(QObject *parent = 0)
- : QGesture(parent), target(0), serial(0)
+ : QGesture(parent), serial(0)
{
}
- QObject *target;
int serial;
static const int SerialMaybeThreshold;
@@ -86,48 +90,51 @@ public:
CustomEvent(int serial_ = 0)
: QEvent(QEvent::Type(CustomEvent::EventType)),
- serial(serial_), targetObject(0)
+ serial(serial_), hasHotSpot(false)
{
}
int serial;
- QObject *targetObject;
- QPoint hotSpot;
+ QPointF hotSpot;
+ bool hasHotSpot;
};
int CustomEvent::EventType = 0;
class CustomGestureRecognizer : public QGestureRecognizer
{
public:
+ static bool ConsumeEvents;
+
CustomGestureRecognizer()
{
- CustomEvent::EventType = QEvent::registerEventType();
- eventsCounter = 0;
+ if (!CustomEvent::EventType)
+ CustomEvent::EventType = QEvent::registerEventType();
}
- QGesture* createGesture(QObject *)
+ QGesture* create(QObject *)
{
return new CustomGesture;
}
- QGestureRecognizer::Result filterEvent(QGesture *state, QObject*, QEvent *event)
+ QGestureRecognizer::Result recognize(QGesture *state, QObject*, QEvent *event)
{
if (event->type() == CustomEvent::EventType) {
- QGestureRecognizer::Result result = QGestureRecognizer::ConsumeEventHint;
+ QGestureRecognizer::Result result = 0;
+ if (CustomGestureRecognizer::ConsumeEvents)
+ result |= QGestureRecognizer::ConsumeEventHint;
CustomGesture *g = static_cast<CustomGesture*>(state);
CustomEvent *e = static_cast<CustomEvent*>(event);
g->serial = e->serial;
- g->setTargetObject(e->targetObject);
- g->setHotSpot(e->hotSpot);
- ++eventsCounter;
+ if (e->hasHotSpot)
+ g->setHotSpot(e->hotSpot);
if (g->serial >= CustomGesture::SerialFinishedThreshold)
- result |= QGestureRecognizer::GestureFinished;
+ result |= QGestureRecognizer::FinishGesture;
else if (g->serial >= CustomGesture::SerialStartedThreshold)
- result |= QGestureRecognizer::GestureTriggered;
+ result |= QGestureRecognizer::TriggerGesture;
else if (g->serial >= CustomGesture::SerialMaybeThreshold)
- result |= QGestureRecognizer::MaybeGesture;
+ result |= QGestureRecognizer::MayBeGesture;
else
- result = QGestureRecognizer::NotGesture;
+ result = QGestureRecognizer::CancelGesture;
return result;
}
return QGestureRecognizer::Ignore;
@@ -135,20 +142,62 @@ public:
void reset(QGesture *state)
{
- CustomGesture *g = static_cast<CustomGesture*>(state);
+ CustomGesture *g = static_cast<CustomGesture *>(state);
g->serial = 0;
QGestureRecognizer::reset(state);
}
+};
+bool CustomGestureRecognizer::ConsumeEvents = false;
+
+// same as CustomGestureRecognizer but triggers early without the maybe state
+class CustomContinuousGestureRecognizer : public QGestureRecognizer
+{
+public:
+ CustomContinuousGestureRecognizer()
+ {
+ if (!CustomEvent::EventType)
+ CustomEvent::EventType = QEvent::registerEventType();
+ }
+
+ QGesture* create(QObject *)
+ {
+ return new CustomGesture;
+ }
- int eventsCounter;
- QString name;
+ QGestureRecognizer::Result recognize(QGesture *state, QObject*, QEvent *event)
+ {
+ if (event->type() == CustomEvent::EventType) {
+ QGestureRecognizer::Result result = QGestureRecognizer::ConsumeEventHint;
+ CustomGesture *g = static_cast<CustomGesture *>(state);
+ CustomEvent *e = static_cast<CustomEvent *>(event);
+ g->serial = e->serial;
+ if (e->hasHotSpot)
+ g->setHotSpot(e->hotSpot);
+ if (g->serial >= CustomGesture::SerialFinishedThreshold)
+ result |= QGestureRecognizer::FinishGesture;
+ else if (g->serial >= CustomGesture::SerialMaybeThreshold)
+ result |= QGestureRecognizer::TriggerGesture;
+ else
+ result = QGestureRecognizer::CancelGesture;
+ return result;
+ }
+ return QGestureRecognizer::Ignore;
+ }
+
+ void reset(QGesture *state)
+ {
+ CustomGesture *g = static_cast<CustomGesture *>(state);
+ g->serial = 0;
+ QGestureRecognizer::reset(state);
+ }
};
class GestureWidget : public QWidget
{
Q_OBJECT
public:
- GestureWidget(const char *name = 0)
+ GestureWidget(const char *name = 0, QWidget *parent = 0)
+ : QWidget(parent)
{
if (name)
setObjectName(QLatin1String(name));
@@ -162,6 +211,7 @@ public:
gestureOverrideEventsReceived = 0;
events.clear();
overrideEvents.clear();
+ ignoredGestures.clear();
}
int customEventsReceived;
@@ -186,14 +236,18 @@ public:
} events, overrideEvents;
bool acceptGestureOverride;
+ QSet<Qt::GestureType> ignoredGestures;
protected:
bool event(QEvent *event)
{
Events *eventsPtr = 0;
if (event->type() == QEvent::Gesture) {
+ QGestureEvent *e = static_cast<QGestureEvent*>(event);
++gestureEventsReceived;
eventsPtr = &events;
+ foreach(Qt::GestureType type, ignoredGestures)
+ e->ignore(e->gesture(type));
} else if (event->type() == QEvent::GestureOverride) {
++gestureOverrideEventsReceived;
eventsPtr = &overrideEvents;
@@ -202,7 +256,7 @@ protected:
}
if (eventsPtr) {
QGestureEvent *e = static_cast<QGestureEvent*>(event);
- QList<QGesture*> gestures = e->allGestures();
+ QList<QGesture*> gestures = e->gestures();
foreach(QGesture *g, gestures) {
eventsPtr->all << g->gestureType();
switch(g->state()) {
@@ -231,14 +285,16 @@ protected:
}
};
-static void sendCustomGesture(QObject *object)
+// TODO rename to sendGestureSequence
+static void sendCustomGesture(CustomEvent *event, QObject *object, QGraphicsScene *scene = 0)
{
- CustomEvent ev;
- ev.targetObject = object;
for (int i = CustomGesture::SerialMaybeThreshold;
i <= CustomGesture::SerialFinishedThreshold; ++i) {
- ev.serial = i;
- QApplication::sendEvent(object, &ev);
+ event->serial = i;
+ if (scene)
+ scene->sendEvent(qobject_cast<QGraphicsObject *>(object), event);
+ else
+ QApplication::sendEvent(object, event);
}
}
@@ -265,6 +321,18 @@ private slots:
void finishedWithoutStarted();
void unknownGesture();
void graphicsItemGesture();
+ void graphicsItemTreeGesture();
+ void explicitGraphicsObjectTarget();
+ void gestureOverChildGraphicsItem();
+ void twoGesturesOnDifferentLevel();
+ void multipleGesturesInTree();
+ void multipleGesturesInComplexTree();
+ void testMapToScene();
+ void ungrabGesture();
+ void consumeEventHint();
+ void unregisterRecognizer();
+ void autoCancelGestures();
+ void autoCancelGestures2();
};
tst_Gestures::tst_Gestures()
@@ -277,13 +345,14 @@ tst_Gestures::~tst_Gestures()
void tst_Gestures::initTestCase()
{
- CustomGesture::GestureType = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+ CustomGesture::GestureType = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
QVERIFY(CustomGesture::GestureType != Qt::GestureType(0));
QVERIFY(CustomGesture::GestureType != Qt::CustomGesture);
}
void tst_Gestures::cleanupTestCase()
{
+ QGestureRecognizer::unregisterRecognizer(CustomGesture::GestureType);
}
void tst_Gestures::init()
@@ -297,8 +366,9 @@ void tst_Gestures::cleanup()
void tst_Gestures::customGesture()
{
GestureWidget widget;
- widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
- sendCustomGesture(&widget);
+ widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+ CustomEvent event;
+ sendCustomGesture(&event, &widget);
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
@@ -314,10 +384,23 @@ void tst_Gestures::customGesture()
QCOMPARE(widget.events.canceled.size(), 0);
}
+void tst_Gestures::consumeEventHint()
+{
+ GestureWidget widget;
+ widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+
+ CustomGestureRecognizer::ConsumeEvents = true;
+ CustomEvent event;
+ sendCustomGesture(&event, &widget);
+ CustomGestureRecognizer::ConsumeEvents = false;
+
+ QCOMPARE(widget.customEventsReceived, 0);
+}
+
void tst_Gestures::autoCancelingGestures()
{
GestureWidget widget;
- widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+ widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
// send partial gesture. The gesture will be in the "maybe" state, but will
// never get enough events to fire, so Qt will have to kill it.
CustomEvent ev;
@@ -341,9 +424,10 @@ void tst_Gestures::gestureOverChild()
GestureWidget *child = new GestureWidget("child");
l->addWidget(child);
- widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+ widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
- sendCustomGesture(child);
+ CustomEvent event;
+ sendCustomGesture(&event, child);
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
@@ -356,12 +440,12 @@ void tst_Gestures::gestureOverChild()
QCOMPARE(widget.gestureOverrideEventsReceived, 0);
// enable gestures over the children
- widget.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture);
+ widget.grabGesture(CustomGesture::GestureType);
widget.reset();
child->reset();
- sendCustomGesture(child);
+ sendCustomGesture(&event, child);
QCOMPARE(child->customEventsReceived, TotalCustomEventsCount);
QCOMPARE(widget.customEventsReceived, 0);
@@ -385,14 +469,15 @@ void tst_Gestures::multipleWidgetOnlyGestureInTree()
GestureWidget *child = new GestureWidget("child");
l->addWidget(child);
- parent.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
- child->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+ parent.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+ child->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
// sending events to the child and making sure there is no conflict
- sendCustomGesture(child);
+ CustomEvent event;
+ sendCustomGesture(&event, child);
QCOMPARE(child->customEventsReceived, TotalCustomEventsCount);
QCOMPARE(parent.customEventsReceived, 0);
@@ -405,7 +490,7 @@ void tst_Gestures::multipleWidgetOnlyGestureInTree()
child->reset();
// same for the parent widget
- sendCustomGesture(&parent);
+ sendCustomGesture(&event, &parent);
QCOMPARE(child->customEventsReceived, 0);
QCOMPARE(parent.customEventsReceived, TotalCustomEventsCount);
@@ -422,8 +507,8 @@ void tst_Gestures::conflictingGestures()
GestureWidget *child = new GestureWidget("child");
l->addWidget(child);
- parent.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture);
- child->grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture);
+ parent.grabGesture(CustomGesture::GestureType);
+ child->grabGesture(CustomGesture::GestureType);
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
@@ -432,10 +517,11 @@ void tst_Gestures::conflictingGestures()
child->acceptGestureOverride = true;
// sending events to the child and making sure there is no conflict
- sendCustomGesture(child);
+ CustomEvent event;
+ sendCustomGesture(&event, child);
- QCOMPARE(child->gestureOverrideEventsReceived, TotalGestureEventsCount);
- QCOMPARE(child->gestureEventsReceived, 0);
+ QCOMPARE(child->gestureOverrideEventsReceived, 1);
+ QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(parent.gestureOverrideEventsReceived, 0);
QCOMPARE(parent.gestureEventsReceived, 0);
@@ -447,33 +533,90 @@ void tst_Gestures::conflictingGestures()
child->acceptGestureOverride = false;
// sending events to the child and making sure there is no conflict
- sendCustomGesture(child);
+ sendCustomGesture(&event, child);
- QCOMPARE(child->gestureOverrideEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(child->gestureOverrideEventsReceived, 1);
QCOMPARE(child->gestureEventsReceived, 0);
- QCOMPARE(parent.gestureOverrideEventsReceived, TotalGestureEventsCount);
- QCOMPARE(parent.gestureEventsReceived, 0);
+ QCOMPARE(parent.gestureOverrideEventsReceived, 1);
+ QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount);
+
+ parent.reset();
+ child->reset();
+
+ // nobody accepts the override, we will send normal events to the closest
+ // context (i.e. to the child widget) and it will be propagated and
+ // accepted by the parent widget
+ parent.acceptGestureOverride = false;
+ child->acceptGestureOverride = false;
+ child->ignoredGestures << CustomGesture::GestureType;
+
+ // sending events to the child and making sure there is no conflict
+ sendCustomGesture(&event, child);
+
+ QCOMPARE(child->gestureOverrideEventsReceived, 1);
+ QCOMPARE(child->gestureEventsReceived, 1);
+ QCOMPARE(parent.gestureOverrideEventsReceived, 1);
+ QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount);
+
+ parent.reset();
+ child->reset();
+
+ // nobody accepts the override, and nobody accepts the gesture event
+ parent.acceptGestureOverride = false;
+ child->acceptGestureOverride = false;
+ parent.ignoredGestures << CustomGesture::GestureType;
+ child->ignoredGestures << CustomGesture::GestureType;
+
+ // sending events to the child and making sure there is no conflict
+ sendCustomGesture(&event, child);
+
+ QCOMPARE(child->gestureOverrideEventsReceived, 1);
+ QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(parent.gestureOverrideEventsReceived, 1);
+ QCOMPARE(parent.gestureEventsReceived, 1);
parent.reset();
child->reset();
- // nobody accepts the override, we will send normal events to the closest context (to the child)
+ // we set an attribute to make sure all gesture events are propagated
+ parent.grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures);
parent.acceptGestureOverride = false;
child->acceptGestureOverride = false;
+ parent.ignoredGestures << CustomGesture::GestureType;
+ child->ignoredGestures << CustomGesture::GestureType;
// sending events to the child and making sure there is no conflict
- sendCustomGesture(child);
+ sendCustomGesture(&event, child);
- QCOMPARE(child->gestureOverrideEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(child->gestureOverrideEventsReceived, 1);
QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
- QCOMPARE(parent.gestureOverrideEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(parent.gestureOverrideEventsReceived, 1);
+ QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount);
+
+ parent.reset();
+ child->reset();
+
+ Qt::GestureType ContinuousGesture = QGestureRecognizer::registerRecognizer(new CustomContinuousGestureRecognizer);
+ static const int ContinuousGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
+ child->grabGesture(ContinuousGesture);
+ // child accepts override. And it also receives another custom gesture.
+ parent.acceptGestureOverride = false;
+ child->acceptGestureOverride = true;
+ sendCustomGesture(&event, child);
+
+ QCOMPARE(child->gestureOverrideEventsReceived, 1);
+ QVERIFY(child->gestureEventsReceived > TotalGestureEventsCount);
+ QCOMPARE(child->events.all.count(), TotalGestureEventsCount + ContinuousGestureEventsCount);
+ QCOMPARE(parent.gestureOverrideEventsReceived, 0);
QCOMPARE(parent.gestureEventsReceived, 0);
+
+ QGestureRecognizer::unregisterRecognizer(ContinuousGesture);
}
void tst_Gestures::finishedWithoutStarted()
{
GestureWidget widget;
- widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+ widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
// the gesture will claim it finished, but it was never started.
CustomEvent ev;
@@ -493,22 +636,32 @@ void tst_Gestures::finishedWithoutStarted()
void tst_Gestures::unknownGesture()
{
GestureWidget widget;
- widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
- widget.grabGesture(Qt::CustomGesture, Qt::WidgetGesture);
- widget.grabGesture(Qt::GestureType(Qt::PanGesture+512), Qt::WidgetGesture);
+ widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+ widget.grabGesture(Qt::CustomGesture, Qt::DontStartGestureOnChildren);
+ widget.grabGesture(Qt::GestureType(Qt::PanGesture+512), Qt::DontStartGestureOnChildren);
- sendCustomGesture(&widget);
+ CustomEvent event;
+ sendCustomGesture(&event, &widget);
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
QCOMPARE(widget.gestureEventsReceived, TotalGestureEventsCount);
}
+static const QColor InstanceColors[] = {
+ Qt::blue, Qt::red, Qt::green, Qt::gray, Qt::yellow
+};
+
class GestureItem : public QGraphicsObject
{
+ static int InstanceCount;
+
public:
- GestureItem()
+ GestureItem(const char *name = 0)
{
+ instanceNumber = InstanceCount++;
+ if (name)
+ setObjectName(QLatin1String(name));
size = QRectF(0, 0, 100, 100);
customEventsReceived = 0;
gestureEventsReceived = 0;
@@ -517,6 +670,10 @@ public:
overrideEvents.clear();
acceptGestureOverride = false;
}
+ ~GestureItem()
+ {
+ --InstanceCount;
+ }
int customEventsReceived;
int gestureEventsReceived;
@@ -540,8 +697,20 @@ public:
} events, overrideEvents;
bool acceptGestureOverride;
+ QSet<Qt::GestureType> ignoredGestures;
QRectF size;
+ int instanceNumber;
+
+ void reset()
+ {
+ customEventsReceived = 0;
+ gestureEventsReceived = 0;
+ gestureOverrideEventsReceived = 0;
+ events.clear();
+ overrideEvents.clear();
+ ignoredGestures.clear();
+ }
protected:
QRectF boundingRect() const
@@ -550,7 +719,8 @@ protected:
}
void paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
- p->fillRect(boundingRect(), Qt::blue);
+ QColor color = InstanceColors[instanceNumber % (sizeof(InstanceColors)/sizeof(InstanceColors[0]))];
+ p->fillRect(boundingRect(), color);
}
bool event(QEvent *event)
@@ -559,6 +729,9 @@ protected:
if (event->type() == QEvent::Gesture) {
++gestureEventsReceived;
eventsPtr = &events;
+ QGestureEvent *e = static_cast<QGestureEvent *>(event);
+ foreach(Qt::GestureType type, ignoredGestures)
+ e->ignore(e->gesture(type));
} else if (event->type() == QEvent::GestureOverride) {
++gestureOverrideEventsReceived;
eventsPtr = &overrideEvents;
@@ -567,7 +740,7 @@ protected:
}
if (eventsPtr) {
QGestureEvent *e = static_cast<QGestureEvent*>(event);
- QList<QGesture*> gestures = e->allGestures();
+ QList<QGesture*> gestures = e->gestures();
foreach(QGesture *g, gestures) {
eventsPtr->all << g->gestureType();
switch(g->state()) {
@@ -595,23 +768,47 @@ protected:
return true;
}
};
+int GestureItem::InstanceCount = 0;
void tst_Gestures::graphicsItemGesture()
{
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
- GestureItem *item = new GestureItem;
+ GestureItem *item = new GestureItem("item");
scene.addItem(item);
item->setPos(100, 100);
- item->grabGesture(CustomGesture::GestureType);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ view.ensureVisible(scene.sceneRect());
- sendCustomGesture(item);
+ view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+ item->grabGesture(CustomGesture::GestureType);
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
+ CustomEvent event;
+ // gesture without hotspot should not be delivered to items in the view
+ QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture");
+ QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture");
+ QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture");
+ QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture");
+ sendCustomGesture(&event, item, &scene);
+
+ QCOMPARE(item->customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(item->gestureEventsReceived, 0);
+ QCOMPARE(item->gestureOverrideEventsReceived, 0);
+
+ item->reset();
+
+ // make sure the event is properly delivered if only the hotspot is set.
+ event.hotSpot = mapToGlobal(QPointF(10, 10), item, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item, &scene);
+
QCOMPARE(item->customEventsReceived, TotalCustomEventsCount);
QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item->gestureOverrideEventsReceived, 0);
@@ -622,6 +819,656 @@ void tst_Gestures::graphicsItemGesture()
QCOMPARE(item->events.updated.size(), TotalGestureEventsCount - 2);
QCOMPARE(item->events.finished.size(), 1);
QCOMPARE(item->events.canceled.size(), 0);
+
+ item->reset();
+
+ // send gesture to the item which ignores it.
+ item->ignoredGestures << CustomGesture::GestureType;
+
+ event.hotSpot = mapToGlobal(QPointF(10, 10), item, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item, &scene);
+ QCOMPARE(item->customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item->gestureOverrideEventsReceived, 0);
+}
+
+void tst_Gestures::graphicsItemTreeGesture()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+
+ GestureItem *item1 = new GestureItem("item1");
+ item1->setPos(100, 100);
+ item1->size = QRectF(0, 0, 350, 200);
+ scene.addItem(item1);
+
+ GestureItem *item1_child1 = new GestureItem("item1_child1");
+ item1_child1->setPos(50, 50);
+ item1_child1->size = QRectF(0, 0, 100, 100);
+ item1_child1->setParentItem(item1);
+
+ GestureItem *item1_child2 = new GestureItem("item1_child2");
+ item1_child2->size = QRectF(0, 0, 100, 100);
+ item1_child2->setPos(200, 50);
+ item1_child2->setParentItem(item1);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ view.ensureVisible(scene.sceneRect());
+
+ view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+ item1->grabGesture(CustomGesture::GestureType);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+
+ CustomEvent event;
+ event.hotSpot = mapToGlobal(QPointF(10, 10), item1_child1, &view);
+ event.hasHotSpot = true;
+
+ item1->ignoredGestures << CustomGesture::GestureType;
+ sendCustomGesture(&event, item1_child1, &scene);
+ QCOMPARE(item1_child1->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item1_child1->gestureEventsReceived, 0);
+ QCOMPARE(item1_child2->gestureEventsReceived, 0);
+ QCOMPARE(item1_child2->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
+
+ item1->reset(); item1_child1->reset(); item1_child2->reset();
+
+ item1_child1->grabGesture(CustomGesture::GestureType);
+
+ item1->ignoredGestures << CustomGesture::GestureType;
+ item1_child1->ignoredGestures << CustomGesture::GestureType;
+ sendCustomGesture(&event, item1_child1, &scene);
+ QCOMPARE(item1_child1->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item1_child1->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item1_child2->gestureEventsReceived, 0);
+ QCOMPARE(item1_child2->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item1->gestureEventsReceived, 1);
+}
+
+void tst_Gestures::explicitGraphicsObjectTarget()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+
+ GestureItem *item1 = new GestureItem("item1");
+ scene.addItem(item1);
+ item1->setPos(100, 100);
+ item1->setZValue(1);
+
+ GestureItem *item2 = new GestureItem("item2");
+ scene.addItem(item2);
+ item2->setPos(100, 100);
+ item2->setZValue(5);
+
+ GestureItem *item2_child1 = new GestureItem("item2_child1");
+ scene.addItem(item2_child1);
+ item2_child1->setParentItem(item2);
+ item2_child1->setPos(10, 10);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ view.ensureVisible(scene.sceneRect());
+
+ view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+ item1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+ item2->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+ item2_child1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+
+ // sending events to item1, but the hotSpot is set to item2
+ CustomEvent event;
+ event.hotSpot = mapToGlobal(QPointF(15, 15), item2, &view);
+ event.hasHotSpot = true;
+
+ sendCustomGesture(&event, item1, &scene);
+
+ QCOMPARE(item1->gestureEventsReceived, 0);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item2_child1->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item2_child1->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item2_child1->events.all.size(), TotalGestureEventsCount);
+ for(int i = 0; i < item2_child1->events.all.size(); ++i)
+ QCOMPARE(item2_child1->events.all.at(i), CustomGesture::GestureType);
+ QCOMPARE(item2_child1->events.started.size(), 1);
+ QCOMPARE(item2_child1->events.updated.size(), TotalGestureEventsCount - 2);
+ QCOMPARE(item2_child1->events.finished.size(), 1);
+ QCOMPARE(item2_child1->events.canceled.size(), 0);
+ QCOMPARE(item2->gestureEventsReceived, 0);
+ QCOMPARE(item2->gestureOverrideEventsReceived, 1);
+}
+
+void tst_Gestures::gestureOverChildGraphicsItem()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+
+ GestureItem *item0 = new GestureItem("item0");
+ scene.addItem(item0);
+ item0->setPos(0, 0);
+ item0->grabGesture(CustomGesture::GestureType);
+ item0->setZValue(1);
+
+ GestureItem *item1 = new GestureItem("item1");
+ scene.addItem(item1);
+ item1->setPos(100, 100);
+ item1->setZValue(5);
+
+ GestureItem *item2 = new GestureItem("item2");
+ scene.addItem(item2);
+ item2->setPos(100, 100);
+ item2->setZValue(10);
+
+ GestureItem *item2_child1 = new GestureItem("item2_child1");
+ scene.addItem(item2_child1);
+ item2_child1->setParentItem(item2);
+ item2_child1->setPos(0, 0);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ view.ensureVisible(scene.sceneRect());
+
+ view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+ item1->grabGesture(CustomGesture::GestureType);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+ static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
+
+ CustomEvent event;
+ event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item0, &scene);
+
+ QCOMPARE(item0->customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(item2_child1->gestureEventsReceived, 0);
+ QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item2->gestureEventsReceived, 0);
+ QCOMPARE(item2->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 0);
+
+ item0->reset(); item1->reset(); item2->reset(); item2_child1->reset();
+ item2->grabGesture(CustomGesture::GestureType);
+ item2->ignoredGestures << CustomGesture::GestureType;
+
+ event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item0, &scene);
+
+ QCOMPARE(item2_child1->gestureEventsReceived, 0);
+ QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item2->gestureEventsReceived, 1);
+ QCOMPARE(item2->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 1);
+
+ item0->reset(); item1->reset(); item2->reset(); item2_child1->reset();
+ item2->grabGesture(CustomGesture::GestureType);
+ item2->ignoredGestures << CustomGesture::GestureType;
+ item1->ignoredGestures << CustomGesture::GestureType;
+
+ event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item0, &scene);
+
+ QCOMPARE(item2_child1->gestureEventsReceived, 0);
+ QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item2->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item1->gestureEventsReceived, 1);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 1);
+
+ item0->reset(); item1->reset(); item2->reset(); item2_child1->reset();
+ item2->grabGesture(CustomGesture::GestureType);
+ item2->ignoredGestures << CustomGesture::GestureType;
+ item1->ignoredGestures << CustomGesture::GestureType;
+ item1->grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures);
+
+ event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item0, &scene);
+
+ QCOMPARE(item2_child1->gestureEventsReceived, 0);
+ QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item2->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 1);
+}
+
+void tst_Gestures::twoGesturesOnDifferentLevel()
+{
+ GestureWidget parent("parent");
+ QVBoxLayout *l = new QVBoxLayout(&parent);
+ GestureWidget *child = new GestureWidget("child");
+ l->addWidget(child);
+
+ Qt::GestureType SecondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+
+ parent.grabGesture(CustomGesture::GestureType);
+ child->grabGesture(SecondGesture);
+
+ CustomEvent event;
+ // sending events that form a gesture to one widget, but they will be
+ // filtered by two different gesture recognizers and will generate two
+ // QGesture objects. Check that those gesture objects are delivered to
+ // different widgets properly.
+ sendCustomGesture(&event, child);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+ static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
+
+ QCOMPARE(child->customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(child->gestureOverrideEventsReceived, 0);
+ QCOMPARE(child->events.all.size(), TotalGestureEventsCount);
+ for(int i = 0; i < child->events.all.size(); ++i)
+ QCOMPARE(child->events.all.at(i), SecondGesture);
+
+ QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(parent.gestureOverrideEventsReceived, 0);
+ QCOMPARE(parent.events.all.size(), TotalGestureEventsCount);
+ for(int i = 0; i < child->events.all.size(); ++i)
+ QCOMPARE(parent.events.all.at(i), CustomGesture::GestureType);
+
+ QGestureRecognizer::unregisterRecognizer(SecondGesture);
+}
+
+void tst_Gestures::multipleGesturesInTree()
+{
+ GestureWidget a("A");
+ GestureWidget *A = &a;
+ GestureWidget *B = new GestureWidget("B", A);
+ GestureWidget *C = new GestureWidget("C", B);
+ GestureWidget *D = new GestureWidget("D", C);
+
+ Qt::GestureType FirstGesture = CustomGesture::GestureType;
+ Qt::GestureType SecondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType ThirdGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+
+ Qt::GestureFlags flags = Qt::ReceivePartialGestures;
+ A->grabGesture(FirstGesture, flags); // A [1 3]
+ A->grabGesture(ThirdGesture, flags); // |
+ B->grabGesture(SecondGesture, flags); // B [ 2 3]
+ B->grabGesture(ThirdGesture, flags); // |
+ C->grabGesture(FirstGesture, flags); // C [1 2 3]
+ C->grabGesture(SecondGesture, flags); // |
+ C->grabGesture(ThirdGesture, flags); // D [1 3]
+ D->grabGesture(FirstGesture, flags);
+ D->grabGesture(ThirdGesture, flags);
+
+ // make sure all widgets ignore events, so they get propagated.
+ A->ignoredGestures << FirstGesture << ThirdGesture;
+ B->ignoredGestures << SecondGesture << ThirdGesture;
+ C->ignoredGestures << FirstGesture << SecondGesture << ThirdGesture;
+ D->ignoredGestures << FirstGesture << ThirdGesture;
+
+ CustomEvent event;
+ sendCustomGesture(&event, D);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+
+ // gesture override events
+ QCOMPARE(D->overrideEvents.all.count(FirstGesture), 1);
+ QCOMPARE(D->overrideEvents.all.count(SecondGesture), 0);
+ QCOMPARE(D->overrideEvents.all.count(ThirdGesture), 1);
+
+ QCOMPARE(C->overrideEvents.all.count(FirstGesture), 1);
+ QCOMPARE(C->overrideEvents.all.count(SecondGesture), 1);
+ QCOMPARE(C->overrideEvents.all.count(ThirdGesture), 1);
+
+ QCOMPARE(B->overrideEvents.all.count(FirstGesture), 0);
+ QCOMPARE(B->overrideEvents.all.count(SecondGesture), 1);
+ QCOMPARE(B->overrideEvents.all.count(ThirdGesture), 1);
+
+ QCOMPARE(A->overrideEvents.all.count(FirstGesture), 1);
+ QCOMPARE(A->overrideEvents.all.count(SecondGesture), 0);
+ QCOMPARE(A->overrideEvents.all.count(ThirdGesture), 1);
+
+ // normal gesture events
+ QCOMPARE(D->events.all.count(FirstGesture), TotalGestureEventsCount);
+ QCOMPARE(D->events.all.count(SecondGesture), 0);
+ QCOMPARE(D->events.all.count(ThirdGesture), TotalGestureEventsCount);
+
+ QCOMPARE(C->events.all.count(FirstGesture), TotalGestureEventsCount);
+ QCOMPARE(C->events.all.count(SecondGesture), TotalGestureEventsCount);
+ QCOMPARE(C->events.all.count(ThirdGesture), TotalGestureEventsCount);
+
+ QCOMPARE(B->events.all.count(FirstGesture), 0);
+ QCOMPARE(B->events.all.count(SecondGesture), TotalGestureEventsCount);
+ QCOMPARE(B->events.all.count(ThirdGesture), TotalGestureEventsCount);
+
+ QCOMPARE(A->events.all.count(FirstGesture), TotalGestureEventsCount);
+ QCOMPARE(A->events.all.count(SecondGesture), 0);
+ QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount);
+
+ QGestureRecognizer::unregisterRecognizer(SecondGesture);
+ QGestureRecognizer::unregisterRecognizer(ThirdGesture);
+}
+
+void tst_Gestures::multipleGesturesInComplexTree()
+{
+ GestureWidget a("A");
+ GestureWidget *A = &a;
+ GestureWidget *B = new GestureWidget("B", A);
+ GestureWidget *C = new GestureWidget("C", B);
+ GestureWidget *D = new GestureWidget("D", C);
+
+ Qt::GestureType FirstGesture = CustomGesture::GestureType;
+ Qt::GestureType SecondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType ThirdGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType FourthGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType FifthGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType SixthGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType SeventhGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+
+ Qt::GestureFlags flags = Qt::ReceivePartialGestures;
+ A->grabGesture(FirstGesture, flags); // A [1,3,4]
+ A->grabGesture(ThirdGesture, flags); // |
+ A->grabGesture(FourthGesture, flags); // B [2,3,5]
+ B->grabGesture(SecondGesture, flags); // |
+ B->grabGesture(ThirdGesture, flags); // C [1,2,3,6]
+ B->grabGesture(FifthGesture, flags); // |
+ C->grabGesture(FirstGesture, flags); // D [1,3,7]
+ C->grabGesture(SecondGesture, flags);
+ C->grabGesture(ThirdGesture, flags);
+ C->grabGesture(SixthGesture, flags);
+ D->grabGesture(FirstGesture, flags);
+ D->grabGesture(ThirdGesture, flags);
+ D->grabGesture(SeventhGesture, flags);
+
+ // make sure all widgets ignore events, so they get propagated.
+ QSet<Qt::GestureType> allGestureTypes;
+ allGestureTypes << FirstGesture << SecondGesture << ThirdGesture
+ << FourthGesture << FifthGesture << SixthGesture << SeventhGesture;
+ A->ignoredGestures = B->ignoredGestures = allGestureTypes;
+ C->ignoredGestures = D->ignoredGestures = allGestureTypes;
+
+ CustomEvent event;
+ sendCustomGesture(&event, D);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+
+ // gesture override events
+ QCOMPARE(D->overrideEvents.all.count(FirstGesture), 1);
+ QCOMPARE(D->overrideEvents.all.count(SecondGesture), 0);
+ QCOMPARE(D->overrideEvents.all.count(ThirdGesture), 1);
+
+ QCOMPARE(C->overrideEvents.all.count(FirstGesture), 1);
+ QCOMPARE(C->overrideEvents.all.count(SecondGesture), 1);
+ QCOMPARE(C->overrideEvents.all.count(ThirdGesture), 1);
+
+ QCOMPARE(B->overrideEvents.all.count(FirstGesture), 0);
+ QCOMPARE(B->overrideEvents.all.count(SecondGesture), 1);
+ QCOMPARE(B->overrideEvents.all.count(ThirdGesture), 1);
+
+ QCOMPARE(A->overrideEvents.all.count(FirstGesture), 1);
+ QCOMPARE(A->overrideEvents.all.count(SecondGesture), 0);
+ QCOMPARE(A->overrideEvents.all.count(ThirdGesture), 1);
+
+ // normal gesture events
+ QCOMPARE(D->events.all.count(FirstGesture), TotalGestureEventsCount);
+ QCOMPARE(D->events.all.count(SecondGesture), 0);
+ QCOMPARE(D->events.all.count(ThirdGesture), TotalGestureEventsCount);
+ QCOMPARE(D->events.all.count(FourthGesture), 0);
+ QCOMPARE(D->events.all.count(FifthGesture), 0);
+ QCOMPARE(D->events.all.count(SixthGesture), 0);
+ QCOMPARE(D->events.all.count(SeventhGesture), TotalGestureEventsCount);
+
+ QCOMPARE(C->events.all.count(FirstGesture), TotalGestureEventsCount);
+ QCOMPARE(C->events.all.count(SecondGesture), TotalGestureEventsCount);
+ QCOMPARE(C->events.all.count(ThirdGesture), TotalGestureEventsCount);
+ QCOMPARE(C->events.all.count(FourthGesture), 0);
+ QCOMPARE(C->events.all.count(FifthGesture), 0);
+ QCOMPARE(C->events.all.count(SixthGesture), TotalGestureEventsCount);
+ QCOMPARE(C->events.all.count(SeventhGesture), 0);
+
+ QCOMPARE(B->events.all.count(FirstGesture), 0);
+ QCOMPARE(B->events.all.count(SecondGesture), TotalGestureEventsCount);
+ QCOMPARE(B->events.all.count(ThirdGesture), TotalGestureEventsCount);
+ QCOMPARE(B->events.all.count(FourthGesture), 0);
+ QCOMPARE(B->events.all.count(FifthGesture), TotalGestureEventsCount);
+ QCOMPARE(B->events.all.count(SixthGesture), 0);
+ QCOMPARE(B->events.all.count(SeventhGesture), 0);
+
+ QCOMPARE(A->events.all.count(FirstGesture), TotalGestureEventsCount);
+ QCOMPARE(A->events.all.count(SecondGesture), 0);
+ QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount);
+ QCOMPARE(A->events.all.count(FourthGesture), TotalGestureEventsCount);
+ QCOMPARE(A->events.all.count(FifthGesture), 0);
+ QCOMPARE(A->events.all.count(SixthGesture), 0);
+ QCOMPARE(A->events.all.count(SeventhGesture), 0);
+
+ QGestureRecognizer::unregisterRecognizer(SecondGesture);
+ QGestureRecognizer::unregisterRecognizer(ThirdGesture);
+ QGestureRecognizer::unregisterRecognizer(FourthGesture);
+ QGestureRecognizer::unregisterRecognizer(FifthGesture);
+ QGestureRecognizer::unregisterRecognizer(SixthGesture);
+ QGestureRecognizer::unregisterRecognizer(SeventhGesture);
+}
+
+void tst_Gestures::testMapToScene()
+{
+ QGesture gesture;
+ QList<QGesture*> list;
+ list << &gesture;
+ QGestureEvent event(list);
+ QCOMPARE(event.mapToGraphicsScene(gesture.hotSpot()), QPointF()); // not set, can't do much
+
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+
+ GestureItem *item0 = new GestureItem;
+ scene.addItem(item0);
+ item0->setPos(14, 16);
+
+ view.show(); // need to show to give it a global coordinate
+ QTest::qWaitForWindowShown(&view);
+ view.ensureVisible(scene.sceneRect());
+
+ QPoint origin = view.mapToGlobal(QPoint());
+ event.setWidget(view.viewport());
+
+ QCOMPARE(event.mapToGraphicsScene(origin + QPoint(100, 200)), view.mapToScene(QPoint(100, 200)));
+}
+
+void tst_Gestures::ungrabGesture() // a method on QWidget
+{
+ class MockGestureWidget : public GestureWidget {
+ public:
+ MockGestureWidget(const char *name = 0, QWidget *parent = 0)
+ : GestureWidget(name, parent) { }
+
+
+ QSet<QGesture*> gestures;
+ protected:
+ bool event(QEvent *event)
+ {
+ if (event->type() == QEvent::Gesture) {
+ QGestureEvent *gestureEvent = static_cast<QGestureEvent*>(event);
+ if (gestureEvent)
+ foreach (QGesture *g, gestureEvent->gestures())
+ gestures.insert(g);
+ }
+ return GestureWidget::event(event);
+ }
+ };
+
+ MockGestureWidget parent("A");
+ MockGestureWidget *a = &parent;
+ MockGestureWidget *b = new MockGestureWidget("B", a);
+
+ a->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+ b->grabGesture(CustomGesture::GestureType);
+ b->ignoredGestures << CustomGesture::GestureType;
+
+ CustomEvent event;
+ // sending an event will cause the QGesture objects to be instantiated for the widgets
+ sendCustomGesture(&event, b);
+
+ QCOMPARE(a->gestures.count(), 1);
+ QPointer<QGesture> customGestureA;
+ customGestureA = *(a->gestures.begin());
+ QVERIFY(!customGestureA.isNull());
+ QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType);
+
+ QCOMPARE(b->gestures.count(), 1);
+ QPointer<QGesture> customGestureB;
+ customGestureB = *(b->gestures.begin());
+ QVERIFY(!customGestureB.isNull());
+ QVERIFY(customGestureA.data() == customGestureB.data());
+ QCOMPARE(customGestureB->gestureType(), CustomGesture::GestureType);
+
+ a->gestures.clear();
+ // sending an event will cause the QGesture objects to be instantiated for the widget
+ sendCustomGesture(&event, a);
+
+ QCOMPARE(a->gestures.count(), 1);
+ customGestureA = *(a->gestures.begin());
+ QVERIFY(!customGestureA.isNull());
+ QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType);
+ QVERIFY(customGestureA.data() != customGestureB.data());
+
+ a->ungrabGesture(CustomGesture::GestureType);
+ QVERIFY(customGestureA.isNull());
+ QVERIFY(!customGestureB.isNull());
+
+ a->gestures.clear();
+ a->reset();
+ // send again to 'b' and make sure a never gets it.
+ sendCustomGesture(&event, b);
+ QCOMPARE(a->gestureEventsReceived, 0);
+ QCOMPARE(a->gestureOverrideEventsReceived, 0);
+}
+
+void tst_Gestures::unregisterRecognizer() // a method on QApplication
+{
+ /*
+ The hardest usecase to get right is when we remove a recognizer while several
+ of the gestures it created are in active state and we immediately add a new recognizer
+ for the same type (thus replacing the old one).
+ The expected result is that all old gestures continue till they are finished/cancelled
+ and the new recognizer starts creating gestures immediately at registration.
+
+ This implies that deleting of the recognizer happens only when there are no more gestures
+ that it created. (since gestures might have a pointer to the recognizer)
+ */
+
+}
+
+void tst_Gestures::autoCancelGestures()
+{
+ class MockWidget : public GestureWidget {
+ public:
+ MockWidget(const char *name) : GestureWidget(name) { }
+
+ bool event(QEvent *event)
+ {
+ if (event->type() == QEvent::Gesture) {
+ QGestureEvent *ge = static_cast<QGestureEvent*>(event);
+ Q_ASSERT(ge->gestures().count() == 1); // can't use QCOMPARE here...
+ ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext);
+ }
+ return GestureWidget::event(event);
+ }
+ };
+
+ const Qt::GestureType secondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+
+ MockWidget parent("parent"); // this one sets the cancel policy to CancelAllInContext
+ parent.resize(300, 100);
+ parent.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ GestureWidget *child = new GestureWidget("child", &parent);
+ child->setGeometry(10, 10, 100, 80);
+
+ parent.grabGesture(CustomGesture::GestureType);
+ child->grabGesture(secondGesture);
+ parent.show();
+ QTest::qWaitForWindowShown(&parent);
+
+ /*
+ An event is send to both the child and the parent, when the child gets it a gesture is triggered
+ and send to the child.
+ When the parent gets the event a new gesture is triggered and delivered to the parent. When the
+ parent gets it he accepts it and that causes the cancel policy to activate.
+ The cause of that is the gesture for the child is cancelled and send to the child as such.
+ */
+ CustomEvent event;
+ event.serial = CustomGesture::SerialStartedThreshold;
+ QApplication::sendEvent(child, &event);
+ QCOMPARE(child->events.all.count(), 2);
+ QCOMPARE(child->events.started.count(), 1);
+ QCOMPARE(child->events.canceled.count(), 1);
+ QCOMPARE(parent.events.all.count(), 1);
+
+ // clean up, make the parent gesture finish
+ event.serial = CustomGesture::SerialFinishedThreshold;
+ QApplication::sendEvent(child, &event);
+ QCOMPARE(parent.events.all.count(), 2);
+}
+
+void tst_Gestures::autoCancelGestures2()
+{
+ class MockItem : public GestureItem {
+ public:
+ MockItem(const char *name) : GestureItem(name) { }
+
+ bool event(QEvent *event) {
+ if (event->type() == QEvent::Gesture) {
+ QGestureEvent *ge = static_cast<QGestureEvent*>(event);
+ Q_ASSERT(ge->gestures().count() == 1); // can't use QCOMPARE here...
+ ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext);
+ }
+ return GestureItem::event(event);
+ }
+ };
+
+ const Qt::GestureType secondGesture = QGestureRecognizer ::registerRecognizer(new CustomGestureRecognizer);
+
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+
+ MockItem *parent = new MockItem("parent");
+ GestureItem *child = new GestureItem("child");
+ child->setParentItem(parent);
+ parent->setPos(0, 0);
+ child->setPos(10, 10);
+ scene.addItem(parent);
+ view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+ view.viewport()->grabGesture(secondGesture, Qt::DontStartGestureOnChildren);
+ parent->grabGesture(CustomGesture::GestureType);
+ child->grabGesture(secondGesture);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ view.ensureVisible(scene.sceneRect());
+
+ CustomEvent event;
+ event.serial = CustomGesture::SerialStartedThreshold;
+ event.hasHotSpot = true;
+ event.hotSpot = mapToGlobal(QPointF(5, 5), child, &view);
+ // qDebug() << event.hotSpot;
+ scene.sendEvent(child, &event);
+ //QEventLoop().exec();
+ QCOMPARE(parent->events.all.count(), 1);
+ QCOMPARE(child->events.started.count(), 1);
+ QCOMPARE(child->events.canceled.count(), 1);
+ QCOMPARE(child->events.all.count(), 2);
+
+ // clean up, make the parent gesture finish
+ event.serial = CustomGesture::SerialFinishedThreshold;
+ scene.sendEvent(child, &event);
+ QCOMPARE(parent->events.all.count(), 2);
}
QTEST_MAIN(tst_Gestures)
diff --git a/tests/auto/guiapplauncher/README.txt b/tests/auto/guiapplauncher/README.txt
new file mode 100644
index 0000000000..317f9d0b72
--- /dev/null
+++ b/tests/auto/guiapplauncher/README.txt
@@ -0,0 +1,14 @@
+This test launches gui applications (tools, demos and prominent examples),
+keeps them running a while (grabbing their top level from the window manager)
+and sends them a Close event via window manager.
+
+It checks that they do not crash nor produce unexpected error output.
+
+Note: Do not play with the machine while it is running as otherwise
+the top-level find algorithm might get confused (especially on Windows).
+
+Environment variables are checked to turned off some tests (see code).
+
+It is currently implemented for X11 (Skips unless DISPLAY is set) and
+Windows, pending an implementation of the WindowManager class and deployment
+on the other platforms.
diff --git a/tests/auto/guiapplauncher/guiapplauncher.pro b/tests/auto/guiapplauncher/guiapplauncher.pro
new file mode 100644
index 0000000000..27c3553a2c
--- /dev/null
+++ b/tests/auto/guiapplauncher/guiapplauncher.pro
@@ -0,0 +1,20 @@
+# -------------------------------------------------
+# Project created by QtCreator 2009-11-10T14:39:06
+# -------------------------------------------------
+
+# Link against gui for X11,etc.
+
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+TARGET = tst_guiapplauncher
+CONFIG += console
+CONFIG -= app_bundle
+CONFIG += qtestlib
+TEMPLATE = app
+SOURCES += tst_guiapplauncher.cpp \
+ windowmanager.cpp
+HEADERS += windowmanager.h
+
+win32 {
+ # process enumeration,etc.
+ LIBS+=user32.lib
+}
diff --git a/tests/auto/guiapplauncher/test.ts b/tests/auto/guiapplauncher/test.ts
new file mode 100644
index 0000000000..79c9c76d1f
--- /dev/null
+++ b/tests/auto/guiapplauncher/test.ts
@@ -0,0 +1,973 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="de">
+<context>
+ <name>AssistantServer</name>
+ <message>
+ <location filename="../tools/assistant/compat/main.cpp" line="+225"/>
+ <source>Qt Assistant</source>
+ <translation>Qt Assistant</translation>
+ </message>
+ <message>
+ <location line="+1"/>
+ <source>Failed to bind to port %1</source>
+ <translation>Kann Port %1 nicht binden</translation>
+ </message>
+</context>
+<context>
+ <name>FontPanel</name>
+ <message>
+ <location filename="../tools/shared/fontpanel/fontpanel.cpp" line="+63"/>
+ <source>Font</source>
+ <translation>Schrift</translation>
+ </message>
+ <message>
+ <location line="+11"/>
+ <source>&amp;Writing system</source>
+ <translation>S&amp;kript</translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>&amp;Family</source>
+ <translation>&amp;Schriftart</translation>
+ </message>
+ <message>
+ <location line="+4"/>
+ <source>&amp;Style</source>
+ <translation>S&amp;chriftschnitt</translation>
+ </message>
+ <message>
+ <location line="+4"/>
+ <source>&amp;Point size</source>
+ <translation>Schriftg&amp;rad</translation>
+ </message>
+</context>
+<context>
+ <name>FontSettingsDialog</name>
+ <message>
+ <location filename="../tools/assistant/compat/fontsettingsdialog.cpp" line="+63"/>
+ <source>Font Settings</source>
+ <translation>Schriftart</translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>Font settings for:</source>
+ <translation>Schriftart für:</translation>
+ </message>
+ <message>
+ <location line="+4"/>
+ <source>Browser</source>
+ <translation>Hilfeseiten</translation>
+ </message>
+ <message>
+ <location line="+1"/>
+ <source>Application</source>
+ <translation>Anwendung</translation>
+ </message>
+ <message>
+ <location line="+6"/>
+ <source>Use custom settings</source>
+ <translation>Erweitere Einstellungen nutzen</translation>
+ </message>
+</context>
+<context>
+ <name>HelpDialog</name>
+ <message>
+ <location filename="../tools/assistant/compat/helpdialog.ui"/>
+ <source>Con&amp;tents</source>
+ <translation>Inhal&amp;t</translation>
+ </message>
+ <message>
+ <location filename="../tools/assistant/compat/helpdialog.cpp" line="+376"/>
+ <location line="+16"/>
+ <location line="+661"/>
+ <source>Qt Assistant</source>
+ <translation>Qt Assistant</translation>
+ </message>
+ <message>
+ <location line="-771"/>
+ <source>Open Link in New Window</source>
+ <translation>Öffne Link in neuem Fenster</translation>
+ </message>
+ <message>
+ <location line="+76"/>
+ <location line="+82"/>
+ <source>Prepare...</source>
+ <translation>Initialisiere...</translation>
+ </message>
+ <message>
+ <location line="-47"/>
+ <source>Cannot open the index file %1</source>
+ <translation>Kann Indexdatei %1 nicht öffnen</translation>
+ </message>
+ <message>
+ <location line="+58"/>
+ <location line="+124"/>
+ <location line="+8"/>
+ <source>Warning</source>
+ <translation>Warnung</translation>
+ </message>
+ <message>
+ <location line="-131"/>
+ <location line="+124"/>
+ <source>Documentation file %1 does not exist!
+Skipping file.</source>
+ <translation>Dokumentation %1 existiert nicht!
+Überspringe Datei.</translation>
+ </message>
+ <message>
+ <location line="-112"/>
+ <location line="+133"/>
+ <source>Parse Error</source>
+ <translation>Syntaxfehler</translation>
+ </message>
+ <message>
+ <location line="+35"/>
+ <location line="+469"/>
+ <source>Done</source>
+ <translation>Fertig</translation>
+ </message>
+ <message>
+ <location line="-18"/>
+ <source>Indexing files...</source>
+ <translation>Indiziere Dokumentation...</translation>
+ </message>
+ <message>
+ <location line="+15"/>
+ <source>Reading dictionary...</source>
+ <translation>Lese Suchindex...</translation>
+ </message>
+ <message>
+ <location line="+46"/>
+ <location line="+9"/>
+ <source>Full Text Search</source>
+ <translation>Volltextsuche</translation>
+ </message>
+ <message>
+ <location line="-8"/>
+ <source>Using a wildcard within phrases is not allowed.</source>
+ <translation>Wildcards innerhalb von Phrasen sind nicht zugelassen.</translation>
+ </message>
+ <message>
+ <location line="+9"/>
+ <source>The closing quotation mark is missing.</source>
+ <translation>Das schließende Anführungszeichen fehlt.</translation>
+ </message>
+ <message numerus="yes">
+ <location line="+7"/>
+ <source>%n document(s) found.</source>
+ <translation>
+ <numerusform>%n Dokumente gefunden.</numerusform>
+ <numerusform></numerusform>
+ </translation>
+ </message>
+ <message>
+ <location line="-882"/>
+ <source>Open Link in Current Tab</source>
+ <translation>Link im Aktuellen Tab öffnen</translation>
+ </message>
+ <message>
+ <location line="+6"/>
+ <source>Open Link in New Tab</source>
+ <translation>Link in einem neuen Tab öffnen</translation>
+ </message>
+ <message>
+ <location line="+91"/>
+ <source>Failed to load keyword index file
+Assistant will not work!</source>
+ <translation>Die Indexdatei konnte nicht geladen werden.
+Der Assistent ist nicht einsatzbereit!</translation>
+ </message>
+ <message>
+ <location line="+208"/>
+ <source>Documentation file %1 is not compatible!
+Skipping file.</source>
+ <translation>Dokumentation %1 ist nicht kompatibel! Datei wird übersprungen.</translation>
+ </message>
+ <message>
+ <location line="+470"/>
+ <source>Failed to save fulltext search index
+Assistant will not work!</source>
+ <translation>Der Index für die Volltextsuche konnte nicht gespeichert werden.
+Assistent ist nicht einsatzbereit!</translation>
+ </message>
+ <message>
+ <location filename="../tools/assistant/compat/helpdialog.ui"/>
+ <source>Help</source>
+ <translation>Hilfe</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&lt;b&gt;Help&lt;/b&gt;&lt;p&gt;Choose the topic you want help on from the contents list, or search the index for keywords.&lt;/p&gt;</source>
+ <translation>&lt;b&gt;Hilfe&lt;/b&gt;&lt;p&gt;Wählen Sie ein Hilfethema aus dem Inhalt oder suchen Sie im Index nach Schlüsselwörtern.&lt;/p&gt;</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Displays help topics organized by category, index or bookmarks. Another tab inherits the full text search.</source>
+ <translation>Zeigt Hilfethemen geordnet nach Kategorie, Index oder Lesezeichen an. Ein weiterer Abschnitt enthält die Volltextsuche.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&lt;b&gt;Help topics organized by category.&lt;/b&gt;&lt;p&gt;Double-click an item to see the topics in that category. To view a topic, just double-click it.&lt;/p&gt;</source>
+ <translation>&lt;b&gt;Hilfethemen geordnet nach Kategorie.&lt;/b&gt;&lt;p&gt;Doppelklicken Sie einen Eintrag, um die Themen dieser Kategorie zu sehen. Doppelklicken Sie ein Thema, um es angezeigt zu bekommen.&lt;/p&gt;</translation>
+ </message>
+ <message>
+ <location/>
+ <source>column 1</source>
+ <translation>Spalte 1</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Index</source>
+ <translation>&amp;Index</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Look For:</source>
+ <translation>Suchen &amp;nach:</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Enter keyword</source>
+ <translation>Geben Sie ein Schlüsselwort ein</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&lt;b&gt;Enter a keyword.&lt;/b&gt;&lt;p&gt;The list will select an item that matches the entered string best.&lt;/p&gt;</source>
+ <translation>&lt;b&gt;Geben Sie ein Schlüsselwort ein.&lt;/b&gt;&lt;p&gt;Es wird dann der Eintrag aus der Liste ausgewählt, der am besten mit dem eingegebenen Begriff übereinstimmt.&lt;/p&gt;</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&lt;b&gt;List of available help topics.&lt;/b&gt;&lt;p&gt;Double-click on an item to open its help page. If more than one is found, you must specify which page you want.&lt;/p&gt;</source>
+ <translation>&lt;b&gt;Liste aller verfügbaren Hilfethemen.&lt;/b&gt;&lt;p&gt;Doppelklicken Sie auf einen Eintrag, um die Hilfe zu öffnen. Wenn mehr als eine Seite gefunden wurde, wählen Sie die gewünschte Seite aus.&lt;/p&gt;</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Bookmarks</source>
+ <translation>L&amp;esezeichen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Displays the list of bookmarks.</source>
+ <translation>Zeigt alle Lesezeichen an.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Add new bookmark</source>
+ <translation>Füge neues Lesezeichen hinzu</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Add the currently displayed page as a new bookmark.</source>
+ <translation>Füge aktuelle Seite zu den Lesezeichen hinzu.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;New</source>
+ <translation>&amp;Neu</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Delete bookmark</source>
+ <translation>Lösche Lesezeichen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Delete the selected bookmark.</source>
+ <translation>Lösche markiertes Lesezeichen.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Delete</source>
+ <translation>&amp;Löschen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Search</source>
+ <translation>&amp;Suche</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Searching f&amp;or:</source>
+ <translation>Suche &amp;nach:</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&lt;b&gt;Enter search word(s).&lt;/b&gt;&lt;p&gt;Enter here the word(s) you are looking for. The words may contain wildcards (*). For a sequence of words quote them.&lt;/p&gt;</source>
+ <translation>&lt;b&gt;Geben Sie Suchbegriffe ein.&lt;/b&gt;&lt;p&gt;Geben Sie hier die gesuchten Begriffe ein. Die Begriffe können Wildcards (*) enthalten. Eine Phrase muß in Anführungszeichen stehen.&lt;/p&gt;</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&lt;b&gt;Found documents&lt;/b&gt;&lt;p&gt;This list contains all found documents from the last search. The documents are ordered, i.e. the first document has the most matches.&lt;/p&gt;</source>
+ <translation>&lt;b&gt;Gefundene Dokumente&lt;/b&gt;&lt;p&gt;Diese Liste beinhaltet alle gefundenen Dokumente der letzten Suche. Die Dokumente sind nach der Häufigkeit der Treffer geordnet.&lt;/p&gt;</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Found &amp;Documents:</source>
+ <translation>Gefundene &amp;Dokumente:</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Display the help page for the full text search.</source>
+ <translation>Zeigt die Hilfeseite für die Volltextsuche an.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>He&amp;lp</source>
+ <translation>Hi&amp;lfe</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Pressing this button starts the search.</source>
+ <translation>Startet die Suche.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Preparing...</source>
+ <translation>Initialisiere...</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Enter searchword(s)</source>
+ <translation>Geben Sie Suchbegriffe ein</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Display the help page</source>
+ <translation>Hilfeseite anzeigen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Start searching</source>
+ <translation>Suche beginnen</translation>
+ </message>
+</context>
+<context>
+ <name>HelpWindow</name>
+ <message>
+ <location filename="../tools/assistant/compat/helpwindow.cpp" line="+97"/>
+ <source>Help</source>
+ <translation>Hilfe</translation>
+ </message>
+ <message>
+ <location line="+93"/>
+ <source>Open Link in New Window Shift+LMB</source>
+ <translation>Öffne Link in neuem Fenster</translation>
+ </message>
+ <message>
+ <location line="-2"/>
+ <source>Open Link in New Tab</source>
+ <translation>Link in einem neuen Tab öffnen</translation>
+ </message>
+ <message>
+ <location line="-90"/>
+ <source>Unable to launch web browser.
+</source>
+ <translation>Der Webbrowser konnte nicht gestartet werden.
+</translation>
+ </message>
+ <message>
+ <location line="+1"/>
+ <source>OK</source>
+ <translation>OK</translation>
+ </message>
+ <message>
+ <location line="+27"/>
+ <source>Failed to open link: &apos;%1&apos;</source>
+ <translation>Der Link &apos;%1&apos; konnte nicht geöffnet werden</translation>
+ </message>
+ <message>
+ <location line="+1"/>
+ <source>&lt;div align=&quot;center&quot;&gt;&lt;h1&gt;The page could not be found&lt;/h1&gt;&lt;br&gt;&lt;h3&gt;&apos;%1&apos;&lt;/h3&gt;&lt;/div&gt;</source>
+ <translation>&lt;div align=&quot;center&quot;&gt;&lt;h1&gt;Die Seite wurde nicht gefunden&lt;/h1&gt;&lt;br&gt;&lt;h3&gt;&apos;%1&apos;&lt;/h3&gt;&lt;/div&gt;</translation>
+ </message>
+ <message>
+ <location line="+2"/>
+ <source>Error...</source>
+ <translation>Fehler ...</translation>
+ </message>
+ <message>
+ <location line="+56"/>
+ <source>Copy &amp;Link Location</source>
+ <translation>Link-Adresse kopieren</translation>
+ </message>
+</context>
+<context>
+ <name>Index</name>
+ <message>
+ <location filename="../tools/assistant/compat/index.cpp" line="+385"/>
+ <source>Untitled</source>
+ <translation>Unbenannt</translation>
+ </message>
+</context>
+<context>
+ <name>MainWindow</name>
+ <message>
+ <location filename="../tools/assistant/compat/mainwindow.ui"/>
+ <source>Toolbar</source>
+ <translation>Werkzeugleiste</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Print...</source>
+ <translation>&amp;Drucken...</translation>
+ </message>
+ <message>
+ <location/>
+ <source>E&amp;xit</source>
+ <translation>&amp;Beenden</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Copy</source>
+ <translation>&amp;Kopieren</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Find in Text...</source>
+ <translation>Text&amp;suche...</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Home</source>
+ <translation>St&amp;artseite</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Previous</source>
+ <translation>&amp;Vorherige</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Next</source>
+ <translation>&amp;Nächste</translation>
+ </message>
+ <message>
+ <location/>
+ <source>About Qt</source>
+ <translation>Über Qt</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Zoom &amp;in</source>
+ <translation>Vergrößern</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Zoom &amp;out</source>
+ <translation>Ver&amp;kleinern</translation>
+ </message>
+ <message>
+ <location/>
+ <source>New Window</source>
+ <translation>Neues Fenster...</translation>
+ </message>
+ <message>
+ <location filename="../tools/assistant/compat/mainwindow.cpp" line="+198"/>
+ <source>Ctrl+T</source>
+ <translation>Strg+T
+</translation>
+ </message>
+ <message>
+ <location line="+1"/>
+ <source>Ctrl+I</source>
+ <translation>Strg+I</translation>
+ </message>
+ <message>
+ <location line="+1"/>
+ <source>Ctrl+B</source>
+ <translation>Strg+E</translation>
+ </message>
+ <message>
+ <location line="+129"/>
+ <location line="+1"/>
+ <source>Qt Assistant</source>
+ <translation>Qt Assistant</translation>
+ </message>
+ <message>
+ <location filename="../tools/assistant/compat/mainwindow.ui"/>
+ <source>&amp;Add Bookmark</source>
+ <translation>&amp;Füge Lesezeichen hinzu</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;File</source>
+ <translation>&amp;Datei</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Edit</source>
+ <translation>&amp;Bearbeiten</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;View</source>
+ <translation>&amp;Ansicht</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Go</source>
+ <translation>&amp;Gehe zu</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Boo&amp;kmarks</source>
+ <translation>&amp;Lesezeichen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Qt Assistant by Nokia</source>
+ <translation>Qt Assistant von Nokia</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Help</source>
+ <translation>&amp;Hilfe</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Print the currently displayed page.</source>
+ <translation>Drucke aktuelle Seite.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Ctrl+P</source>
+ <translation>Strg+P</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Quit Qt Assistant.</source>
+ <translation>Qt Assistant beenden.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Ctrl+Q</source>
+ <translation>Strg+Q</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Copy the selected text to the clipboard.</source>
+ <translation>Den markierten Text in die Zwischenablage kopieren.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Ctrl+C</source>
+ <translation>Strg+C</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Open the Find dialog. Qt Assistant will search the currently displayed page for the text you enter.</source>
+ <translation>Den Suchdialog öffnen. Qt Assistant sucht in der aktuellen Seite nach dem eingegebenen Text.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Ctrl+F</source>
+ <translation>Strg+F</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Go to the home page. Qt Assistant&apos;s home page is the Qt Reference Documentation.</source>
+ <translation>Zur Startseite gehen. Startseite im Qt Assistant ist die Qt-Referenzdokumentation.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Ctrl+Home</source>
+ <translation>Strg+Pos1</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Go to the previous page.</source>
+ <translation>Gehe zur vorherigen Seite.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Alt+Left</source>
+ <translation>Alt+Links</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Go to the next page.</source>
+ <translation>Gehe zur nächsten Seite.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Alt+Right</source>
+ <translation>Alt+Rechts</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Display further information about Qt Assistant.</source>
+ <translation>Zeigt das Handbuch zum Qt Designer an.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Zoom in on the document, i.e. increase the font size.</source>
+ <translation>Vergrößert die Schrift.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Ctrl++</source>
+ <translation>Strg++</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Zoom out on the document, i.e. decrease the font size.</source>
+ <translation>Verkleinert die Schrift.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Ctrl+-</source>
+ <translation>Strg+-</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Open a new window.</source>
+ <translation>Öffnet ein neues Fenster.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Ctrl+N</source>
+ <translation>Strg+N</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Close</source>
+ <translation>&amp;Schließen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Close the current window.</source>
+ <translation>Schließt das aktuelle Fenster.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Qt Assistant Manual</source>
+ <translation>Handbuch zu Qt Assistant</translation>
+ </message>
+ <message>
+ <location/>
+ <source>F1</source>
+ <translation>F1</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Add the currently displayed page as a new bookmark.</source>
+ <translation>Aktuelle Seite zu den Lesezeichen hinzufügen.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>What&apos;s This?</source>
+ <translation>Direkthilfe</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&quot;What&apos;s This?&quot; context sensitive help.</source>
+ <translation>Kontextbezogene Direkthilfe.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Shift+F1</source>
+ <translation>Umschalt+F1</translation>
+ </message>
+ <message>
+ <location filename="../tools/assistant/compat/mainwindow.cpp" line="-129"/>
+ <source>Ctrl+S</source>
+ <translation>Strg+S</translation>
+ </message>
+ <message>
+ <location line="-33"/>
+ <source>Initializing Qt Assistant...</source>
+ <translation>Qt Assistant wird initialisiert...</translation>
+ </message>
+ <message>
+ <location filename="../tools/assistant/compat/mainwindow.ui"/>
+ <source>Go</source>
+ <translation>Gehe zu</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Find &amp;Next</source>
+ <translation>Weitersuchen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>F3</source>
+ <translation>F3</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Find &amp;Previous</source>
+ <translation>Vorheriges suchen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Shift+F3</source>
+ <translation>Umschalt+F3</translation>
+ </message>
+ <message>
+ <location/>
+ <source>About Qt Assistant</source>
+ <translation>Über Qt Assistent</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Add Tab</source>
+ <translation>Tab einfügen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Ctrl+Alt+N</source>
+ <translation></translation>
+ </message>
+ <message>
+ <location/>
+ <source>Next Tab</source>
+ <translation>Nächster Tab</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Ctrl+Alt+Right</source>
+ <translation></translation>
+ </message>
+ <message>
+ <location/>
+ <source>Previous Tab</source>
+ <translation>Voriger Tab</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Ctrl+Alt+Left</source>
+ <translation></translation>
+ </message>
+ <message>
+ <location/>
+ <source>Close Tab</source>
+ <translation>Tab schließen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Ctrl+Alt+Q</source>
+ <translation></translation>
+ </message>
+ <message>
+ <location filename="../tools/assistant/compat/mainwindow.cpp" line="+181"/>
+ <source>Failed to open about application contents in file: &apos;%1&apos;</source>
+ <translation>Fehler beim Öffnen des Inhalts in Datei: &apos;%1&apos;</translation>
+ </message>
+ <message>
+ <location line="-246"/>
+ <source>Sidebar</source>
+ <translation>Sidebar</translation>
+ </message>
+ <message>
+ <location line="+18"/>
+ <source>&amp;Window</source>
+ <translation>&amp;Fenster</translation>
+ </message>
+ <message>
+ <location line="+2"/>
+ <source>Minimize</source>
+ <translation>Minimieren</translation>
+ </message>
+ <message>
+ <location line="+1"/>
+ <source>Ctrl+M</source>
+ <translation>Strg+M</translation>
+ </message>
+ <message>
+ <location line="+70"/>
+ <source>SHIFT+CTRL+=</source>
+ <translation>Umschalt+Strg+=</translation>
+ </message>
+ <message>
+ <location filename="../tools/assistant/compat/mainwindow.ui"/>
+ <source>Ctrl+W</source>
+ <translation>Strg+W</translation>
+ </message>
+ <message>
+ <location filename="../tools/assistant/compat/mainwindow.cpp" line="+8"/>
+ <source>Ctrl+]</source>
+ <translation>Strg+AltGr+]</translation>
+ </message>
+ <message>
+ <location line="+1"/>
+ <source>Ctrl+[</source>
+ <translation>Strg+AltGr+[</translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>Views</source>
+ <translation>Menüleisten/Sidebar</translation>
+ </message>
+ <message>
+ <location line="+80"/>
+ <source>Displays the main page of a specific documentation set.</source>
+ <translation>Zeigt die Hauptseite eines Dokumentensets an.</translation>
+ </message>
+ <message>
+ <location line="+262"/>
+ <source>...</source>
+ <translation>...</translation>
+ </message>
+ <message>
+ <location line="+238"/>
+ <location line="+6"/>
+ <source>Save Page</source>
+ <translation>Seite speichern</translation>
+ </message>
+ <message>
+ <location line="+0"/>
+ <source>Cannot open file for writing!</source>
+ <translation>Die Datei konnte nicht zum Schreiben geöffnet werden.</translation>
+ </message>
+ <message>
+ <location filename="../tools/assistant/compat/mainwindow.ui"/>
+ <source>Save Page As...</source>
+ <translation>Seite speichern als...</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Ctrl+Alt+S</source>
+ <translation>Strg+Alt+S</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Sync with Table of Contents</source>
+ <translation>Seite mit Inhalt-Tab syncronisieren</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Select the page in contents tab.</source>
+ <translation>Wählt die Seite im Inhalt-Tab aus.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Font Settings...</source>
+ <translation>Schriftart...</translation>
+ </message>
+</context>
+<context>
+ <name>QObject</name>
+ <message>
+ <location filename="../tools/assistant/compat/config.cpp" line="+350"/>
+ <source>Qt Assistant by Nokia</source>
+ <translation>Qt Assistant von Nokia</translation>
+ </message>
+</context>
+<context>
+ <name>TabbedBrowser</name>
+ <message>
+ <location filename="../tools/assistant/compat/tabbedbrowser.ui"/>
+ <source>TabbedBrowser</source>
+ <translation></translation>
+ </message>
+ <message>
+ <location/>
+ <source>Untitled</source>
+ <translation>Unbenannt</translation>
+ </message>
+ <message>
+ <location filename="../tools/assistant/compat/tabbedbrowser.cpp" line="+235"/>
+ <source>Add page</source>
+ <translation>Seite einfügen</translation>
+ </message>
+ <message>
+ <location line="+9"/>
+ <source>Close page</source>
+ <translation>Seite schließen</translation>
+ </message>
+ <message>
+ <location line="-95"/>
+ <source>...</source>
+ <translation>...</translation>
+ </message>
+ <message>
+ <location line="+338"/>
+ <source>New Tab</source>
+ <translation>Neuer Tab</translation>
+ </message>
+ <message>
+ <location line="+1"/>
+ <source>Close Tab</source>
+ <translation>Tab schließen</translation>
+ </message>
+ <message>
+ <location line="+1"/>
+ <source>Close Other Tabs</source>
+ <translation>Andere Tabs schließen</translation>
+ </message>
+ <message>
+ <location filename="../tools/assistant/compat/tabbedbrowser.ui"/>
+ <source>Previous</source>
+ <translation>Vorheriger</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Next</source>
+ <translation>Nächster</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Case Sensitive</source>
+ <translation>Groß-/Kleinschreibung beachten</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Whole words</source>
+ <translation>Ganze Wörter</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&lt;img src=&quot;:/trolltech/assistant/images/wrap.png&quot;&gt;&amp;nbsp;Search wrapped</source>
+ <translation>&lt;img src=&quot;:/trolltech/assistant/images/wrap.png&quot;&gt;&amp;nbsp;Seitenende</translation>
+ </message>
+</context>
+<context>
+ <name>TopicChooser</name>
+ <message>
+ <location filename="../tools/assistant/compat/topicchooser.cpp" line="+56"/>
+ <source>Choose a topic for &lt;b&gt;%1&lt;/b&gt;</source>
+ <translation>Wählen Sie ein Thema für &lt;b&gt;%1&lt;/b&gt;</translation>
+ </message>
+ <message>
+ <location filename="../tools/assistant/compat/topicchooser.ui"/>
+ <source>Choose Topic</source>
+ <translation>Thema wählen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Select a topic from the list and click the &lt;b&gt;Display&lt;/b&gt;-button to open the online help.</source>
+ <translation>Wählen Sie ein Thema aus der Liste aus und klicken Sie &lt;b&gt;Anzeigen&lt;/b&gt; um die Hilfe zu öffnen.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Topics</source>
+ <translation>&amp;Themen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Displays a list of available help topics for the keyword.</source>
+ <translation>Zeigt eine Liste der verfügbaren Hilfethemen für diesen Begriff an.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Display</source>
+ <translation>&amp;Anzeigen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Open the topic selected in the list.</source>
+ <translation>Öffne das gewählte Thema aus der Liste.</translation>
+ </message>
+ <message>
+ <location/>
+ <source>&amp;Close</source>
+ <translation>&amp;Schließen</translation>
+ </message>
+ <message>
+ <location/>
+ <source>Close the Dialog.</source>
+ <translation>Schließt den Dialog.</translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/guiapplauncher/test.ui b/tests/auto/guiapplauncher/test.ui
new file mode 100644
index 0000000000..02efcd45ad
--- /dev/null
+++ b/tests/auto/guiapplauncher/test.ui
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPlainTextEdit" name="plainTextEdit"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>23</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile">
+ <property name="title">
+ <string>File</string>
+ </property>
+ <addaction name="actionExit"/>
+ </widget>
+ <addaction name="menuFile"/>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ <action name="actionExit">
+ <property name="text">
+ <string>Exit</string>
+ </property>
+ </action>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>actionExit</sender>
+ <signal>triggered()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>399</x>
+ <y>299</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/tests/auto/guiapplauncher/tst_guiapplauncher.cpp b/tests/auto/guiapplauncher/tst_guiapplauncher.cpp
new file mode 100644
index 0000000000..a61bd5e8f1
--- /dev/null
+++ b/tests/auto/guiapplauncher/tst_guiapplauncher.cpp
@@ -0,0 +1,526 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 "windowmanager.h"
+
+#include <QtCore/QDir>
+#include <QtCore/QString>
+#include <QtTest/QtTest>
+#include <QtCore/QProcess>
+#include <QtCore/QByteArray>
+#include <QtCore/QLibraryInfo>
+#include <QtCore/QVariant>
+#include <QtCore/QDateTime>
+#include <QtCore/QMap>
+
+// AppLaunch: Launch gui applications, keep them running a while
+// (grabbing their top level from the window manager) and send
+// them a Close event via window manager. Verify that they do not
+// not crash nor produces unexpected error output.
+// Note: Do not play with the machine while it is running as otherwise
+// the top-level find algorithm might get confused (especially on Windows).
+// Environment variables are checked to turned off some tests
+// It is currently implemented for X11 and Windows, pending an
+// implementation of the WindowManager class and deployment on
+// the other platforms.
+
+enum { defaultUpTimeMS = 3000, defaultTopLevelWindowTimeoutMS = 30000,
+ defaultTerminationTimeoutMS = 35000 };
+
+// List the examples to test (Gui examples only).
+struct Example {
+ const char *name;
+ const char *directory;
+ const char *binary;
+ unsigned priority; // 0-highest
+ int upTimeMS;
+};
+
+const struct Example examples[] = {
+ {"animation/animatedtiles Example", "animation/animatedtiles", "animatedtiles", 0, -1},
+ {"animation/appchooser Example", "animation/appchooser", "appchooser", 10, -1},
+ {"animation/easing Example", "animation/easing", "easing", 10, -1},
+ {"animation/moveblocks Example", "animation/moveblocks", "moveblocks", 10, -1},
+ {"animation/states Example", "animation/states", "states", 10, -1},
+ {"animation/stickman Example", "animation/stickman", "stickman", 10, -1},
+ {"designer/calculatorbuilder Example", "designer/calculatorbuilder", "calculatorbuilder", 10, -1},
+ {"dialogs/standarddialogs Example", "dialogs/standarddialogs", "standarddialogs", 10, -1},
+ {"draganddrop/dropsite Example", "draganddrop/dropsite", "dropsite", 10, -1},
+ {"draganddrop/fridgemagnets Example", "draganddrop/fridgemagnets", "fridgemagnets", 10, -1},
+ {"draganddrop/puzzle Example", "draganddrop/puzzle", "puzzle", 10, -1},
+ {"effects/blurpicker Example", "effects/blurpicker", "blurpicker", 10, -1},
+ {"effects/customshader Example", "effects/customshader", "customshader", 10, -1},
+ {"effects/fademessage Example", "effects/fademessage", "fademessage", 10, -1},
+ {"effects/lighting Example", "effects/lighting", "lighting", 10, -1},
+ {"graphicsview/anchorlayout Example", "graphicsview/anchorlayout", "anchorlayout", 10, -1},
+ {"graphicsview/basicgraphicslayouts Example", "graphicsview/basicgraphicslayouts", "basicgraphicslayouts", 0, -1},
+ {"graphicsview/collidingmice Example", "graphicsview/collidingmice", "collidingmice", 10, -1},
+ {"graphicsview/diagramscene Example", "graphicsview/diagramscene", "diagramscene", 10, -1},
+ {"graphicsview/dragdroprobot Example", "graphicsview/dragdroprobot", "dragdroprobot", 10, -1},
+ {"graphicsview/elasticnodes Example", "graphicsview/elasticnodes", "elasticnodes", 10, -1},
+ {"graphicsview/flowlayout Example", "graphicsview/flowlayout", "flowlayout", 10, -1},
+ {"graphicsview/padnavigator Example", "graphicsview/padnavigator", "padnavigator", 0, -1},
+ {"graphicsview/portedasteroids Example", "graphicsview/portedasteroids", "portedasteroids", 10, -1},
+ {"graphicsview/portedcanvas Example", "graphicsview/portedcanvas", "portedcanvas", 10, -1},
+ {"graphicsview/weatheranchorlayout Example", "graphicsview/weatheranchorlayout", "weatheranchorlayout", 10, -1},
+ {"itemviews/addressbook Example", "itemviews/addressbook", "addressbook", 0, -1},
+ {"itemviews/basicsortfiltermodel Example", "itemviews/basicsortfiltermodel", "basicsortfiltermodel", 10, -1},
+ {"itemviews/chart Example", "itemviews/chart", "chart", 0, -1},
+ {"itemviews/coloreditorfactory Example", "itemviews/coloreditorfactory", "coloreditorfactory", 10, -1},
+ {"itemviews/combowidgetmapper Example", "itemviews/combowidgetmapper", "combowidgetmapper", 6, -1},
+ {"itemviews/customsortfiltermodel Example", "itemviews/customsortfiltermodel", "customsortfiltermodel", 6, -1},
+ {"itemviews/dirview Example", "itemviews/dirview", "dirview", 0, -1},
+ {"itemviews/editabletreemodel Example", "itemviews/editabletreemodel", "editabletreemodel", 0, -1},
+ {"itemviews/fetchmore Example", "itemviews/fetchmore", "fetchmore", 10, -1},
+ {"itemviews/frozencolumn Example", "itemviews/frozencolumn", "frozencolumn", 10, -1},
+ {"itemviews/pixelator Example", "itemviews/pixelator", "pixelator", 10, -1},
+ {"itemviews/puzzle Example", "itemviews/puzzle", "puzzle", 10, -1},
+ {"itemviews/simpledommodel Example", "itemviews/simpledommodel", "simpledommodel", 10, -1},
+ {"itemviews/simpletreemodel Example", "itemviews/simpletreemodel", "simpletreemodel", 10, -1},
+ {"itemviews/simplewidgetmapper Example", "itemviews/simplewidgetmapper", "simplewidgetmapper", 10, -1},
+ {"itemviews/spinboxdelegate Example", "itemviews/spinboxdelegate", "spinboxdelegate", 0, -1},
+ {"itemviews/stardelegate Example", "itemviews/stardelegate", "stardelegate", 10, -1},
+ {"layouts/basiclayouts Example", "layouts/basiclayouts", "basiclayouts", 0, -1},
+ {"layouts/borderlayout Example", "layouts/borderlayout", "borderlayout", 10, -1},
+ {"layouts/dynamiclayouts Example", "layouts/dynamiclayouts", "dynamiclayouts", 10, -1},
+ {"layouts/flowlayout Example", "layouts/flowlayout", "flowlayout", 10, -1},
+ {"mainwindows/application Example", "mainwindows/application", "application", 6, -1},
+ {"mainwindows/dockwidgets Example", "mainwindows/dockwidgets", "dockwidgets", 0, -1},
+ {"mainwindows/mdi Example", "mainwindows/mdi", "mdi", 0, -1},
+ {"mainwindows/menus Example", "mainwindows/menus", "menus", 10, -1},
+ {"mainwindows/recentfiles Example", "mainwindows/recentfiles", "recentfiles", 10, -1},
+ {"mainwindows/sdi Example", "mainwindows/sdi", "sdi", 10, -1},
+ {"multitouch/dials Example", "multitouch/dials", "dials", 10, -1},
+ {"multitouch/fingerpaint Example", "multitouch/fingerpaint", "fingerpaint", 10, -1},
+ {"multitouch/knobs Example", "multitouch/knobs", "knobs", 10, -1},
+ {"multitouch/pinchzoom Example", "multitouch/pinchzoom", "pinchzoom", 10, -1},
+ {"opengl/2dpainting Example", "opengl/2dpainting", "2dpainting", 10, -1},
+ {"opengl/grabber Example", "opengl/grabber", "grabber", 10, -1},
+ {"opengl/hellogl Example", "opengl/hellogl", "hellogl", 10, -1},
+ {"opengl/overpainting Example", "opengl/overpainting", "overpainting", 10, -1},
+ {"opengl/samplebuffers Example", "opengl/samplebuffers", "samplebuffers", 10, -1},
+ {"opengl/textures Example", "opengl/textures", "textures", 10, -1},
+ {"painting/basicdrawing Example", "painting/basicdrawing", "basicdrawing", 10, -1},
+ {"painting/concentriccircles Example", "painting/concentriccircles", "concentriccircles", 0, -1},
+ {"painting/fontsampler Example", "painting/fontsampler", "fontsampler", 0, -1},
+ {"painting/imagecomposition Example", "painting/imagecomposition", "imagecomposition", 10, -1},
+ {"painting/painterpaths Example", "painting/painterpaths", "painterpaths", 10, -1},
+ {"painting/svggenerator Example", "painting/svggenerator", "svggenerator", 10, -1},
+ {"painting/svgviewer Example", "painting/svgviewer", "svgviewer", 0, -1},
+ {"painting/transformations Example", "painting/transformations", "transformations", 0, -1},
+ {"qtconcurrent/imagescaling Example", "qtconcurrent/imagescaling", "imagescaling", 10, -1},
+ {"richtext/calendar Example", "richtext/calendar", "calendar", 0, -1},
+ {"richtext/orderform Example", "richtext/orderform", "orderform", 10, -1},
+ {"richtext/syntaxhighlighter Example", "richtext/syntaxhighlighter", "syntaxhighlighter", 0, -1},
+ {"richtext/textobject Example", "richtext/textobject", "textobject", 10, -1},
+ {"script/calculator Example", "script/calculator", "calculator", 6, -1},
+ {"script/qstetrix Example", "script/qstetrix", "qstetrix", 0, -1},
+ {"statemachine/eventtransitions Example", "statemachine/eventtransitions", "eventtransitions", 10, -1},
+ {"statemachine/rogue Example", "statemachine/rogue", "rogue", 10, -1},
+ {"statemachine/trafficlight Example", "statemachine/trafficlight", "trafficlight", 0, -1},
+ {"statemachine/twowaybutton Example", "statemachine/twowaybutton", "twowaybutton", 10, -1},
+ {"tutorials/addressbook/part7 Example", "tutorials/addressbook/part7", "part7", 0, -1},
+ {"webkit/fancybrowser Example", "webkit/fancybrowser", "fancybrowser", 0, 7000},
+ {"widgets/analogclock Example", "widgets/analogclock", "analogclock", 6, -1},
+ {"widgets/calculator Example", "widgets/calculator", "calculator", 6, -1},
+ {"widgets/calendarwidget Example", "widgets/calendarwidget", "calendarwidget", 10, -1},
+ {"widgets/charactermap Example", "widgets/charactermap", "charactermap", 10, -1},
+ {"widgets/codeeditor Example", "widgets/codeeditor", "codeeditor", 0, -1},
+ {"widgets/digitalclock Example", "widgets/digitalclock", "digitalclock", 10, -1},
+ {"widgets/groupbox Example", "widgets/groupbox", "groupbox", 10, -1},
+ {"widgets/icons Example", "widgets/icons", "icons", 10, -1},
+ {"widgets/imageviewer Example", "widgets/imageviewer", "imageviewer", 10, -1},
+ {"widgets/lineedits Example", "widgets/lineedits", "lineedits", 10, -1},
+ {"widgets/scribble Example", "widgets/scribble", "scribble", 10, -1},
+ {"widgets/sliders Example", "widgets/sliders", "sliders", 10, -1},
+ {"widgets/spinboxes Example", "widgets/spinboxes", "spinboxes", 10, -1},
+ {"widgets/styles Example", "widgets/styles", "styles", 0, -1},
+ {"widgets/stylesheet Example", "widgets/stylesheet", "stylesheet", 0, -1},
+ {"widgets/tablet Example", "widgets/tablet", "tablet", 10, -1},
+ {"widgets/tetrix Example", "widgets/tetrix", "tetrix", 0, -1},
+ {"widgets/tooltips Example", "widgets/tooltips", "tooltips", 10, -1},
+ {"widgets/validators Example", "widgets/validators", "validators", 10, -1},
+ {"widgets/wiggly Example", "widgets/wiggly", "wiggly", 10, -1}
+};
+
+const struct Example demos[] = {
+ {"Affine Demo", "affine", "affine", 0, -1},
+ {"Books Demo", "books", "books", 0, -1},
+ {"Browser Demo", "browser", "browser", 0, 0000},
+ {"Chip Demo", "chip", "chip", 0, -1},
+ {"Composition Demo", "composition", "composition", 0, -1},
+ {"Deform Demo", "deform", "deform", 0, -1},
+ {"Embeddeddialogs Demo", "embeddeddialogs", "embeddeddialogs", 0, -1},
+ {"Gradients Demo", "gradients", "gradients", 0, -1},
+ {"Interview Demo", "interview", "interview", 0, -1},
+ {"Mainwindow Demo", "mainwindow", "mainwindow", 0, -1},
+ {"PathStroke Demo", "pathstroke", "pathstroke", 0, -1},
+ {"Spreadsheet Demo", "spreadsheet", "spreadsheet", 0, -1},
+ {"Sub-Attac Demo", "sub-attaq", "sub-attaq", 0, -1},
+ {"TextEdit Demo", "textedit", "textedit", 0, -1},
+ {"Undo Demo", "undo", "undo", 0, -1}
+};
+
+// Data struct used in tests, specifying paths and timeouts
+struct AppLaunchData {
+ AppLaunchData();
+ void clear();
+
+ QString binary;
+ QStringList args;
+ QString workingDirectory;
+ int upTimeMS;
+ int topLevelWindowTimeoutMS;
+ int terminationTimeoutMS;
+ bool splashScreen;
+};
+
+AppLaunchData::AppLaunchData() :
+ upTimeMS(defaultUpTimeMS),
+ topLevelWindowTimeoutMS(defaultTopLevelWindowTimeoutMS),
+ terminationTimeoutMS(defaultTerminationTimeoutMS),
+ splashScreen(false)
+{
+}
+
+void AppLaunchData::clear()
+{
+ binary.clear();
+ args.clear();
+ workingDirectory.clear();
+ upTimeMS = defaultUpTimeMS;
+ topLevelWindowTimeoutMS = defaultTopLevelWindowTimeoutMS;
+ terminationTimeoutMS = defaultTerminationTimeoutMS;
+ splashScreen = false;
+}
+
+Q_DECLARE_METATYPE(AppLaunchData)
+
+
+class tst_GuiAppLauncher : public QObject
+{
+ Q_OBJECT
+
+public:
+ // Test name (static const char title!) + data
+ typedef QPair<const char*, AppLaunchData> TestDataEntry;
+ typedef QList<TestDataEntry> TestDataEntries;
+
+ enum { TestTools = 0x1, TestDemo = 0x2, TestExamples = 0x4,
+ TestAll = TestTools|TestDemo|TestExamples };
+
+ tst_GuiAppLauncher();
+
+private Q_SLOTS:
+ void initTestCase();
+
+ void run();
+ void run_data();
+
+ void cleanupTestCase();
+
+private:
+ QString workingDir() const;
+
+private:
+ bool runApp(const AppLaunchData &data, QString *errorMessage) const;
+ TestDataEntries testData() const;
+
+ const unsigned m_testMask;
+ const unsigned m_examplePriority;
+ const QString m_dir;
+ const QSharedPointer<WindowManager> m_wm;
+};
+
+// Test mask from enviroment as test lib does not allow options.
+static inline unsigned testMask()
+{
+ unsigned testMask = tst_GuiAppLauncher::TestAll;
+ if (!qgetenv("QT_TEST_NOTOOLS").isEmpty())
+ testMask &= ~ tst_GuiAppLauncher::TestTools;
+ if (!qgetenv("QT_TEST_NOEXAMPLES").isEmpty())
+ testMask &= ~tst_GuiAppLauncher::TestExamples;
+ if (!qgetenv("QT_TEST_NODEMOS").isEmpty())
+ testMask &= ~tst_GuiAppLauncher::TestDemo;
+ return testMask;
+}
+
+static inline unsigned testExamplePriority()
+{
+ const QByteArray priorityD = qgetenv("QT_TEST_EXAMPLE_PRIORITY");
+ if (!priorityD.isEmpty()) {
+ bool ok;
+ const unsigned rc = priorityD.toUInt(&ok);
+ if (ok)
+ return rc;
+ }
+ return 5;
+}
+
+tst_GuiAppLauncher::tst_GuiAppLauncher() :
+ m_testMask(testMask()),
+ m_examplePriority(testExamplePriority()),
+ m_dir(QLatin1String(SRCDIR)),
+ m_wm(WindowManager::create())
+{
+}
+
+void tst_GuiAppLauncher::initTestCase()
+{
+ QString message = QString::fromLatin1("### App Launcher test on %1 in %2 (%3)").
+ arg(QDateTime::currentDateTime().toString(), QDir::currentPath()).
+ arg(QLibraryInfo::buildKey());
+ qDebug("%s", qPrintable(message));
+ qWarning("### PLEASE LEAVE THE MACHINE UNATTENDED WHILE THIS TEST IS RUNNING\n");
+
+ // Does a window manager exist on the platform?
+ if (!m_wm->openDisplay(&message)) {
+ QSKIP(message.toLatin1().constData(), SkipAll);
+ }
+
+ // Paranoia: Do we have our test file?
+ const QDir workDir(m_dir);
+ if (!workDir.exists()) {
+ message = QString::fromLatin1("Invalid working directory %1").arg(m_dir);
+ QFAIL(message.toLocal8Bit().constData());
+ }
+}
+
+void tst_GuiAppLauncher::run()
+{
+ QString errorMessage;
+ QFETCH(AppLaunchData, data);
+ const bool rc = runApp(data, &errorMessage);
+ if (!rc) // Wait for windows to disappear after kill
+ WindowManager::sleepMS(500);
+ QVERIFY2(rc, qPrintable(errorMessage));
+}
+
+// Cross platform galore!
+static inline QString guiBinary(QString in)
+{
+#ifdef Q_OS_MAC
+ return in + QLatin1String(".app/Contents/MacOS/") + in;
+#endif
+ in[0] = in.at(0).toLower();
+#ifdef Q_OS_WIN
+ in += QLatin1String(".exe");
+#endif
+ return in;
+}
+
+void tst_GuiAppLauncher::run_data()
+{
+ QTest::addColumn<AppLaunchData>("data");
+ foreach(const TestDataEntry &data, testData())
+ QTest::newRow(data.first) << data.second;
+}
+
+// Read out the examples array structures and convert to test data.
+static tst_GuiAppLauncher::TestDataEntries exampleData(unsigned priority,
+ const QString &path,
+ bool debug,
+ const Example *exArray,
+ unsigned n)
+{
+ Q_UNUSED(debug)
+ tst_GuiAppLauncher::TestDataEntries rc;
+ const QChar slash = QLatin1Char('/');
+ AppLaunchData data;
+ for (unsigned e = 0; e < n; e++) {
+ const Example &example = exArray[e];
+ if (example.priority <= priority) {
+ data.clear();
+ const QString examplePath = path + slash + QLatin1String(example.directory);
+ data.binary = examplePath + slash;
+#ifdef Q_OS_WIN
+ data.binary += debug? QLatin1String("debug/") : QLatin1String("release/");
+#endif
+ data.binary += guiBinary(QLatin1String(example.binary));
+ data.workingDirectory = examplePath;
+ if (example.upTimeMS > 0)
+ data.upTimeMS = example.upTimeMS;
+ rc.append(tst_GuiAppLauncher::TestDataEntry(example.name, data));
+ }
+ }
+ return rc;
+}
+
+tst_GuiAppLauncher::TestDataEntries tst_GuiAppLauncher::testData() const
+{
+ TestDataEntries rc;
+ const QChar slash = QLatin1Char('/');
+ const QString binPath = QLibraryInfo::location(QLibraryInfo::BinariesPath) + slash;
+ const bool debug = QLibraryInfo::buildKey().contains(QLatin1String("debug"));
+ Q_UNUSED(debug)
+
+ AppLaunchData data;
+
+ if (m_testMask & TestTools) {
+ data.binary = binPath + guiBinary(QLatin1String("Designer"));
+ data.args.append(m_dir + QLatin1String("test.ui"));
+ rc.append(TestDataEntry("Qt Designer", data));
+
+ data.clear();
+ data.binary = binPath + guiBinary(QLatin1String("Linguist"));
+ data.splashScreen = true;
+ data.upTimeMS = 5000; // Slow loading
+ data.args.append(m_dir + QLatin1String("test.ts"));
+ rc.append(TestDataEntry("Qt Linguist", data));
+ }
+
+ if (m_testMask & TestDemo) {
+ data.clear();
+ data.upTimeMS = 5000; // Startup animation
+ data.binary = binPath + guiBinary(QLatin1String("qtdemo"));
+ rc.append(TestDataEntry("Qt Demo", data));
+
+ const QString demosPath = QLibraryInfo::location(QLibraryInfo::DemosPath);
+ if (!demosPath.isEmpty())
+ rc += exampleData(m_examplePriority, demosPath, debug, demos, sizeof(demos)/sizeof(Example));
+ }
+
+ if (m_testMask & TestExamples) {
+ const QString examplesPath = QLibraryInfo::location(QLibraryInfo::ExamplesPath);
+ if (!examplesPath.isEmpty())
+ rc += exampleData(m_examplePriority, examplesPath, debug, examples, sizeof(examples)/sizeof(Example));
+ }
+ qDebug("Running %d tests...", rc.size());
+ return rc;
+}
+
+static inline void ensureTerminated(QProcess *p)
+{
+ if (p->state() != QProcess::Running)
+ return;
+ p->terminate();
+ if (p->waitForFinished(300))
+ return;
+ p->kill();
+ if (!p->waitForFinished(500))
+ qWarning("Unable to terminate process");
+}
+
+static const QStringList &stderrWhiteList()
+{
+ static QStringList rc;
+ if (rc.empty()) {
+ rc << QLatin1String("QPainter::begin: Paint device returned engine == 0, type: 2")
+ << QLatin1String("QPainter::setRenderHint: Painter must be active to set rendering hints")
+ << QLatin1String("QPainter::setPen: Painter not active")
+ << QLatin1String("QPainter::setBrush: Painter not active")
+ << QLatin1String("QPainter::end: Painter not active, aborted");
+ }
+ return rc;
+}
+
+bool tst_GuiAppLauncher::runApp(const AppLaunchData &data, QString *errorMessage) const
+{
+ qDebug("Launching: %s\n", qPrintable(data.binary));
+ QProcess process;
+ process.setProcessChannelMode(QProcess::MergedChannels);
+ if (!data.workingDirectory.isEmpty())
+ process.setWorkingDirectory(data.workingDirectory);
+ process.start(data.binary, data.args);
+ process.closeWriteChannel();
+ if (!process.waitForStarted()) {
+ *errorMessage = QString::fromLatin1("Unable to execute %1: %2").arg(data.binary, process.errorString());
+ return false;
+ }
+ // Get window id.
+ const QString winId = m_wm->waitForTopLevelWindow(data.splashScreen ? 2 : 1, process.pid(), data.topLevelWindowTimeoutMS, errorMessage);
+ if (winId.isEmpty()) {
+ ensureTerminated(&process);
+ return false;
+ }
+ qDebug("Window: %s\n", qPrintable(winId));
+ // Wait a bit, then send close
+ WindowManager::sleepMS(data.upTimeMS);
+ if (m_wm->sendCloseEvent(winId, process.pid(), errorMessage)) {
+ qDebug("Sent close to window: %s\n", qPrintable(winId));
+ } else {
+ ensureTerminated(&process);
+ return false;
+ }
+ // Terminate
+ if (!process.waitForFinished(data.terminationTimeoutMS)) {
+ *errorMessage = QString::fromLatin1("%1: Timeout %2ms").arg(data.binary).arg(data.terminationTimeoutMS);
+ ensureTerminated(&process);
+ return false;
+ }
+ if (process.exitStatus() != QProcess::NormalExit) {
+ *errorMessage = QString::fromLatin1("%1: Startup crash").arg(data.binary);
+ return false;
+ }
+
+ const int exitCode = process.exitCode();
+ // check stderr
+ const QStringList stderrOutput = QString::fromLocal8Bit(process.readAllStandardOutput()).split(QLatin1Char('\n'));
+ foreach(const QString &stderrLine, stderrOutput) {
+ // Skip expected QPainter warnings from oxygen.
+ if (stderrWhiteList().contains(stderrLine)) {
+ qWarning("%s: stderr: %s\n", qPrintable(data.binary), qPrintable(stderrLine));
+ } else {
+ if (!stderrLine.isEmpty()) { // Split oddity gives empty messages
+ *errorMessage = QString::fromLatin1("%1: Unexpected output (ex=%2): '%3'").arg(data.binary).arg(exitCode).arg(stderrLine);
+ return false;
+ }
+ }
+ }
+
+ if (exitCode != 0) {
+ *errorMessage = QString::fromLatin1("%1: Exit code %2").arg(data.binary).arg(exitCode);
+ return false;
+ }
+ return true;
+}
+
+void tst_GuiAppLauncher::cleanupTestCase()
+{
+}
+
+#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
+QTEST_NOOP_MAIN
+#else
+QTEST_APPLESS_MAIN(tst_GuiAppLauncher)
+#endif
+
+#include "tst_guiapplauncher.moc"
diff --git a/tests/auto/guiapplauncher/windowmanager.cpp b/tests/auto/guiapplauncher/windowmanager.cpp
new file mode 100644
index 0000000000..758a14eba8
--- /dev/null
+++ b/tests/auto/guiapplauncher/windowmanager.cpp
@@ -0,0 +1,508 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 "windowmanager.h"
+#include <QtCore/QTime>
+#include <QtCore/QThread>
+#include <QtCore/QDebug>
+#include <QtCore/QTextStream>
+
+#ifdef Q_WS_X11
+# include <string.h> // memset
+# include <X11/Xlib.h>
+# include <X11/Xatom.h> // XA_WM_STATE
+# include <X11/Xutil.h>
+# include <X11/Xmd.h> // CARD32
+#endif
+
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+# include <windows.h>
+#endif
+
+// Export the sleep function
+class FriendlySleepyThread : public QThread {
+public:
+ static void sleepMS(int milliSeconds) { msleep(milliSeconds); }
+};
+
+#ifdef Q_WS_X11
+// X11 Window manager
+
+// Register our own error handler to prevent the defult crashing
+// behaviour. It simply counts errors in global variables that
+// can be checked after calls.
+
+static unsigned x11ErrorCount = 0;
+static const char *currentX11Function = 0;
+
+int xErrorHandler(Display *, XErrorEvent *e)
+{
+ x11ErrorCount++;
+
+ QString msg;
+ QTextStream str(&msg);
+ str << "An X11 error (#" << x11ErrorCount<< ") occurred: ";
+ if (currentX11Function)
+ str << ' ' << currentX11Function << "()";
+ str << " code: " << e->error_code;
+ str.setIntegerBase(16);
+ str << " resource: 0x" << e->resourceid;
+ qWarning("%s", qPrintable(msg));
+
+ return 0;
+}
+
+static bool isMapped(Display *display, Atom xa_wm_state, Window window, bool *isMapped)
+{
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *prop;
+
+ *isMapped = false;
+ currentX11Function = "XGetWindowProperty";
+ const int retv = XGetWindowProperty(display, window, xa_wm_state, 0L, 1L, False, xa_wm_state,
+ &actual_type, &actual_format, &nitems, &bytes_after, &prop);
+
+ if (retv != Success || actual_type == None || actual_type != xa_wm_state
+ || nitems != 1 || actual_format != 32)
+ return false;
+
+ const CARD32 state = * reinterpret_cast<CARD32 *>(prop);
+
+ switch ((int) state) {
+ case WithdrawnState:
+ *isMapped = false;
+ break;
+ case NormalState:
+ case IconicState:
+ *isMapped = true;
+ break;
+ default:
+ *isMapped = true;
+ break;
+ }
+ return true;
+}
+
+// Wait until a X11 top level has been mapped, courtesy of xtoolwait.
+static Window waitForTopLevelMapped(Display *display, unsigned count, int timeOutMS, QString * errorMessage)
+{
+ unsigned mappingsCount = count;
+ Atom xa_wm_state;
+ XEvent event;
+
+ // Discard all pending events
+ currentX11Function = "XSync";
+ XSync(display, True);
+
+ // Listen for top level creation
+ currentX11Function = "XSelectInput";
+ XSelectInput(display, DefaultRootWindow(display), SubstructureNotifyMask);
+
+ /* We assume that the window manager provides the WM_STATE property on top-level
+ * windows, as required by ICCCM 2.0.
+ * If the window manager has not yet completed its initialisation, the WM_STATE atom
+ * might not exist, in which case we create it. */
+
+#ifdef XA_WM_STATE /* probably in X11R7 */
+ xa_wm_state = XA_WM_STATE;
+#else
+ xa_wm_state = XInternAtom(display, "WM_STATE", False);
+#endif
+
+ QTime elapsedTime;
+ elapsedTime.start();
+ while (mappingsCount) {
+ if (elapsedTime.elapsed() > timeOutMS) {
+ *errorMessage = QString::fromLatin1("X11: Timed out waiting for toplevel %1ms").arg(timeOutMS);
+ return 0;
+ }
+ currentX11Function = "XNextEvent";
+ unsigned errorCount = x11ErrorCount;
+ XNextEvent(display, &event);
+ if (x11ErrorCount > errorCount) {
+ *errorMessage = QString::fromLatin1("X11: Error in XNextEvent");
+ return 0;
+ }
+ switch (event.type) {
+ case CreateNotify:
+ // Window created, listen for its mapping now
+ if (!event.xcreatewindow.send_event && !event.xcreatewindow.override_redirect)
+ XSelectInput(display, event.xcreatewindow.window, PropertyChangeMask);
+ break;
+ case PropertyNotify:
+ // Watch for map
+ if (!event.xproperty.send_event && event.xproperty.atom == xa_wm_state) {
+ bool mapped;
+ if (isMapped(display, xa_wm_state, event.xproperty.window, &mapped)) {
+ if (mapped && --mappingsCount == 0)
+ return event.xproperty.window;
+ // Past splash screen, listen for next window to be created
+ XSelectInput(display, DefaultRootWindow(display), SubstructureNotifyMask);
+ } else {
+ // Some temporary window disappeared. Listen for next creation
+ XSelectInput(display, DefaultRootWindow(display), SubstructureNotifyMask);
+ }
+ // Main app window opened?
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ *errorMessage = QString::fromLatin1("X11: Timed out waiting for toplevel %1ms").arg(timeOutMS);
+ return 0;
+}
+
+
+class X11_WindowManager : public WindowManager
+{
+public:
+ X11_WindowManager();
+ ~X11_WindowManager();
+
+protected:
+ virtual bool isDisplayOpenImpl() const;
+ virtual bool openDisplayImpl(QString *errorMessage);
+ virtual QString waitForTopLevelWindowImpl(unsigned count, Q_PID, int timeOutMS, QString *errorMessage);
+ virtual bool sendCloseEventImpl(const QString &winId, Q_PID pid, QString *errorMessage);
+
+private:
+ Display *m_display;
+ const QByteArray m_displayVariable;
+ XErrorHandler m_oldErrorHandler;
+};
+
+X11_WindowManager::X11_WindowManager() :
+ m_display(0),
+ m_displayVariable(qgetenv("DISPLAY")),
+ m_oldErrorHandler(0)
+{
+}
+
+X11_WindowManager::~X11_WindowManager()
+{
+ if (m_display) {
+ XSetErrorHandler(m_oldErrorHandler);
+ XCloseDisplay(m_display);
+ }
+}
+
+bool X11_WindowManager::isDisplayOpenImpl() const
+{
+ return m_display != 0;
+}
+
+bool X11_WindowManager::openDisplayImpl(QString *errorMessage)
+{
+ if (m_displayVariable.isEmpty()) {
+ *errorMessage = QLatin1String("X11: Display not set");
+ return false;
+ }
+ m_display = XOpenDisplay(NULL);
+ if (!m_display) {
+ *errorMessage = QString::fromLatin1("X11: Cannot open display %1.").arg(QString::fromLocal8Bit(m_displayVariable));
+ return false;
+ }
+
+ m_oldErrorHandler = XSetErrorHandler(xErrorHandler);
+ return true;
+}
+
+QString X11_WindowManager::waitForTopLevelWindowImpl(unsigned count, Q_PID, int timeOutMS, QString *errorMessage)
+{
+ const Window w = waitForTopLevelMapped(m_display, count, timeOutMS, errorMessage);
+ if (w == 0)
+ return QString();
+ return QLatin1String("0x") + QString::number(w, 16);
+}
+
+ bool X11_WindowManager::sendCloseEventImpl(const QString &winId, Q_PID, QString *errorMessage)
+ {
+ // Get win id
+ bool ok;
+ const Window window = winId.toULong(&ok, 16);
+ if (!ok) {
+ *errorMessage = QString::fromLatin1("Invalid win id %1.").arg(winId);
+ return false;
+ }
+ // Send a window manager close event
+ XEvent ev;
+ memset(&ev, 0, sizeof (ev));
+ ev.xclient.type = ClientMessage;
+ ev.xclient.window = window;
+ ev.xclient.message_type = XInternAtom(m_display, "WM_PROTOCOLS", true);
+ ev.xclient.format = 32;
+ ev.xclient.data.l[0] = XInternAtom(m_display, "WM_DELETE_WINDOW", false);
+ ev.xclient.data.l[1] = CurrentTime;
+ // Window disappeared or some error triggered?
+ unsigned errorCount = x11ErrorCount;
+ currentX11Function = "XSendEvent";
+ XSendEvent(m_display, window, False, NoEventMask, &ev);
+ if (x11ErrorCount > errorCount) {
+ *errorMessage = QString::fromLatin1("Error sending event to win id %1.").arg(winId);
+ return false;
+ }
+ currentX11Function = "XSync";
+ errorCount = x11ErrorCount;
+ XSync(m_display, False);
+ if (x11ErrorCount > errorCount) {
+ *errorMessage = QString::fromLatin1("Error sending event to win id %1 (XSync).").arg(winId);
+ return false;
+ }
+ return true;
+ }
+
+#endif
+
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+// Windows
+
+ QString winErrorMessage(unsigned long error)
+{
+ QString rc = QString::fromLatin1("#%1: ").arg(error);
+ ushort *lpMsgBuf;
+
+ const int len = FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, error, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
+ if (len) {
+ rc = QString::fromUtf16(lpMsgBuf, len);
+ LocalFree(lpMsgBuf);
+ } else {
+ rc += QString::fromLatin1("<unknown error>");
+ }
+ return rc;
+}
+
+ class Win_WindowManager : public WindowManager
+ {
+ public:
+ Win_WindowManager() {}
+
+ protected:
+ virtual bool isDisplayOpenImpl() const;
+ virtual bool openDisplayImpl(QString *errorMessage);
+ virtual QString waitForTopLevelWindowImpl(unsigned count, Q_PID, int timeOutMS, QString *errorMessage);
+ virtual bool sendCloseEventImpl(const QString &winId, Q_PID pid, QString *errorMessage);
+
+ private:
+ };
+
+bool Win_WindowManager::isDisplayOpenImpl() const
+{
+ return true;
+}
+
+bool Win_WindowManager::openDisplayImpl(QString *)
+{
+ return true;
+}
+
+// Enumerate window looking for toplevel of process id
+struct FindProcessWindowEnumContext {
+ FindProcessWindowEnumContext(DWORD pid) : window(0),processId(pid) {}
+
+ HWND window;
+ DWORD processId;
+};
+
+/* Check for the active main window of the Application
+ * of class QWidget. */
+static inline bool isQtMainWindow(HWND hwnd)
+{
+ static char buffer[MAX_PATH];
+ if (!GetClassNameA(hwnd, buffer, MAX_PATH) || qstrcmp(buffer, "QWidget"))
+ return false;
+ WINDOWINFO windowInfo;
+ if (!GetWindowInfo(hwnd, &windowInfo))
+ return false;
+ if (!(windowInfo.dwWindowStatus & WS_ACTIVECAPTION))
+ return false;
+ // Check the style for a real mainwindow
+ const DWORD excluded = WS_DISABLED | WS_POPUP;
+ const DWORD required = WS_CAPTION | WS_SYSMENU | WS_VISIBLE;
+ return (windowInfo.dwStyle & excluded) == 0
+ && (windowInfo.dwStyle & required) == required;
+}
+
+static BOOL CALLBACK findProcessWindowEnumWindowProc(HWND hwnd, LPARAM lParam)
+{
+ DWORD processId = 0;
+ FindProcessWindowEnumContext *context= reinterpret_cast<FindProcessWindowEnumContext *>(lParam);
+ GetWindowThreadProcessId(hwnd, &processId);
+ if (context->processId == processId && isQtMainWindow(hwnd)) {
+ context->window = hwnd;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+QString Win_WindowManager::waitForTopLevelWindowImpl(unsigned /* count */, Q_PID pid, int timeOutMS, QString *errorMessage)
+{
+ QTime elapsed;
+ elapsed.start();
+ // First, wait until the application is up
+ if (WaitForInputIdle(pid->hProcess, timeOutMS) != 0) {
+ *errorMessage = QString::fromLatin1("WaitForInputIdle time out after %1ms").arg(timeOutMS);
+ return QString();
+ }
+ // Try to locate top level app window. App still might be in splash screen or initialization
+ // phase.
+ const int remainingMilliSeconds = qMax(timeOutMS - elapsed.elapsed(), 500);
+ const int attempts = 10;
+ const int intervalMilliSeconds = remainingMilliSeconds / attempts;
+ for (int a = 0; a < attempts; a++) {
+ FindProcessWindowEnumContext context(pid->dwProcessId);
+ EnumWindows(findProcessWindowEnumWindowProc, reinterpret_cast<LPARAM>(&context));
+ if (context.window)
+ return QLatin1String("0x") + QString::number(reinterpret_cast<quintptr>(context.window), 16);
+ sleepMS(intervalMilliSeconds);
+ }
+ *errorMessage = QString::fromLatin1("Unable to find toplevel of process %1 after %2ms.").arg(pid->dwProcessId).arg(timeOutMS);
+ return QString();
+}
+
+bool Win_WindowManager::sendCloseEventImpl(const QString &winId, Q_PID, QString *errorMessage)
+{
+ // Convert window back.
+ quintptr winIdIntPtr;
+ QTextStream str(const_cast<QString*>(&winId), QIODevice::ReadOnly);
+ str.setIntegerBase(16);
+ str >> winIdIntPtr;
+ if (str.status() != QTextStream::Ok) {
+ *errorMessage = QString::fromLatin1("Invalid win id %1.").arg(winId);
+ return false;
+ }
+ if (!PostMessage(reinterpret_cast<HWND>(winIdIntPtr), WM_CLOSE, 0, 0)) {
+ *errorMessage = QString::fromLatin1("Cannot send event to 0x%1: %2").arg(winIdIntPtr, 0, 16).arg(winErrorMessage(GetLastError()));
+ return false;
+ }
+ return true;
+}
+#endif
+
+// ------- Default implementation
+
+WindowManager::WindowManager()
+{
+}
+
+WindowManager::~WindowManager()
+{
+}
+
+QSharedPointer<WindowManager> WindowManager::create()
+{
+#ifdef Q_WS_X11
+ return QSharedPointer<WindowManager>(new X11_WindowManager);
+#endif
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ return QSharedPointer<WindowManager>(new Win_WindowManager);
+#else
+ return QSharedPointer<WindowManager>(new WindowManager);
+#endif
+}
+
+static inline QString msgNoDisplayOpen() { return QLatin1String("No display opened."); }
+
+bool WindowManager::openDisplay(QString *errorMessage)
+{
+ if (isDisplayOpen())
+ return true;
+ return openDisplayImpl(errorMessage);
+}
+
+bool WindowManager::isDisplayOpen() const
+{
+ return isDisplayOpenImpl();
+}
+
+
+
+QString WindowManager::waitForTopLevelWindow(unsigned count, Q_PID pid, int timeOutMS, QString *errorMessage)
+{
+ if (!isDisplayOpen()) {
+ *errorMessage = msgNoDisplayOpen();
+ return QString();
+ }
+ return waitForTopLevelWindowImpl(count, pid, timeOutMS, errorMessage);
+}
+
+bool WindowManager::sendCloseEvent(const QString &winId, Q_PID pid, QString *errorMessage)
+{
+ if (!isDisplayOpen()) {
+ *errorMessage = msgNoDisplayOpen();
+ return false;
+ }
+ return sendCloseEventImpl(winId, pid, errorMessage);
+}
+
+// Default Implementation
+bool WindowManager::openDisplayImpl(QString *errorMessage)
+{
+ *errorMessage = QLatin1String("Not implemented.");
+ return false;
+}
+
+bool WindowManager::isDisplayOpenImpl() const
+{
+ return false;
+}
+
+QString WindowManager::waitForTopLevelWindowImpl(unsigned, Q_PID, int, QString *errorMessage)
+{
+ *errorMessage = QLatin1String("Not implemented.");
+ return QString();
+}
+
+bool WindowManager::sendCloseEventImpl(const QString &, Q_PID, QString *errorMessage)
+{
+ *errorMessage = QLatin1String("Not implemented.");
+ return false;
+}
+
+void WindowManager::sleepMS(int milliSeconds)
+{
+ FriendlySleepyThread::sleepMS(milliSeconds);
+}
diff --git a/tests/benchmarks/qnetworkreply/main.cpp b/tests/auto/guiapplauncher/windowmanager.h
index 666e4f1418..56e2eb9a54 100644
--- a/tests/benchmarks/qnetworkreply/main.cpp
+++ b/tests/auto/guiapplauncher/windowmanager.h
@@ -38,37 +38,41 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-// This file contains benchmarks for QNetworkReply functions.
-#include <QDebug>
-#include <qtest.h>
-#include <QtTest/QtTest>
-#include <QtNetwork/qnetworkreply.h>
-#include <QtNetwork/qnetworkrequest.h>
-#include <QtNetwork/qnetworkaccessmanager.h>
-#include "../../auto/network-settings.h"
+#ifndef WINDOWMANAGER_H
+#define WINDOWMANAGER_H
-class tst_qnetworkreply : public QObject
-{
- Q_OBJECT
-private slots:
- void httpLatency();
+#include <QtCore/QSharedPointer>
+#include <QtCore/QString>
+#include <QtCore/QProcess>
-};
+/* WindowManager: Provides functions to retrieve the top level window of
+ * an application and send it a close event. */
-void tst_qnetworkreply::httpLatency()
+class WindowManager
{
- QNetworkAccessManager manager;
- QBENCHMARK{
- QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/"));
- QNetworkReply* reply = manager.get(request);
- connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
- QTestEventLoop::instance().enterLoop(5);
- QVERIFY(!QTestEventLoop::instance().timeout());
- delete reply;
- }
-}
+ Q_DISABLE_COPY(WindowManager)
+public:
+ static QSharedPointer<WindowManager> create();
+
+ virtual ~WindowManager();
+
+ bool openDisplay(QString *errorMessage);
+ bool isDisplayOpen() const;
-QTEST_MAIN(tst_qnetworkreply)
+ // Count: Number of toplevels, 1 for normal apps, 2 for apps with a splash screen
+ QString waitForTopLevelWindow(unsigned count, Q_PID pid, int timeOutMS, QString *errorMessage);
+ bool sendCloseEvent(const QString &winId, Q_PID pid, QString *errorMessage);
+
+ static void sleepMS(int milliSeconds);
+
+protected:
+ WindowManager();
+
+ virtual bool openDisplayImpl(QString *errorMessage);
+ virtual bool isDisplayOpenImpl() const;
+ virtual QString waitForTopLevelWindowImpl(unsigned count, Q_PID pid, int timeOutMS, QString *errorMessage);
+ virtual bool sendCloseEventImpl(const QString &winId, Q_PID pid, QString *errorMessage);
+};
-#include "main.moc"
+#endif // WINDOWMANAGER_H
diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp
index d4f2ff4419..36d25fe054 100644
--- a/tests/auto/headers/tst_headers.cpp
+++ b/tests/auto/headers/tst_headers.cpp
@@ -77,7 +77,7 @@ private:
tst_Headers::tst_Headers() :
copyrightPattern("\\*\\* Copyright \\(C\\) 20[0-9][0-9] Nokia Corporation and/or its subsidiary\\(-ies\\)."),
- licensePattern("\\*\\* \\$QT_BEGIN_LICENSE:(LGPL|BSD|3RDPARTY)\\$"),
+ licensePattern("\\*\\* \\$QT_BEGIN_LICENSE:(LGPL|BSD|3RDPARTY|LGPL-ONLY)\\$"),
moduleTest(QLatin1String("\\*\\* This file is part of the .+ of the Qt Toolkit."))
{
}
diff --git a/tests/auto/linguist/lconvert/tst_lconvert.cpp b/tests/auto/linguist/lconvert/tst_lconvert.cpp
index e38e22c62b..10098a4b6b 100644
--- a/tests/auto/linguist/lconvert/tst_lconvert.cpp
+++ b/tests/auto/linguist/lconvert/tst_lconvert.cpp
@@ -105,7 +105,7 @@ void tst_lconvert::doCompare(QIODevice *actualDev, const QString &expectedFn)
QList<QByteArray> actual = actualDev->readAll().split('\n');
QFile file(expectedFn);
- QVERIFY(file.open(QIODevice::ReadOnly));
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
QList<QByteArray> expected = file.readAll().split('\n');
int i = 0, ei = expected.size(), gi = actual.size();
@@ -179,7 +179,7 @@ void tst_lconvert::convertChain(const QString &_inFileName, const QString &_outF
if (!argList.isEmpty())
args += argList[i];
args << "-if" << stations[i] << "-i" << "-" << "-of" << stations[i + 1];
- cvts.at(i)->start(binDir + "/lconvert", args);
+ cvts.at(i)->start(binDir + "/lconvert", args, QIODevice::ReadWrite | QIODevice::Text);
}
int st = 0;
foreach (QProcess *cvt, cvts)
@@ -243,7 +243,9 @@ void tst_lconvert::converts()
QString outFileNameFq = dataDir + outFileName;
QProcess cvt;
- cvt.start(binDir + "/lconvert", QStringList() << "-i" << (dataDir + inFileName) << "-of" << format);
+ cvt.start(binDir + "/lconvert",
+ QStringList() << "-i" << (dataDir + inFileName) << "-of" << format,
+ QIODevice::ReadWrite | QIODevice::Text);
doWait(&cvt, 0);
if (QTest::currentTestFailed())
return;
diff --git a/tests/auto/linguist/lrelease/testdata/idbased.ts b/tests/auto/linguist/lrelease/testdata/idbased.ts
index 61497deecb..c7555c846e 100644
--- a/tests/auto/linguist/lrelease/testdata/idbased.ts
+++ b/tests/auto/linguist/lrelease/testdata/idbased.ts
@@ -9,6 +9,7 @@
</message>
<message id="untranslated_id">
<source>This has no translation.</source>
+ <translation type="unfinished"></translation>
</message>
<message id="this_another_id">
<source>Foo bar.</source>
@@ -17,5 +18,11 @@
<message>
<source>Drop me!</source>
</message>
+ <message id="one_id">
+ <source></source>
+ </message>
+ <message id="two_id">
+ <source></source>
+ </message>
</context>
</TS>
diff --git a/tests/auto/linguist/lrelease/tst_lrelease.cpp b/tests/auto/linguist/lrelease/tst_lrelease.cpp
index 39de8a15fa..c9e774fd15 100644
--- a/tests/auto/linguist/lrelease/tst_lrelease.cpp
+++ b/tests/auto/linguist/lrelease/tst_lrelease.cpp
@@ -60,6 +60,7 @@ private slots:
void mixedcodecs();
void compressed();
void idbased();
+ void markuntranslated();
void dupes();
private:
@@ -71,8 +72,8 @@ private:
void tst_lrelease::doCompare(const QStringList &actual, const QString &expectedFn)
{
QFile file(expectedFn);
- QVERIFY(file.open(QIODevice::ReadOnly));
- QStringList expected = QString(file.readAll()).trimmed().remove('\r').split('\n');
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
+ QStringList expected = QString(file.readAll()).trimmed().split('\n');
int i = 0, ei = expected.size(), gi = actual.size();
for (; ; i++) {
@@ -210,13 +211,25 @@ void tst_lrelease::idbased()
QCOMPARE(qtTrId("untranslated_id"), QString::fromAscii("This has no translation."));
}
+void tst_lrelease::markuntranslated()
+{
+ QVERIFY(!QProcess::execute(binDir + "/lrelease -markuntranslated # -idbased testdata/idbased.ts"));
+
+ QTranslator translator;
+ QVERIFY(translator.load("testdata/idbased.qm"));
+ qApp->installTranslator(&translator);
+
+ QCOMPARE(qtTrId("test_id"), QString::fromAscii("This is a test string."));
+ QCOMPARE(qtTrId("untranslated_id"), QString::fromAscii("#This has no translation."));
+}
+
void tst_lrelease::dupes()
{
QProcess proc;
- proc.start(binDir + "/lrelease testdata/dupes.ts");
+ proc.start(binDir + "/lrelease testdata/dupes.ts", QIODevice::ReadWrite | QIODevice::Text);
QVERIFY(proc.waitForFinished());
QVERIFY(proc.exitStatus() == QProcess::NormalExit);
- doCompare(QString(proc.readAllStandardError()).trimmed().remove('\r').split('\n'), "testdata/dupes.errors");
+ doCompare(QString(proc.readAllStandardError()).trimmed().split('\n'), "testdata/dupes.errors");
}
QTEST_MAIN(tst_lrelease)
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp
index 53eba32fb6..5bd7a0a1f5 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp
@@ -63,5 +63,20 @@ void FindDialog::reset()
{
tr("%n item(s)", "merge from singular to plural form", 4);
tr("%n item(s)", "merge from a finished singular form to an unfinished plural form", 4);
-}
+
+
+ //% "Hello"
+ qtTrId("xx_hello");
+
+ //% "New world"
+ qtTrId("xx_world");
+
+
+ //= new_id
+ tr("this is just some text");
+
+
+ //: A message without source string
+ qtTrId("qtn_virtual");
+}
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before
index d06252cec2..379cce465c 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before
@@ -1,6 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="1.1" language="zh_CN">
<context>
+ <name></name>
+ <message id="xx_hello">
+ <location filename="finddialog.cpp" line="70"/>
+ <source>Hello</source>
+ <translation>Hallo</translation>
+ </message>
+ <message id="xx_world">
+ <location filename="finddialog.cpp" line="73"/>
+ <source>World</source>
+ <translation>Welt</translation>
+ </message>
+ <message id="qtn_virtual">
+ <location filename="finddialog.cpp" line="79"/>
+ <extracomment>A message without source string</extracomment>
+ </message>
+</context>
+<context>
<name>FindDialog</name>
<message>
<source></source>
@@ -44,5 +61,10 @@
<numerusform></numerusform>
</translation>
</message>
+ <message>
+ <location filename="finddialog.cpp" line="59"/>
+ <source>this is just some text</source>
+ <translation type="unfinished">Unfertige Uebersetzung</translation>
+ </message>
</context>
</TS>
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result
index be4e02ee9d..de43266d29 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result
@@ -2,6 +2,26 @@
<!DOCTYPE TS>
<TS version="2.0" language="zh_CN">
<context>
+ <name></name>
+ <message id="xx_hello">
+ <location filename="finddialog.cpp" line="70"/>
+ <source>Hello</source>
+ <translation>Hallo</translation>
+ </message>
+ <message id="xx_world">
+ <location filename="finddialog.cpp" line="73"/>
+ <source>New world</source>
+ <oldsource>World</oldsource>
+ <translation type="unfinished">Welt</translation>
+ </message>
+ <message id="qtn_virtual">
+ <location filename="finddialog.cpp" line="81"/>
+ <source></source>
+ <extracomment>A message without source string</extracomment>
+ <translation></translation>
+ </message>
+</context>
+<context>
<name>FindDialog</name>
<message>
<source></source>
@@ -45,5 +65,10 @@
<numerusform></numerusform>
</translation>
</message>
+ <message id="new_id">
+ <location filename="finddialog.cpp" line="77"/>
+ <source>this is just some text</source>
+ <translation type="unfinished">Unfertige Uebersetzung</translation>
+ </message>
</context>
</TS>
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp
index e1464a2d65..9abb367ec7 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp
@@ -148,4 +148,7 @@ void FindDialog::doFind(bool forward)
bool FindDialog::hasFindExpression() const
{
// statusMessage(tr( "Should be obsolete" ));
+
+ //% "This is some random text"
+ qtTrId("keep_id")
}
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before
index 834f5121eb..feab1694d9 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before
@@ -1,6 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="1.1">
<context>
+ <name></name>
+ <message id="keep_id">
+ <location filename="finddialog.cpp" line="153"/>
+ <source>This is some random text</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="obsolete_id">
+ <location filename="finddialog.cpp" line="155"/>
+ <source>Should be obsolete, too</source>
+ <translation type="unfinished">SHOULD BE OBSOLETE AS WELL</translation>
+ </message>
+</context>
+<context>
<name>FindDialog</name>
<message>
<location filename="finddialog.cpp" line="85"/>
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result
index b328e90482..ee3d0f69bb 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result
@@ -2,6 +2,14 @@
<!DOCTYPE TS>
<TS version="2.0">
<context>
+ <name></name>
+ <message id="keep_id">
+ <location filename="finddialog.cpp" line="153"/>
+ <source>This is some random text</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
<name>FindDialog</name>
<message>
<location filename="finddialog.cpp" line="85"/>
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp
index 7b28c75e19..cc3af488e9 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp
@@ -150,6 +150,9 @@ void FindDialog::doFind(bool forward)
bool FindDialog::hasFindExpression() const
{
+ //% "This is some random text"
+ qtTrId("keep_id")
+
return !findExpr.isEmpty();
}
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before
index 1fa0fd35fc..2bc60491c4 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before
@@ -1,6 +1,19 @@
<?xml version="1.0"?>
<!DOCTYPE TS><TS version="1.1">
<context>
+ <name></name>
+ <message id="keep_id">
+ <location filename="finddialog.cpp" line="154"/>
+ <source>This is some random text</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="obsolete_id">
+ <location filename="finddialog.cpp" line="155"/>
+ <source>Should be obsolete, too</source>
+ <translation type="unfinished">SHOULD BE OBSOLETE AS WELL</translation>
+ </message>
+</context>
+<context>
<name>FindDialog</name>
<message>
<location filename="finddialog.cpp" line="85"/>
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result
index cfd11b1806..f442cbcc99 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result
@@ -2,6 +2,18 @@
<!DOCTYPE TS>
<TS version="2.0">
<context>
+ <name></name>
+ <message id="keep_id">
+ <location filename="finddialog.cpp" line="154"/>
+ <source>This is some random text</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="obsolete_id">
+ <source>Should be obsolete, too</source>
+ <translation type="obsolete">SHOULD BE OBSOLETE AS WELL</translation>
+ </message>
+</context>
+<context>
<name>FindDialog</name>
<message>
<source>Enter the text you are looking for.</source>
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
index 8201add7ff..386d9b7194 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
@@ -228,3 +228,27 @@ QT_TRID_NOOP("this_a_id")
//~ some thing
//% "This needs to be here. Really."
QString test = qtTrId("this_another_id", n);
+
+
+
+class YetAnotherTest : QObject {
+ Q_OBJECT
+
+ int function(void)
+ {
+ //
+ //:
+ //=
+ //~
+ //#
+ //=============
+ //~~~~~~~~~~~~~
+ //:::::::::::::
+ tr("nothing");
+ }
+};
+
+
+
+//: This is a message without a source string
+QString test = qtTrId("yet_another_id");
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
index d63c7c336a..6d50c21c0d 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
@@ -18,6 +18,12 @@ backslashed \ stuff.</source>
</translation>
<extra-some>thing</extra-some>
</message>
+ <message id="yet_another_id">
+ <location filename="main.cpp" line="254"/>
+ <source></source>
+ <extracomment>This is a message without a source string</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>Dialog2</name>
@@ -278,6 +284,14 @@ backslashed \ stuff.</source>
</message>
</context>
<context>
+ <name>YetAnotherTest</name>
+ <message>
+ <location filename="main.cpp" line="247"/>
+ <source>nothing</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
<name>scope</name>
<message numerus="yes">
<location filename="main.cpp" line="187"/>
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp
index eaa271aea2..7ddb68fbb1 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp
@@ -63,3 +63,52 @@ line c++ comment } (with brace)
#define This is another // comment in } define \
something } comment
} // complain here
+
+
+
+// Nested class in same file
+class TopLevel {
+ Q_OBJECT
+
+ class Nested;
+};
+
+class TopLevel::Nested {
+ void foo();
+};
+
+TopLevel::Nested::foo()
+{
+ TopLevel::tr("TopLevel");
+}
+
+// Nested class in other file
+#include "main.h"
+
+class TopLevel2::Nested {
+ void foo();
+};
+
+TopLevel2::Nested::foo()
+{
+ TopLevel2::tr("TopLevel2");
+}
+
+
+
+namespace NameSpace {
+class ToBeUsed;
+}
+
+// using statement before class definition
+using NameSpace::ToBeUsed;
+
+class NameSpace::ToBeUsed {
+ Q_OBJECT
+ void caller();
+};
+
+void ToBeUsed::caller()
+{
+ tr("NameSpace::ToBeUsed");
+}
diff --git a/tests/auto/qstringbuilder1/stringbuilder.h b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.h
index 5ac9dbea82..54a76ab3aa 100644
--- a/tests/auto/qstringbuilder1/stringbuilder.h
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the test suite of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,17 +39,13 @@
**
****************************************************************************/
-#ifndef TST_QSTRINGBUILDER_H
-#define TST_QSTRINGBUILDER_H
+// IMPORTANT!!!! If you want to add testdata to this file,
+// always add it to the end in order to not change the linenumbers of translations!!!
-#include <qobject.h>
-
-class tst_QStringBuilder : public QObject
-{
+class TopLevel2 {
Q_OBJECT
-private slots:
- void scenario();
+ class Nested;
};
-#endif
+
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result
index 07a7469f10..6f48e27021 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result
@@ -1,4 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0">
+<context>
+ <name>NameSpace::ToBeUsed</name>
+ <message>
+ <location filename="main.cpp" line="113"/>
+ <source>NameSpace::ToBeUsed</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>TopLevel</name>
+ <message>
+ <location filename="main.cpp" line="82"/>
+ <source>TopLevel</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>TopLevel2</name>
+ <message>
+ <location filename="main.cpp" line="94"/>
+ <source>TopLevel2</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
</TS>
diff --git a/tests/auto/linguist/lupdate/testlupdate.cpp b/tests/auto/linguist/lupdate/testlupdate.cpp
index 8e57323eae..d43fbc4f82 100644
--- a/tests/auto/linguist/lupdate/testlupdate.cpp
+++ b/tests/auto/linguist/lupdate/testlupdate.cpp
@@ -98,9 +98,9 @@ bool TestLUpdate::runChild( bool showOutput, const QString &program, const QStri
connect(childProc, SIGNAL(finished(int)), this, SLOT(childReady(int)));
childProc->setProcessChannelMode(QProcess::MergedChannels);
if (argList.isEmpty()) {
- childProc->start( program );
+ childProc->start( program, QIODevice::ReadWrite | QIODevice::Text );
} else {
- childProc->start( program, argList );
+ childProc->start( program, argList, QIODevice::ReadWrite | QIODevice::Text );
}
bool ok;
diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp
index 230392cdb6..7140eded61 100644
--- a/tests/auto/linguist/lupdate/tst_lupdate.cpp
+++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp
@@ -80,8 +80,8 @@ private:
void tst_lupdate::doCompare(const QStringList &actual, const QString &expectedFn, bool err)
{
QFile file(expectedFn);
- QVERIFY(file.open(QIODevice::ReadOnly));
- QStringList expected = QString(file.readAll()).trimmed().remove('\r').split('\n');
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
+ QStringList expected = QString(file.readAll()).trimmed().split('\n');
int i = 0, ei = expected.size(), gi = actual.size();
for (; ; i++) {
@@ -141,8 +141,8 @@ void tst_lupdate::doCompare(const QStringList &actual, const QString &expectedFn
void tst_lupdate::doCompare(const QString &actualFn, const QString &expectedFn, bool err)
{
QFile afile(actualFn);
- QVERIFY(afile.open(QIODevice::ReadOnly));
- QStringList actual = QString(afile.readAll()).trimmed().remove('\r').split('\n');
+ QVERIFY(afile.open(QIODevice::ReadOnly | QIODevice::Text));
+ QStringList actual = QString(afile.readAll()).trimmed().split('\n');
doCompare(actual, expectedFn, err);
}
@@ -180,7 +180,7 @@ void tst_lupdate::good()
QString lupdatecmd;
QFile file(dir + "/lupdatecmd");
if (file.exists()) {
- QVERIFY(file.open(QIODevice::ReadOnly));
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
while (!file.atEnd()) {
QByteArray cmdstring = file.readLine().simplified();
if (cmdstring.startsWith('#'))
@@ -226,7 +226,7 @@ void tst_lupdate::output_ts()
QString lupdatecmd;
QFile file(dir + "/lupdatecmd");
if (file.exists()) {
- QVERIFY(file.open(QIODevice::ReadOnly));
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
while (!file.atEnd()) {
QByteArray cmdstring = file.readLine().simplified();
if (cmdstring.startsWith('#'))
diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp
index d58402b0e8..f13bcad89a 100644
--- a/tests/auto/networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/networkselftest/tst_networkselftest.cpp
@@ -80,6 +80,9 @@ private slots:
void httpProxyNtlmAuth();
void socks5Proxy();
void socks5ProxyAuth();
+
+ // ssl supported test
+ void supportsSsl();
};
class Chat
@@ -333,6 +336,11 @@ QHostAddress tst_NetworkSelfTest::serverIpAddress()
if (cachedIpAddress.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) {
// need resolving
QHostInfo resolved = QHostInfo::fromName(QtNetworkSettings::serverName());
+ if(resolved.error() != QHostInfo::NoError ||
+ !resolved.addresses().isEmpty()) {
+ qWarning("QHostInfo::fromName failed (%d).", resolved.error());
+ return QHostAddress(QHostAddress::Null);
+ }
cachedIpAddress = resolved.addresses().first();
}
return cachedIpAddress;
@@ -712,5 +720,14 @@ void tst_NetworkSelfTest::socks5ProxyAuth()
);
}
+void tst_NetworkSelfTest::supportsSsl()
+{
+#ifdef QT_NO_OPENSSL
+ QFAIL("SSL not compiled in");
+#else
+ QVERIFY(QSslSocket::supportsSsl());
+#endif
+}
+
QTEST_MAIN(tst_NetworkSelfTest)
#include "tst_networkselftest.moc"
diff --git a/tests/auto/q3filedialog/tst_q3filedialog.cpp b/tests/auto/q3filedialog/tst_q3filedialog.cpp
index 2585f60b71..e2686eb97d 100644
--- a/tests/auto/q3filedialog/tst_q3filedialog.cpp
+++ b/tests/auto/q3filedialog/tst_q3filedialog.cpp
@@ -59,7 +59,9 @@ public:
virtual ~tst_Q3FileDialog();
private slots:
+#ifndef QT_MAC_USE_COCOA
void getSetCheck();
+#endif
};
tst_Q3FileDialog::tst_Q3FileDialog()
@@ -70,6 +72,7 @@ tst_Q3FileDialog::~tst_Q3FileDialog()
{
}
+#ifndef QT_MAC_USE_COCOA
class Preview : public QLabel, public Q3FilePreview
{
public:
@@ -125,6 +128,7 @@ void tst_Q3FileDialog::getSetCheck()
obj1.setPreviewMode(Q3FileDialog::PreviewMode(Q3FileDialog::Info));
QCOMPARE(obj1.previewMode(), Q3FileDialog::PreviewMode(Q3FileDialog::Info));
}
+#endif
QTEST_MAIN(tst_Q3FileDialog)
#include "tst_q3filedialog.moc"
diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
index ecc0594e34..4b62302472 100644
--- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
+++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
@@ -152,10 +152,10 @@ void tst_Q3SqlCursor::createTestTables( QSqlDatabase db )
if ( tst_Databases::isSqlServer( db ) ) {
//workaround for SQL SERVER since he can store unicode only in nvarchar fields
QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode") + " (id int not null, "
- "t_varchar nvarchar(40) not null, t_char nchar(40) )" ));
+ "t_varchar nvarchar(80) not null, t_char nchar(80) )" ));
} else {
QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode") + " (id int not null, "
- "t_varchar varchar(40) not null," "t_char char(40))" ));
+ "t_varchar varchar(100) not null," "t_char char(100))" ));
}
if (tst_Databases::isMSAccess(db)) {
@@ -521,8 +521,7 @@ void tst_Q3SqlCursor::unicode()
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- static const unsigned short utf8arr[] = { 0xd792,0xd79c,0xd792,0xd79c,0xd799,0x20,0xd7a9,0xd799,0x00 };
- static const QString utf8str = QString::fromUcs2( utf8arr );
+ static const QString utf8str = QString::fromUtf8( "ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει." );
if ( !db.driver()->hasFeature( QSqlDriver::Unicode ) ) {
QSKIP( "DBMS not Unicode capable", SkipSingle );
}
diff --git a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
index bdc31af1c2..413419d2a1 100644
--- a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -865,15 +865,22 @@ void tst_QAbstractItemModel::testMoveSameParentDown_data()
QTest::addColumn<int>("startRow");
QTest::addColumn<int>("endRow");
QTest::addColumn<int>("destRow");
+ // We can't put the actual parent index for the move in here because m_model is not defined until init() is run.
+ QTest::addColumn<bool>("topLevel");
// Move from the start to the middle
- QTest::newRow("move01") << 0 << 2 << 8;
+ QTest::newRow("move01") << 0 << 2 << 8 << true;
// Move from the start to the end
- QTest::newRow("move02") << 0 << 2 << 10;
+ QTest::newRow("move02") << 0 << 2 << 10 << true;
// Move from the middle to the middle
- QTest::newRow("move03") << 3 << 5 << 8;
+ QTest::newRow("move03") << 3 << 5 << 8 << true;
// Move from the middle to the end
- QTest::newRow("move04") << 3 << 5 << 10;
+ QTest::newRow("move04") << 3 << 5 << 10 << true;
+
+ QTest::newRow("move05") << 0 << 2 << 8 << false;
+ QTest::newRow("move06") << 0 << 2 << 10 << false;
+ QTest::newRow("move07") << 3 << 5 << 8 << false;
+ QTest::newRow("move08") << 3 << 5 << 10 << false;
}
void tst_QAbstractItemModel::testMoveSameParentDown()
@@ -881,6 +888,9 @@ void tst_QAbstractItemModel::testMoveSameParentDown()
QFETCH( int, startRow);
QFETCH( int, endRow);
QFETCH( int, destRow);
+ QFETCH( bool, topLevel);
+
+ QModelIndex moveParent = topLevel ? QModelIndex() : m_model->index(5, 0);
QList<QPersistentModelIndex> persistentList;
QModelIndexList indexList;
@@ -913,33 +923,37 @@ void tst_QAbstractItemModel::testMoveSameParentDown()
ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
moveCommand->setNumCols(4);
+ if (!topLevel)
+ moveCommand->setAncestorRowNumbers(QList<int>() << 5);
moveCommand->setStartRow(startRow);
moveCommand->setEndRow(endRow);
moveCommand->setDestRow(destRow);
+ if (!topLevel)
+ moveCommand->setDestAncestors(QList<int>() << 5);
moveCommand->doCommand();
QVariantList beforeSignal = beforeSpy.takeAt(0);
QVariantList afterSignal = afterSpy.takeAt(0);
QCOMPARE(beforeSignal.size(), 5);
- QCOMPARE(beforeSignal.at(0).value<QModelIndex>(), QModelIndex());
+ QCOMPARE(beforeSignal.at(0).value<QModelIndex>(), moveParent);
QCOMPARE(beforeSignal.at(1).toInt(), startRow);
QCOMPARE(beforeSignal.at(2).toInt(), endRow);
- QCOMPARE(beforeSignal.at(3).value<QModelIndex>(), QModelIndex());
+ QCOMPARE(beforeSignal.at(3).value<QModelIndex>(), moveParent);
QCOMPARE(beforeSignal.at(4).toInt(), destRow);
QCOMPARE(afterSignal.size(), 5);
- QCOMPARE(afterSignal.at(0).value<QModelIndex>(), QModelIndex());
+ QCOMPARE(afterSignal.at(0).value<QModelIndex>(), moveParent);
QCOMPARE(afterSignal.at(1).toInt(), startRow);
QCOMPARE(afterSignal.at(2).toInt(), endRow);
- QCOMPARE(afterSignal.at(3).value<QModelIndex>(), QModelIndex());
+ QCOMPARE(afterSignal.at(3).value<QModelIndex>(), moveParent);
QCOMPARE(afterSignal.at(4).toInt(), destRow);
for (int i = 0; i < indexList.size(); i++)
{
QModelIndex idx = indexList.at(i);
QModelIndex persistentIndex = persistentList.at(i);
- if (idx.parent() == QModelIndex())
+ if (idx.parent() == moveParent)
{
int row = idx.row();
if ( row >= startRow)
@@ -976,15 +990,21 @@ void tst_QAbstractItemModel::testMoveSameParentUp_data()
QTest::addColumn<int>("startRow");
QTest::addColumn<int>("endRow");
QTest::addColumn<int>("destRow");
+ QTest::addColumn<bool>("topLevel");
// Move from the middle to the start
- QTest::newRow("move01") << 5 << 7 << 0;
+ QTest::newRow("move01") << 5 << 7 << 0 << true;
// Move from the end to the start
- QTest::newRow("move02") << 8 << 9 << 0;
+ QTest::newRow("move02") << 8 << 9 << 0 << true;
// Move from the middle to the middle
- QTest::newRow("move03") << 5 << 7 << 2;
+ QTest::newRow("move03") << 5 << 7 << 2 << true;
// Move from the end to the middle
- QTest::newRow("move04") << 8 << 9 << 5;
+ QTest::newRow("move04") << 8 << 9 << 5 << true;
+
+ QTest::newRow("move05") << 5 << 7 << 0 << false;
+ QTest::newRow("move06") << 8 << 9 << 0 << false;
+ QTest::newRow("move07") << 5 << 7 << 2 << false;
+ QTest::newRow("move08") << 8 << 9 << 5 << false;
}
void tst_QAbstractItemModel::testMoveSameParentUp()
@@ -993,6 +1013,9 @@ void tst_QAbstractItemModel::testMoveSameParentUp()
QFETCH( int, startRow);
QFETCH( int, endRow);
QFETCH( int, destRow);
+ QFETCH( bool, topLevel);
+
+ QModelIndex moveParent = topLevel ? QModelIndex() : m_model->index(5, 0);
QList<QPersistentModelIndex> persistentList;
QModelIndexList indexList;
@@ -1026,26 +1049,30 @@ void tst_QAbstractItemModel::testMoveSameParentUp()
ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
moveCommand->setNumCols(4);
+ if (!topLevel)
+ moveCommand->setAncestorRowNumbers(QList<int>() << 5);
moveCommand->setStartRow(startRow);
moveCommand->setEndRow(endRow);
moveCommand->setDestRow(destRow);
+ if (!topLevel)
+ moveCommand->setDestAncestors(QList<int>() << 5);
moveCommand->doCommand();
QVariantList beforeSignal = beforeSpy.takeAt(0);
QVariantList afterSignal = afterSpy.takeAt(0);
QCOMPARE(beforeSignal.size(), 5);
- QCOMPARE(beforeSignal.at(0).value<QModelIndex>(), QModelIndex());
+ QCOMPARE(beforeSignal.at(0).value<QModelIndex>(), moveParent);
QCOMPARE(beforeSignal.at(1).toInt(), startRow);
QCOMPARE(beforeSignal.at(2).toInt(), endRow);
- QCOMPARE(beforeSignal.at(3).value<QModelIndex>(), QModelIndex());
+ QCOMPARE(beforeSignal.at(3).value<QModelIndex>(), moveParent);
QCOMPARE(beforeSignal.at(4).toInt(), destRow);
QCOMPARE(afterSignal.size(), 5);
- QCOMPARE(afterSignal.at(0).value<QModelIndex>(), QModelIndex());
+ QCOMPARE(afterSignal.at(0).value<QModelIndex>(), moveParent);
QCOMPARE(afterSignal.at(1).toInt(), startRow);
QCOMPARE(afterSignal.at(2).toInt(), endRow);
- QCOMPARE(afterSignal.at(3).value<QModelIndex>(), QModelIndex());
+ QCOMPARE(afterSignal.at(3).value<QModelIndex>(), moveParent);
QCOMPARE(afterSignal.at(4).toInt(), destRow);
@@ -1053,7 +1080,7 @@ void tst_QAbstractItemModel::testMoveSameParentUp()
{
QModelIndex idx = indexList.at(i);
QModelIndex persistentIndex = persistentList.at(i);
- if (idx.parent() == QModelIndex())
+ if (idx.parent() == moveParent)
{
int row = idx.row();
if ( row >= destRow)
diff --git a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
index d6911d2d8e..db840f45fe 100644
--- a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
@@ -223,6 +223,7 @@ private slots:
void task257481_emptyEditor();
void shiftArrowSelectionAfterScrolling();
void shiftSelectionAfterRubberbandSelection();
+ void ctrlRubberbandSelection();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -1388,5 +1389,49 @@ void tst_QAbstractItemView::shiftSelectionAfterRubberbandSelection()
QVERIFY(selected.contains(index2));
}
+void tst_QAbstractItemView::ctrlRubberbandSelection()
+{
+ QStandardItemModel model;
+ for (int i=0; i<3; ++i) {
+ QStandardItem *item = new QStandardItem(QString("%1").arg(i));
+ model.setItem(i, 0, item);
+ }
+
+ QListView view;
+ view.setFixedSize(150, 450);
+ view.setFlow(QListView::LeftToRight);
+ view.setGridSize(QSize(100, 100));
+ view.setSelectionMode(QListView::ExtendedSelection);
+ view.setViewMode(QListView::IconMode);
+ view.setModel(&model);
+ view.show();
+ QTest::qWait(30);
+
+ QModelIndex index1 = model.index(1, 0);
+ QModelIndex index2 = model.index(2, 0);
+
+ // Select item 1
+ view.setCurrentIndex(index1);
+ QModelIndexList selected = view.selectionModel()->selectedIndexes();
+ QCOMPARE(selected.count(), 1);
+ QVERIFY(selected.contains(index1));
+
+ // Now press control and draw a rubberband around items 1 and 2.
+ // The mouse move event has to be created manually because the QTest framework does not
+ // contain a function for mouse moves with buttons pressed.
+ QPoint pressPos = view.visualRect(index1).topLeft() - QPoint(1, 1);
+ QPoint releasePos = view.visualRect(index2).bottomRight() + QPoint(1, 1);
+ QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, pressPos);
+ QMouseEvent moveEvent(QEvent::MouseMove, releasePos, Qt::NoButton, Qt::LeftButton, Qt::ControlModifier);
+ bool moveEventReceived = qApp->notify(view.viewport(), &moveEvent);
+ QVERIFY(moveEventReceived);
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, releasePos);
+
+ // Verify that item 2 is selected now
+ selected = view.selectionModel()->selectedIndexes();
+ QCOMPARE(selected.count(), 1);
+ QVERIFY(selected.contains(index2));
+}
+
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"
diff --git a/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp
index 5033a50068..99a263be1e 100644
--- a/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp
+++ b/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp
@@ -71,6 +71,8 @@ private slots:
void viewportCrash();
void task214488_layoutDirection_data();
void task214488_layoutDirection();
+ void wheelEvent_data();
+ void wheelEvent();
};
tst_QAbstractScrollArea::tst_QAbstractScrollArea()
@@ -296,10 +298,10 @@ public:
setAttribute(Qt::WA_DropSiteRegistered, true);
- startTimer(2000);
+ startTimer(200);
}
- void timerEvent(QTimerEvent *event)
+ void timerEvent(QTimerEvent *)
{
// should not crash.
(void)new QScrollArea(this);
@@ -385,5 +387,96 @@ void tst_QAbstractScrollArea::patternBackground()
QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::red).rgb());
}
+Q_DECLARE_METATYPE(QWheelEvent *);
+
+void tst_QAbstractScrollArea::wheelEvent_data()
+{
+ QTest::addColumn<QSize>("widgetSize");
+ QTest::addColumn<QPoint>("initialOffset");
+ QTest::addColumn<QWheelEvent *>("event");
+ QTest::addColumn<int>("movedX"); // -1 , 0 , or 1
+ QTest::addColumn<int>("movedY");
+
+ QPoint pos(100,100);
+ int delta =-120;
+
+ QTest::newRow("1") << QSize(600,600) << QPoint(50,50)
+ << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 1 << 0;
+
+ QTest::newRow("2") << QSize(600,600) << QPoint(50,50)
+ << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 0 << 1;
+
+ QTest::newRow("3") << QSize(600,600) << QPoint(50,50)
+ << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << -1 << 0;
+
+ QTest::newRow("4") << QSize(600,600) << QPoint(50,50)
+ << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << 0 << -1;
+
+ QTest::newRow("5") << QSize(20,600) << QPoint(0,50)
+ << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 0 << 1;
+
+ QTest::newRow("6") << QSize(20,600) << QPoint(0,50)
+ << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 0 << 1;
+
+ QTest::newRow("7") << QSize(20,600) << QPoint(0,50)
+ << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << 0 << -1;
+
+ QTest::newRow("8") << QSize(20,600) << QPoint(0,50)
+ << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << 0 << -1;
+
+ QTest::newRow("9") << QSize(600,20) << QPoint(50,0)
+ << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 1 << 0;
+
+ QTest::newRow("a") << QSize(600,20) << QPoint(50,0)
+ << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 1 << 0;
+
+ QTest::newRow("b") << QSize(600,20) << QPoint(50,0)
+ << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << -1 << 0;
+
+ QTest::newRow("c") << QSize(600,20) << QPoint(50,0)
+ << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << -1 << 0;
+}
+
+
+
+
+void tst_QAbstractScrollArea::wheelEvent()
+{
+ QFETCH(QSize, widgetSize);
+ QFETCH(QPoint, initialOffset);
+ QFETCH(QWheelEvent *, event);
+ QFETCH(int, movedX);
+ QFETCH(int, movedY);
+
+ QScrollArea scrollArea;
+ scrollArea.resize(200, 200);
+ QLabel widget("H e l l o");
+ widget.resize(widgetSize);
+ scrollArea.setWidget(&widget);
+ scrollArea.show();
+ QTest::qWait(20);
+
+ scrollArea.verticalScrollBar()->setValue(initialOffset.y());
+ scrollArea.horizontalScrollBar()->setValue(initialOffset.x());
+
+ QCOMPARE(scrollArea.verticalScrollBar()->value(), initialOffset.y());
+ QCOMPARE(scrollArea.horizontalScrollBar()->value(), initialOffset.x());
+
+ QApplication::sendEvent(scrollArea.viewport(), event);
+
+ if(movedX == 0)
+ QCOMPARE(scrollArea.horizontalScrollBar()->value(), initialOffset.x());
+ else
+ QVERIFY(movedX * scrollArea.horizontalScrollBar()->value() > movedX * initialOffset.x());
+
+ if(movedY == 0)
+ QCOMPARE(scrollArea.verticalScrollBar()->value(), initialOffset.y());
+ else
+ QVERIFY(movedY * scrollArea.verticalScrollBar()->value() > movedY * initialOffset.y());
+
+ delete event;
+}
+
+
QTEST_MAIN(tst_QAbstractScrollArea)
#include "tst_qabstractscrollarea.moc"
diff --git a/tests/auto/qabstractslider/tst_qabstractslider.cpp b/tests/auto/qabstractslider/tst_qabstractslider.cpp
index 5c70bded8b..ee1ba19df4 100644
--- a/tests/auto/qabstractslider/tst_qabstractslider.cpp
+++ b/tests/auto/qabstractslider/tst_qabstractslider.cpp
@@ -714,11 +714,7 @@ void tst_QAbstractSlider::wheelEvent_data()
<< 1 // delta
<< int(Qt::Vertical) // orientation of slider
<< int(Qt::Vertical) // orientation of wheel
-#ifdef Q_WS_MAC
- << 1 // expected position after
-#else
<< 20 // expected position after
-#endif
<< QPoint(0,0);
QTest::newRow("Normal data page") << 0 // initial position
@@ -746,11 +742,9 @@ void tst_QAbstractSlider::wheelEvent_data()
<< 1 // delta
<< int(Qt::Horizontal) // orientation of slider
<< int(Qt::Vertical) // orientation of wheel
- << 0 // expected position after
+ << 1 // expected position after
<< QPoint(1,1);
- // Scrolling in a slider of a different orientation than the wheel works
- // if the mouse pointer is within the widget's rect
QTest::newRow("Different orientation2")<< 0 // initial position
<< 0 // minimum
<< 100 // maximum
@@ -777,11 +771,7 @@ void tst_QAbstractSlider::wheelEvent_data()
<< 1 // delta
<< int(Qt::Horizontal) // orientation of slider
<< int(Qt::Horizontal) // orientation of wheel
-#ifdef Q_WS_MAC
- << 49 // expected position after
-#else
<< 30 // expected position after
-#endif
<< QPoint(1,1);
QTest::newRow("Past end") << 50 // initial position
@@ -792,11 +782,7 @@ void tst_QAbstractSlider::wheelEvent_data()
<< false // inverted controls
<< 1 // wheel scroll lines
<< false // with modifiers
-#ifdef Q_WS_MAC
- << 60 // delta
-#else
<< 2 // delta
-#endif
<< int(Qt::Horizontal) // orientation of slider
<< int(Qt::Horizontal) // orientation of wheel
<< 100 // expected position after
@@ -810,11 +796,7 @@ void tst_QAbstractSlider::wheelEvent_data()
<< false // inverted controls
<< 1 // wheel scroll lines
<< false // with modifiers
-#ifdef Q_WS_MAC
- << -60 // delta
-#else
<< -2 // delta
-#endif
<< int(Qt::Horizontal) // orientation of slider
<< int(Qt::Horizontal) // orientation of wheel
<< 0 // expected position after
diff --git a/tests/auto/qabstractvideosurface/tst_qabstractvideosurface.cpp b/tests/auto/qabstractvideosurface/tst_qabstractvideosurface.cpp
index 20ca759b05..b4d2ac8342 100644
--- a/tests/auto/qabstractvideosurface/tst_qabstractvideosurface.cpp
+++ b/tests/auto/qabstractvideosurface/tst_qabstractvideosurface.cpp
@@ -61,6 +61,8 @@ private slots:
void setError();
void isFormatSupported_data();
void isFormatSupported();
+ void nearestFormat_data();
+ void nearestFormat();
void start_data();
void start();
};
@@ -232,6 +234,22 @@ void tst_QAbstractVideoSurface::isFormatSupported()
QCOMPARE(surface.isFormatSupported(format), supported);
}
+void tst_QAbstractVideoSurface::nearestFormat_data()
+{
+ isFormatSupported_data();
+}
+
+void tst_QAbstractVideoSurface::nearestFormat()
+{
+ QFETCH(SupportedFormatMap, supportedFormats);
+ QFETCH(QVideoSurfaceFormat, format);
+ QFETCH(bool, supported);
+
+ QtTestVideoSurface surface(supportedFormats);
+
+ QCOMPARE(surface.nearestFormat(format) == format, supported);
+}
+
void tst_QAbstractVideoSurface::start_data()
{
QTest::addColumn<QVideoSurfaceFormat>("format");
@@ -256,35 +274,35 @@ void tst_QAbstractVideoSurface::start()
surface.setError(QAbstractVideoSurface::ResourceError);
QSignalSpy formatSpy(&surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)));
- QSignalSpy startedSpy(&surface, SIGNAL(startedChanged(bool)));
+ QSignalSpy activeSpy(&surface, SIGNAL(activeChanged(bool)));
- QVERIFY(!surface.isStarted());
+ QVERIFY(!surface.isActive());
QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat());
QVERIFY(surface.start(format));
- QVERIFY(surface.isStarted());
+ QVERIFY(surface.isActive());
QCOMPARE(surface.surfaceFormat(), format);
QCOMPARE(formatSpy.count(), 1);
- QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.at(0).at(0)), format);
+ QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), format);
- QCOMPARE(startedSpy.count(), 1);
- QCOMPARE(startedSpy.at(0).at(0).toBool(), true);
+ QCOMPARE(activeSpy.count(), 1);
+ QCOMPARE(activeSpy.last().at(0).toBool(), true);
// error() is reset on a successful start.
QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
surface.stop();
- QVERIFY(!surface.isStarted());
+ QVERIFY(!surface.isActive());
QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat());
QCOMPARE(formatSpy.count(), 2);
- QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.at(1).at(0)), QVideoSurfaceFormat());
+ QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), QVideoSurfaceFormat());
- QCOMPARE(startedSpy.count(), 2);
- QCOMPARE(startedSpy.at(1).at(0).toBool(), false);
+ QCOMPARE(activeSpy.count(), 2);
+ QCOMPARE(activeSpy.last().at(0).toBool(), false);
}
QTEST_MAIN(tst_QAbstractVideoSurface)
diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp
index 9f2e4e7afb..25c2649e43 100644
--- a/tests/auto/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp
@@ -4034,6 +4034,27 @@ void tst_QAccessibility::labelTest()
delete acc_label;
delete label;
QTestAccessibility::clearEvents();
+
+ QPixmap testPixmap(50, 50);
+ testPixmap.fill();
+
+ QLabel imageLabel;
+ imageLabel.setPixmap(testPixmap);
+ imageLabel.setToolTip("Test Description");
+
+ acc_label = QAccessible::queryAccessibleInterface(&imageLabel);
+ QVERIFY(acc_label);
+
+ QAccessibleImageInterface *imageInterface = acc_label->imageInterface();
+ QVERIFY(imageInterface);
+
+ QCOMPARE(imageInterface->imageSize(), testPixmap.size());
+ QCOMPARE(imageInterface->imageDescription(), QString::fromLatin1("Test Description"));
+ QCOMPARE(imageInterface->imagePosition(QAccessible2::RelativeToParent), imageLabel.geometry());
+
+ delete acc_label;
+
+ QTestAccessibility::clearEvents();
#else
QSKIP("Test needs accessibility support.", SkipAll);
#endif
diff --git a/tests/auto/qactiongroup/tst_qactiongroup.cpp b/tests/auto/qactiongroup/tst_qactiongroup.cpp
index 2d215a0a7d..7259479e4c 100644
--- a/tests/auto/qactiongroup/tst_qactiongroup.cpp
+++ b/tests/auto/qactiongroup/tst_qactiongroup.cpp
@@ -70,6 +70,7 @@ private slots:
void separators();
void testActionInTwoQActionGroup();
+ void unCheckCurrentAction();
};
tst_QActionGroup::tst_QActionGroup()
@@ -278,5 +279,25 @@ void tst_QActionGroup::testActionInTwoQActionGroup()
QCOMPARE(group1.actions().isEmpty(), true);
}
+void tst_QActionGroup::unCheckCurrentAction()
+{
+ QActionGroup group(0);
+ QAction action1(&group) ,action2(&group);
+ action1.setCheckable(true);
+ action2.setCheckable(true);
+ QVERIFY(!action1.isChecked());
+ QVERIFY(!action2.isChecked());
+ action1.setChecked(true);
+ QVERIFY(action1.isChecked());
+ QVERIFY(!action2.isChecked());
+ QAction *current = group.checkedAction();
+ QCOMPARE(current, &action1);
+ current->setChecked(false);
+ QVERIFY(!action1.isChecked());
+ QVERIFY(!action2.isChecked());
+ QVERIFY(group.checkedAction() == 0);
+}
+
+
QTEST_MAIN(tst_QActionGroup)
#include "tst_qactiongroup.moc"
diff --git a/tests/auto/qalgorithms/tst_qalgorithms.cpp b/tests/auto/qalgorithms/tst_qalgorithms.cpp
index 1f1de82e57..176a451814 100644
--- a/tests/auto/qalgorithms/tst_qalgorithms.cpp
+++ b/tests/auto/qalgorithms/tst_qalgorithms.cpp
@@ -602,9 +602,15 @@ void tst_QAlgorithms::test_qUpperBound()
void tst_QAlgorithms::test_qBinaryFind_data()
{
QTest::addColumn<QList<int> >("data");
- QTest::addColumn<int>("resultValue");
+ QTest::addColumn<int>("resultValue"); // -42 means not found
QTest::newRow("sorted-duplicate") << (QList<int>() << 1 << 2 << 2 << 3) << 2;
+ QTest::newRow("sorted-end") << (QList<int>() << -5 << -2 << 0 << 8) << 8;
+ QTest::newRow("sorted-beginning") << (QList<int>() << -5 << -2 << 0 << 8) << -5;
+ QTest::newRow("sorted-duplicate-beginning") << (QList<int>() << -5 << -5 << -2 << 0 << 8) << -5;
+ QTest::newRow("empty") << (QList<int>()) << -42;
+ QTest::newRow("not found 1 ") << (QList<int>() << 1 << 5 << 8 << 65) << -42;
+ QTest::newRow("not found 2 ") << (QList<int>() << -456 << -5 << 8 << 65) << -42;
}
void tst_QAlgorithms::test_qBinaryFind()
@@ -612,6 +618,15 @@ void tst_QAlgorithms::test_qBinaryFind()
QFETCH(QList<int>, data);
QFETCH(int, resultValue);
+ //-42 means not found
+ if (resultValue == -42) {
+ QVERIFY(qBinaryFind(data.constBegin(), data.constEnd(), resultValue) == data.end());
+ QVERIFY(qBinaryFind(data, resultValue) == data.end());
+ QVERIFY(qBinaryFind(data.begin(), data.end(), resultValue) == data.end());
+ QVERIFY(qBinaryFind(data.begin(), data.end(), resultValue, qLess<int>()) == data.end());
+ return;
+ }
+
QCOMPARE(*qBinaryFind(data.constBegin(), data.constEnd(), resultValue), resultValue);
QCOMPARE(*qBinaryFind(data.begin(), data.end(), resultValue), resultValue);
QCOMPARE(*qBinaryFind(data, resultValue), resultValue);
diff --git a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp
index 81c51eddde..b4e4a491fd 100644
--- a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp
+++ b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp
@@ -165,9 +165,9 @@ void tst_QAnimationGroup::emptyGroup()
QCOMPARE(groupStateChangedSpy.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
@@ -180,9 +180,9 @@ void tst_QAnimationGroup::emptyGroup()
group.start();
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(2).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(3).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(3).first()),
QAnimationGroup::Stopped);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
@@ -259,54 +259,54 @@ void tst_QAnimationGroup::setCurrentTime()
QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped);
QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped);
- QCOMPARE(group.currentTime(), 1);
- QCOMPARE(sequence->currentTime(), 1);
- QCOMPARE(a1_s_o1->currentTime(), 1);
- QCOMPARE(a2_s_o1->currentTime(), 0);
- QCOMPARE(a3_s_o1->currentTime(), 0);
- QCOMPARE(a1_s_o2->currentTime(), 1);
- QCOMPARE(a1_s_o3->currentTime(), 0);
- QCOMPARE(a1_p_o1->currentTime(), 1);
- QCOMPARE(a1_p_o2->currentTime(), 1);
- QCOMPARE(a1_p_o3->currentTime(), 1);
- QCOMPARE(notTimeDriven->currentTime(), 1);
- QCOMPARE(loopsForever->currentTime(), 1);
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 1);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 1);
+ QCOMPARE(loopsForever->currentLoopTime(), 1);
// Current time = 250
group.setCurrentTime(250);
- QCOMPARE(group.currentTime(), 250);
- QCOMPARE(sequence->currentTime(), 250);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 0);
- QCOMPARE(a3_s_o1->currentTime(), 0);
- QCOMPARE(a1_s_o2->currentTime(), 250);
- QCOMPARE(a1_s_o3->currentTime(), 0);
- QCOMPARE(a1_p_o1->currentTime(), 250);
- QCOMPARE(a1_p_o2->currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(sequence->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 0);
QCOMPARE(a1_p_o2->currentLoop(), 1);
- QCOMPARE(a1_p_o3->currentTime(), 250);
- QCOMPARE(notTimeDriven->currentTime(), 250);
- QCOMPARE(loopsForever->currentTime(), 0);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 250);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
QCOMPARE(loopsForever->currentLoop(), 1);
QCOMPARE(sequence->currentAnimation(), a2_s_o1);
// Current time = 251
group.setCurrentTime(251);
- QCOMPARE(group.currentTime(), 251);
- QCOMPARE(sequence->currentTime(), 251);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 1);
+ QCOMPARE(group.currentLoopTime(), 251);
+ QCOMPARE(sequence->currentLoopTime(), 251);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 1);
QCOMPARE(a2_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentTime(), 0);
- QCOMPARE(sequence2->currentTime(), 251);
- QCOMPARE(a1_s_o2->currentTime(), 250);
- QCOMPARE(a1_s_o3->currentTime(), 1);
- QCOMPARE(a1_p_o1->currentTime(), 250);
- QCOMPARE(a1_p_o2->currentTime(), 1);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 251);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 1);
QCOMPARE(a1_p_o2->currentLoop(), 1);
- QCOMPARE(a1_p_o3->currentTime(), 250);
- QCOMPARE(notTimeDriven->currentTime(), 251);
- QCOMPARE(loopsForever->currentTime(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 251);
+ QCOMPARE(loopsForever->currentLoopTime(), 1);
QCOMPARE(sequence->currentAnimation(), a2_s_o1);
}
@@ -356,7 +356,7 @@ void tst_QAnimationGroup::addChildTwice()
parent->addAnimation(subGroup);
QCOMPARE(parent->animationCount(), 1);
- parent->clearAnimations();
+ parent->clear();
QCOMPARE(parent->animationCount(), 0);
diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp
index 97aa0924d0..58888669a5 100644
--- a/tests/auto/qapplication/tst_qapplication.cpp
+++ b/tests/auto/qapplication/tst_qapplication.cpp
@@ -129,6 +129,7 @@ private slots:
void style();
void allWidgets();
+ void topLevelWidgets();
void setAttribute();
@@ -136,6 +137,9 @@ private slots:
void windowsCommandLine();
void touchEventPropagation();
+
+ void symbianNeedForTraps();
+ void symbianLeaveThroughMain();
};
class EventSpy : public QObject
@@ -1792,6 +1796,27 @@ void tst_QApplication::allWidgets()
QVERIFY(!app.allWidgets().contains(w)); // removal test
}
+void tst_QApplication::topLevelWidgets()
+{
+ int argc = 1;
+ QApplication app(argc, &argv0, QApplication::GuiServer);
+ QWidget *w = new QWidget;
+ w->show();
+#ifndef QT_NO_CLIPBOARD
+ QClipboard *clipboard = QApplication::clipboard();
+ QString originalText = clipboard->text();
+ clipboard->setText(QString("newText"));
+#endif
+ app.processEvents();
+ QVERIFY(QApplication::topLevelWidgets().contains(w));
+ QCOMPARE(QApplication::topLevelWidgets().count(), 1);
+ delete w;
+ w = 0;
+ app.processEvents();
+ QCOMPARE(QApplication::topLevelWidgets().count(), 0);
+}
+
+
void tst_QApplication::setAttribute()
{
@@ -2011,6 +2036,66 @@ void tst_QApplication::touchEventPropagation()
}
}
+#ifdef Q_OS_SYMBIAN
+class CBaseDummy : public CBase
+{
+public:
+ CBaseDummy(int *numDestroyed) : numDestroyed(numDestroyed)
+ {
+ }
+ ~CBaseDummy()
+ {
+ (*numDestroyed)++;
+ }
+
+private:
+ int *numDestroyed;
+};
+
+static void fakeMain(int *numDestroyed)
+{
+ // Push a few objects, just so that the cleanup stack has something to clean up.
+ CleanupStack::PushL(new (ELeave) CBaseDummy(numDestroyed));
+ int argc = 0;
+ QApplication app(argc, 0);
+ CleanupStack::PushL(new (ELeave) CBaseDummy(numDestroyed));
+
+ User::Leave(KErrGeneral); // Fake error
+}
+#endif
+
+void tst_QApplication::symbianNeedForTraps()
+{
+#ifndef Q_OS_SYMBIAN
+ QSKIP("This is a Symbian-only test", SkipAll);
+#else
+ int argc = 0;
+ QApplication app(argc, 0);
+ int numDestroyed = 0;
+
+ // This next part should not require a trap. If it does, the test will crash.
+ CleanupStack::PushL(new (ELeave) CBaseDummy(&numDestroyed));
+ CleanupStack::PopAndDestroy();
+
+ QCOMPARE(numDestroyed, 1);
+
+ // No other failure condition. The program will crash if it does not pass.
+#endif
+}
+
+void tst_QApplication::symbianLeaveThroughMain()
+{
+#ifndef Q_OS_SYMBIAN
+ QSKIP("This is a Symbian-only test", SkipAll);
+#else
+ int numDestroyed = 0;
+ TInt err;
+ TRAP(err, fakeMain(&numDestroyed));
+
+ QCOMPARE(numDestroyed, 2);
+#endif
+}
+
//QTEST_APPLESS_MAIN(tst_QApplication)
int main(int argc, char *argv[])
{
diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
index 7b9a422314..715f21936d 100644
--- a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
+++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
@@ -77,7 +77,7 @@ private:
void tst_QAudioDeviceInfo::initTestCase()
{
// Only perform tests if audio output device exists!
- QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput);
+ QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
if(devices.size() > 0)
available = true;
else {
@@ -90,7 +90,7 @@ void tst_QAudioDeviceInfo::checkAvailableDefaultInput()
{
// Only perform tests if audio input device exists!
bool storeAvailable = available;
- QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput);
+ QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
if(devices.size() > 0)
available = true;
else {
@@ -111,7 +111,7 @@ void tst_QAudioDeviceInfo::checkAvailableDefaultOutput()
void tst_QAudioDeviceInfo::outputList()
{
if(available) {
- QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput);
+ QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
QVERIFY(devices.size() > 0);
device = new QAudioDeviceInfo(devices.at(0));
}
diff --git a/tests/auto/qaudioformat/tst_qaudioformat.cpp b/tests/auto/qaudioformat/tst_qaudioformat.cpp
index 286e63fbde..0778a8e4a3 100644
--- a/tests/auto/qaudioformat/tst_qaudioformat.cpp
+++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp
@@ -69,17 +69,20 @@ private slots:
void tst_QAudioFormat::checkNull()
{
- // Default constructed QAudioFormat is null.
+ // Default constructed QAudioFormat is invalid.
QAudioFormat audioFormat0;
- QVERIFY(audioFormat0.isNull());
+ QVERIFY(!audioFormat0.isValid());
- // Null is transferred
+ // validity is transferred
QAudioFormat audioFormat1(audioFormat0);
- QVERIFY(audioFormat1.isNull());
+ QVERIFY(!audioFormat1.isValid());
- // Null is voided on activity
audioFormat0.setFrequency(44100);
- QVERIFY(!audioFormat0.isNull());
+ audioFormat0.setChannels(2);
+ audioFormat0.setSampleSize(16);
+ audioFormat0.setCodec("audio/pcm");
+ audioFormat0.setSampleType(QAudioFormat::SignedInt);
+ QVERIFY(audioFormat0.isValid());
}
void tst_QAudioFormat::checkFrequency()
diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp
index 3945364c75..744ce38cbe 100644
--- a/tests/auto/qaudioinput/tst_qaudioinput.cpp
+++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp
@@ -76,7 +76,7 @@ void tst_QAudioInput::initTestCase()
format.setSampleType(QAudioFormat::UnSignedInt);
// Only perform tests if audio input device exists!
- QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput);
+ QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
if(devices.size() > 0)
available = true;
else {
@@ -137,16 +137,16 @@ void tst_QAudioInput::pullFile()
QSignalSpy stateSignal(audio, SIGNAL(stateChanged(QAudio::State)));
// Always have default states, before start
- QVERIFY(audio->state() == QAudio::StopState);
+ QVERIFY(audio->state() == QAudio::StoppedState);
QVERIFY(audio->error() == QAudio::NoError);
- QVERIFY(audio->clock() == 0);
+ QVERIFY(audio->elapsedUSecs() == 0);
audio->start(&filename);
QTest::qWait(20);
// Check state and periodSize() are valid non-zero values.
QVERIFY(audio->state() == QAudio::ActiveState);
QVERIFY(audio->error() == QAudio::NoError);
- QVERIFY(audio->clock() > 0);
+ QVERIFY(audio->elapsedUSecs() > 10000 && audio->elapsedUSecs() < 800000);
QVERIFY(audio->periodSize() > 0);
QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState
@@ -154,12 +154,12 @@ void tst_QAudioInput::pullFile()
QTest::qWait(5000);
QVERIFY(readSignal.count() > 0);
- QVERIFY(audio->totalTime() > 0);
+ QVERIFY(audio->processedUSecs() > 0);
audio->stop();
QTest::qWait(20);
- QVERIFY(audio->state() == QAudio::StopState);
- QVERIFY(audio->clock() == 0);
+ QVERIFY(audio->state() == QAudio::StoppedState);
+ QVERIFY(audio->elapsedUSecs() == 0);
// Can only check to make sure we got at least 1 more signal, but can be more.
QVERIFY(stateSignal.count() > 1);
diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
index b46f88ddb2..26694cc3e0 100644
--- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
+++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
@@ -79,7 +79,7 @@ void tst_QAudioOutput::initTestCase()
format.setSampleType(QAudioFormat::UnSignedInt);
// Only perform tests if audio output device exists!
- QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput);
+ QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
if(devices.size() > 0)
available = true;
else {
@@ -140,9 +140,9 @@ void tst_QAudioOutput::pullFile()
audio->setNotifyInterval(100);
// Always have default states, before start
- QVERIFY(audio->state() == QAudio::StopState);
+ QVERIFY(audio->state() == QAudio::StoppedState);
QVERIFY(audio->error() == QAudio::NoError);
- QVERIFY(audio->clock() == 0);
+ QVERIFY(audio->elapsedUSecs() == 0);
audio->start(&file);
QTest::qWait(20); // wait 20ms
@@ -150,12 +150,12 @@ void tst_QAudioOutput::pullFile()
QVERIFY(audio->state() == QAudio::ActiveState);
QVERIFY(audio->error() == QAudio::NoError);
QVERIFY(audio->periodSize() > 0);
- QVERIFY(audio->clock() > 0);
+ QVERIFY(audio->elapsedUSecs() > 10000 && audio->elapsedUSecs() < 800000);
QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState
// Wait until finished...
QTestEventLoop::instance().enterLoop(1);
- QCOMPARE(audio->totalTime(), qint64(692250));
+ QCOMPARE(audio->processedUSecs(), qint64(692250));
#ifdef Q_OS_WINCE
// 4.wav is a little less than 700ms, so notify should fire 4 times on Wince!
@@ -166,8 +166,8 @@ void tst_QAudioOutput::pullFile()
#endif
audio->stop();
QTest::qWait(20); // wait 20ms
- QVERIFY(audio->state() == QAudio::StopState);
- QVERIFY(audio->clock() == 0);
+ QVERIFY(audio->state() == QAudio::StoppedState);
+ QVERIFY(audio->elapsedUSecs() == 0);
// Can only check to make sure we got at least 1 more signal, but can be more.
QVERIFY(stateSignal.count() > 1);
@@ -184,7 +184,7 @@ void tst_QAudioOutput::pushFile()
const qint64 fileSize = file.size();
- QIODevice* feed = audio->start(0);
+ QIODevice* feed = audio->start();
char* buffer = new char[fileSize];
file.read(buffer, fileSize);
@@ -199,7 +199,7 @@ void tst_QAudioOutput::pushFile()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(written == fileSize);
- QVERIFY(audio->totalTime() == 692250);
+ QVERIFY(audio->processedUSecs() == 692250);
audio->stop();
file.close();
diff --git a/tests/auto/qboxlayout/tst_qboxlayout.cpp b/tests/auto/qboxlayout/tst_qboxlayout.cpp
index 7ff444b5f9..8887288001 100644
--- a/tests/auto/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/qboxlayout/tst_qboxlayout.cpp
@@ -211,7 +211,6 @@ void tst_QBoxLayout::setGeometry()
QRect newGeom(0, 0, 70, 70);
lay2->setGeometry(newGeom);
- QApplication::processEvents();
QVERIFY2(newGeom.contains(dial->geometry()), "dial->geometry() should be smaller and within newGeom");
}
diff --git a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
index a19f8650c4..8b0335c376 100644
--- a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
@@ -128,14 +128,15 @@ void tst_QButtonGroup::cleanup()
{
}
+QT_BEGIN_NAMESPACE
+extern bool Q_GUI_EXPORT qt_tab_all_widgets;
+QT_END_NAMESPACE
+
+
void tst_QButtonGroup::arrowKeyNavigation()
{
-#ifdef Q_WS_MAC
- QSettings appleSettings(QLatin1String("apple.com"));
- QVariant appleValue = appleSettings.value(QLatin1String("AppleKeyboardUIMode"), 0);
- if (!(appleValue.toInt() & 0x2))
+ if (!qt_tab_all_widgets)
QSKIP("This test requires full keyboard control to be enabled.", SkipAll);
-#endif
QDialog dlg(0);
QHBoxLayout layout(&dlg);
diff --git a/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp
index 381f46f61b..a57c1d6185 100644
--- a/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp
+++ b/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp
@@ -75,6 +75,8 @@ private slots:
void resetTextFormat();
void setWeekdayFormat();
+ void showPrevNext_data();
+ void showPrevNext();
};
// Testing get/set functions
@@ -293,5 +295,73 @@ void tst_QCalendarWidget::cleanup()
{
}
+
+typedef void (QCalendarWidget::*ShowFunc)();
+Q_DECLARE_METATYPE(ShowFunc)
+
+void tst_QCalendarWidget::showPrevNext_data()
+{
+ QTest::addColumn<ShowFunc>("function");
+ QTest::addColumn<QDate>("dateOrigin");
+ QTest::addColumn<QDate>("expectedDate");
+
+ QTest::newRow("showNextMonth") << &QCalendarWidget::showNextMonth << QDate(1984,7,30) << QDate(1984,8,30);
+ QTest::newRow("showPrevMonth") << &QCalendarWidget::showPreviousMonth << QDate(1984,7,30) << QDate(1984,6,30);
+ QTest::newRow("showNextYear") << &QCalendarWidget::showNextYear << QDate(1984,7,30) << QDate(1985,7,30);
+ QTest::newRow("showPrevYear") << &QCalendarWidget::showPreviousYear << QDate(1984,7,30) << QDate(1983,7,30);
+
+ QTest::newRow("showNextMonth limit") << &QCalendarWidget::showNextMonth << QDate(2007,12,4) << QDate(2008,1,4);
+ QTest::newRow("showPreviousMonth limit") << &QCalendarWidget::showPreviousMonth << QDate(2006,1,23) << QDate(2005,12,23);
+
+ QTest::newRow("showNextMonth now") << &QCalendarWidget::showNextMonth << QDate() << QDate::currentDate().addMonths(1);
+ QTest::newRow("showNextYear now") << &QCalendarWidget::showNextYear << QDate() << QDate::currentDate().addYears(1);
+ QTest::newRow("showPrevieousMonth now") << &QCalendarWidget::showPreviousMonth << QDate() << QDate::currentDate().addMonths(-1);
+ QTest::newRow("showPreviousYear now") << &QCalendarWidget::showPreviousYear << QDate() << QDate::currentDate().addYears(-1);
+
+ QTest::newRow("showToday now") << &QCalendarWidget::showToday << QDate(2000,1,31) << QDate::currentDate();
+ QTest::newRow("showNextMonth 31") << &QCalendarWidget::showNextMonth << QDate(2000,1,31) << QDate(2000,2,28);
+ QTest::newRow("selectedDate") << &QCalendarWidget::showSelectedDate << QDate(2008,2,29) << QDate(2008,2,29);
+
+}
+
+void tst_QCalendarWidget::showPrevNext()
+{
+ QFETCH(ShowFunc, function);
+ QFETCH(QDate, dateOrigin);
+ QFETCH(QDate, expectedDate);
+
+ QCalendarWidget calWidget;
+ calWidget.show();
+ QTest::qWaitForWindowShown(&calWidget);
+ if(!dateOrigin.isNull()) {
+ calWidget.setSelectedDate(dateOrigin);
+ calWidget.setCurrentPage(dateOrigin.year(), dateOrigin.month());
+
+ QCOMPARE(calWidget.yearShown(), dateOrigin.year());
+ QCOMPARE(calWidget.monthShown(), dateOrigin.month());
+ } else {
+ QCOMPARE(calWidget.yearShown(), QDate::currentDate().year());
+ QCOMPARE(calWidget.monthShown(), QDate::currentDate().month());
+ }
+
+ (calWidget.*function)();
+
+ QCOMPARE(calWidget.yearShown(), expectedDate.year());
+ QCOMPARE(calWidget.monthShown(), expectedDate.month());
+
+ // QTBUG-4058
+ QTest::qWait(20);
+ QToolButton *button = qFindChild<QToolButton *>(&calWidget, "qt_calendar_prevmonth");
+ QTest::mouseClick(button, Qt::LeftButton);
+ expectedDate = expectedDate.addMonths(-1);
+ QCOMPARE(calWidget.yearShown(), expectedDate.year());
+ QCOMPARE(calWidget.monthShown(), expectedDate.month());
+
+ if(!dateOrigin.isNull()) {
+ //the selectedDate should not have changed
+ QCOMPARE(calWidget.selectedDate(), dateOrigin);
+ }
+}
+
QTEST_MAIN(tst_QCalendarWidget)
#include "tst_qcalendarwidget.moc"
diff --git a/tests/auto/qclipboard/test/test.pro b/tests/auto/qclipboard/test/test.pro
index 508eba1d9e..62a38afa5d 100644
--- a/tests/auto/qclipboard/test/test.pro
+++ b/tests/auto/qclipboard/test/test.pro
@@ -13,7 +13,18 @@ win32 {
wince*|symbian*: {
copier.sources = ../copier/copier.exe
copier.path = copier
- paster.sources = ../paster/paster.exe
+ paster.sources = ../paster/paster.exe
paster.path = paster
- DEPLOYMENT = copier paster
+
+ symbian*: {
+ load(data_caging_paths)
+ rsc.sources = $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/copier.rsc
+ rsc.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/paster.rsc
+ rsc.path = $$APP_RESOURCE_DIR
+ reg_resource.sources = $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/copier_reg.rsc
+ reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/paster_reg.rsc
+ reg_resource.path = $$REG_RESOURCE_IMPORT_DIR
+ }
+
+ DEPLOYMENT = copier paster rsc reg_resource
} \ No newline at end of file
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index e76f0f789e..e903ab508e 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -57,6 +57,7 @@
#include <qtreewidget.h>
#include <qtablewidget.h>
#include <qscrollbar.h>
+#include <qboxlayout.h>
#ifdef Q_WS_MAC
#include <qmacstyle_mac.h>
#elif defined Q_WS_X11
@@ -151,6 +152,10 @@ private slots:
void subControlRectsWithOffset_data();
void subControlRectsWithOffset();
void task260974_menuItemRectangleForComboBoxPopup();
+ void removeItem();
+ void resetModel();
+ void keyBoardNavigationWithMouse();
+ void task_QTBUG_1071_changingFocusEmitsActivated();
protected slots:
void onEditTextChanged( const QString &newString );
@@ -810,21 +815,25 @@ void tst_QComboBox::autoCompletionCaseSensitivity()
// case insensitive
testWidget->clearEditText();
+ QSignalSpy spyReturn(testWidget, SIGNAL(activated(int)));
testWidget->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive);
QVERIFY(testWidget->autoCompletionCaseSensitivity() == Qt::CaseInsensitive);
QTest::keyClick(testWidget->lineEdit(), Qt::Key_A);
qApp->processEvents();
QCOMPARE(testWidget->currentText(), QString("aww"));
+ QCOMPARE(spyReturn.count(), 0);
QTest::keyClick(testWidget->lineEdit(), Qt::Key_B);
qApp->processEvents();
// autocompletions preserve userkey-case from 4.2
QCOMPARE(testWidget->currentText(), QString("abCDEF"));
+ QCOMPARE(spyReturn.count(), 0);
QTest::keyClick(testWidget->lineEdit(), Qt::Key_Enter);
qApp->processEvents();
QCOMPARE(testWidget->currentText(), QString("aBCDEF")); // case restored to item's case
+ QCOMPARE(spyReturn.count(), 1);
testWidget->clearEditText();
QTest::keyClick(testWidget->lineEdit(), 'c');
@@ -2398,5 +2407,134 @@ void tst_QComboBox::task260974_menuItemRectangleForComboBoxPopup()
#endif
}
+void tst_QComboBox::removeItem()
+{
+ QComboBox cb;
+ cb.removeItem(-1);
+ cb.removeItem(1);
+ cb.removeItem(0);
+ QCOMPARE(cb.count(), 0);
+
+ cb.addItem("foo");
+ cb.removeItem(-1);
+ QCOMPARE(cb.count(), 1);
+ cb.removeItem(1);
+ QCOMPARE(cb.count(), 1);
+ cb.removeItem(0);
+ QCOMPARE(cb.count(), 0);
+}
+
+void tst_QComboBox::resetModel()
+{
+ class StringListModel : public QStringListModel
+ {
+ public:
+ StringListModel(const QStringList &list) : QStringListModel(list)
+ {
+ }
+
+ void reset()
+ {
+ QStringListModel::reset();
+ }
+ };
+ QComboBox cb;
+ StringListModel model( QStringList() << "1" << "2");
+ QSignalSpy spy(&cb, SIGNAL(currentIndexChanged(int)));
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(cb.currentIndex(), -1); //no selection
+
+ cb.setModel(&model);
+
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(cb.currentIndex(), 0); //first item selected
+
+ model.reset();
+ QCOMPARE(spy.count(), 2);
+ QCOMPARE(cb.currentIndex(), -1); //no selection
+
+}
+
+void tst_QComboBox::keyBoardNavigationWithMouse()
+{
+ QComboBox combo;
+ combo.setEditable(false);
+ for (int i = 0; i < 80; i++)
+ combo.addItem( QString::number(i));
+ combo.show();
+ QApplication::setActiveWindow(&combo);
+ QTest::qWaitForWindowShown(&combo);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&combo));
+
+ QCOMPARE(combo.currentText(), QLatin1String("0"));
+
+ combo.setFocus();
+ QTRY_VERIFY(combo.hasFocus());
+
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_Space);
+ QTest::qWait(30);
+ QTRY_VERIFY(combo.view());
+ QTRY_VERIFY(combo.view()->isVisible());
+ QTest::qWait(130);
+
+ QCOMPARE(combo.currentText(), QLatin1String("0"));
+
+#ifdef Q_OS_WINCE
+ QSKIP("When calling cursor function, Windows CE responds with: This function is not supported on this system.", SkipAll);
+#endif
+
+ QCursor::setPos(combo.view()->mapToGlobal(combo.view()->rect().center()));
+ QTest::qWait(200);
+
+#define GET_SELECTION(SEL) \
+ QCOMPARE(combo.view()->selectionModel()->selection().count(), 1); \
+ QCOMPARE(combo.view()->selectionModel()->selection().indexes().count(), 1); \
+ SEL = combo.view()->selectionModel()->selection().indexes().first().row()
+
+ int selection;
+ GET_SELECTION(selection);
+
+ //since we moved the mouse is in the middle it should even be around 5;
+ QVERIFY(selection > 3);
+
+ static const int final = 40;
+ for (int i = selection + 1; i <= final; i++)
+ {
+ QTest::keyClick(combo.view(), Qt::Key_Down);
+ QTest::qWait(20);
+ GET_SELECTION(selection);
+ QCOMPARE(selection, i);
+ }
+
+ QTest::keyClick(combo.view(), Qt::Key_Enter);
+ QTRY_COMPARE(combo.currentText(), QString::number(final));
+}
+
+void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated()
+{
+ QWidget w;
+ QVBoxLayout layout(&w);
+ QComboBox cb;
+ cb.setEditable(true);
+ QSignalSpy spy(&cb, SIGNAL(activated(int)));
+ cb.addItem("0");
+ cb.addItem("1");
+ cb.addItem("2");
+ QLineEdit edit;
+ layout.addWidget(&cb);
+ layout.addWidget(&edit);
+
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+ cb.clearEditText();
+ cb.setFocus();
+ QApplication::processEvents();
+ QTest::keyClick(0, '1');
+ QCOMPARE(spy.count(), 0);
+ edit.setFocus();
+ QTRY_VERIFY(edit.hasFocus());
+ QTRY_COMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index 43205e157c..2a17984d5f 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -267,7 +267,7 @@ void tst_QCompleter::filter()
//QModelIndex si = completer->currentIndex();
//QCOMPARE(completer->model()->data(si).toString(), completion);
- QCOMPARE(completer->currentCompletion(), completionText);
+ QVERIFY(0 == QString::compare(completer->currentCompletion(), completionText, completer->caseSensitivity()));
}
// Testing get/set functions
diff --git a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp
index c5f06e2bb9..3c61f81513 100644
--- a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp
+++ b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp
@@ -58,6 +58,7 @@ private slots:
#endif
void applicationPid();
void globalPostedEventsCount();
+ void processEventsAlwaysSendsPostedEvents();
};
class EventSpy : public QObject
@@ -488,5 +489,40 @@ void tst_QCoreApplication::globalPostedEventsCount()
QCOMPARE(x.globalPostedEventsCount, expected);
}
+class ProcessEventsAlwaysSendsPostedEventsObject : public QObject
+{
+public:
+ int counter;
+
+ inline ProcessEventsAlwaysSendsPostedEventsObject()
+ : counter(0)
+ { }
+
+ bool event(QEvent *event)
+ {
+ if (event->type() == QEvent::User)
+ ++counter;
+ return QObject::event(event);
+ }
+};
+
+void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents()
+{
+ int argc = 1;
+ char *argv[] = { "tst_qcoreapplication" };
+ QCoreApplication app(argc, argv);
+
+ ProcessEventsAlwaysSendsPostedEventsObject object;
+ QTime t;
+ t.start();
+ int i = 1;
+ do {
+ QCoreApplication::postEvent(&object, new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+ QCOMPARE(object.counter, i);
+ ++i;
+ } while (t.elapsed() < 3000);
+}
+
QTEST_APPLESS_MAIN(tst_QCoreApplication)
#include "tst_qcoreapplication.moc"
diff --git a/tests/auto/qcssparser/tst_qcssparser.cpp b/tests/auto/qcssparser/tst_qcssparser.cpp
index 150f131f02..3580252c7f 100644
--- a/tests/auto/qcssparser/tst_qcssparser.cpp
+++ b/tests/auto/qcssparser/tst_qcssparser.cpp
@@ -1556,8 +1556,11 @@ void tst_QCssParser::extractFontFamily_data()
QTest::newRow("shorthand") << "font: 12pt Times New Roman" << QString("Times New Roman");
QTest::newRow("shorthand multiple quote") << "font: 12pt invalid, \"Times New Roman\" " << QString("Times New Roman");
QTest::newRow("shorthand multiple") << "font: 12pt invalid, Times New Roman " << QString("Times New Roman");
+ QTest::newRow("invalid spaces") << "font-family: invalid spaces, Times New Roman " << QString("Times New Roman");
+ QTest::newRow("invalid spaces quotes") << "font-family: 'invalid spaces', 'Times New Roman' " << QString("Times New Roman");
}
+
void tst_QCssParser::extractFontFamily()
{
QFETCH(QString, css);
diff --git a/tests/auto/qdatastream/qdatastream.pro b/tests/auto/qdatastream/qdatastream.pro
index 5b903571d4..c132073aea 100644
--- a/tests/auto/qdatastream/qdatastream.pro
+++ b/tests/auto/qdatastream/qdatastream.pro
@@ -12,7 +12,7 @@ QT += svg
wince*: {
- addFiles.sources = datastream.q42 gearflowers.svg
+ addFiles.sources = datastream.q42 tests2.svg
addFiles.path = .
DEPLOYMENT += addFiles
DEFINES += SRCDIR=\\\"\\\"
diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp
index add0945148..24447ea404 100644
--- a/tests/auto/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/qdatastream/tst_qdatastream.cpp
@@ -320,8 +320,7 @@ void tst_QDataStream::getSetCheck()
tst_QDataStream::tst_QDataStream()
{
- svgFile = QLatin1String(SRCDIR) + QLatin1String("/") +
- QLatin1String(SVGFILE);
+ svgFile = QLatin1String(SRCDIR SVGFILE);
}
tst_QDataStream::~tst_QDataStream()
@@ -1461,7 +1460,7 @@ void tst_QDataStream::readQImage(QDataStream *s)
QVERIFY(d12.width() == ref.width());
QVERIFY(d12.height() == ref.height());
QVERIFY(d12.depth() == ref.depth());
- QVERIFY(d12.numColors() == ref.numColors());
+ QVERIFY(d12.colorCount() == ref.colorCount());
#ifdef QT3_SUPPORT
QVERIFY(d12.hasAlphaBuffer() == ref.hasAlphaBuffer());
#else
@@ -3100,22 +3099,6 @@ void tst_QDataStream::streamToAndFromQByteArray()
void tst_QDataStream::streamRealDataTypes()
{
-#if defined(Q_OS_WINCE)
- // Note: Probably actually same 'qreal being typedeffed as float instead of double' issue as in Symbian
- // instead of what CE skip message says.
- QSKIP("Skipped on CE as it demands too much memory and fragments", SkipAll);
-#elif defined(Q_OS_SYMBIAN)
- // qreal is typedeffed float in symbian instead of double like in most platforms, so reference stream
- // gets corrupted. Basically this test is flawed, as one shouldn't use naked typedeffed types in
- // streams that are meant to work cross-platform.
- // As this test also tests other floating point using classes, we do not simply skip it, but work around
- // the qreal issue by redefining qreal as double for the duration of this function.
- // Note that streaming classes works because they do explicitly use double instead of qreal when
- // writing/reading to/from stream.
-# define qreal double
- qWarning("Note: streamRealDataTypes test redefines qreal as double in symbian!!!");
-#endif
-
// Generate QPicture from SVG.
QSvgRenderer renderer(svgFile);
QVERIFY(renderer.isValid());
@@ -3163,7 +3146,6 @@ void tst_QDataStream::streamRealDataTypes()
file.close();
}
- qreal a, b, c, d, e, f;
QPointF point;
QRectF rect;
QPolygonF polygon;
@@ -3180,28 +3162,50 @@ void tst_QDataStream::streamRealDataTypes()
QDataStream stream(&file);
stream.setVersion(QDataStream::Qt_4_2);
- stream >> a >> b >> c >> d >> e >> f >> point
- >> rect >> polygon >> matrix >> p;
- if (i == 1)
- stream >> pict;
- stream >> textLength >> col >> rGrad >> cGrad
- >> pen;
-
- QCOMPARE(stream.status(), QDataStream::Ok);
-
- QCOMPARE(a, qreal(0));
- QCOMPARE(b, qreal(1.0));
- QCOMPARE(c, qreal(1.1));
- QCOMPARE(d, qreal(3.14));
- QCOMPARE(e, qreal(-3.14));
- QCOMPARE(f, qreal(-1));
+ if (i == 0) {
+ // the reference stream for 4.2 contains doubles,
+ // so we must read them out as doubles!
+ double a, b, c, d, e, f;
+ stream >> a;
+ QCOMPARE(a, 0.0);
+ stream >> b;
+ QCOMPARE(b, 1.0);
+ stream >> c;
+ QCOMPARE(c, 1.1);
+ stream >> d;
+ QCOMPARE(d, 3.14);
+ stream >> e;
+ QCOMPARE(e, -3.14);
+ stream >> f;
+ QCOMPARE(f, -1.0);
+ } else {
+ qreal a, b, c, d, e, f;
+ stream >> a;
+ QCOMPARE(a, qreal(0));
+ stream >> b;
+ QCOMPARE(b, qreal(1.0));
+ stream >> c;
+ QCOMPARE(c, qreal(1.1));
+ stream >> d;
+ QCOMPARE(d, qreal(3.14));
+ stream >> e;
+ QCOMPARE(e, qreal(-3.14));
+ stream >> f;
+ QCOMPARE(f, qreal(-1));
+ }
+ stream >> point;
QCOMPARE(point, QPointF(3, 5));
+ stream >> rect;
QCOMPARE(rect, QRectF(-1, -2, 3, 4));
+ stream >> polygon;
QCOMPARE((QVector<QPointF> &)polygon, (QPolygonF() << QPointF(0, 0) << QPointF(1, 2)));
+ stream >> matrix;
QCOMPARE(matrix, QMatrix().rotate(90).scale(2, 2));
+ stream >> p;
QCOMPARE(p, path);
+ if (i == 1) {
+ stream >> pict;
- if (i == 0) {
QByteArray pictA, pictB;
QBuffer bufA, bufB;
QVERIFY(bufA.open(QIODevice::ReadWrite));
@@ -3212,8 +3216,11 @@ void tst_QDataStream::streamRealDataTypes()
QCOMPARE(pictA, pictB);
}
+ stream >> textLength;
QCOMPARE(textLength, QTextLength(QTextLength::VariableLength, 1.5));
+ stream >> col;
QCOMPARE(col, color);
+ stream >> rGrad;
QCOMPARE(rGrad.style(), radialBrush.style());
QCOMPARE(rGrad.matrix(), radialBrush.matrix());
QCOMPARE(rGrad.gradient()->type(), radialBrush.gradient()->type());
@@ -3222,6 +3229,7 @@ void tst_QDataStream::streamRealDataTypes()
QCOMPARE(((QRadialGradient *)rGrad.gradient())->center(), ((QRadialGradient *)radialBrush.gradient())->center());
QCOMPARE(((QRadialGradient *)rGrad.gradient())->focalPoint(), ((QRadialGradient *)radialBrush.gradient())->focalPoint());
QCOMPARE(((QRadialGradient *)rGrad.gradient())->radius(), ((QRadialGradient *)radialBrush.gradient())->radius());
+ stream >> cGrad;
QCOMPARE(cGrad.style(), conicalBrush.style());
QCOMPARE(cGrad.matrix(), conicalBrush.matrix());
QCOMPARE(cGrad.gradient()->type(), conicalBrush.gradient()->type());
@@ -3231,11 +3239,11 @@ void tst_QDataStream::streamRealDataTypes()
QCOMPARE(((QConicalGradient *)cGrad.gradient())->angle(), ((QConicalGradient *)conicalBrush.gradient())->angle());
QCOMPARE(cGrad, conicalBrush);
+ stream >> pen;
QCOMPARE(pen.widthF(), qreal(1.5));
+
+ QCOMPARE(stream.status(), QDataStream::Ok);
}
-#if defined(Q_OS_SYMBIAN)
- #undef qreal
-#endif
}
#ifdef QT3_SUPPORT
diff --git a/tests/auto/qdatawidgetmapper/tst_qdatawidgetmapper.cpp b/tests/auto/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
index 002aeb760b..dedc0cbc5f 100644
--- a/tests/auto/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
+++ b/tests/auto/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
@@ -379,7 +379,7 @@ void tst_QDataWidgetMapper::comboBox()
model->setData(model->index(0, 1), QString("read write item z"), Qt::EditRole);
QCOMPARE(readOnlyBox.currentIndex(), 2);
- QEXPECT_FAIL("", "See tasks 125493 and 147153", Abort);
+ QEXPECT_FAIL("", "See task 125493 and QTBUG-428", Abort);
QCOMPARE(readWriteBox.currentText(), QString("read write item z"));
}
diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp
index 8fb0c912c0..11404022e6 100644
--- a/tests/auto/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/qdatetime/tst_qdatetime.cpp
@@ -447,7 +447,15 @@ void tst_QDateTime::toString_enumformat()
QCOMPARE(str2, QString("1995-05-20T12:34:56"));
QString str3 = dt1.toString(Qt::LocalDate);
+ qDebug() << str3;
QVERIFY(!str3.isEmpty());
+ //check for date/time components in any order
+ //year may be 2 or 4 digits
+ QVERIFY(str3.contains("95"));
+ //day and month may be in numeric or word form
+ QVERIFY(str3.contains("12"));
+ QVERIFY(str3.contains("34"));
+ //seconds may be absent
}
void tst_QDateTime::addDays()
diff --git a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
index baf769f6de..a2c4758ebc 100644
--- a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
+++ b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
@@ -103,6 +103,8 @@ private slots:
void getComplexSignal_data();
void getComplexSignal();
+ void followSignal();
+
void createErrors_data();
void createErrors();
@@ -130,6 +132,9 @@ tst_QDBusAbstractInterface::tst_QDBusAbstractInterface()
void tst_QDBusAbstractInterface::initTestCase()
{
+ // enable debugging temporarily:
+ //putenv("QDBUS_DEBUG=1");
+
// register the object
QDBusConnection con = QDBusConnection::sessionBus();
QVERIFY(con.isConnected());
@@ -432,6 +437,61 @@ void tst_QDBusAbstractInterface::getComplexSignal()
QCOMPARE(s[0][0].value<RegisteredType>(), expectedValue);
}
+void tst_QDBusAbstractInterface::followSignal()
+{
+ const QString serviceToFollow = "com.trolltech.tst_qdbusabstractinterface.FollowMe";
+ Pinger p = getPinger(serviceToFollow);
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ QDBusConnection con = p->connection();
+ QVERIFY(!con.interface()->isServiceRegistered(serviceToFollow));
+ Pinger control = getPinger("");
+
+ // we need to connect the signal somewhere in order for D-Bus to enable the rules
+ QTestEventLoop::instance().connect(p.data(), SIGNAL(voidSignal()), SLOT(exitLoop()));
+ QTestEventLoop::instance().connect(control.data(), SIGNAL(voidSignal()), SLOT(exitLoop()));
+ QSignalSpy s(p.data(), SIGNAL(voidSignal()));
+
+ emit targetObj.voidSignal();
+ QTestEventLoop::instance().enterLoop(200);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ // signal must not have been received because the service isn't registered
+ QVERIFY(s.isEmpty());
+
+ // now register the service
+ QDBusReply<QDBusConnectionInterface::RegisterServiceReply> r =
+ con.interface()->registerService(serviceToFollow, QDBusConnectionInterface::DontQueueService,
+ QDBusConnectionInterface::DontAllowReplacement);
+ QVERIFY(r.isValid() && r.value() == QDBusConnectionInterface::ServiceRegistered);
+ QVERIFY(con.interface()->isServiceRegistered(serviceToFollow));
+ QCoreApplication::instance()->processEvents();
+
+ // emit the signal again:
+ emit targetObj.voidSignal();
+ QTestEventLoop::instance().enterLoop(2);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ // now the signal must have been received:
+ QCOMPARE(s.size(), 1);
+ QVERIFY(s.at(0).size() == 0);
+ s.clear();
+
+ // disconnect the signal
+ disconnect(p.data(), SIGNAL(voidSignal()), &QTestEventLoop::instance(), 0);
+
+ // emit the signal again:
+ emit targetObj.voidSignal();
+ QTestEventLoop::instance().enterLoop(2);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ // and now it mustn't have been received
+ QVERIFY(s.isEmpty());
+
+ // cleanup:
+ con.interface()->unregisterService(serviceToFollow);
+}
+
void tst_QDBusAbstractInterface::createErrors_data()
{
QTest::addColumn<QString>("service");
diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp
index e31a3a0952..bcd5bd97e1 100644
--- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp
+++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp
@@ -171,6 +171,13 @@ class tst_QDBusInterface: public QObject
{
Q_OBJECT
MyObject obj;
+public slots:
+ void testServiceOwnerChanged(const QString &service)
+ {
+ if (service == "com.example.Test")
+ QTestEventLoop::instance().exitLoop();
+ }
+
private slots:
void initTestCase();
@@ -227,6 +234,7 @@ void tst_QDBusInterface::notValid()
void tst_QDBusInterface::invalidAfterServiceOwnerChanged()
{
+ // this test is technically the same as tst_QDBusAbstractInterface::followSignal
QDBusConnection conn = QDBusConnection::sessionBus();
QDBusConnectionInterface *connIface = conn.interface();
@@ -235,33 +243,14 @@ void tst_QDBusInterface::invalidAfterServiceOwnerChanged()
QDBusInterface invalidInterface("com.example.Test", "/");
QVERIFY(!invalidInterface.isValid());
+ QTestEventLoop::instance().connect(connIface, SIGNAL(serviceOwnerChanged(QString, QString, QString)),
+ SLOT(exitLoop()));
QVERIFY(connIface->registerService("com.example.Test") == QDBusConnectionInterface::ServiceRegistered);
- QSignalSpy serviceOwnerChangedSpy(connIface, SIGNAL(serviceOwnerChanged(QString, QString, QString)));
-
- QEventLoop loop;
- QObject::connect(connIface, SIGNAL(serviceOwnerChanged(QString, QString, QString)),
- &loop, SLOT(quit()));
- loop.exec();
-
- // at least once, but other services might have changed while running the test, too.
- QVERIFY(serviceOwnerChangedSpy.count() >= 1);
- bool foundOurService = false;
- for (int i = 0; i < serviceOwnerChangedSpy.count(); ++i) {
- QList<QVariant> args = serviceOwnerChangedSpy.at(i);
- QString name = args[0].toString();
- QString oldOwner = args[1].toString();
- QString newOwner = args[2].toString();
- if (name == QLatin1String("com.example.Test")) {
- if (newOwner == conn.baseService()) {
- foundOurService = true;
- break;
- }
- }
- }
- QVERIFY(foundOurService);
+ QTestEventLoop::instance().enterLoop(5);
- QVERIFY(!invalidInterface.isValid());
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(invalidInterface.isValid());
}
void tst_QDBusInterface::introspect()
diff --git a/tests/auto/qdbusperformance/tst_qdbusperformance.cpp b/tests/auto/qdbusperformance/tst_qdbusperformance.cpp
index 7227d5d991..066b5b28f4 100644
--- a/tests/auto/qdbusperformance/tst_qdbusperformance.cpp
+++ b/tests/auto/qdbusperformance/tst_qdbusperformance.cpp
@@ -80,6 +80,14 @@ Q_DECLARE_METATYPE(QVariant)
void tst_QDBusPerformance::initTestCase()
{
+ QDBusConnection con = QDBusConnection::sessionBus();
+ QVERIFY(con.isConnected());
+
+ QDBusServiceWatcher watcher(serviceName, con,
+ QDBusServiceWatcher::WatchForRegistration);
+ connect(&watcher, SIGNAL(serviceRegistered(QString)),
+ &QTestEventLoop::instance(), SLOT(exitLoop()));
+
#ifdef Q_OS_WIN
proc.start("server");
#else
@@ -87,19 +95,7 @@ void tst_QDBusPerformance::initTestCase()
#endif
QVERIFY(proc.waitForStarted());
- QDBusConnection con = QDBusConnection::sessionBus();
- QVERIFY(con.isConnected());
-
- connect(con.interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
- &QTestEventLoop::instance(), SLOT(exitLoop()));
- QTime timer;
- timer.start();
-
- while (timer.elapsed() < 5000) {
- QTestEventLoop::instance().enterLoop(5);
- if (con.interface()->isServiceRegistered(serviceName))
- break;
- }
+ QTestEventLoop::instance().enterLoop(5);
QVERIFY(con.interface()->isServiceRegistered(serviceName));
remote = new QDBusInterface(serviceName, "/", "com.trolltech.autotests.Performance", con, this);
diff --git a/tests/auto/qdbusservicewatcher/qdbusservicewatcher.pro b/tests/auto/qdbusservicewatcher/qdbusservicewatcher.pro
new file mode 100644
index 0000000000..4970f16863
--- /dev/null
+++ b/tests/auto/qdbusservicewatcher/qdbusservicewatcher.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+QT = core
+contains(QT_CONFIG,dbus): {
+ SOURCES += tst_qdbusservicewatcher.cpp
+ QT += dbus
+} else {
+ SOURCES += ../qdbusmarshall/dummy.cpp
+}
diff --git a/tests/auto/qdbusservicewatcher/tst_qdbusservicewatcher.cpp b/tests/auto/qdbusservicewatcher/tst_qdbusservicewatcher.cpp
new file mode 100644
index 0000000000..10b43b1e32
--- /dev/null
+++ b/tests/auto/qdbusservicewatcher/tst_qdbusservicewatcher.cpp
@@ -0,0 +1,273 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 <QtDBus/QDBusServiceWatcher>
+#include <QtDBus>
+#include <QtTest>
+
+class tst_QDBusServiceWatcher: public QObject
+{
+ Q_OBJECT
+ QString serviceName;
+public:
+ tst_QDBusServiceWatcher();
+
+private slots:
+ void initTestCase();
+ void cleanup();
+
+ void watchForCreation();
+ void watchForDisappearance();
+ void watchForOwnerChange();
+ void modeChange();
+};
+
+tst_QDBusServiceWatcher::tst_QDBusServiceWatcher()
+ : serviceName("com.example.TestName")
+{
+}
+
+void tst_QDBusServiceWatcher::initTestCase()
+{
+ QDBusConnection con = QDBusConnection::sessionBus();
+ QVERIFY(con.isConnected());
+}
+
+void tst_QDBusServiceWatcher::cleanup()
+{
+ // ensure that the name isn't registered
+ QDBusConnection::sessionBus().unregisterService(serviceName);
+}
+
+void tst_QDBusServiceWatcher::watchForCreation()
+{
+ QDBusConnection con = QDBusConnection::sessionBus();
+ QVERIFY(con.isConnected());
+
+ QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForRegistration);
+
+ QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString)));
+ QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString)));
+ QSignalSpy spyO(&watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)));
+ QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceRegistered(QString)), SLOT(exitLoop()));
+
+ // register a name
+ QVERIFY(con.registerService(serviceName));
+
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QCOMPARE(spyR.count(), 1);
+ QCOMPARE(spyR.at(0).at(0).toString(), serviceName);
+
+ QCOMPARE(spyU.count(), 0);
+
+ QCOMPARE(spyO.count(), 1);
+ QCOMPARE(spyO.at(0).at(0).toString(), serviceName);
+ QVERIFY(spyO.at(0).at(1).toString().isEmpty());
+ QCOMPARE(spyO.at(0).at(2).toString(), con.baseService());
+
+ spyR.clear();
+ spyU.clear();
+ spyO.clear();
+
+ // unregister it:
+ con.unregisterService(serviceName);
+
+ // and register again
+ QVERIFY(con.registerService(serviceName));
+
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QCOMPARE(spyR.count(), 1);
+ QCOMPARE(spyR.at(0).at(0).toString(), serviceName);
+
+ QCOMPARE(spyU.count(), 0);
+
+ QCOMPARE(spyO.count(), 1);
+ QCOMPARE(spyO.at(0).at(0).toString(), serviceName);
+ QVERIFY(spyO.at(0).at(1).toString().isEmpty());
+ QCOMPARE(spyO.at(0).at(2).toString(), con.baseService());
+}
+
+void tst_QDBusServiceWatcher::watchForDisappearance()
+{
+ QDBusConnection con = QDBusConnection::sessionBus();
+ QVERIFY(con.isConnected());
+
+ QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForUnregistration);
+
+ QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString)));
+ QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString)));
+ QSignalSpy spyO(&watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)));
+ QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceUnregistered(QString)), SLOT(exitLoop()));
+
+ // register a name
+ QVERIFY(con.registerService(serviceName));
+
+ // unregister it:
+ con.unregisterService(serviceName);
+
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QCOMPARE(spyR.count(), 0);
+
+ QCOMPARE(spyU.count(), 1);
+ QCOMPARE(spyU.at(0).at(0).toString(), serviceName);
+
+ QCOMPARE(spyO.count(), 1);
+ QCOMPARE(spyO.at(0).at(0).toString(), serviceName);
+ QCOMPARE(spyO.at(0).at(1).toString(), con.baseService());
+ QVERIFY(spyO.at(0).at(2).toString().isEmpty());
+}
+
+void tst_QDBusServiceWatcher::watchForOwnerChange()
+{
+ QDBusConnection con = QDBusConnection::sessionBus();
+ QVERIFY(con.isConnected());
+
+ QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForOwnerChange);
+
+ QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString)));
+ QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString)));
+ QSignalSpy spyO(&watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)));
+ QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceRegistered(QString)), SLOT(exitLoop()));
+
+ // register a name
+ QVERIFY(con.registerService(serviceName));
+
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QCOMPARE(spyR.count(), 1);
+ QCOMPARE(spyR.at(0).at(0).toString(), serviceName);
+
+ QCOMPARE(spyU.count(), 0);
+
+ QCOMPARE(spyO.count(), 1);
+ QCOMPARE(spyO.at(0).at(0).toString(), serviceName);
+ QVERIFY(spyO.at(0).at(1).toString().isEmpty());
+ QCOMPARE(spyO.at(0).at(2).toString(), con.baseService());
+
+ spyR.clear();
+ spyU.clear();
+ spyO.clear();
+
+ // unregister it:
+ con.unregisterService(serviceName);
+
+ // and register again
+ QVERIFY(con.registerService(serviceName));
+
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QCOMPARE(spyR.count(), 1);
+ QCOMPARE(spyR.at(0).at(0).toString(), serviceName);
+
+ QCOMPARE(spyU.count(), 1);
+ QCOMPARE(spyU.at(0).at(0).toString(), serviceName);
+
+ QCOMPARE(spyO.count(), 2);
+ QCOMPARE(spyO.at(0).at(0).toString(), serviceName);
+ QCOMPARE(spyO.at(0).at(1).toString(), con.baseService());
+ QVERIFY(spyO.at(0).at(2).toString().isEmpty());
+ QCOMPARE(spyO.at(1).at(0).toString(), serviceName);
+ QVERIFY(spyO.at(1).at(1).toString().isEmpty());
+ QCOMPARE(spyO.at(1).at(2).toString(), con.baseService());
+}
+
+void tst_QDBusServiceWatcher::modeChange()
+{
+ QDBusConnection con = QDBusConnection::sessionBus();
+ QVERIFY(con.isConnected());
+
+ QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForRegistration);
+
+ QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString)));
+ QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString)));
+ QSignalSpy spyO(&watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)));
+ QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceRegistered(QString)), SLOT(exitLoop()));
+
+ // register a name
+ QVERIFY(con.registerService(serviceName));
+
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QCOMPARE(spyR.count(), 1);
+ QCOMPARE(spyR.at(0).at(0).toString(), serviceName);
+
+ QCOMPARE(spyU.count(), 0);
+
+ QCOMPARE(spyO.count(), 1);
+ QCOMPARE(spyO.at(0).at(0).toString(), serviceName);
+ QVERIFY(spyO.at(0).at(1).toString().isEmpty());
+ QCOMPARE(spyO.at(0).at(2).toString(), con.baseService());
+
+ spyR.clear();
+ spyU.clear();
+ spyO.clear();
+
+ watcher.setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
+
+ // unregister it:
+ con.unregisterService(serviceName);
+
+ QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceUnregistered(QString)), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QCOMPARE(spyR.count(), 0);
+
+ QCOMPARE(spyU.count(), 1);
+ QCOMPARE(spyU.at(0).at(0).toString(), serviceName);
+
+ QCOMPARE(spyO.count(), 1);
+ QCOMPARE(spyO.at(0).at(0).toString(), serviceName);
+ QCOMPARE(spyO.at(0).at(1).toString(), con.baseService());
+ QVERIFY(spyO.at(0).at(2).toString().isEmpty());
+}
+
+QTEST_MAIN(tst_QDBusServiceWatcher)
+#include "tst_qdbusservicewatcher.moc"
diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp
index dc67f36b32..8f72e399c1 100644
--- a/tests/auto/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp
@@ -50,6 +50,7 @@
#include <qlineedit.h>
#include <QDesktopWidget>
#include <QtGui/QPainter>
+#include "private/qdockwidget_p.h"
bool hasFeature(QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature)
{ return (dockwidget->features() & feature) == feature; }
@@ -86,12 +87,15 @@ private slots:
void visibilityChanged();
void dockLocationChanged();
void setTitleBarWidget();
+ void titleBarDoubleClick();
+ void restoreStateOfFloating();
// task specific tests:
void task165177_deleteFocusWidget();
void task169808_setFloating();
void task237438_setFloatingCrash();
void task248604_infiniteResize();
void task258459_visibilityChanged();
+ void taskQTBUG_1665_closableChanged();
};
// Testing get/set functions
@@ -611,6 +615,7 @@ void tst_QDockWidget::dockLocationChanged()
QMainWindow mw;
QDockWidget dw;
+ dw.setObjectName("dock1");
QSignalSpy spy(&dw, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)));
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
@@ -635,6 +640,7 @@ void tst_QDockWidget::dockLocationChanged()
QCOMPARE(spy.count(), 0);
QDockWidget dw2;
+ dw2.setObjectName("dock2");
mw.addDockWidget(Qt::TopDockWidgetArea, &dw2);
mw.tabifyDockWidget(&dw2, &dw);
QCOMPARE(spy.count(), 1);
@@ -656,6 +662,12 @@ void tst_QDockWidget::dockLocationChanged()
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
Qt::TopDockWidgetArea);
spy.clear();
+
+ QByteArray ba = mw.saveState();
+ mw.restoreState(ba);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
+ Qt::TopDockWidgetArea);
}
void tst_QDockWidget::featuresChanged()
@@ -694,6 +706,39 @@ void tst_QDockWidget::setTitleBarWidget()
QCOMPARE(w2.isVisible(), false);
}
+void tst_QDockWidget::titleBarDoubleClick()
+{
+ QMainWindow win;
+ QDockWidget dock(&win);
+ win.show();
+ dock.setFloating(true);
+
+ QEvent e(QEvent::NonClientAreaMouseButtonDblClick);
+ QApplication::sendEvent(&dock, &e);
+ QVERIFY(dock.isFloating());
+ QCOMPARE(win.dockWidgetArea(&dock), Qt::NoDockWidgetArea);
+
+ win.addDockWidget(Qt::TopDockWidgetArea, &dock);
+ dock.setFloating(true);
+ QApplication::sendEvent(&dock, &e);
+ QVERIFY(!dock.isFloating());
+ QCOMPARE(win.dockWidgetArea(&dock), Qt::TopDockWidgetArea);
+}
+
+void tst_QDockWidget::restoreStateOfFloating()
+{
+ QMainWindow mw;
+ QDockWidget dock;
+ dock.setObjectName("dock1");
+ mw.addDockWidget(Qt::TopDockWidgetArea, &dock);
+ QVERIFY(!dock.isFloating());
+ QByteArray ba = mw.saveState();
+ dock.setFloating(true);
+ QVERIFY(dock.isFloating());
+ QVERIFY(mw.restoreState(ba));
+ QVERIFY(!dock.isFloating());
+}
+
void tst_QDockWidget::task165177_deleteFocusWidget()
{
@@ -815,5 +860,24 @@ void tst_QDockWidget::task258459_visibilityChanged()
QCOMPARE(spy2.first().first().toBool(), true); //dock1 is visible
}
+void tst_QDockWidget::taskQTBUG_1665_closableChanged()
+{
+ QDockWidget dock;
+ dock.show();
+ QTest::qWaitForWindowShown(&dock);
+
+ QDockWidgetLayout *l = qobject_cast<QDockWidgetLayout*>(dock.layout());
+
+ if (l && !l->nativeWindowDeco())
+ QSKIP("this machine doesn't support native dock widget", SkipAll);
+
+ QVERIFY(dock.windowFlags() & Qt::WindowCloseButtonHint);
+
+ //now let's remove the closable attribute
+ dock.setFeatures(dock.features() ^ QDockWidget::DockWidgetClosable);
+ QVERIFY(!(dock.windowFlags() & Qt::WindowCloseButtonHint));
+}
+
+
QTEST_MAIN(tst_QDockWidget)
#include "tst_qdockwidget.moc"
diff --git a/tests/auto/qfile/largefile/largefile.pro b/tests/auto/qfile/largefile/largefile.pro
new file mode 100644
index 0000000000..d67cb46fad
--- /dev/null
+++ b/tests/auto/qfile/largefile/largefile.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+QT = core
+SOURCES += tst_largefile.cpp
+
+wince*: SOURCES += $$QT_SOURCE_TREE/src/corelib/kernel/qfunctions_wince.cpp
diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp
new file mode 100644
index 0000000000..980f4bae50
--- /dev/null
+++ b/tests/auto/qfile/largefile/tst_largefile.cpp
@@ -0,0 +1,540 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 <QTest>
+
+#include <QtAlgorithms>
+#include <QFile>
+#include <QFileInfo>
+#include <qplatformdefs.h>
+
+#include <QDebug>
+
+#include <cstdlib>
+#include <cstdio>
+
+#ifdef Q_OS_WIN
+
+#include <windows.h>
+
+#ifndef Q_OS_WINCE
+#include <io.h>
+#endif
+
+#ifndef FSCTL_SET_SPARSE
+// MinGW doesn't define this.
+#define FSCTL_SET_SPARSE (0x900C4)
+#endif
+
+#endif // Q_OS_WIN
+
+class tst_LargeFile
+ : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_LargeFile()
+ : blockSize(1 << 12)
+ , maxSizeBits()
+ , fd_(-1)
+ , stream_(0)
+ {
+ #if defined(QT_LARGEFILE_SUPPORT) && !defined(Q_OS_MAC)
+ maxSizeBits = 36; // 64 GiB
+ #elif defined(Q_OS_MAC)
+ // HFS+ does not support sparse files, so we limit file size for the test
+ // on Mac OS.
+ maxSizeBits = 32; // 4 GiB
+ #else
+ maxSizeBits = 24; // 16 MiB
+ #endif
+ }
+
+private:
+ void sparseFileData();
+ QByteArray const &getDataBlock(int index, qint64 position);
+
+private slots:
+ // The LargeFile test case was designed to be run in order as a single unit
+
+ void initTestCase();
+ void cleanupTestCase();
+
+ void init();
+ void cleanup();
+
+ // Create and fill large file
+ void createSparseFile();
+ void fillFileSparsely();
+ void closeSparseFile();
+
+ // Verify file was created
+ void fileCreated();
+
+ // Positioning in large files
+ void filePositioning();
+ void fdPositioning();
+ void streamPositioning();
+
+ // Read data from file
+ void openFileForReading();
+ void readFile();
+
+ // Map/unmap large file
+ void mapFile();
+ void mapOffsetOverflow();
+
+ void closeFile() { largeFile.close(); }
+
+ // Test data
+ void fillFileSparsely_data() { sparseFileData(); }
+ void filePositioning_data() { sparseFileData(); }
+ void fdPositioning_data() { sparseFileData(); }
+ void streamPositioning_data() { sparseFileData(); }
+ void readFile_data() { sparseFileData(); }
+ void mapFile_data() { sparseFileData(); }
+
+private:
+ const int blockSize;
+ int maxSizeBits;
+
+ QFile largeFile;
+
+ QVector<QByteArray> generatedBlocks;
+
+ int fd_;
+ FILE *stream_;
+};
+
+/*
+ Convenience function to hide reinterpret_cast when copying a POD directly
+ into a QByteArray.
+ */
+template <class T>
+static inline void appendRaw(QByteArray &array, T data)
+{
+ array.append(reinterpret_cast<char *>(&data), sizeof(T));
+}
+
+/*
+ Pad array with filler up to size. On return, array.size() returns size.
+ */
+static inline void topUpWith(QByteArray &array, QByteArray filler, int size)
+{
+ Q_ASSERT(filler.size() > 0);
+
+ for (int i = (size - array.size()) / filler.size(); i > 0; --i)
+ array.append(filler);
+
+ if (array.size() < size) {
+ Q_ASSERT(size - array.size() < filler.size());
+ array.append(filler.left(size - array.size()));
+ }
+}
+
+/*
+ Generate a unique data block containing identifiable data. Unaligned,
+ overlapping and partial blocks should not compare equal.
+ */
+static inline QByteArray generateDataBlock(int blockSize, QString text, qint64 userBits = -1)
+{
+ QByteArray block;
+ block.reserve(blockSize);
+
+ // Use of counter and randomBits means content of block will be dependent
+ // on the generation order. For (file-)systems that do not support sparse
+ // files, these can be removed so the test file can be reused and doesn't
+ // have to be generated for every run.
+
+ static qint64 counter = 0;
+
+ qint64 randomBits = ((qint64)qrand() << 32)
+ | ((qint64)qrand() & 0x00000000ffffffff);
+
+ appendRaw(block, randomBits);
+ appendRaw(block, userBits);
+ appendRaw(block, counter);
+ appendRaw(block, (qint32)0xdeadbeef);
+ appendRaw(block, blockSize);
+
+ QByteArray userContent = text.toUtf8();
+ appendRaw(block, userContent.size());
+ block.append(userContent);
+ appendRaw(block, (qint64)0);
+
+ // size, so far
+ appendRaw(block, block.size());
+
+ QByteArray filler("0123456789");
+ block.append(filler.right(10 - block.size() % 10));
+ topUpWith(block, filler, blockSize - 2 * sizeof(qint64));
+
+ appendRaw(block, counter);
+ appendRaw(block, userBits);
+ appendRaw(block, randomBits);
+
+ Q_ASSERT( block.size() >= blockSize );
+ block.resize(blockSize);
+
+ ++counter;
+ return block;
+}
+
+/*
+ Generates data blocks the first time they are requested. Keeps copies for reuse.
+ */
+QByteArray const &tst_LargeFile::getDataBlock(int index, qint64 position)
+{
+ if (index >= generatedBlocks.size())
+ generatedBlocks.resize(index + 1);
+
+ if (generatedBlocks[index].isNull()) {
+ QString text = QString("Current %1-byte block (index = %2) "
+ "starts %3 bytes into the file '%4'.")
+ .arg(blockSize)
+ .arg(index)
+ .arg(position)
+ .arg("qt_largefile.tmp");
+
+ generatedBlocks[index] = generateDataBlock(blockSize, text, (qint64)1 << index);
+ }
+
+ return generatedBlocks[index];
+}
+
+void tst_LargeFile::initTestCase()
+{
+ QFile file("qt_largefile.tmp");
+ QVERIFY( !file.exists() || file.remove() );
+}
+
+void tst_LargeFile::cleanupTestCase()
+{
+ if (largeFile.isOpen())
+ largeFile.close();
+
+ QFile file("qt_largefile.tmp");
+ QVERIFY( !file.exists() || file.remove() );
+}
+
+void tst_LargeFile::init()
+{
+ fd_ = -1;
+ stream_ = 0;
+}
+
+void tst_LargeFile::cleanup()
+{
+ if (-1 != fd_)
+ QT_CLOSE(fd_);
+ if (stream_)
+ ::fclose(stream_);
+}
+
+void tst_LargeFile::sparseFileData()
+{
+ QTest::addColumn<int>("index");
+ QTest::addColumn<qint64>("position");
+ QTest::addColumn<QByteArray>("block");
+
+ QTest::newRow(QString("block[%1] @%2)")
+ .arg(0).arg(0)
+ .toLocal8Bit().constData())
+ << 0 << (qint64)0 << getDataBlock(0, 0);
+
+ // While on Linux sparse files scale well, on Windows, testing at every
+ // power of 2 leads to very large files. i += 4 gives us a good coverage
+ // without taxing too much on resources.
+ for (int index = 12; index <= maxSizeBits; index += 4) {
+ qint64 position = (qint64)1 << index;
+ QByteArray block = getDataBlock(index, position);
+
+ QTest::newRow(
+ QString("block[%1] @%2)")
+ .arg(index).arg(position)
+ .toLocal8Bit().constData())
+ << index << position << block;
+ }
+}
+
+void tst_LargeFile::createSparseFile()
+{
+#if defined(Q_OS_WIN32)
+ // On Windows platforms, we must explicitly set the file to be sparse,
+ // so disk space is not allocated for the full file when writing to it.
+ HANDLE handle = ::CreateFileA("qt_largefile.tmp",
+ GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
+ QVERIFY( INVALID_HANDLE_VALUE != handle );
+
+ DWORD bytes;
+ if (!::DeviceIoControl(handle, FSCTL_SET_SPARSE, NULL, 0, NULL, 0,
+ &bytes, NULL)) {
+ QWARN("Unable to set test file as sparse. "
+ "Limiting test file to 16MiB.");
+ maxSizeBits = 24;
+ }
+
+ int fd = ::_open_osfhandle((intptr_t)handle, 0);
+ QVERIFY( -1 != fd );
+ QVERIFY( largeFile.open(fd, QIODevice::WriteOnly | QIODevice::Unbuffered) );
+#else // !Q_OS_WIN32
+ largeFile.setFileName("qt_largefile.tmp");
+ QVERIFY( largeFile.open(QIODevice::WriteOnly | QIODevice::Unbuffered) );
+#endif
+}
+
+void tst_LargeFile::closeSparseFile()
+{
+#if defined(Q_OS_WIN32)
+ int fd = largeFile.handle();
+#endif
+
+ largeFile.close();
+
+#if defined(Q_OS_WIN32)
+ if (-1 != fd)
+ ::_close(fd);
+#endif
+}
+
+void tst_LargeFile::fillFileSparsely()
+{
+ QFETCH( qint64, position );
+ QFETCH( QByteArray, block );
+ QCOMPARE( block.size(), blockSize );
+
+ static int lastKnownGoodIndex = 0;
+ struct ScopeGuard {
+ ScopeGuard(tst_LargeFile* test)
+ : this_(test)
+ , failed(true)
+ {
+ QFETCH( int, index );
+ index_ = index;
+ }
+
+ ~ScopeGuard()
+ {
+ if (failed) {
+ this_->maxSizeBits = lastKnownGoodIndex;
+ QWARN( qPrintable(
+ QString("QFile::error %1: '%2'. Maximum size bits reset to %3.")
+ .arg(this_->largeFile.error())
+ .arg(this_->largeFile.errorString())
+ .arg(this_->maxSizeBits)) );
+ } else
+ lastKnownGoodIndex = qMax<int>(index_, lastKnownGoodIndex);
+ }
+
+ private:
+ tst_LargeFile * const this_;
+ int index_;
+
+ public:
+ bool failed;
+ };
+
+ ScopeGuard resetMaxSizeBitsOnFailure(this);
+
+ QVERIFY( largeFile.seek(position) );
+ QCOMPARE( largeFile.pos(), position );
+
+ QCOMPARE( largeFile.write(block), (qint64)blockSize );
+ QCOMPARE( largeFile.pos(), position + blockSize );
+ QVERIFY( largeFile.flush() );
+
+ resetMaxSizeBitsOnFailure.failed = false;
+}
+
+void tst_LargeFile::fileCreated()
+{
+ QFileInfo info("qt_largefile.tmp");
+
+ QVERIFY( info.exists() );
+ QVERIFY( info.isFile() );
+ QVERIFY( info.size() >= ((qint64)1 << maxSizeBits) + blockSize );
+}
+
+void tst_LargeFile::filePositioning()
+{
+ QFETCH( qint64, position );
+
+ QFile file("qt_largefile.tmp");
+ QVERIFY( file.open(QIODevice::ReadOnly) );
+
+ QVERIFY( file.seek(position) );
+ QCOMPARE( file.pos(), position );
+}
+
+void tst_LargeFile::fdPositioning()
+{
+ QFETCH( qint64, position );
+
+ fd_ = QT_OPEN("qt_largefile.tmp",
+ QT_OPEN_RDONLY | QT_OPEN_LARGEFILE);
+ QVERIFY( -1 != fd_ );
+
+ QFile file;
+ QVERIFY( file.open(fd_, QIODevice::ReadOnly) );
+ QCOMPARE( file.pos(), (qint64)0 );
+ QVERIFY( file.seek(position) );
+ QCOMPARE( file.pos(), position );
+
+ file.close();
+
+ QCOMPARE( QT_LSEEK(fd_, QT_OFF_T(0), SEEK_SET), QT_OFF_T(0) );
+ QCOMPARE( QT_LSEEK(fd_, QT_OFF_T(position), SEEK_SET), QT_OFF_T(position) );
+
+ QVERIFY( file.open(fd_, QIODevice::ReadOnly) );
+ QCOMPARE( QT_LSEEK(fd_, QT_OFF_T(0), SEEK_CUR), QT_OFF_T(position) );
+ QCOMPARE( file.pos(), position );
+ QVERIFY( file.seek(0) );
+ QCOMPARE( file.pos(), (qint64)0 );
+
+ file.close();
+
+ QVERIFY( !QT_CLOSE(fd_) );
+ fd_ = -1;
+}
+
+void tst_LargeFile::streamPositioning()
+{
+ QFETCH( qint64, position );
+
+#if defined(QT_LARGEFILE_SUPPORT) && defined(Q_CC_MSVC) && _MSC_VER < 1400
+ if (position >= (qint64)1 << 31)
+ QSKIP("MSVC 2003 doesn't have 64 bit versions of fseek/ftell.", SkipSingle);
+#endif
+
+ stream_ = QT_FOPEN("qt_largefile.tmp", "rb");
+ QVERIFY( 0 != stream_ );
+
+ QFile file;
+ QVERIFY( file.open(stream_, QIODevice::ReadOnly) );
+ QCOMPARE( file.pos(), (qint64)0 );
+ QVERIFY( file.seek(position) );
+ QCOMPARE( file.pos(), position );
+
+ file.close();
+
+ QVERIFY( !QT_FSEEK(stream_, QT_OFF_T(0), SEEK_SET) );
+ QCOMPARE( QT_FTELL(stream_), QT_OFF_T(0) );
+ QVERIFY( !QT_FSEEK(stream_, QT_OFF_T(position), SEEK_SET) );
+ QCOMPARE( QT_FTELL(stream_), QT_OFF_T(position) );
+
+ QVERIFY( file.open(stream_, QIODevice::ReadOnly) );
+ QCOMPARE( QT_FTELL(stream_), QT_OFF_T(position) );
+ QCOMPARE( file.pos(), position );
+ QVERIFY( file.seek(0) );
+ QCOMPARE( file.pos(), (qint64)0 );
+
+ file.close();
+
+ QVERIFY( !::fclose(stream_) );
+ stream_ = 0;
+}
+
+void tst_LargeFile::openFileForReading()
+{
+ largeFile.setFileName("qt_largefile.tmp");
+ QVERIFY( largeFile.open(QIODevice::ReadOnly) );
+}
+
+void tst_LargeFile::readFile()
+{
+ QFETCH( qint64, position );
+ QFETCH( QByteArray, block );
+ QCOMPARE( block.size(), blockSize );
+
+ QVERIFY( largeFile.size() >= position + blockSize );
+
+ QVERIFY( largeFile.seek(position) );
+ QCOMPARE( largeFile.pos(), position );
+
+ QCOMPARE( largeFile.read(blockSize), block );
+ QCOMPARE( largeFile.pos(), position + blockSize );
+}
+
+void tst_LargeFile::mapFile()
+{
+ QFETCH( qint64, position );
+ QFETCH( QByteArray, block );
+ QCOMPARE( block.size(), blockSize );
+
+ // Keep full block mapped to facilitate OS and/or internal reuse by Qt.
+ uchar *baseAddress = largeFile.map(position, blockSize);
+ QVERIFY( baseAddress );
+ QVERIFY( qEqual(block.begin(), block.end(), reinterpret_cast<char*>(baseAddress)) );
+
+ for (int offset = 1; offset < blockSize; ++offset) {
+ uchar *address = largeFile.map(position + offset, blockSize - offset);
+
+ QVERIFY( address );
+ if ( !qEqual(block.begin() + offset, block.end(), reinterpret_cast<char*>(address)) ) {
+ qDebug() << "Expected:" << block.toHex();
+ qDebug() << "Actual :" << QByteArray(reinterpret_cast<char*>(address), blockSize).toHex();
+ QVERIFY(false);
+ }
+
+ QVERIFY( largeFile.unmap( address ) );
+ }
+
+ QVERIFY( largeFile.unmap( baseAddress ) );
+}
+
+void tst_LargeFile::mapOffsetOverflow()
+{
+ // Out-of-range mappings should fail, and not silently clip the offset
+ for (int i = 50; i < 63; ++i) {
+ uchar *address = 0;
+
+ address = largeFile.map(((qint64)1 << i), blockSize);
+ QVERIFY( !address );
+
+ address = largeFile.map(((qint64)1 << i) + blockSize, blockSize);
+ QVERIFY( !address );
+ }
+}
+
+QTEST_APPLESS_MAIN(tst_LargeFile)
+#include "tst_largefile.moc"
+
diff --git a/tests/auto/qfile/qfile.pro b/tests/auto/qfile/qfile.pro
index eebfcdafe9..33fd2fd7c0 100644
--- a/tests/auto/qfile/qfile.pro
+++ b/tests/auto/qfile/qfile.pro
@@ -5,5 +5,5 @@ wince*:{
SUBDIRS = test stdinprocess
}
-
+!symbian*:SUBDIRS += largefile
diff --git a/tests/auto/qfile/test/test.pro b/tests/auto/qfile/test/test.pro
index 46f63b3aec..faaa927450 100644
--- a/tests/auto/qfile/test/test.pro
+++ b/tests/auto/qfile/test/test.pro
@@ -14,6 +14,7 @@ wince*|symbian {
}
wince* {
+ SOURCES += $$QT_SOURCE_TREE/src/corelib/kernel/qfunctions_wince.cpp # needed for QT_OPEN
DEFINES += SRCDIR=\\\"\\\"
} else:symbian {
# do not define SRCDIR at all
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index 19fbecd239..cf46ce1616 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -79,6 +79,22 @@
# define SRCDIR ""
#endif
+#ifndef STDIN_FILENO
+#define STDIN_FILENO 0
+#endif
+
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+
+#ifndef STDERR_FILENO
+#define STDERR_FILENO 2
+#endif
+
+#ifndef QT_OPEN_BINARY
+#define QT_OPEN_BINARY 0
+#endif
+
Q_DECLARE_METATYPE(QFile::FileError)
//TESTED_CLASS=
@@ -105,6 +121,7 @@ private slots:
void openUnbuffered();
void size_data();
void size();
+ void sizeNoExist();
void seek();
void setSize();
void setSizeSeek();
@@ -187,15 +204,93 @@ private slots:
void mapOpenMode_data();
void mapOpenMode();
+ void openStandardStreams();
+
// --- Task related tests below this line
void task167217();
void openDirectory();
+ void writeNothing();
public:
// disabled this test for the moment... it hangs
void invalidFile_data();
void invalidFile();
+
+private:
+ enum FileType { OpenQFile, OpenFd, OpenStream };
+
+ bool openFd(QFile &file, QIODevice::OpenMode mode)
+ {
+ int fdMode = QT_OPEN_LARGEFILE | QT_OPEN_BINARY;
+
+ // File will be truncated if in Write mode.
+ if (mode & QIODevice::WriteOnly)
+ fdMode |= QT_OPEN_WRONLY | QT_OPEN_TRUNC;
+ if (mode & QIODevice::ReadOnly)
+ fdMode |= QT_OPEN_RDONLY;
+
+ fd_ = QT_OPEN(qPrintable(file.fileName()), fdMode);
+
+ return (-1 != fd_) && file.open(fd_, mode);
+ }
+
+ bool openStream(QFile &file, QIODevice::OpenMode mode)
+ {
+ char const *streamMode = "";
+
+ // File will be truncated if in Write mode.
+ if (mode & QIODevice::WriteOnly)
+ streamMode = "wb+";
+ else if (mode & QIODevice::ReadOnly)
+ streamMode = "rb";
+
+ stream_ = QT_FOPEN(qPrintable(file.fileName()), streamMode);
+
+ return stream_ && file.open(stream_, mode);
+ }
+
+ bool openFile(QFile &file, QIODevice::OpenMode mode, FileType type = OpenQFile)
+ {
+ if (mode & QIODevice::WriteOnly && !file.exists())
+ {
+ // Make sure the file exists
+ QFile createFile(file.fileName());
+ if (!createFile.open(QIODevice::ReadWrite))
+ return false;
+ }
+
+ // Note: openFd and openStream will truncate the file if write mode.
+ switch (type)
+ {
+ case OpenQFile:
+ return file.open(mode);
+
+ case OpenFd:
+ return openFd(file, mode);
+
+ case OpenStream:
+ return openStream(file, mode);
+ }
+
+ return false;
+ }
+
+ void closeFile(QFile &file)
+ {
+ file.close();
+
+ if (-1 != fd_)
+ QT_CLOSE(fd_);
+ if (stream_)
+ ::fclose(stream_);
+
+ fd_ = -1;
+ stream_ = 0;
+ }
+
+ int fd_;
+ FILE *stream_;
};
tst_QFile::tst_QFile()
@@ -211,6 +306,8 @@ void tst_QFile::init()
{
// TODO: Add initialization code here.
// This will be executed immediately before each test is run.
+ fd_ = -1;
+ stream_ = 0;
}
void tst_QFile::cleanup()
@@ -239,6 +336,11 @@ void tst_QFile::cleanup()
QFile::remove("existing-file.txt");
QFile::remove("file-renamed-once.txt");
QFile::remove("file-renamed-twice.txt");
+
+ if (-1 != fd_)
+ QT_CLOSE(fd_);
+ if (stream_)
+ ::fclose(stream_);
}
void tst_QFile::initTestCase()
@@ -438,23 +540,57 @@ void tst_QFile::openUnbuffered()
void tst_QFile::size_data()
{
QTest::addColumn<QString>("filename");
- QTest::addColumn<int>("size");
+ QTest::addColumn<qint64>("size");
- QTest::newRow( "exist01" ) << QString(SRCDIR "testfile.txt") << 245;
- QTest::newRow( "nonexist01" ) << QString("foo.txt") << 0;
+ QTest::newRow( "exist01" ) << QString(SRCDIR "testfile.txt") << (qint64)245;
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
// Only test UNC on Windows./
- QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testsharewritable/test.pri") << 34;
+ QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testsharewritable/test.pri") << (qint64)34;
#endif
}
void tst_QFile::size()
{
QFETCH( QString, filename );
- QFile f( filename );
- QTEST( (int)f.size(), "size" );
- if (f.open(QFile::ReadOnly))
- QTEST( (int)f.size(), "size" );
+ QFETCH( qint64, size );
+
+ {
+ QFile f( filename );
+ QCOMPARE( f.size(), size );
+
+ QVERIFY( f.open(QIODevice::ReadOnly) );
+ QCOMPARE( f.size(), size );
+ }
+
+ {
+ QFile f;
+ int fd = QT_OPEN(filename.toLocal8Bit().constData(), QT_OPEN_RDONLY);
+ QVERIFY( fd != -1 );
+ QVERIFY( f.open(fd, QIODevice::ReadOnly) );
+ QCOMPARE( f.size(), size );
+
+ f.close();
+ QT_CLOSE(fd);
+ }
+
+ {
+ QFile f;
+ FILE* stream = QT_FOPEN(filename.toLocal8Bit().constData(), "rb");
+ QVERIFY( stream );
+ QVERIFY( f.open(stream, QIODevice::ReadOnly) );
+ QCOMPARE( f.size(), size );
+
+ f.close();
+ fclose(stream);
+ }
+}
+
+void tst_QFile::sizeNoExist()
+{
+ QFile file("nonexist01");
+ QVERIFY( !file.exists() );
+ QCOMPARE( file.size(), (qint64)0 );
+ QVERIFY( !file.open(QIODevice::ReadOnly) );
}
void tst_QFile::seek()
@@ -615,6 +751,7 @@ void tst_QFile::readAllStdin()
QProcess process;
process.start("stdinprocess/stdinprocess all");
+ QVERIFY( process.waitForStarted() );
for (int i = 0; i < 5; ++i) {
QTest::qWait(1000);
process.write(lotsOfData);
@@ -1909,53 +2046,71 @@ void tst_QFile::fullDisk()
void tst_QFile::writeLargeDataBlock_data()
{
QTest::addColumn<QString>("fileName");
+ QTest::addColumn<int>("type");
+
+ QTest::newRow("localfile-QFile") << "./largeblockfile.txt" << (int)OpenQFile;
+ QTest::newRow("localfile-Fd") << "./largeblockfile.txt" << (int)OpenFd;
+ QTest::newRow("localfile-Stream") << "./largeblockfile.txt" << (int)OpenStream;
- QTest::newRow("localfile") << QString("./largeblockfile.txt");
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
// Some semi-randomness to avoid collisions.
QTest::newRow("unc file")
<< QString("//" + QtNetworkSettings::winServerName() + "/TESTSHAREWRITABLE/largefile-%1-%2.txt")
.arg(QHostInfo::localHostName())
- .arg(QTime::currentTime().msec());
+ .arg(QTime::currentTime().msec()) << (int)OpenQFile;
#endif
}
-void tst_QFile::writeLargeDataBlock()
+static QByteArray getLargeDataBlock()
{
- QFETCH(QString, fileName);
+ static QByteArray array;
- // Generate a 64MB array with well defined contents.
- QByteArray array;
+ if (array.isNull())
+ {
#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
- int resizeSize = 1024 * 1024; // WinCE and Symbian do not have much space
+ int resizeSize = 1024 * 1024; // WinCE and Symbian do not have much space
#else
- int resizeSize = 64 * 1024 * 1024;
+ int resizeSize = 64 * 1024 * 1024;
#endif
- array.resize(resizeSize);
- for (int i = 0; i < array.size(); ++i)
- array[i] = uchar(i);
+ array.resize(resizeSize);
+ for (int i = 0; i < array.size(); ++i)
+ array[i] = uchar(i);
+ }
- // Remove and open the target file
- QFile file(fileName);
- file.remove();
- if (file.open(QFile::WriteOnly)) {
- QCOMPARE(file.write(array), qint64(array.size()));
- file.close();
- QVERIFY(file.open(QFile::ReadOnly));
- array.clear();
- array = file.readAll();
- file.remove();
- } else {
- QFAIL(qPrintable(QString("Couldn't open file for writing: [%1]").arg(fileName)));
- }
- // Check that we got the right content
- QCOMPARE(array.size(), resizeSize);
- for (int i = 0; i < array.size(); ++i) {
- if (array[i] != char(i)) {
- QFAIL(qPrintable(QString("Wrong contents! Char at %1 = %2, expected %3")
- .arg(i).arg(int(uchar(array[i]))).arg(int(uchar(i)))));
- }
+ return array;
+}
+
+void tst_QFile::writeLargeDataBlock()
+{
+ QFETCH(QString, fileName);
+ QFETCH( int, type );
+
+ QByteArray const originalData = getLargeDataBlock();
+
+ {
+ QFile file(fileName);
+
+ QVERIFY2( openFile(file, QIODevice::WriteOnly, (FileType)type),
+ qPrintable(QString("Couldn't open file for writing: [%1]").arg(fileName)) );
+ QCOMPARE( file.write(originalData), (qint64)originalData.size() );
+ QVERIFY( file.flush() );
+
+ closeFile(file);
+ }
+
+ QByteArray readData;
+
+ {
+ QFile file(fileName);
+
+ QVERIFY2( openFile(file, QIODevice::ReadOnly, (FileType)type),
+ qPrintable(QString("Couldn't open file for reading: [%1]").arg(fileName)) );
+ readData = file.readAll();
+ closeFile(file);
}
+
+ QCOMPARE( readData, originalData );
+ QVERIFY( QFile::remove(fileName) );
}
void tst_QFile::readFromWriteOnlyFile()
@@ -2336,13 +2491,13 @@ void tst_QFile::readEof()
}
QByteArray ret = file.read(10);
- QVERIFY(ret.isNull());
+ QVERIFY(ret.isEmpty());
QVERIFY(file.error() == QFile::NoError);
QVERIFY(file.atEnd());
// Do it again to ensure that we get the same result
ret = file.read(10);
- QVERIFY(ret.isNull());
+ QVERIFY(ret.isEmpty());
QVERIFY(file.error() == QFile::NoError);
QVERIFY(file.atEnd());
}
@@ -2634,5 +2789,69 @@ void tst_QFile::openDirectory()
QVERIFY(!f1.open(QIODevice::ReadOnly|QIODevice::Unbuffered));
}
+void tst_QFile::openStandardStreams()
+{
+ // Using file descriptors
+ {
+ QFile in;
+ in.open(STDIN_FILENO, QIODevice::ReadOnly);
+ QCOMPARE( in.pos(), (qint64)0 );
+ QCOMPARE( in.size(), (qint64)0 );
+ QVERIFY( in.isSequential() );
+ }
+
+ {
+ QFile out;
+ out.open(STDOUT_FILENO, QIODevice::WriteOnly);
+ QCOMPARE( out.pos(), (qint64)0 );
+ QCOMPARE( out.size(), (qint64)0 );
+ QVERIFY( out.isSequential() );
+ }
+
+ {
+ QFile err;
+ err.open(STDERR_FILENO, QIODevice::WriteOnly);
+ QCOMPARE( err.pos(), (qint64)0 );
+ QCOMPARE( err.size(), (qint64)0 );
+ QVERIFY( err.isSequential() );
+ }
+
+ // Using streams
+ {
+ QFile in;
+ in.open(stdin, QIODevice::ReadOnly);
+ QCOMPARE( in.pos(), (qint64)0 );
+ QCOMPARE( in.size(), (qint64)0 );
+ QVERIFY( in.isSequential() );
+ }
+
+ {
+ QFile out;
+ out.open(stdout, QIODevice::WriteOnly);
+ QCOMPARE( out.pos(), (qint64)0 );
+ QCOMPARE( out.size(), (qint64)0 );
+ QVERIFY( out.isSequential() );
+ }
+
+ {
+ QFile err;
+ err.open(stderr, QIODevice::WriteOnly);
+ QCOMPARE( err.pos(), (qint64)0 );
+ QCOMPARE( err.size(), (qint64)0 );
+ QVERIFY( err.isSequential() );
+ }
+}
+
+void tst_QFile::writeNothing()
+{
+ for (int i = 0; i < 3; ++i) {
+ QFile file("file.txt");
+ QVERIFY( openFile(file, QIODevice::WriteOnly | QIODevice::Unbuffered, FileType(i)) );
+ QVERIFY( 0 == file.write((char *)0, 0) );
+ QCOMPARE( file.error(), QFile::NoError );
+ closeFile(file);
+ }
+}
+
QTEST_MAIN(tst_QFile)
#include "tst_qfile.moc"
diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp
index dc2ca61e0f..2f9410bf65 100644
--- a/tests/auto/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp
@@ -140,36 +140,6 @@ private slots:
void clearLineEdit();
void enableChooseButton();
void hooks();
- void listRoot();
- void heapCorruption();
- void deleteDirAndFiles();
- void filter();
- void showNameFilterDetails();
- void unc();
- void emptyUncPath();
-
- void task178897_minimumSize();
- void task180459_lastDirectory_data();
- void task180459_lastDirectory();
- void task227304_proxyOnFileDialog();
- void task227930_correctNavigationKeyboardBehavior();
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- void task226366_lowerCaseHardDriveWindows();
-#endif
- void task233037_selectingDirectory();
- void task235069_hideOnEscape();
- void task236402_dontWatchDeletedDir();
- void task203703_returnProperSeparator();
- void task228844_ensurePreviousSorting();
- void task239706_editableFilterCombo();
- void task218353_relativePaths();
- void task251321_sideBarHiddenEntries();
- void task251341_sideBarRemoveEntries();
- void task254490_selectFileMultipleTimes();
- void task257579_sideBarWithNonCleanUrls();
- void task259105_filtersCornerCases();
-
- void QTBUG4419_lineEditSelectAll();
private:
QByteArray userSettings;
@@ -1345,842 +1315,5 @@ void tst_QFiledialog::hooks()
QCOMPARE(QFileDialog::getSaveFileName(), QString("saveName"));
}
-void tst_QFiledialog::listRoot()
-{
-#if defined QT_BUILD_INTERNAL
- QFileInfoGatherer::fetchedRoot = false;
- QString dir(QDir::currentPath());
- QNonNativeFileDialog fd(0, QString(), dir);
- fd.show();
- QCOMPARE(QFileInfoGatherer::fetchedRoot,false);
- fd.setDirectory("");
- QTest::qWait(500);
- QCOMPARE(QFileInfoGatherer::fetchedRoot,true);
-#endif
-}
-
-void tst_QFiledialog::heapCorruption()
-{
- QVector<QNonNativeFileDialog*> dialogs;
- for (int i=0; i < 10; i++) {
- QNonNativeFileDialog *f = new QNonNativeFileDialog(NULL);
- dialogs << f;
- }
- qDeleteAll(dialogs);
-}
-
-struct FriendlyQFileDialog : public QFileDialog
-{
- friend class tst_QFileDialog;
- Q_DECLARE_PRIVATE(QFileDialog)
-};
-
-
-void tst_QFiledialog::deleteDirAndFiles()
-{
-#if defined QT_BUILD_INTERNAL
- QString tempPath = QDir::tempPath() + '/' + "QFileDialogTestDir4FullDelete";
- QDir dir;
- QVERIFY(dir.mkpath(tempPath + "/foo"));
- QVERIFY(dir.mkpath(tempPath + "/foo/B"));
- QVERIFY(dir.mkpath(tempPath + "/foo/B"));
- QVERIFY(dir.mkpath(tempPath + "/foo/c"));
- QVERIFY(dir.mkpath(tempPath + "/bar"));
- QFile(tempPath + "/foo/a");
- QTemporaryFile *t;
- t = new QTemporaryFile(tempPath + "/foo/aXXXXXX");
- t->setAutoRemove(false);
- t->open();
- t->close();
- delete t;
-
- t = new QTemporaryFile(tempPath + "/foo/B/yXXXXXX");
- t->setAutoRemove(false);
- t->open();
- t->close();
- delete t;
- FriendlyQFileDialog fd;
- fd.setOption(QFileDialog::DontUseNativeDialog);
- fd.d_func()->removeDirectory(tempPath);
- QFileInfo info(tempPath);
- QTest::qWait(2000);
- QVERIFY(!info.exists());
-#endif
-}
-
-void tst_QFiledialog::filter()
-{
- QNonNativeFileDialog fd;
- QAction *hiddenAction = qFindChild<QAction*>(&fd, "qt_show_hidden_action");
- QVERIFY(hiddenAction);
- QVERIFY(hiddenAction->isEnabled());
- QVERIFY(!hiddenAction->isChecked());
- QDir::Filters filter = fd.filter();
- filter |= QDir::Hidden;
- fd.setFilter(filter);
- QVERIFY(hiddenAction->isChecked());
-}
-
-void tst_QFiledialog::showNameFilterDetails()
-{
- QNonNativeFileDialog fd;
- QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo");
- QVERIFY(filters);
- QVERIFY(fd.isNameFilterDetailsVisible());
-
-
- QStringList filterChoices;
- filterChoices << "Image files (*.png *.xpm *.jpg)"
- << "Text files (*.txt)"
- << "Any files (*.*)";
- fd.setFilters(filterChoices);
-
- fd.setNameFilterDetailsVisible(false);
- QCOMPARE(filters->itemText(0), QString("Image files"));
- QCOMPARE(filters->itemText(1), QString("Text files"));
- QCOMPARE(filters->itemText(2), QString("Any files"));
-
- fd.setNameFilterDetailsVisible(true);
- QCOMPARE(filters->itemText(0), filterChoices.at(0));
- QCOMPARE(filters->itemText(1), filterChoices.at(1));
- QCOMPARE(filters->itemText(2), filterChoices.at(2));
-}
-
-void tst_QFiledialog::unc()
-{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- // Only test UNC on Windows./
- QString dir("\\\\" + QtNetworkSettings::winServerName() + "\\testsharewritable");
-#else
- QString dir(QDir::currentPath());
-#endif
- QVERIFY(QFile::exists(dir));
- QNonNativeFileDialog fd(0, QString(), dir);
- QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
- QVERIFY(model);
- QCOMPARE(model->index(fd.directory().absolutePath()), model->index(dir));
-}
-
-void tst_QFiledialog::emptyUncPath()
-{
- QNonNativeFileDialog fd;
- fd.show();
- QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
- QVERIFY(lineEdit);
- // press 'keys' for the input
- for (int i = 0; i < 3 ; ++i)
- QTest::keyPress(lineEdit, Qt::Key_Backslash);
- QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
- QVERIFY(model);
-}
-
-void tst_QFiledialog::task178897_minimumSize()
-{
- QNonNativeFileDialog fd;
- QStringList history = fd.history();
- history << QDir::toNativeSeparators("/verylongdirectory/"
- "aaaaaaaaaabbbbbbbbcccccccccccddddddddddddddeeeeeeeeeeeeffffffffffgggtggggggggghhhhhhhhiiiiiijjjk");
- fd.setHistory(history);
- fd.show();
-
- QSize ms = fd.layout()->minimumSize();
- QVERIFY(ms.width() < 400);
-}
-
-void tst_QFiledialog::task180459_lastDirectory_data()
-{
- QTest::addColumn<QString>("path");
- QTest::addColumn<QString>("directory");
- QTest::addColumn<bool>("isEnabled");
- QTest::addColumn<QString>("result");
-
- QTest::newRow("path+file") << QDir::homePath() + QDir::separator() + "foo"
- << QDir::homePath() << true
- << QDir::homePath() + QDir::separator() + "foo" ;
- QTest::newRow("no path") << ""
- << QDir::tempPath() << false << QString();
- QTest::newRow("file") << "foo"
- << QDir::currentPath() << true
- << QDir::currentPath() + QDir::separator() + "foo" ;
- QTest::newRow("path") << QDir::homePath()
- << QDir::homePath() << false << QString();
- QTest::newRow("path not existing") << "/usr/bin/foo/bar/foo/foo.txt"
- << QDir::tempPath() << true
- << QDir::tempPath() + QDir::separator() + "foo.txt";
-
-}
-
-void tst_QFiledialog::task180459_lastDirectory()
-{
- //first visit the temp directory and close the dialog
- QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", QDir::tempPath());
- QFileSystemModel *model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model");
- QVERIFY(model);
- QCOMPARE(model->index(QDir::tempPath()), model->index(dlg->directory().absolutePath()));
- delete dlg;
-
- QFETCH(QString, path);
- QFETCH(QString, directory);
- QFETCH(bool, isEnabled);
- QFETCH(QString, result);
-
- dlg = new QNonNativeFileDialog(0, "", path);
- model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model");
- QVERIFY(model);
- dlg->setAcceptMode(QFileDialog::AcceptSave);
- QCOMPARE(model->index(dlg->directory().absolutePath()), model->index(directory));
-
- QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(dlg, "buttonBox");
- QPushButton *button = buttonBox->button(QDialogButtonBox::Save);
- QVERIFY(button);
- QCOMPARE(button->isEnabled(), isEnabled);
- if (isEnabled)
- QCOMPARE(model->index(result), model->index(dlg->selectedFiles().first()));
-
- delete dlg;
-}
-
-
-
-class FilterDirModel : public QSortFilterProxyModel
-{
-
-public:
- FilterDirModel(QString root, QObject* parent=0):QSortFilterProxyModel(parent), m_root(root)
- {}
- ~FilterDirModel()
- {};
-
-protected:
- bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
- {
- QModelIndex parentIndex;
- parentIndex = source_parent;
-
- QString path;
- path = parentIndex.child(source_row,0).data(Qt::DisplayRole).toString();
-
- do {
- path = parentIndex.data(Qt::DisplayRole).toString() + "/" + path;
- parentIndex = parentIndex.parent();
- } while(parentIndex.isValid());
-
- QFileInfo info(path);
- if (info.isDir() && (QDir(path) != m_root))
- return false;
- return true;
- }
-
-
-private:
- QDir m_root;
-
-
-};
-
-class sortProxy : public QSortFilterProxyModel
-{
-public:
- sortProxy(QObject *parent) : QSortFilterProxyModel(parent)
- {
- }
-protected:
- virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
- {
- QFileSystemModel * const model = qobject_cast<QFileSystemModel *>(sourceModel());
- const QFileInfo leftInfo(model->fileInfo(left));
- const QFileInfo rightInfo(model->fileInfo(right));
-
- if (leftInfo.isDir() == rightInfo.isDir())
- return(leftInfo.filePath().compare(rightInfo.filePath(),Qt::CaseInsensitive) < 0);
- else if (leftInfo.isDir())
- return(false);
- else
- return(true);
- }
-};
-
-class CrashDialog : public QNonNativeFileDialog
-{
- Q_OBJECT
-
-public:
- CrashDialog(QWidget *parent, const QString &caption, const
-QString &dir, const QString &filter)
- : QNonNativeFileDialog(parent, caption, dir, filter)
- {
- sortProxy *proxyModel = new sortProxy(this);
- setProxyModel(proxyModel);
- }
-};
-
-void tst_QFiledialog::task227304_proxyOnFileDialog()
-{
-#if defined QT_BUILD_INTERNAL
- QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0);
- fd.setProxyModel(new FilterDirModel(QDir::currentPath()));
- fd.show();
- QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
- QTest::qWait(200);
- QTest::keyClick(edit, Qt::Key_T);
- QTest::keyClick(edit, Qt::Key_S);
- QTest::qWait(200);
- QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
-
- CrashDialog *dialog = new CrashDialog(0, QString("crash dialog test"), QDir::homePath(), QString("*") );
- dialog->setFileMode(QFileDialog::ExistingFile);
- dialog->show();
-
- QListView *list = qFindChild<QListView*>(dialog, "listView");
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Down);
- QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
-
- dialog->close();
- fd.close();
-
- QNonNativeFileDialog fd2(0, "I should not crash with a proxy", QDir::tempPath(), 0);
- QSortFilterProxyModel *pm = new QSortFilterProxyModel;
- fd2.setProxyModel(pm);
- fd2.show();
- QSidebar *sidebar = qFindChild<QSidebar*>(&fd2, "sidebar");
- sidebar->setFocus();
- sidebar->selectUrl(QUrl::fromLocalFile(QDir::homePath()));
- QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center());
- QTest::qWait(250);
- //We shouldn't crash
-#endif
-}
-
-void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior()
-{
- QDir current = QDir::currentPath();
- current.mkdir("test");
- current.cd("test");
- QFile file("test/out.txt");
- QFile file2("test/out2.txt");
- QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
- QVERIFY(file2.open(QIODevice::WriteOnly | QIODevice::Text));
- current.cdUp();
- current.mkdir("test2");
- QNonNativeFileDialog fd;
- fd.setViewMode(QFileDialog::List);
- fd.setDirectory(current.absolutePath());
- fd.show();
- QListView *list = qFindChild<QListView*>(&fd, "listView");
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Down);
- QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
- QTest::mouseClick(list->viewport(), Qt::LeftButton,0);
- QTest::keyClick(list, Qt::Key_Down);
- QTest::keyClick(list, Qt::Key_Backspace);
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Down);
- QTest::keyClick(list, Qt::Key_Down);
- QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
- QCOMPARE(fd.isVisible(), true);
- QTest::qWait(200);
- file.close();
- file2.close();
- file.remove();
- file2.remove();
- current.rmdir("test");
- current.rmdir("test2");
-}
-
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
-void tst_QFiledialog::task226366_lowerCaseHardDriveWindows()
-{
- QNonNativeFileDialog fd;
- fd.setDirectory(QDir::root().path());
- fd.show();
- QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
- QToolButton *buttonParent = qFindChild<QToolButton*>(&fd, "toParentButton");
- QTest::qWait(200);
- QTest::mouseClick(buttonParent, Qt::LeftButton,0,QPoint(0,0));
- QTest::qWait(2000);
- QTest::keyClick(edit, Qt::Key_C);
- QTest::qWait(200);
- QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
- QTest::qWait(200);
- QCOMPARE(edit->text(), QString("C:"));
- QTest::qWait(2000);
- //i clear my previous selection in the completer
- QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
- edit->clear();
- QTest::keyClick(edit, (char)(Qt::Key_C | Qt::SHIFT));
- QTest::qWait(200);
- QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
- QCOMPARE(edit->text(), QString("C:"));
-}
-#endif
-
-void tst_QFiledialog::task233037_selectingDirectory()
-{
- QDir current = QDir::currentPath();
- current.mkdir("test");
- QNonNativeFileDialog fd;
- fd.setViewMode(QFileDialog::List);
- fd.setDirectory(current.absolutePath());
- fd.setAcceptMode( QFileDialog::AcceptSave);
- fd.show();
- QListView *list = qFindChild<QListView*>(&fd, "listView");
- QTest::qWait(3000); // Wait for sort to settle (I need a signal).
-#ifdef QT_KEYPAD_NAVIGATION
- list->setEditFocus(true);
-#endif
- QTest::keyClick(list, Qt::Key_Down);
- QTest::qWait(100);
- QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox");
- QPushButton *button = buttonBox->button(QDialogButtonBox::Save);
- QVERIFY(button);
- QCOMPARE(button->isEnabled(), true);
- current.rmdir("test");
-}
-
-void tst_QFiledialog::task235069_hideOnEscape()
-{
- QDir current = QDir::currentPath();
- QNonNativeFileDialog fd;
- fd.setViewMode(QFileDialog::List);
- fd.setDirectory(current.absolutePath());
- fd.setAcceptMode( QFileDialog::AcceptSave);
- fd.show();
- QListView *list = qFindChild<QListView*>(&fd, "listView");
- list->setFocus();
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Escape);
- QCOMPARE(fd.isVisible(), false);
- QNonNativeFileDialog fd2;
- fd2.setDirectory(current.absolutePath());
- fd2.setAcceptMode( QFileDialog::AcceptSave);
- fd2.show();
- QLineEdit *edit = qFindChild<QLineEdit*>(&fd2, "fileNameEdit");
- QTest::keyClick(edit, Qt::Key_Escape);
- QCOMPARE(fd2.isVisible(), false);
-}
-
-void tst_QFiledialog::task236402_dontWatchDeletedDir()
-{
-#if defined QT_BUILD_INTERNAL
- //THIS TEST SHOULD NOT DISPLAY WARNINGS
- QDir current = QDir::currentPath();
- //make sure it is the first on the list
- current.mkdir("aaaaaaaaaa");
- FriendlyQFileDialog fd;
- fd.setViewMode(QFileDialog::List);
- fd.setDirectory(current.absolutePath());
- fd.setAcceptMode( QFileDialog::AcceptSave);
- fd.show();
- QListView *list = qFindChild<QListView*>(&fd, "listView");
- list->setFocus();
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Backspace);
- QTest::keyClick(list, Qt::Key_Down);
- QTest::qWait(200);
- fd.d_func()->removeDirectory(current.absolutePath() + "/aaaaaaaaaa/");
- QTest::qWait(1000);
-#endif
-}
-
-void tst_QFiledialog::task203703_returnProperSeparator()
-{
- QDir current = QDir::currentPath();
- current.mkdir("aaaaaaaaaaaaaaaaaa");
- QNonNativeFileDialog fd;
- fd.setDirectory(current.absolutePath());
- fd.setViewMode(QFileDialog::List);
- fd.setFileMode(QFileDialog::Directory);
- fd.show();
- QTest::qWait(500);
- QListView *list = qFindChild<QListView*>(&fd, "listView");
- list->setFocus();
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(1000);
- QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox");
- QPushButton *button = buttonBox->button(QDialogButtonBox::Cancel);
- QTest::keyClick(button, Qt::Key_Return);
- QTest::qWait(500);
- QString result = fd.selectedFiles().first();
- QVERIFY(result.at(result.count() - 1) != '/');
- QVERIFY(!result.contains('\\'));
- current.rmdir("aaaaaaaaaaaaaaaaaa");
-}
-
-void tst_QFiledialog::task228844_ensurePreviousSorting()
-{
- QDir current = QDir::currentPath();
- current.mkdir("aaaaaaaaaaaaaaaaaa");
- current.cd("aaaaaaaaaaaaaaaaaa");
- current.mkdir("a");
- current.mkdir("b");
- current.mkdir("c");
- current.mkdir("d");
- current.mkdir("e");
- current.mkdir("f");
- current.mkdir("g");
- QTemporaryFile *tempFile = new QTemporaryFile(current.absolutePath() + "/rXXXXXX");
- tempFile->open();
- current.cdUp();
-
- QNonNativeFileDialog fd;
- fd.setDirectory(current.absolutePath());
- fd.setViewMode(QFileDialog::Detail);
- fd.show();
- QTest::qWait(500);
- QTreeView *tree = qFindChild<QTreeView*>(&fd, "treeView");
- tree->header()->setSortIndicator(3,Qt::DescendingOrder);
- QTest::qWait(200);
- QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox");
- QPushButton *button = buttonBox->button(QDialogButtonBox::Open);
- QTest::mouseClick(button, Qt::LeftButton);
- QTest::qWait(500);
-
- QNonNativeFileDialog fd2;
- fd2.setFileMode(QFileDialog::Directory);
- fd2.restoreState(fd.saveState());
- current.cd("aaaaaaaaaaaaaaaaaa");
- fd2.setDirectory(current.absolutePath());
- fd2.show();
- QTest::qWait(500);
- QTreeView *tree2 = qFindChild<QTreeView*>(&fd2, "treeView");
- tree2->setFocus();
-
- QCOMPARE(tree2->rootIndex().data(QFileSystemModel::FilePathRole).toString(),current.absolutePath());
-
- QDialogButtonBox *buttonBox2 = qFindChild<QDialogButtonBox*>(&fd2, "buttonBox");
- QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Open);
- fd2.selectFile("g");
- QTest::mouseClick(button2, Qt::LeftButton);
- QTest::qWait(500);
-
- QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QChar('/') + QLatin1String("g"));
-
- QNonNativeFileDialog fd3(0, "This is a third file dialog", tempFile->fileName());
- fd3.restoreState(fd.saveState());
- fd3.setFileMode(QFileDialog::Directory);
- fd3.show();
- QTest::qWait(500);
- QTreeView *tree3 = qFindChild<QTreeView*>(&fd3, "treeView");
- tree3->setFocus();
-
- QCOMPARE(tree3->rootIndex().data(QFileSystemModel::FilePathRole).toString(), current.absolutePath());
-
- QDialogButtonBox *buttonBox3 = qFindChild<QDialogButtonBox*>(&fd3, "buttonBox");
- QPushButton *button3 = buttonBox3->button(QDialogButtonBox::Open);
- QTest::mouseClick(button3, Qt::LeftButton);
- QTest::qWait(500);
-
- QCOMPARE(fd3.selectedFiles().first(), tempFile->fileName());
-
- current.cd("aaaaaaaaaaaaaaaaaa");
- current.rmdir("a");
- current.rmdir("b");
- current.rmdir("c");
- current.rmdir("d");
- current.rmdir("e");
- current.rmdir("f");
- current.rmdir("g");
- tempFile->close();
- delete tempFile;
- current.cdUp();
- current.rmdir("aaaaaaaaaaaaaaaaaa");
-}
-
-
-void tst_QFiledialog::task239706_editableFilterCombo()
-{
- QNonNativeFileDialog d;
- d.setNameFilter("*.cpp *.h");
-
- d.show();
- QTest::qWait(500);
-
- QList<QComboBox *> comboList = d.findChildren<QComboBox *>();
- QComboBox *filterCombo = 0;
- foreach (QComboBox *combo, comboList) {
- if (combo->objectName() == QString("fileTypeCombo")) {
- filterCombo = combo;
- break;
- }
- }
- Q_ASSERT(filterCombo);
- filterCombo->setEditable(true);
- QTest::mouseClick(filterCombo, Qt::LeftButton);
- QTest::keyPress(filterCombo, Qt::Key_X);
- QTest::keyPress(filterCombo, Qt::Key_Enter); // should not trigger assertion failure
-}
-
-void tst_QFiledialog::task218353_relativePaths()
-{
- QDir appDir = QDir::current();
- QVERIFY(appDir.cdUp() != false);
- QNonNativeFileDialog d(0, "TestDialog", "..");
- QCOMPARE(d.directory().absolutePath(), appDir.absolutePath());
-
- d.setDirectory(appDir.absolutePath() + QLatin1String("/non-existing-directory/../another-non-existing-dir/../"));
- QCOMPARE(d.directory().absolutePath(), appDir.absolutePath());
-
- QDir::current().mkdir("test");
- appDir = QDir::current();
- d.setDirectory(appDir.absolutePath() + QLatin1String("/test/../test/../"));
- QCOMPARE(d.directory().absolutePath(), appDir.absolutePath());
- appDir.rmdir("test");
-}
-
-void tst_QFiledialog::task251321_sideBarHiddenEntries()
-{
-#if defined QT_BUILD_INTERNAL
- QNonNativeFileDialog fd;
-
- QDir current = QDir::currentPath();
- current.mkdir(".hidden");
- QDir hiddenDir = QDir(".hidden");
- hiddenDir.mkdir("subdir");
- QDir hiddenSubDir = QDir(".hidden/subdir");
- hiddenSubDir.mkdir("happy");
- hiddenSubDir.mkdir("happy2");
-
- QList<QUrl> urls;
- urls << QUrl::fromLocalFile(hiddenSubDir.absolutePath());
- fd.setSidebarUrls(urls);
- fd.show();
- QTest::qWait(250);
-
- QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
- sidebar->setFocus();
- sidebar->selectUrl(QUrl::fromLocalFile(hiddenSubDir.absolutePath()));
- QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
- QTest::qWait(250);
-
- QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
- QCOMPARE(model->rowCount(model->index(hiddenSubDir.absolutePath())), 2);
-
- hiddenSubDir.rmdir("happy2");
- hiddenSubDir.rmdir("happy");
- hiddenDir.rmdir("subdir");
- current.rmdir(".hidden");
-#endif
-}
-
-#if defined QT_BUILD_INTERNAL
-class MyQSideBar : public QSidebar
-{
-public :
- MyQSideBar(QWidget *parent = 0) : QSidebar(parent)
- {}
-
- void removeSelection() {
- QList<QModelIndex> idxs = selectionModel()->selectedIndexes();
- QList<QPersistentModelIndex> indexes;
- for (int i = 0; i < idxs.count(); i++)
- indexes.append(idxs.at(i));
-
- for (int i = 0; i < indexes.count(); ++i)
- if (!indexes.at(i).data(Qt::UserRole + 1).toUrl().path().isEmpty())
- model()->removeRow(indexes.at(i).row());
- }
-};
-#endif
-
-void tst_QFiledialog::task251341_sideBarRemoveEntries()
-{
-#if defined QT_BUILD_INTERNAL
- QNonNativeFileDialog fd;
-
- QDir current = QDir::currentPath();
- current.mkdir("testDir");
- QDir testSubDir = QDir("testDir");
-
- QList<QUrl> urls;
- urls << QUrl::fromLocalFile(testSubDir.absolutePath());
- urls << QUrl::fromLocalFile("NotFound");
- fd.setSidebarUrls(urls);
- fd.show();
- QTest::qWait(250);
-
- QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
- sidebar->setFocus();
- //We enter in the first bookmark
- sidebar->selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
- QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
- QTest::qWait(250);
-
- QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
- //There is no file
- QCOMPARE(model->rowCount(model->index(testSubDir.absolutePath())), 0);
- //Icon is not enabled QUrlModel::EnabledRole
- QVariant value = sidebar->model()->index(0, 0).data(Qt::UserRole + 2);
- QCOMPARE(qvariant_cast<bool>(value), true);
-
- sidebar->setFocus();
- //We enter in the second bookmark which is invalid
- sidebar->selectUrl(QUrl::fromLocalFile("NotFound"));
- QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center());
- QTest::qWait(250);
-
- //We fallback to root because the entry in the bookmark is invalid
- QCOMPARE(model->rowCount(model->index("NotFound")), model->rowCount(model->index(model->rootPath())));
- //Icon is not enabled QUrlModel::EnabledRole
- value = sidebar->model()->index(1, 0).data(Qt::UserRole + 2);
- QCOMPARE(qvariant_cast<bool>(value), false);
-
- MyQSideBar mySideBar;
- mySideBar.init(model, urls);
- mySideBar.show();
- mySideBar.selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
- QTest::qWait(1000);
- mySideBar.removeSelection();
-
- //We remove the first entry
- QList<QUrl> expected;
- expected << QUrl::fromLocalFile("NotFound");
- QCOMPARE(mySideBar.urls(), expected);
-
- mySideBar.selectUrl(QUrl::fromLocalFile("NotFound"));
- mySideBar.removeSelection();
-
- //We remove the second entry
- expected.clear();
- QCOMPARE(mySideBar.urls(), expected);
-
- current.rmdir("testDir");
-#endif
-}
-
-void tst_QFiledialog::task254490_selectFileMultipleTimes()
-{
- QString tempPath = QDir::tempPath();
- QTemporaryFile *t;
- t = new QTemporaryFile;
- t->open();
- QNonNativeFileDialog fd(0, "TestFileDialog");
-
- fd.setDirectory(tempPath);
- fd.setViewMode(QFileDialog::List);
- fd.setAcceptMode(QFileDialog::AcceptSave);
- fd.setFileMode(QFileDialog::AnyFile);
-
- //This should select the file in the QFileDialog
- fd.selectFile(t->fileName());
-
- //This should clear the selection and write it into the filename line edit
- fd.selectFile("new_file.txt");
-
- fd.show();
- QTest::qWait(250);
-
- QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
- QVERIFY(lineEdit);
- QCOMPARE(lineEdit->text(),QLatin1String("new_file.txt"));
- QListView *list = qFindChild<QListView*>(&fd, "listView");
- QVERIFY(list);
- QCOMPARE(list->selectionModel()->selectedRows(0).count(), 0);
-
- t->deleteLater();
-}
-
-void tst_QFiledialog::task257579_sideBarWithNonCleanUrls()
-{
-#if defined QT_BUILD_INTERNAL
- QDir tempDir = QDir::temp();
- QLatin1String dirname("autotest_task257579");
- tempDir.rmdir(dirname); //makes sure it doesn't exist any more
- QVERIFY(tempDir.mkdir(dirname));
- QString url = QString::fromLatin1("%1/%2/..").arg(tempDir.absolutePath()).arg(dirname);
- QNonNativeFileDialog fd;
- fd.setSidebarUrls(QList<QUrl>() << QUrl::fromLocalFile(url));
- QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
- QCOMPARE(sidebar->urls().count(), 1);
- QVERIFY(sidebar->urls().first().toLocalFile() != url);
- QCOMPARE(sidebar->urls().first().toLocalFile(), QDir::cleanPath(url));
-
-#ifdef Q_OS_WIN
- QCOMPARE(sidebar->model()->index(0,0).data().toString().toLower(), tempDir.dirName().toLower());
-#else
- QCOMPARE(sidebar->model()->index(0,0).data().toString(), tempDir.dirName());
-#endif
-
- //all tests are finished, we can remove the temporary dir
- QVERIFY(tempDir.rmdir(dirname));
-#endif
-}
-
-void tst_QFiledialog::task259105_filtersCornerCases()
-{
- QNonNativeFileDialog fd(0, "TestFileDialog");
- fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)"));
- fd.setOption(QFileDialog::HideNameFilterDetails, true);
- fd.show();
- QTest::qWait(250);
-
- //Extensions are hidden
- QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo");
- QVERIFY(filters);
- QCOMPARE(filters->currentText(), QLatin1String("All Files!"));
- filters->setCurrentIndex(1);
- QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
-
- //We should have the full names
- fd.setOption(QFileDialog::HideNameFilterDetails, false);
- QTest::qWait(250);
- filters->setCurrentIndex(0);
- QCOMPARE(filters->currentText(), QLatin1String("All Files! (*)"));
- filters->setCurrentIndex(1);
- QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)"));
-
- //Corner case undocumented of the task
- fd.setNameFilter(QLatin1String("\352 (I like cheese) All Files! (*);;Text Files (*.txt)"));
- QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files! (*)"));
- filters->setCurrentIndex(1);
- QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)"));
-
- fd.setOption(QFileDialog::HideNameFilterDetails, true);
- filters->setCurrentIndex(0);
- QTest::qWait(500);
- QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
- filters->setCurrentIndex(1);
- QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
-
- fd.setOption(QFileDialog::HideNameFilterDetails, true);
- filters->setCurrentIndex(0);
- QTest::qWait(500);
- QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
- filters->setCurrentIndex(1);
- QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
-}
-
-void tst_QFiledialog::QTBUG4419_lineEditSelectAll()
-{
- QString tempPath = QDir::tempPath();
- QTemporaryFile *t;
- t = new QTemporaryFile;
- t->open();
- QNonNativeFileDialog fd(0, "TestFileDialog", t->fileName());
-
- fd.setDirectory(tempPath);
- fd.setViewMode(QFileDialog::List);
- fd.setAcceptMode(QFileDialog::AcceptSave);
- fd.setFileMode(QFileDialog::AnyFile);
-
- fd.show();
- QApplication::setActiveWindow(&fd);
- QTest::qWaitForWindowShown(&fd);
- QTRY_COMPARE(fd.isVisible(), true);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
-
- QTest::qWait(250);
- QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
-
- QCOMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName());
- QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName());
-}
-
QTEST_MAIN(tst_QFiledialog)
#include "tst_qfiledialog.moc"
diff --git a/tests/auto/qfiledialog2/qfiledialog2.pro b/tests/auto/qfiledialog2/qfiledialog2.pro
new file mode 100644
index 0000000000..4ebf9775d8
--- /dev/null
+++ b/tests/auto/qfiledialog2/qfiledialog2.pro
@@ -0,0 +1,27 @@
+############################################################
+# Project file for autotest for file qfiledialog.h
+############################################################
+
+load(qttest_p4)
+
+SOURCES += tst_qfiledialog2.cpp
+
+wince*|symbian {
+ addFiles.sources = *.cpp
+ addFiles.path = .
+ filesInDir.sources = *.pro
+ filesInDir.path = someDir
+ DEPLOYMENT += addFiles filesInDir
+}
+
+symbian:TARGET.EPOCHEAPSIZE="0x100 0x1000000"
+symbian:HEADERS += ../../../include/qtgui/private/qfileinfogatherer_p.h
+
+wince* {
+ DEFINES += SRCDIR=\\\"./\\\"
+} else:symbian {
+ TARGET.UID3 = 0xE0340003
+ DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x",""))
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD/\\\"
+}
diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp
new file mode 100644
index 0000000000..83ddd39e11
--- /dev/null
+++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp
@@ -0,0 +1,1044 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 <QtTest/QtTest>
+
+#include <qcoreapplication.h>
+#include <qdebug.h>
+#include <qfiledialog.h>
+#include <qabstractitemdelegate.h>
+#include <qdirmodel.h>
+#include <qitemdelegate.h>
+#include <qlistview.h>
+#include <qcombobox.h>
+#include <qpushbutton.h>
+#include <qtoolbutton.h>
+#include <qtreeview.h>
+#include <qheaderview.h>
+#include <qcompleter.h>
+#include <qaction.h>
+#include <qdialogbuttonbox.h>
+#include <qsortfilterproxymodel.h>
+#include <qlineedit.h>
+#include <qlayout.h>
+#include "../../shared/util.h"
+#include "../../../src/gui/dialogs/qsidebar_p.h"
+#include "../../../src/gui/dialogs/qfilesystemmodel_p.h"
+#include "../../../src/gui/dialogs/qfiledialog_p.h"
+
+#include "../network-settings.h"
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+#if defined(Q_OS_SYMBIAN)
+# define STRINGIFY(x) #x
+# define TOSTRING(x) STRINGIFY(x)
+# define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/"
+#endif
+
+class QNonNativeFileDialog : public QFileDialog
+{
+ Q_OBJECT
+public:
+ QNonNativeFileDialog(QWidget *parent = 0, const QString &caption = QString(), const QString &directory = QString(), const QString &filter = QString())
+ : QFileDialog(parent, caption, directory, filter)
+ {
+ setOption(QFileDialog::DontUseNativeDialog, true);
+ }
+};
+
+class tst_QFiledialog : public QObject
+{
+Q_OBJECT
+
+public:
+ tst_QFiledialog();
+ virtual ~tst_QFiledialog();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void listRoot();
+ void heapCorruption();
+ void deleteDirAndFiles();
+ void filter();
+ void showNameFilterDetails();
+ void unc();
+ void emptyUncPath();
+
+ void task178897_minimumSize();
+ void task180459_lastDirectory_data();
+ void task180459_lastDirectory();
+ void task227304_proxyOnFileDialog();
+ void task227930_correctNavigationKeyboardBehavior();
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ void task226366_lowerCaseHardDriveWindows();
+#endif
+ void task233037_selectingDirectory();
+ void task235069_hideOnEscape();
+ void task236402_dontWatchDeletedDir();
+ void task203703_returnProperSeparator();
+ void task228844_ensurePreviousSorting();
+ void task239706_editableFilterCombo();
+ void task218353_relativePaths();
+ void task251321_sideBarHiddenEntries();
+ void task251341_sideBarRemoveEntries();
+ void task254490_selectFileMultipleTimes();
+ void task257579_sideBarWithNonCleanUrls();
+ void task259105_filtersCornerCases();
+
+ void QTBUG4419_lineEditSelectAll();
+
+private:
+ QByteArray userSettings;
+};
+
+tst_QFiledialog::tst_QFiledialog()
+{
+#if defined(Q_OS_WINCE)
+ qApp->setAutoMaximizeThreshold(-1);
+#endif
+}
+
+tst_QFiledialog::~tst_QFiledialog()
+{
+}
+
+void tst_QFiledialog::init()
+{
+ // Save the developers settings so they don't get mad when their sidebar folders are gone.
+ QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
+ settings.beginGroup(QLatin1String("Qt"));
+ userSettings = settings.value(QLatin1String("filedialog")).toByteArray();
+ settings.remove(QLatin1String("filedialog"));
+
+ // populate it with some default settings
+ QNonNativeFileDialog fd;
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1000);
+#endif
+}
+
+void tst_QFiledialog::cleanup()
+{
+ QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
+ settings.beginGroup(QLatin1String("Qt"));
+ settings.setValue(QLatin1String("filedialog"), userSettings);
+}
+
+void tst_QFiledialog::listRoot()
+{
+#if defined QT_BUILD_INTERNAL
+ QFileInfoGatherer fileInfoGatherer;
+ fileInfoGatherer.start();
+ QTest::qWait(1500);
+
+ QFileInfoGatherer::fetchedRoot = false;
+ QString dir(QDir::currentPath());
+ QNonNativeFileDialog fd(0, QString(), dir);
+ fd.show();
+ QCOMPARE(QFileInfoGatherer::fetchedRoot,false);
+ fd.setDirectory("");
+#ifdef Q_OS_WINCE
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ QCOMPARE(QFileInfoGatherer::fetchedRoot,true);
+#endif
+}
+
+void tst_QFiledialog::heapCorruption()
+{
+ QVector<QNonNativeFileDialog*> dialogs;
+ for (int i=0; i < 10; i++) {
+ QNonNativeFileDialog *f = new QNonNativeFileDialog(NULL);
+ dialogs << f;
+ }
+ qDeleteAll(dialogs);
+}
+
+struct FriendlyQFileDialog : public QFileDialog
+{
+ friend class tst_QFileDialog;
+ Q_DECLARE_PRIVATE(QFileDialog)
+};
+
+
+void tst_QFiledialog::deleteDirAndFiles()
+{
+#if defined QT_BUILD_INTERNAL
+ QString tempPath = QDir::tempPath() + '/' + "QFileDialogTestDir4FullDelete";
+ QDir dir;
+ QVERIFY(dir.mkpath(tempPath + "/foo"));
+ QVERIFY(dir.mkpath(tempPath + "/foo/B"));
+ QVERIFY(dir.mkpath(tempPath + "/foo/B"));
+ QVERIFY(dir.mkpath(tempPath + "/foo/c"));
+ QVERIFY(dir.mkpath(tempPath + "/bar"));
+ QFile(tempPath + "/foo/a");
+ QTemporaryFile *t;
+ t = new QTemporaryFile(tempPath + "/foo/aXXXXXX");
+ t->setAutoRemove(false);
+ t->open();
+ t->close();
+ delete t;
+
+ t = new QTemporaryFile(tempPath + "/foo/B/yXXXXXX");
+ t->setAutoRemove(false);
+ t->open();
+ t->close();
+ delete t;
+ FriendlyQFileDialog fd;
+ fd.setOption(QFileDialog::DontUseNativeDialog);
+ fd.d_func()->removeDirectory(tempPath);
+ QFileInfo info(tempPath);
+ QTest::qWait(2000);
+ QVERIFY(!info.exists());
+#endif
+}
+
+void tst_QFiledialog::filter()
+{
+ QNonNativeFileDialog fd;
+ QAction *hiddenAction = qFindChild<QAction*>(&fd, "qt_show_hidden_action");
+ QVERIFY(hiddenAction);
+ QVERIFY(hiddenAction->isEnabled());
+ QVERIFY(!hiddenAction->isChecked());
+ QDir::Filters filter = fd.filter();
+ filter |= QDir::Hidden;
+ fd.setFilter(filter);
+ QVERIFY(hiddenAction->isChecked());
+}
+
+void tst_QFiledialog::showNameFilterDetails()
+{
+ QNonNativeFileDialog fd;
+ QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo");
+ QVERIFY(filters);
+ QVERIFY(fd.isNameFilterDetailsVisible());
+
+
+ QStringList filterChoices;
+ filterChoices << "Image files (*.png *.xpm *.jpg)"
+ << "Text files (*.txt)"
+ << "Any files (*.*)";
+ fd.setFilters(filterChoices);
+
+ fd.setNameFilterDetailsVisible(false);
+ QCOMPARE(filters->itemText(0), QString("Image files"));
+ QCOMPARE(filters->itemText(1), QString("Text files"));
+ QCOMPARE(filters->itemText(2), QString("Any files"));
+
+ fd.setNameFilterDetailsVisible(true);
+ QCOMPARE(filters->itemText(0), filterChoices.at(0));
+ QCOMPARE(filters->itemText(1), filterChoices.at(1));
+ QCOMPARE(filters->itemText(2), filterChoices.at(2));
+}
+
+void tst_QFiledialog::unc()
+{
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ // Only test UNC on Windows./
+ QString dir("\\\\" + QtNetworkSettings::winServerName() + "\\testsharewritable");
+#else
+ QString dir(QDir::currentPath());
+#endif
+ QVERIFY(QFile::exists(dir));
+ QNonNativeFileDialog fd(0, QString(), dir);
+ QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
+ QVERIFY(model);
+ QCOMPARE(model->index(fd.directory().absolutePath()), model->index(dir));
+}
+
+void tst_QFiledialog::emptyUncPath()
+{
+ QNonNativeFileDialog fd;
+ fd.show();
+ QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
+ QVERIFY(lineEdit);
+ // press 'keys' for the input
+ for (int i = 0; i < 3 ; ++i)
+ QTest::keyPress(lineEdit, Qt::Key_Backslash);
+ QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
+ QVERIFY(model);
+}
+
+void tst_QFiledialog::task178897_minimumSize()
+{
+ QNonNativeFileDialog fd;
+ QSize oldMs = fd.layout()->minimumSize();
+ QStringList history = fd.history();
+ history << QDir::toNativeSeparators("/verylongdirectory/"
+ "aaaaaaaaaabbbbbbbbcccccccccccddddddddddddddeeeeeeeeeeeeffffffffffgggtggggggggghhhhhhhhiiiiiijjjk");
+ fd.setHistory(history);
+ fd.show();
+
+ QSize ms = fd.layout()->minimumSize();
+ QVERIFY(ms.width() <= oldMs.width());
+}
+
+void tst_QFiledialog::task180459_lastDirectory_data()
+{
+ QTest::addColumn<QString>("path");
+ QTest::addColumn<QString>("directory");
+ QTest::addColumn<bool>("isEnabled");
+ QTest::addColumn<QString>("result");
+
+ QTest::newRow("path+file") << QDir::homePath() + QDir::separator() + "foo"
+ << QDir::homePath() << true
+ << QDir::homePath() + QDir::separator() + "foo" ;
+ QTest::newRow("no path") << ""
+ << QDir::tempPath() << false << QString();
+ QTest::newRow("file") << "foo"
+ << QDir::currentPath() << true
+ << QDir::currentPath() + QDir::separator() + "foo" ;
+ QTest::newRow("path") << QDir::homePath()
+ << QDir::homePath() << false << QString();
+ QTest::newRow("path not existing") << "/usr/bin/foo/bar/foo/foo.txt"
+ << QDir::tempPath() << true
+ << QDir::tempPath() + QDir::separator() + "foo.txt";
+
+}
+
+void tst_QFiledialog::task180459_lastDirectory()
+{
+ //first visit the temp directory and close the dialog
+ QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", QDir::tempPath());
+ QFileSystemModel *model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model");
+ QVERIFY(model);
+ QCOMPARE(model->index(QDir::tempPath()), model->index(dlg->directory().absolutePath()));
+ delete dlg;
+
+ QFETCH(QString, path);
+ QFETCH(QString, directory);
+ QFETCH(bool, isEnabled);
+ QFETCH(QString, result);
+
+ dlg = new QNonNativeFileDialog(0, "", path);
+ model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model");
+ QVERIFY(model);
+ dlg->setAcceptMode(QFileDialog::AcceptSave);
+ QCOMPARE(model->index(dlg->directory().absolutePath()), model->index(directory));
+
+ QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(dlg, "buttonBox");
+ QPushButton *button = buttonBox->button(QDialogButtonBox::Save);
+ QVERIFY(button);
+ QCOMPARE(button->isEnabled(), isEnabled);
+ if (isEnabled)
+ QCOMPARE(model->index(result), model->index(dlg->selectedFiles().first()));
+
+ delete dlg;
+}
+
+
+
+class FilterDirModel : public QSortFilterProxyModel
+{
+
+public:
+ FilterDirModel(QString root, QObject* parent=0):QSortFilterProxyModel(parent), m_root(root)
+ {}
+ ~FilterDirModel()
+ {};
+
+protected:
+ bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
+ {
+ QModelIndex parentIndex;
+ parentIndex = source_parent;
+
+ QString path;
+ path = parentIndex.child(source_row,0).data(Qt::DisplayRole).toString();
+
+ do {
+ path = parentIndex.data(Qt::DisplayRole).toString() + "/" + path;
+ parentIndex = parentIndex.parent();
+ } while(parentIndex.isValid());
+
+ QFileInfo info(path);
+ if (info.isDir() && (QDir(path) != m_root))
+ return false;
+ return true;
+ }
+
+
+private:
+ QDir m_root;
+
+
+};
+
+class sortProxy : public QSortFilterProxyModel
+{
+public:
+ sortProxy(QObject *parent) : QSortFilterProxyModel(parent)
+ {
+ }
+protected:
+ virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
+ {
+ QFileSystemModel * const model = qobject_cast<QFileSystemModel *>(sourceModel());
+ const QFileInfo leftInfo(model->fileInfo(left));
+ const QFileInfo rightInfo(model->fileInfo(right));
+
+ if (leftInfo.isDir() == rightInfo.isDir())
+ return(leftInfo.filePath().compare(rightInfo.filePath(),Qt::CaseInsensitive) < 0);
+ else if (leftInfo.isDir())
+ return(false);
+ else
+ return(true);
+ }
+};
+
+class CrashDialog : public QNonNativeFileDialog
+{
+ Q_OBJECT
+
+public:
+ CrashDialog(QWidget *parent, const QString &caption, const
+QString &dir, const QString &filter)
+ : QNonNativeFileDialog(parent, caption, dir, filter)
+ {
+ sortProxy *proxyModel = new sortProxy(this);
+ setProxyModel(proxyModel);
+ }
+};
+
+void tst_QFiledialog::task227304_proxyOnFileDialog()
+{
+#if defined QT_BUILD_INTERNAL
+ QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0);
+ fd.setProxyModel(new FilterDirModel(QDir::currentPath()));
+ fd.show();
+ QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
+ QTest::qWait(200);
+ QTest::keyClick(edit, Qt::Key_T);
+ QTest::keyClick(edit, Qt::Key_S);
+ QTest::qWait(200);
+ QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
+
+ CrashDialog *dialog = new CrashDialog(0, QString("crash dialog test"), QDir::homePath(), QString("*") );
+ dialog->setFileMode(QFileDialog::ExistingFile);
+ dialog->show();
+
+ QListView *list = qFindChild<QListView*>(dialog, "listView");
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::keyClick(list, Qt::Key_Return);
+ QTest::qWait(200);
+
+ dialog->close();
+ fd.close();
+
+ QNonNativeFileDialog fd2(0, "I should not crash with a proxy", QDir::tempPath(), 0);
+ QSortFilterProxyModel *pm = new QSortFilterProxyModel;
+ fd2.setProxyModel(pm);
+ fd2.show();
+ QSidebar *sidebar = qFindChild<QSidebar*>(&fd2, "sidebar");
+ sidebar->setFocus();
+ sidebar->selectUrl(QUrl::fromLocalFile(QDir::homePath()));
+ QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center());
+ QTest::qWait(250);
+ //We shouldn't crash
+#endif
+}
+
+void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior()
+{
+ QDir current = QDir::currentPath();
+ current.mkdir("test");
+ current.cd("test");
+ QFile file("test/out.txt");
+ QFile file2("test/out2.txt");
+ QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
+ QVERIFY(file2.open(QIODevice::WriteOnly | QIODevice::Text));
+ current.cdUp();
+ current.mkdir("test2");
+ QNonNativeFileDialog fd;
+ fd.setViewMode(QFileDialog::List);
+ fd.setDirectory(current.absolutePath());
+ fd.show();
+ QListView *list = qFindChild<QListView*>(&fd, "listView");
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::keyClick(list, Qt::Key_Return);
+ QTest::qWait(200);
+ QTest::mouseClick(list->viewport(), Qt::LeftButton,0);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::keyClick(list, Qt::Key_Backspace);
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::keyClick(list, Qt::Key_Return);
+ QTest::qWait(200);
+ QCOMPARE(fd.isVisible(), true);
+ QTest::qWait(200);
+ file.close();
+ file2.close();
+ file.remove();
+ file2.remove();
+ current.rmdir("test");
+ current.rmdir("test2");
+}
+
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+void tst_QFiledialog::task226366_lowerCaseHardDriveWindows()
+{
+ QNonNativeFileDialog fd;
+ fd.setDirectory(QDir::root().path());
+ fd.show();
+ QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
+ QToolButton *buttonParent = qFindChild<QToolButton*>(&fd, "toParentButton");
+ QTest::qWait(200);
+ QTest::mouseClick(buttonParent, Qt::LeftButton,0,QPoint(0,0));
+ QTest::qWait(2000);
+ QTest::keyClick(edit, Qt::Key_C);
+ QTest::qWait(200);
+ QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
+ QTest::qWait(200);
+ QCOMPARE(edit->text(), QString("C:"));
+ QTest::qWait(2000);
+ //i clear my previous selection in the completer
+ QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
+ edit->clear();
+ QTest::keyClick(edit, (char)(Qt::Key_C | Qt::SHIFT));
+ QTest::qWait(200);
+ QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
+ QCOMPARE(edit->text(), QString("C:"));
+}
+#endif
+
+void tst_QFiledialog::task233037_selectingDirectory()
+{
+ QDir current = QDir::currentPath();
+ current.mkdir("test");
+ QNonNativeFileDialog fd;
+ fd.setViewMode(QFileDialog::List);
+ fd.setDirectory(current.absolutePath());
+ fd.setAcceptMode( QFileDialog::AcceptSave);
+ fd.show();
+ QListView *list = qFindChild<QListView*>(&fd, "listView");
+ QTest::qWait(3000); // Wait for sort to settle (I need a signal).
+#ifdef QT_KEYPAD_NAVIGATION
+ list->setEditFocus(true);
+#endif
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::qWait(100);
+ QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox");
+ QPushButton *button = buttonBox->button(QDialogButtonBox::Save);
+ QVERIFY(button);
+ QCOMPARE(button->isEnabled(), true);
+ current.rmdir("test");
+}
+
+void tst_QFiledialog::task235069_hideOnEscape()
+{
+ QDir current = QDir::currentPath();
+ QNonNativeFileDialog fd;
+ fd.setViewMode(QFileDialog::List);
+ fd.setDirectory(current.absolutePath());
+ fd.setAcceptMode( QFileDialog::AcceptSave);
+ fd.show();
+ QListView *list = qFindChild<QListView*>(&fd, "listView");
+ list->setFocus();
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Escape);
+ QCOMPARE(fd.isVisible(), false);
+ QNonNativeFileDialog fd2;
+ fd2.setDirectory(current.absolutePath());
+ fd2.setAcceptMode( QFileDialog::AcceptSave);
+ fd2.show();
+ QLineEdit *edit = qFindChild<QLineEdit*>(&fd2, "fileNameEdit");
+ QTest::keyClick(edit, Qt::Key_Escape);
+ QCOMPARE(fd2.isVisible(), false);
+}
+
+void tst_QFiledialog::task236402_dontWatchDeletedDir()
+{
+#if defined QT_BUILD_INTERNAL
+ //THIS TEST SHOULD NOT DISPLAY WARNINGS
+ QDir current = QDir::currentPath();
+ //make sure it is the first on the list
+ current.mkdir("aaaaaaaaaa");
+ FriendlyQFileDialog fd;
+ fd.setViewMode(QFileDialog::List);
+ fd.setDirectory(current.absolutePath());
+ fd.setAcceptMode( QFileDialog::AcceptSave);
+ fd.show();
+ QListView *list = qFindChild<QListView*>(&fd, "listView");
+ list->setFocus();
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Return);
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Backspace);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::qWait(200);
+ fd.d_func()->removeDirectory(current.absolutePath() + "/aaaaaaaaaa/");
+ QTest::qWait(1000);
+#endif
+}
+
+void tst_QFiledialog::task203703_returnProperSeparator()
+{
+ QDir current = QDir::currentPath();
+ current.mkdir("aaaaaaaaaaaaaaaaaa");
+ QNonNativeFileDialog fd;
+ fd.setDirectory(current.absolutePath());
+ fd.setViewMode(QFileDialog::List);
+ fd.setFileMode(QFileDialog::Directory);
+ fd.show();
+ QTest::qWait(500);
+ QListView *list = qFindChild<QListView*>(&fd, "listView");
+ list->setFocus();
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Return);
+ QTest::qWait(1000);
+ QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox");
+ QPushButton *button = buttonBox->button(QDialogButtonBox::Cancel);
+ QTest::keyClick(button, Qt::Key_Return);
+ QTest::qWait(500);
+ QString result = fd.selectedFiles().first();
+ QVERIFY(result.at(result.count() - 1) != '/');
+ QVERIFY(!result.contains('\\'));
+ current.rmdir("aaaaaaaaaaaaaaaaaa");
+}
+
+void tst_QFiledialog::task228844_ensurePreviousSorting()
+{
+ QDir current = QDir::currentPath();
+ current.mkdir("aaaaaaaaaaaaaaaaaa");
+ current.cd("aaaaaaaaaaaaaaaaaa");
+ current.mkdir("a");
+ current.mkdir("b");
+ current.mkdir("c");
+ current.mkdir("d");
+ current.mkdir("e");
+ current.mkdir("f");
+ current.mkdir("g");
+ QTemporaryFile *tempFile = new QTemporaryFile(current.absolutePath() + "/rXXXXXX");
+ tempFile->open();
+ current.cdUp();
+
+ QNonNativeFileDialog fd;
+ fd.setDirectory(current.absolutePath());
+ fd.setViewMode(QFileDialog::Detail);
+ fd.show();
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ QTreeView *tree = qFindChild<QTreeView*>(&fd, "treeView");
+ tree->header()->setSortIndicator(3,Qt::DescendingOrder);
+ QTest::qWait(200);
+ QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox");
+ QPushButton *button = buttonBox->button(QDialogButtonBox::Open);
+ QTest::mouseClick(button, Qt::LeftButton);
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ QNonNativeFileDialog fd2;
+ fd2.setFileMode(QFileDialog::Directory);
+ fd2.restoreState(fd.saveState());
+ current.cd("aaaaaaaaaaaaaaaaaa");
+ fd2.setDirectory(current.absolutePath());
+ fd2.show();
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ QTreeView *tree2 = qFindChild<QTreeView*>(&fd2, "treeView");
+ tree2->setFocus();
+
+ QCOMPARE(tree2->rootIndex().data(QFileSystemModel::FilePathRole).toString(),current.absolutePath());
+
+ QDialogButtonBox *buttonBox2 = qFindChild<QDialogButtonBox*>(&fd2, "buttonBox");
+ QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Open);
+ fd2.selectFile("g");
+ QTest::mouseClick(button2, Qt::LeftButton);
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QChar('/') + QLatin1String("g"));
+
+ QNonNativeFileDialog fd3(0, "This is a third file dialog", tempFile->fileName());
+ fd3.restoreState(fd.saveState());
+ fd3.setFileMode(QFileDialog::Directory);
+ fd3.show();
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ QTreeView *tree3 = qFindChild<QTreeView*>(&fd3, "treeView");
+ tree3->setFocus();
+
+ QCOMPARE(tree3->rootIndex().data(QFileSystemModel::FilePathRole).toString(), current.absolutePath());
+
+ QDialogButtonBox *buttonBox3 = qFindChild<QDialogButtonBox*>(&fd3, "buttonBox");
+ QPushButton *button3 = buttonBox3->button(QDialogButtonBox::Open);
+ QTest::mouseClick(button3, Qt::LeftButton);
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ QCOMPARE(fd3.selectedFiles().first(), tempFile->fileName());
+
+ current.cd("aaaaaaaaaaaaaaaaaa");
+ current.rmdir("a");
+ current.rmdir("b");
+ current.rmdir("c");
+ current.rmdir("d");
+ current.rmdir("e");
+ current.rmdir("f");
+ current.rmdir("g");
+ tempFile->close();
+ delete tempFile;
+ current.cdUp();
+ current.rmdir("aaaaaaaaaaaaaaaaaa");
+}
+
+
+void tst_QFiledialog::task239706_editableFilterCombo()
+{
+ QNonNativeFileDialog d;
+ d.setNameFilter("*.cpp *.h");
+
+ d.show();
+ QTest::qWait(500);
+
+ QList<QComboBox *> comboList = d.findChildren<QComboBox *>();
+ QComboBox *filterCombo = 0;
+ foreach (QComboBox *combo, comboList) {
+ if (combo->objectName() == QString("fileTypeCombo")) {
+ filterCombo = combo;
+ break;
+ }
+ }
+ Q_ASSERT(filterCombo);
+ filterCombo->setEditable(true);
+ QTest::mouseClick(filterCombo, Qt::LeftButton);
+ QTest::keyPress(filterCombo, Qt::Key_X);
+ QTest::keyPress(filterCombo, Qt::Key_Enter); // should not trigger assertion failure
+}
+
+void tst_QFiledialog::task218353_relativePaths()
+{
+ QDir appDir = QDir::current();
+ QVERIFY(appDir.cdUp() != false);
+ QNonNativeFileDialog d(0, "TestDialog", "..");
+ QCOMPARE(d.directory().absolutePath(), appDir.absolutePath());
+
+ d.setDirectory(appDir.absolutePath() + QLatin1String("/non-existing-directory/../another-non-existing-dir/../"));
+ QCOMPARE(d.directory().absolutePath(), appDir.absolutePath());
+
+ QDir::current().mkdir("test");
+ appDir = QDir::current();
+ d.setDirectory(appDir.absolutePath() + QLatin1String("/test/../test/../"));
+ QCOMPARE(d.directory().absolutePath(), appDir.absolutePath());
+ appDir.rmdir("test");
+}
+
+void tst_QFiledialog::task251321_sideBarHiddenEntries()
+{
+#if defined QT_BUILD_INTERNAL
+ QNonNativeFileDialog fd;
+
+ QDir current = QDir::currentPath();
+ current.mkdir(".hidden");
+ QDir hiddenDir = QDir(".hidden");
+ hiddenDir.mkdir("subdir");
+ QDir hiddenSubDir = QDir(".hidden/subdir");
+ hiddenSubDir.mkdir("happy");
+ hiddenSubDir.mkdir("happy2");
+
+ QList<QUrl> urls;
+ urls << QUrl::fromLocalFile(hiddenSubDir.absolutePath());
+ fd.setSidebarUrls(urls);
+ fd.show();
+ QTest::qWait(250);
+
+ QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
+ sidebar->setFocus();
+ sidebar->selectUrl(QUrl::fromLocalFile(hiddenSubDir.absolutePath()));
+ QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
+ // give the background processes more time on windows mobile
+#ifdef Q_OS_WINCE
+ QTest::qWait(1000);
+#else
+ QTest::qWait(250);
+#endif
+
+ QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
+ QCOMPARE(model->rowCount(model->index(hiddenSubDir.absolutePath())), 2);
+
+ hiddenSubDir.rmdir("happy2");
+ hiddenSubDir.rmdir("happy");
+ hiddenDir.rmdir("subdir");
+ current.rmdir(".hidden");
+#endif
+}
+
+#if defined QT_BUILD_INTERNAL
+class MyQSideBar : public QSidebar
+{
+public :
+ MyQSideBar(QWidget *parent = 0) : QSidebar(parent)
+ {}
+
+ void removeSelection() {
+ QList<QModelIndex> idxs = selectionModel()->selectedIndexes();
+ QList<QPersistentModelIndex> indexes;
+ for (int i = 0; i < idxs.count(); i++)
+ indexes.append(idxs.at(i));
+
+ for (int i = 0; i < indexes.count(); ++i)
+ if (!indexes.at(i).data(Qt::UserRole + 1).toUrl().path().isEmpty())
+ model()->removeRow(indexes.at(i).row());
+ }
+};
+#endif
+
+void tst_QFiledialog::task251341_sideBarRemoveEntries()
+{
+#if defined QT_BUILD_INTERNAL
+ QNonNativeFileDialog fd;
+
+ QDir current = QDir::currentPath();
+ current.mkdir("testDir");
+ QDir testSubDir = QDir("testDir");
+
+ QList<QUrl> urls;
+ urls << QUrl::fromLocalFile(testSubDir.absolutePath());
+ urls << QUrl::fromLocalFile("NotFound");
+ fd.setSidebarUrls(urls);
+ fd.show();
+ QTest::qWait(250);
+
+ QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
+ sidebar->setFocus();
+ //We enter in the first bookmark
+ sidebar->selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
+ QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
+ QTest::qWait(250);
+
+ QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
+ //There is no file
+ QCOMPARE(model->rowCount(model->index(testSubDir.absolutePath())), 0);
+ //Icon is not enabled QUrlModel::EnabledRole
+ QVariant value = sidebar->model()->index(0, 0).data(Qt::UserRole + 2);
+ QCOMPARE(qvariant_cast<bool>(value), true);
+
+ sidebar->setFocus();
+ //We enter in the second bookmark which is invalid
+ sidebar->selectUrl(QUrl::fromLocalFile("NotFound"));
+ QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center());
+ QTest::qWait(250);
+
+ //We fallback to root because the entry in the bookmark is invalid
+ QCOMPARE(model->rowCount(model->index("NotFound")), model->rowCount(model->index(model->rootPath())));
+ //Icon is not enabled QUrlModel::EnabledRole
+ value = sidebar->model()->index(1, 0).data(Qt::UserRole + 2);
+ QCOMPARE(qvariant_cast<bool>(value), false);
+
+ MyQSideBar mySideBar;
+ mySideBar.init(model, urls);
+ mySideBar.show();
+ mySideBar.selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
+ QTest::qWait(1000);
+ mySideBar.removeSelection();
+
+ //We remove the first entry
+ QList<QUrl> expected;
+ expected << QUrl::fromLocalFile("NotFound");
+ QCOMPARE(mySideBar.urls(), expected);
+
+ mySideBar.selectUrl(QUrl::fromLocalFile("NotFound"));
+ mySideBar.removeSelection();
+
+ //We remove the second entry
+ expected.clear();
+ QCOMPARE(mySideBar.urls(), expected);
+
+ current.rmdir("testDir");
+#endif
+}
+
+void tst_QFiledialog::task254490_selectFileMultipleTimes()
+{
+ QString tempPath = QDir::tempPath();
+ QTemporaryFile *t;
+ t = new QTemporaryFile;
+ t->open();
+ QNonNativeFileDialog fd(0, "TestFileDialog");
+
+ fd.setDirectory(tempPath);
+ fd.setViewMode(QFileDialog::List);
+ fd.setAcceptMode(QFileDialog::AcceptSave);
+ fd.setFileMode(QFileDialog::AnyFile);
+
+ //This should select the file in the QFileDialog
+ fd.selectFile(t->fileName());
+
+ //This should clear the selection and write it into the filename line edit
+ fd.selectFile("new_file.txt");
+
+ fd.show();
+ QTest::qWait(250);
+
+ QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
+ QVERIFY(lineEdit);
+ QCOMPARE(lineEdit->text(),QLatin1String("new_file.txt"));
+ QListView *list = qFindChild<QListView*>(&fd, "listView");
+ QVERIFY(list);
+ QCOMPARE(list->selectionModel()->selectedRows(0).count(), 0);
+
+ t->deleteLater();
+}
+
+void tst_QFiledialog::task257579_sideBarWithNonCleanUrls()
+{
+#if defined QT_BUILD_INTERNAL
+ QDir tempDir = QDir::temp();
+ QLatin1String dirname("autotest_task257579");
+ tempDir.rmdir(dirname); //makes sure it doesn't exist any more
+ QVERIFY(tempDir.mkdir(dirname));
+ QString url = QString::fromLatin1("%1/%2/..").arg(tempDir.absolutePath()).arg(dirname);
+ QNonNativeFileDialog fd;
+ fd.setSidebarUrls(QList<QUrl>() << QUrl::fromLocalFile(url));
+ QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
+ QCOMPARE(sidebar->urls().count(), 1);
+ QVERIFY(sidebar->urls().first().toLocalFile() != url);
+ QCOMPARE(sidebar->urls().first().toLocalFile(), QDir::cleanPath(url));
+
+#ifdef Q_OS_WIN
+ QCOMPARE(sidebar->model()->index(0,0).data().toString().toLower(), tempDir.dirName().toLower());
+#else
+ QCOMPARE(sidebar->model()->index(0,0).data().toString(), tempDir.dirName());
+#endif
+
+ //all tests are finished, we can remove the temporary dir
+ QVERIFY(tempDir.rmdir(dirname));
+#endif
+}
+
+void tst_QFiledialog::task259105_filtersCornerCases()
+{
+ QNonNativeFileDialog fd(0, "TestFileDialog");
+ fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)"));
+ fd.setOption(QFileDialog::HideNameFilterDetails, true);
+ fd.show();
+ QTest::qWait(250);
+
+ //Extensions are hidden
+ QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo");
+ QVERIFY(filters);
+ QCOMPARE(filters->currentText(), QLatin1String("All Files!"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
+
+ //We should have the full names
+ fd.setOption(QFileDialog::HideNameFilterDetails, false);
+ QTest::qWait(250);
+ filters->setCurrentIndex(0);
+ QCOMPARE(filters->currentText(), QLatin1String("All Files! (*)"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)"));
+
+ //Corner case undocumented of the task
+ fd.setNameFilter(QLatin1String("\352 (I like cheese) All Files! (*);;Text Files (*.txt)"));
+ QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files! (*)"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)"));
+
+ fd.setOption(QFileDialog::HideNameFilterDetails, true);
+ filters->setCurrentIndex(0);
+ QTest::qWait(500);
+ QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
+
+ fd.setOption(QFileDialog::HideNameFilterDetails, true);
+ filters->setCurrentIndex(0);
+ QTest::qWait(500);
+ QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
+}
+
+void tst_QFiledialog::QTBUG4419_lineEditSelectAll()
+{
+ QString tempPath = QDir::tempPath();
+ QTemporaryFile *t;
+ t = new QTemporaryFile;
+ t->open();
+ QNonNativeFileDialog fd(0, "TestFileDialog", t->fileName());
+
+ fd.setDirectory(tempPath);
+ fd.setViewMode(QFileDialog::List);
+ fd.setAcceptMode(QFileDialog::AcceptSave);
+ fd.setFileMode(QFileDialog::AnyFile);
+
+ fd.show();
+ QApplication::setActiveWindow(&fd);
+ QTest::qWaitForWindowShown(&fd);
+ QTRY_COMPARE(fd.isVisible(), true);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
+
+ QTest::qWait(250);
+ QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
+
+ QCOMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName());
+ QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName());
+}
+
+QTEST_MAIN(tst_QFiledialog)
+#include "tst_qfiledialog2.moc"
diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 3b2435206b..f2d9017733 100644
--- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -806,21 +806,13 @@ void tst_QFileSystemModel::sort()
myModel->d_func()->disableRecursiveSort = true;
QDir dir(QDir::tempPath());
- dir.mkdir("sortTemp");
- dir.cd("sortTemp");
+ //initialize the randomness
+ qsrand(QDateTime::currentDateTime().toTime_t());
+ QString tempName = QLatin1String("sortTemp.") + QString::number(qrand());
+ dir.mkdir(tempName);
+ dir.cd(tempName);
QTRY_VERIFY(dir.exists());
- //To be sure we clean the dir if it was there before
- QDirIterator it(dir.absolutePath(), QDir::NoDotAndDotDot);
- while(it.hasNext())
- {
- it.next();
- QFileInfo info = it.fileInfo();
- if (info.isDir())
- dir.rmdir(info.fileName());
- else
- QFile::remove(info.absoluteFilePath());
- }
const QString dirPath = dir.absolutePath();
QVERIFY(dir.exists());
@@ -882,11 +874,11 @@ void tst_QFileSystemModel::sort()
delete myModel;
dir.setPath(QDir::tempPath());
- dir.cd("sortTemp");
+ dir.cd(tempName);
tempFile.remove();
tempFile2.remove();
dir.cdUp();
- dir.rmdir("sortTemp");
+ dir.rmdir(tempName);
}
diff --git a/tests/auto/qfont/tst_qfont.cpp b/tests/auto/qfont/tst_qfont.cpp
index fa76e44fee..5622e10de7 100644
--- a/tests/auto/qfont/tst_qfont.cpp
+++ b/tests/auto/qfont/tst_qfont.cpp
@@ -395,6 +395,13 @@ void tst_QFont::compare()
font.setOverline(false);
QVERIFY( font == font2 );
QVERIFY(!(font < font2));
+
+ font.setCapitalization(QFont::SmallCaps);
+ QVERIFY( font != font2 );
+ QCOMPARE(font < font2,!(font2 < font));
+ font.setCapitalization(QFont::MixedCase);
+ QVERIFY( font == font2 );
+ QVERIFY(!(font < font2));
}
#if defined(Q_WS_X11)
diff --git a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp
index 7045c196df..b974ecab53 100644
--- a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp
+++ b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp
@@ -153,7 +153,7 @@ void tst_QFontComboBox::currentFont()
if (oldCurrentFont != box.currentFont()) {
//the signal may be emit twice if there is a foundry into brackets
- QVERIFY(spy0.count() >= 1);
+ QCOMPARE(spy0.count(),1);
}
}
@@ -286,6 +286,10 @@ void tst_QFontComboBox::currentFontChanged()
if (box.model()->rowCount() > 2) {
QTest::keyPress(&box, Qt::Key_Down);
QCOMPARE(spy0.count(), 1);
+
+ QFont f( "Sans Serif" );
+ box.setCurrentFont(f);
+ QCOMPARE(spy0.count(), 2);
} else
qWarning("Not enough fonts installed on test system. Consider adding some");
}
diff --git a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
index 6b2f0fed64..e80f8e00fe 100644
--- a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
+++ b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
@@ -100,6 +100,20 @@ void tst_QFontMetrics::same()
QFontMetrics fm(font);
const QString text = QLatin1String("Some stupid STRING");
QCOMPARE(fm.size(0, text), fm.size(0, text)) ;
+
+ {
+ QImage image;
+ QFontMetrics fm2(font, &image);
+ QString text2 = QLatin1String("Foo Foo");
+ QCOMPARE(fm2.size(0, text2), fm2.size(0, text2)); //used to crash
+ }
+
+ {
+ QImage image;
+ QFontMetricsF fm3(font, &image);
+ QString text2 = QLatin1String("Foo Foo");
+ QCOMPARE(fm3.size(0, text2), fm3.size(0, text2)); //used to crash
+ }
}
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index e036e4bc6d..5dc072d4a1 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -76,13 +76,13 @@ private slots:
void partialGLWidgetUpdates_data();
void partialGLWidgetUpdates();
void glWidgetRendering();
+ void glFBOSimpleRendering();
void glFBORendering();
void multipleFBOInterleavedRendering();
void glFBOUseInGLWidget();
void glPBufferRendering();
void glWidgetReparent();
void glWidgetRenderPixmap();
- void stackedFBOs();
void colormap();
void fboFormat();
void testDontCrashOnDanglingResources();
@@ -118,6 +118,16 @@ public:
void setAutoBufferSwap(bool on) { QGLWidget::setAutoBufferSwap(on); }
};
+static int appDefaultDepth()
+{
+ static int depth = 0;
+ if (depth == 0) {
+ QPixmap pm(1, 1);
+ depth = pm.depth();
+ }
+ return depth;
+}
+
// Using INT_MIN and INT_MAX will cause failures on systems
// where "int" is 64-bit, so use the explicit values instead.
#define TEST_INT_MIN (-2147483647 - 1)
@@ -702,6 +712,79 @@ void tst_QGL::openGLVersionCheck()
#endif //QT_BUILD_INTERNAL
}
+static bool fuzzyComparePixels(const QRgb testPixel, const QRgb refPixel, const char* file, int line, int x = -1, int y = -1)
+{
+ static int maxFuzz = 1;
+ static bool maxFuzzSet = false;
+
+ // On 16 bpp systems, we need to allow for more fuzz:
+ if (!maxFuzzSet) {
+ maxFuzzSet = true;
+ if (appDefaultDepth() < 24)
+ maxFuzz = 32;
+ }
+
+ int redFuzz = qAbs(qRed(testPixel) - qRed(refPixel));
+ int greenFuzz = qAbs(qGreen(testPixel) - qGreen(refPixel));
+ int blueFuzz = qAbs(qBlue(testPixel) - qBlue(refPixel));
+ int alphaFuzz = qAbs(qAlpha(testPixel) - qAlpha(refPixel));
+
+ if (refPixel != 0 && testPixel == 0) {
+ QString msg;
+ if (x >= 0) {
+ msg = QString("Test pixel [%1, %2] is null (black) when it should be (%3,%4,%5,%6)")
+ .arg(x).arg(y)
+ .arg(qRed(refPixel)).arg(qGreen(refPixel)).arg(qBlue(refPixel)).arg(qAlpha(refPixel));
+ } else {
+ msg = QString("Test pixel is null (black) when it should be (%2,%3,%4,%5)")
+ .arg(qRed(refPixel)).arg(qGreen(refPixel)).arg(qBlue(refPixel)).arg(qAlpha(refPixel));
+ }
+
+ QTest::qFail(msg.toLatin1(), file, line);
+ return false;
+ }
+
+ if (redFuzz > maxFuzz || greenFuzz > maxFuzz || blueFuzz > maxFuzz || alphaFuzz > maxFuzz) {
+ QString msg;
+
+ if (x >= 0)
+ msg = QString("Pixel [%1,%2]: ").arg(x).arg(y);
+ else
+ msg = QString("Pixel ");
+
+ msg += QString("Max fuzz (%1) exceeded: (%2,%3,%4,%5) vs (%6,%7,%8,%9)")
+ .arg(maxFuzz)
+ .arg(qRed(testPixel)).arg(qGreen(testPixel)).arg(qBlue(testPixel)).arg(qAlpha(testPixel))
+ .arg(qRed(refPixel)).arg(qGreen(refPixel)).arg(qBlue(refPixel)).arg(qAlpha(refPixel));
+ QTest::qFail(msg.toLatin1(), file, line);
+ return false;
+ }
+ return true;
+}
+
+static void fuzzyCompareImages(const QImage &testImage, const QImage &referenceImage, const char* file, int line)
+{
+ QCOMPARE(testImage.width(), referenceImage.width());
+ QCOMPARE(testImage.height(), referenceImage.height());
+
+ for (int y = 0; y < testImage.height(); y++) {
+ for (int x = 0; x < testImage.width(); x++) {
+ if (!fuzzyComparePixels(testImage.pixel(x, y), referenceImage.pixel(x, y), file, line, x, y)) {
+ // Might as well save the images for easier debugging:
+ referenceImage.save("referenceImage.png");
+ testImage.save("testImage.png");
+ return;
+ }
+ }
+ }
+}
+
+#define QFUZZY_COMPARE_IMAGES(A,B) \
+ fuzzyCompareImages(A, B, __FILE__, __LINE__)
+
+#define QFUZZY_COMPARE_PIXELS(A,B) \
+ fuzzyComparePixels(A, B, __FILE__, __LINE__)
+
class UnclippedWidget : public QWidget
{
public:
@@ -723,6 +806,9 @@ void tst_QGL::graphicsViewClipping()
scene.addWidget(widget)->setPos(0, 0);
QGraphicsView view(&scene);
+#ifdef Q_WS_QWS
+ view.setWindowFlags(Qt::FramelessWindowHint);
+#endif
view.resize(2*size, 2*size);
QGLWidget *viewport = new QGLWidget;
@@ -747,7 +833,7 @@ void tst_QGL::graphicsViewClipping()
p.fillRect(QRect(0, 0, size, size), Qt::black);
p.end();
- QCOMPARE(image, expected);
+ QFUZZY_COMPARE_IMAGES(image, expected);
}
void tst_QGL::partialGLWidgetUpdates_data()
@@ -838,7 +924,7 @@ void tst_QGL::glPBufferRendering()
p.fillRect(32, 32, 64, 64, Qt::blue);
p.end();
- QCOMPARE(fb, reference);
+ QFUZZY_COMPARE_IMAGES(fb, reference);
}
class GLWidget : public QGLWidget
@@ -857,8 +943,8 @@ public:
// This test only ensures it's possible to paint onto a QGLWidget. Full
// paint engine feature testing is way out of scope!
+ p.fillRect(-1, -1, width()+2, height()+2, Qt::red);
- p.fillRect(0, 0, width(), height(), Qt::red);
// No p.end() or swap buffers, should be done automatically
}
@@ -867,6 +953,10 @@ public:
void tst_QGL::glWidgetRendering()
{
GLWidget w;
+#ifdef Q_WS_QWS
+ w.setWindowFlags(Qt::FramelessWindowHint);
+#endif
+ w.setGeometry(100, 100, 200, 200);
w.show();
#ifdef Q_WS_X11
@@ -881,7 +971,37 @@ void tst_QGL::glWidgetRendering()
QImage reference(fb.size(), QImage::Format_RGB32);
reference.fill(0xffff0000);
- QCOMPARE(fb, reference);
+ QFUZZY_COMPARE_IMAGES(fb, reference);
+}
+
+void tst_QGL::glFBOSimpleRendering()
+{
+ if (!QGLFramebufferObject::hasOpenGLFramebufferObjects())
+ QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle);
+
+ QGLWidget glw;
+ glw.makeCurrent();
+
+ // No multisample with combined depth/stencil attachment:
+ QGLFramebufferObjectFormat fboFormat;
+ fboFormat.setAttachment(QGLFramebufferObject::NoAttachment);
+
+ // Don't complicate things by using NPOT:
+ QGLFramebufferObject *fbo = new QGLFramebufferObject(256, 128, fboFormat);
+
+ fbo->bind();
+
+ glClearColor(1.0, 0.0, 0.0, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glFinish();
+
+ QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32);
+ QImage reference(fb.size(), QImage::Format_RGB32);
+ reference.fill(0xffff0000);
+
+ QFUZZY_COMPARE_IMAGES(fb, reference);
+
+ delete fbo;
}
// NOTE: This tests that CombinedDepthStencil attachment works by assuming the
@@ -936,14 +1056,14 @@ void tst_QGL::glFBORendering()
// As we're doing more than trivial painting, we can't just compare to
// an image rendered with raster. Instead, we sample at well-defined
// test-points:
- QCOMPARE(fb.pixel(39, 64), QColor(Qt::red).rgb());
- QCOMPARE(fb.pixel(89, 64), QColor(Qt::red).rgb());
- QCOMPARE(fb.pixel(64, 39), QColor(Qt::blue).rgb());
- QCOMPARE(fb.pixel(64, 89), QColor(Qt::blue).rgb());
-
- QCOMPARE(fb.pixel(167, 39), QColor(Qt::red).rgb());
- QCOMPARE(fb.pixel(217, 39), QColor(Qt::red).rgb());
- QCOMPARE(fb.pixel(192, 64), QColor(Qt::green).rgb());
+ QFUZZY_COMPARE_PIXELS(fb.pixel(39, 64), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(fb.pixel(89, 64), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(fb.pixel(64, 39), QColor(Qt::blue).rgb());
+ QFUZZY_COMPARE_PIXELS(fb.pixel(64, 89), QColor(Qt::blue).rgb());
+
+ QFUZZY_COMPARE_PIXELS(fb.pixel(167, 39), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(fb.pixel(217, 39), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(fb.pixel(192, 64), QColor(Qt::green).rgb());
}
@@ -1034,29 +1154,29 @@ void tst_QGL::multipleFBOInterleavedRendering()
// As we're doing more than trivial painting, we can't just compare to
// an image rendered with raster. Instead, we sample at well-defined
// test-points:
- QCOMPARE(fb1.pixel(39, 64), QColor(Qt::red).rgb());
- QCOMPARE(fb1.pixel(89, 64), QColor(Qt::red).rgb());
- QCOMPARE(fb1.pixel(64, 39), QColor(Qt::blue).rgb());
- QCOMPARE(fb1.pixel(64, 89), QColor(Qt::blue).rgb());
- QCOMPARE(fb1.pixel(167, 39), QColor(Qt::red).rgb());
- QCOMPARE(fb1.pixel(217, 39), QColor(Qt::red).rgb());
- QCOMPARE(fb1.pixel(192, 64), QColor(Qt::green).rgb());
-
- QCOMPARE(fb2.pixel(39, 64), QColor(Qt::green).rgb());
- QCOMPARE(fb2.pixel(89, 64), QColor(Qt::green).rgb());
- QCOMPARE(fb2.pixel(64, 39), QColor(Qt::red).rgb());
- QCOMPARE(fb2.pixel(64, 89), QColor(Qt::red).rgb());
- QCOMPARE(fb2.pixel(167, 39), QColor(Qt::green).rgb());
- QCOMPARE(fb2.pixel(217, 39), QColor(Qt::green).rgb());
- QCOMPARE(fb2.pixel(192, 64), QColor(Qt::blue).rgb());
-
- QCOMPARE(fb3.pixel(39, 64), QColor(Qt::blue).rgb());
- QCOMPARE(fb3.pixel(89, 64), QColor(Qt::blue).rgb());
- QCOMPARE(fb3.pixel(64, 39), QColor(Qt::green).rgb());
- QCOMPARE(fb3.pixel(64, 89), QColor(Qt::green).rgb());
- QCOMPARE(fb3.pixel(167, 39), QColor(Qt::blue).rgb());
- QCOMPARE(fb3.pixel(217, 39), QColor(Qt::blue).rgb());
- QCOMPARE(fb3.pixel(192, 64), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(fb1.pixel(39, 64), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(fb1.pixel(89, 64), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(fb1.pixel(64, 39), QColor(Qt::blue).rgb());
+ QFUZZY_COMPARE_PIXELS(fb1.pixel(64, 89), QColor(Qt::blue).rgb());
+ QFUZZY_COMPARE_PIXELS(fb1.pixel(167, 39), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(fb1.pixel(217, 39), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(fb1.pixel(192, 64), QColor(Qt::green).rgb());
+
+ QFUZZY_COMPARE_PIXELS(fb2.pixel(39, 64), QColor(Qt::green).rgb());
+ QFUZZY_COMPARE_PIXELS(fb2.pixel(89, 64), QColor(Qt::green).rgb());
+ QFUZZY_COMPARE_PIXELS(fb2.pixel(64, 39), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(fb2.pixel(64, 89), QColor(Qt::red).rgb());
+ QFUZZY_COMPARE_PIXELS(fb2.pixel(167, 39), QColor(Qt::green).rgb());
+ QFUZZY_COMPARE_PIXELS(fb2.pixel(217, 39), QColor(Qt::green).rgb());
+ QFUZZY_COMPARE_PIXELS(fb2.pixel(192, 64), QColor(Qt::blue).rgb());
+
+ QFUZZY_COMPARE_PIXELS(fb3.pixel(39, 64), QColor(Qt::blue).rgb());
+ QFUZZY_COMPARE_PIXELS(fb3.pixel(89, 64), QColor(Qt::blue).rgb());
+ QFUZZY_COMPARE_PIXELS(fb3.pixel(64, 39), QColor(Qt::green).rgb());
+ QFUZZY_COMPARE_PIXELS(fb3.pixel(64, 89), QColor(Qt::green).rgb());
+ QFUZZY_COMPARE_PIXELS(fb3.pixel(167, 39), QColor(Qt::blue).rgb());
+ QFUZZY_COMPARE_PIXELS(fb3.pixel(217, 39), QColor(Qt::blue).rgb());
+ QFUZZY_COMPARE_PIXELS(fb3.pixel(192, 64), QColor(Qt::red).rgb());
}
class FBOUseInGLWidget : public QGLWidget
@@ -1076,11 +1196,11 @@ protected:
QPainter fboPainter;
fboPainterBeginOk = fboPainter.begin(fbo);
- fboPainter.fillRect(0, 0, 128, 128, Qt::red);
+ fboPainter.fillRect(-1, -1, 130, 130, Qt::red);
fboPainter.end();
fboImage = fbo->toImage();
- widgetPainter.fillRect(rect(), Qt::blue);
+ widgetPainter.fillRect(-1, -1, width()+2, width()+2, Qt::blue);
delete fbo;
}
@@ -1093,6 +1213,9 @@ void tst_QGL::glFBOUseInGLWidget()
QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle);
FBOUseInGLWidget w;
+#ifdef Q_WS_QWS
+ w.setWindowFlags(Qt::FramelessWindowHint);
+#endif
w.resize(128, 128);
w.show();
@@ -1107,11 +1230,11 @@ void tst_QGL::glFBOUseInGLWidget()
QImage widgetFB = w.grabFrameBuffer(false);
QImage widgetReference(widgetFB.size(), widgetFB.format());
widgetReference.fill(0xff0000ff);
- QCOMPARE(widgetFB, widgetReference);
+ QFUZZY_COMPARE_IMAGES(widgetFB, widgetReference);
QImage fboReference(w.fboImage.size(), w.fboImage.format());
fboReference.fill(0xffff0000);
- QCOMPARE(w.fboImage, fboReference);
+ QFUZZY_COMPARE_IMAGES(w.fboImage, fboReference);
}
void tst_QGL::glWidgetReparent()
@@ -1205,113 +1328,9 @@ void tst_QGL::glWidgetRenderPixmap()
QImage reference(fb.size(), QImage::Format_RGB32);
reference.fill(0xffff0000);
- QCOMPARE(fb, reference);
+ QFUZZY_COMPARE_IMAGES(fb, reference);
}
-
-// When using multiple FBOs at the same time, unbinding one FBO should re-bind the
-// previous. I.e. It should be possible to have a stack of FBOs where pop'ing there
-// top re-binds the one underneeth.
-void tst_QGL::stackedFBOs()
-{
- if (!QGLFramebufferObject::hasOpenGLFramebufferObjects())
- QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle);
-
- QGLWidget glw;
- glw.show();
-
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&glw);
-#endif
- QTest::qWait(200);
-
- glw.makeCurrent();
-
- // No multisample with combined depth/stencil attachment:
- QGLFramebufferObjectFormat fboFormat;
- fboFormat.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
-
- // Don't complicate things by using NPOT:
- QGLFramebufferObject *fbo1 = new QGLFramebufferObject(128, 128, fboFormat);
- QGLFramebufferObject *fbo2 = new QGLFramebufferObject(128, 128, fboFormat);
- QGLFramebufferObject *fbo3 = new QGLFramebufferObject(128, 128, fboFormat);
-
- glClearColor(1.0, 0.0, 1.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- fbo1->bind();
- glClearColor(1.0, 0.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- fbo2->bind();
- glClearColor(0.0, 1.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- fbo3->bind();
- glClearColor(0.0, 0.0, 1.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glScissor(32, 32, 64, 64);
- glEnable(GL_SCISSOR_TEST);
- glClearColor(0.0, 1.0, 1.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- fbo3->release();
-
- // Scissor rect & test should be left untouched by the fbo release...
- glClearColor(0.0, 0.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- fbo2->release();
-
- glClearColor(1.0, 1.0, 1.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- fbo1->release();
-
- glClearColor(1.0, 1.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- glw.swapBuffers();
-
- QImage widgetFB = glw.grabFrameBuffer(false).convertToFormat(QImage::Format_RGB32);
- QImage fb1 = fbo1->toImage().convertToFormat(QImage::Format_RGB32);
- QImage fb2 = fbo2->toImage().convertToFormat(QImage::Format_RGB32);
- QImage fb3 = fbo3->toImage().convertToFormat(QImage::Format_RGB32);
-
- delete fbo1;
- delete fbo2;
- delete fbo3;
-
- QImage widgetReference(widgetFB.size(), widgetFB.format());
- QImage fb1Reference(fb1.size(), fb1.format());
- QImage fb2Reference(fb2.size(), fb2.format());
- QImage fb3Reference(fb3.size(), fb3.format());
-
- QPainter widgetReferencePainter(&widgetReference);
- QPainter fb1ReferencePainter(&fb1Reference);
- QPainter fb2ReferencePainter(&fb2Reference);
- QPainter fb3ReferencePainter(&fb3Reference);
-
- widgetReferencePainter.fillRect(0, 0, widgetReference.width(), widgetReference.height(), Qt::magenta);
- fb1ReferencePainter.fillRect(0, 0, fb1Reference.width(), fb1Reference.height(), Qt::red);
- fb2ReferencePainter.fillRect(0, 0, fb2Reference.width(), fb2Reference.height(), Qt::green);
- fb3ReferencePainter.fillRect(0, 0, fb3Reference.width(), fb3Reference.height(), Qt::blue);
-
- // Flip y-coords to match GL for the widget (which can be any size)
- widgetReferencePainter.fillRect(32, glw.height() - 96, 64, 64, Qt::yellow);
- fb1ReferencePainter.fillRect(32, 32, 64, 64, Qt::white);
- fb2ReferencePainter.fillRect(32, 32, 64, 64, Qt::black);
- fb3ReferencePainter.fillRect(32, 32, 64, 64, Qt::cyan);
-
- widgetReferencePainter.end();
- fb1ReferencePainter.end();
- fb2ReferencePainter.end();
- fb3ReferencePainter.end();
-
- QCOMPARE(widgetFB, widgetReference);
- QCOMPARE(fb1, fb1Reference);
- QCOMPARE(fb2, fb2Reference);
- QCOMPARE(fb3, fb3Reference);
-}
-
-
class ColormapExtended : public QGLColormap
{
public:
@@ -1583,6 +1602,9 @@ protected:
void tst_QGL::replaceClipping()
{
ReplaceClippingGLWidget glw;
+#ifdef Q_WS_QWS
+ glw.setWindowFlags(Qt::FramelessWindowHint);
+#endif
glw.resize(300, 300);
glw.show();
@@ -1598,7 +1620,13 @@ void tst_QGL::replaceClipping()
const QImage widgetFB = glw.grabFrameBuffer(false).convertToFormat(QImage::Format_RGB32);
- QCOMPARE(widgetFB, reference);
+ // Sample pixels in a grid pattern which avoids false failures due to
+ // off-by-one pixel errors on some buggy GL implementations
+ for (int x = 25; x < reference.width(); x += 50) {
+ for (int y = 25; y < reference.width(); y += 50) {
+ QFUZZY_COMPARE_PIXELS(widgetFB.pixel(x, y), reference.pixel(x, y));
+ }
+ }
}
class ClipTestGLWidget : public QGLWidget
@@ -1606,7 +1634,7 @@ class ClipTestGLWidget : public QGLWidget
public:
void paint(QPainter *painter)
{
- painter->fillRect(rect(), Qt::white);
+ painter->fillRect(-1, -1, width()+2, height()+2, Qt::white);
painter->setClipRect(10, 10, width()-20, height()-20);
painter->fillRect(rect(), Qt::cyan);
@@ -1708,6 +1736,9 @@ protected:
void tst_QGL::clipTest()
{
ClipTestGLWidget glw;
+#ifdef Q_WS_QWS
+ glw.setWindowFlags(Qt::FramelessWindowHint);
+#endif
glw.resize(220, 220);
glw.show();
@@ -1723,7 +1754,13 @@ void tst_QGL::clipTest()
const QImage widgetFB = glw.grabFrameBuffer(false).convertToFormat(QImage::Format_RGB32);
- QCOMPARE(widgetFB, reference);
+ // Sample pixels in a grid pattern which avoids false failures due to
+ // off-by-one pixel errors on some buggy GL implementations
+ for (int x = 2; x < reference.width(); x += 5) {
+ for (int y = 2; y < reference.width(); y += 5) {
+ QFUZZY_COMPARE_PIXELS(widgetFB.pixel(x, y), reference.pixel(x, y));
+ }
+ }
}
void tst_QGL::destroyFBOAfterContext()
@@ -1805,12 +1842,14 @@ void tst_QGL::shareRegister()
QVERIFY(qt_shared_test()->value(glw1->context()) == res1);
// Create another context that shares with the first.
+ QVERIFY(!glw1->isSharing());
QGLWidget *glw2 = new QGLWidget(0, glw1);
if (!glw2->isSharing()) {
delete glw2;
delete glw1;
QSKIP("Context sharing is not supported", SkipSingle);
}
+ QVERIFY(glw1->isSharing());
QVERIFY(glw1->context() != glw2->context());
// Check that the first context's resource is also on the second.
@@ -1842,6 +1881,7 @@ void tst_QGL::shareRegister()
// Create a third context, not sharing with the others.
QGLWidget *glw3 = new QGLWidget();
+ QVERIFY(!glw3->isSharing());
// Create a guard on the standalone context.
QGLSharedResourceGuard guard3(glw3->context());
@@ -1890,6 +1930,9 @@ void tst_QGL::shareRegister()
// Delete the first context.
delete glw1;
+ // The second context should no longer register as sharing.
+ QVERIFY(!glw2->isSharing());
+
// The first context's resource should transfer to the second context.
QCOMPARE(tst_QGLResource::deletions, 0);
QVERIFY(qt_shared_test()->value(glw2->context()) == res1);
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 286ea2da98..2ad024fe5e 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -45,10 +45,19 @@
#include <QtGui/qgraphicswidget.h>
#include <QtGui/qgraphicsproxywidget.h>
#include <QtGui/qgraphicsview.h>
+#include <QtGui/qwindowsstyle.h>
class tst_QGraphicsAnchorLayout : public QObject {
Q_OBJECT;
+public:
+ tst_QGraphicsAnchorLayout() : QObject() {
+ hasSimplification = qgetenv("QT_ANCHORLAYOUT_NO_SIMPLIFICATION").isEmpty();
+ }
+
+private:
+ bool hasSimplification;
+
private slots:
void simple();
void simple_center();
@@ -64,15 +73,19 @@ private slots:
void proportionalPreferred();
void example();
void setSpacing();
+ void styleDefaults();
void hardComplexS60();
void stability();
void delete_anchor();
void conflicts();
void sizePolicy();
- void expandingSequence();
- void expandingSequenceFairDistribution();
- void expandingParallel();
void floatConflict();
+ void infiniteMaxSizes();
+ void simplifiableUnfeasible();
+ void simplificationVsOrder();
+ void parallelSimplificationOfCenter();
+ void simplificationVsRedundance();
+ void spacingPersistency();
};
class RectWidget : public QGraphicsWidget
@@ -152,6 +165,15 @@ static bool layoutHasConflict(QGraphicsAnchorLayout *l)
return QGraphicsAnchorLayoutPrivate::get(l)->hasConflicts();
}
+static bool usedSimplex(QGraphicsAnchorLayout *l, Qt::Orientation o)
+{
+ QGraphicsAnchorLayoutPrivate::Orientation oo = (o == Qt::Horizontal) ?
+ QGraphicsAnchorLayoutPrivate::Horizontal :
+ QGraphicsAnchorLayoutPrivate::Vertical;
+
+ return QGraphicsAnchorLayoutPrivate::get(l)->lastCalculationUsedSimplex[oo];
+}
+
void tst_QGraphicsAnchorLayout::simple()
{
QGraphicsWidget *w1 = createItem();
@@ -169,10 +191,16 @@ void tst_QGraphicsAnchorLayout::simple()
l->addAnchors(l, w1, Qt::Vertical);
l->addAnchors(l, w2, Qt::Vertical);
+ QCOMPARE(l->count(), 2);
+
QGraphicsWidget p;
p.setLayout(l);
+ p.adjustSize();
- QCOMPARE(l->count(), 2);
+ if (hasSimplification) {
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
}
void tst_QGraphicsAnchorLayout::simple_center()
@@ -212,6 +240,11 @@ void tst_QGraphicsAnchorLayout::simple_center()
QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
QCOMPARE(layoutMaximumSize, QSizeF(200, 20));
+ if (hasSimplification) {
+ QVERIFY(usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
+
delete p;
}
@@ -309,6 +342,11 @@ void tst_QGraphicsAnchorLayout::layoutDirection()
QCOMPARE(checkReverseDirection(p), true);
+ if (hasSimplification) {
+ QVERIFY(usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
+
delete p;
delete view;
}
@@ -397,6 +435,11 @@ void tst_QGraphicsAnchorLayout::diagonal()
QCOMPARE(e->geometry(), QRectF(100.0, 200.0, 75.0, 100.0));
QCOMPARE(p.size(), testA);
+ if (hasSimplification) {
+ QVERIFY(usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
+
QCOMPARE(checkReverseDirection(&p), true);
c->setMinimumWidth(300);
@@ -473,6 +516,9 @@ void tst_QGraphicsAnchorLayout::parallel()
QCOMPARE(f->geometry(), QRectF(350, 500, 100, 100));
QCOMPARE(p.size(), layoutMinimumSize);
+ if (!hasSimplification)
+ return;
+
p.resize(layoutPreferredSize);
QCOMPARE(a->geometry(), QRectF(0, 0, 150, 100));
QCOMPARE(b->geometry(), QRectF(150, 100, 150, 100));
@@ -493,6 +539,9 @@ void tst_QGraphicsAnchorLayout::parallel()
QCOMPARE(e->geometry(), QRectF(375, 400, 175, 100));
QCOMPARE(f->geometry(), QRectF(550, 500, 200, 100));
QCOMPARE(p.size(), layoutMaximumSize);
+
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
}
void tst_QGraphicsAnchorLayout::parallel2()
@@ -538,6 +587,11 @@ void tst_QGraphicsAnchorLayout::parallel2()
p.resize(layoutMaximumSize);
QCOMPARE(p.size(), layoutMaximumSize);
+
+ if (hasSimplification) {
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
}
void tst_QGraphicsAnchorLayout::snake()
@@ -729,6 +783,8 @@ void tst_QGraphicsAnchorLayout::fairDistribution()
QCOMPARE(layoutMaximumSize, QSizeF(300.0, 400.0));
p.resize(layoutMinimumSize);
+ if (!hasSimplification)
+ QEXPECT_FAIL("", "Without simplification there is no fair distribution.", Abort);
QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 20.0, 100.0));
QCOMPARE(b->geometry(), QRectF(20.0, 100.0, 20.0, 100.0));
QCOMPARE(c->geometry(), QRectF(40.0, 200.0, 20.0, 100.0));
@@ -748,6 +804,11 @@ void tst_QGraphicsAnchorLayout::fairDistribution()
QCOMPARE(c->geometry(), QRectF(200.0, 200.0, 100.0, 100.0));
QCOMPARE(d->geometry(), QRectF(0.0, 300.0, 300.0, 100.0));
QCOMPARE(p.size(), layoutMaximumSize);
+
+ if (hasSimplification) {
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
}
void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections()
@@ -804,6 +865,9 @@ void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections()
QCOMPARE(layoutPreferredSize, QSizeF(220.0, 500.0));
QCOMPARE(layoutMaximumSize, QSizeF(400.0, 500.0));
+ if (!hasSimplification)
+ return;
+
p.resize(layoutMinimumSize);
QCOMPARE(a->size(), b->size());
QCOMPARE(a->size(), c->size());
@@ -824,6 +888,9 @@ void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections()
QCOMPARE(a->size(), d->size());
QCOMPARE(e->size().width(), 4 * a->size().width());
QCOMPARE(p.size(), layoutMaximumSize);
+
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
}
void tst_QGraphicsAnchorLayout::proportionalPreferred()
@@ -886,6 +953,11 @@ void tst_QGraphicsAnchorLayout::proportionalPreferred()
QCOMPARE(a->size().width(), 10 * factor);
QCOMPARE(c->size().width(), 14 * factor);
QCOMPARE(p.size(), QSizeF(12, 400));
+
+ if (hasSimplification) {
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
}
void tst_QGraphicsAnchorLayout::example()
@@ -969,6 +1041,11 @@ void tst_QGraphicsAnchorLayout::example()
QCOMPARE(a->size(), e->size());
QCOMPARE(b->size(), d->size());
QCOMPARE(f->size(), g->size());
+
+ if (hasSimplification) {
+ QVERIFY(usedSimplex(l, Qt::Horizontal));
+ QVERIFY(usedSimplex(l, Qt::Vertical));
+ }
}
void tst_QGraphicsAnchorLayout::setSpacing()
@@ -1031,6 +1108,166 @@ void tst_QGraphicsAnchorLayout::setSpacing()
delete view;
}
+class CustomLayoutStyle : public QWindowsStyle
+{
+ Q_OBJECT
+public:
+ CustomLayoutStyle() : QWindowsStyle()
+ {
+ hspacing = 5;
+ vspacing = 10;
+ }
+
+ virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0,
+ const QWidget * widget = 0 ) const;
+
+ int hspacing;
+ int vspacing;
+
+protected slots:
+ int layoutSpacingImplementation(QSizePolicy::ControlType control1,
+ QSizePolicy::ControlType control2,
+ Qt::Orientation orientation,
+ const QStyleOption *option = 0,
+ const QWidget *widget = 0) const;
+
+};
+
+#define CT1(c) CT2(c, c)
+#define CT2(c1, c2) ((uint)c1 << 16) | (uint)c2
+
+int CustomLayoutStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1,
+ QSizePolicy::ControlType control2,
+ Qt::Orientation orientation,
+ const QStyleOption * /*option = 0*/,
+ const QWidget * /*widget = 0*/) const
+{
+ if (orientation == Qt::Horizontal) {
+ switch (CT2(control1, control2)) {
+ case CT1(QSizePolicy::PushButton):
+ return 2;
+ break;
+ }
+ return 5;
+ } else {
+ switch (CT2(control1, control2)) {
+ case CT1(QSizePolicy::RadioButton):
+ return 2;
+ break;
+
+ }
+ return 10;
+ }
+}
+
+int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * option /*= 0*/,
+ const QWidget * widget /*= 0*/ ) const
+{
+ switch (metric) {
+ case PM_LayoutLeftMargin:
+ return 0;
+ break;
+ case PM_LayoutTopMargin:
+ return 3;
+ break;
+ case PM_LayoutRightMargin:
+ return 6;
+ break;
+ case PM_LayoutBottomMargin:
+ return 9;
+ break;
+ case PM_LayoutHorizontalSpacing:
+ return hspacing;
+ case PM_LayoutVerticalSpacing:
+ return vspacing;
+ break;
+ default:
+ break;
+ }
+ return QWindowsStyle::pixelMetric(metric, option, widget);
+}
+
+void tst_QGraphicsAnchorLayout::styleDefaults()
+{
+ QSizeF min (10, 10);
+ QSizeF pref(20, 20);
+ QSizeF max (50, 50);
+
+ /*
+ create this layout, where a,b have controlType QSizePolicy::RadioButton
+ c,d have controlType QSizePolicy::PushButton:
+ +-------+
+ |a |
+ | b |
+ | c |
+ | d|
+ +-------+
+ */
+ QGraphicsScene scene;
+ QGraphicsWidget *a = createItem(min, pref, max);
+ QSizePolicy spRadioButton = a->sizePolicy();
+ spRadioButton.setControlType(QSizePolicy::RadioButton);
+ a->setSizePolicy(spRadioButton);
+
+ QGraphicsWidget *b = createItem(min, pref, max);
+ b->setSizePolicy(spRadioButton);
+
+ QGraphicsWidget *c = createItem(min, pref, max);
+ QSizePolicy spPushButton = c->sizePolicy();
+ spPushButton.setControlType(QSizePolicy::PushButton);
+ c->setSizePolicy(spPushButton);
+
+ QGraphicsWidget *d = createItem(min, pref, max);
+ d->setSizePolicy(spPushButton);
+
+ QGraphicsWidget *window = new QGraphicsWidget(0, Qt::Window);
+
+ // Test layoutSpacingImplementation
+ CustomLayoutStyle *style = new CustomLayoutStyle;
+ style->hspacing = -1;
+ style->vspacing = -1;
+ window->setStyle(style);
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+
+ l->addCornerAnchors(l, Qt::TopLeftCorner, a, Qt::TopLeftCorner);
+ l->addCornerAnchors(a, Qt::BottomRightCorner, b, Qt::TopLeftCorner);
+ l->addCornerAnchors(b, Qt::BottomRightCorner, c, Qt::TopLeftCorner);
+ l->addCornerAnchors(c, Qt::BottomRightCorner, d, Qt::TopLeftCorner);
+ l->addCornerAnchors(d, Qt::BottomRightCorner, l, Qt::BottomRightCorner);
+
+ window->setLayout(l);
+
+ scene.addItem(window);
+
+ window->show();
+ QGraphicsView *view = new QGraphicsView(&scene);
+ view->resize(200, 200);
+ view->show();
+
+ window->adjustSize();
+ QCOMPARE(a->geometry(), QRectF(0, 3, 20, 20)); //radio
+ QCOMPARE(b->geometry(), QRectF(25, 25, 20, 20)); //radio
+ QCOMPARE(c->geometry(), QRectF(50, 55, 20, 20)); //push
+ QCOMPARE(d->geometry(), QRectF(72, 85, 20, 20)); //push
+ QCOMPARE(l->geometry(), QRectF(0, 0, 98, 114));
+
+
+ // Test pixelMetric(PM_Layout{Horizontal|Vertical}Spacing
+ window->setStyle(0);
+
+ style->hspacing = 1;
+ style->vspacing = 2;
+
+ window->setStyle(style);
+ window->adjustSize();
+ QCOMPARE(a->geometry(), QRectF(0, 3, 20, 20));
+ QCOMPARE(b->geometry(), QRectF(21, 25, 20, 20));
+ QCOMPARE(c->geometry(), QRectF(42, 47, 20, 20));
+ QCOMPARE(d->geometry(), QRectF(63, 69, 20, 20));
+ QCOMPARE(l->geometry(), QRectF(0, 0, 89, 98));
+}
+
+
/*!
Taken from "hard" complex case, found at
https://cwiki.nokia.com/S60QTUI/AnchorLayoutComplexCases
@@ -1225,19 +1462,8 @@ void tst_QGraphicsAnchorLayout::sizePolicy()
l->setSpacing(0);
l->setContentsMargins(0, 0, 0, 0);
- // horizontal
- QGraphicsAnchor *anchor = l->addAnchor(l, Qt::AnchorLeft, w1, Qt::AnchorLeft);
- anchor->setSpacing(0);
-
- anchor = l->addAnchor(w1, Qt::AnchorRight, l, Qt::AnchorRight);
- anchor->setSpacing(0);
-
- // vertical
- anchor = l->addAnchor(l, Qt::AnchorTop, w1, Qt::AnchorTop);
- anchor->setSpacing(0);
-
- anchor = l->addAnchor(w1, Qt::AnchorBottom, l, Qt::AnchorBottom);
- anchor->setSpacing(0);
+ // horizontal and vertical
+ l->addAnchors(l, w1);
QGraphicsWidget *p = new QGraphicsWidget;
p->setLayout(l);
@@ -1287,9 +1513,53 @@ void tst_QGraphicsAnchorLayout::sizePolicy()
w1->adjustSize();
QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(0, 0));
- QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(100, 100));
+ QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(0, 0));
QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(100, 100));
+ // Anchor size policies
+ w1->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ QGraphicsAnchor *anchor = l->anchor(l, Qt::AnchorLeft, w1, Qt::AnchorLeft);
+ anchor->setSpacing(10);
+
+ // QSizePolicy::Minimum
+ anchor->setSizePolicy(QSizePolicy::Minimum);
+ QApplication::processEvents();
+
+ QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(60, 50));
+ QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(60, 50));
+ // The layout has a maximum size of QWIDGETSIZE_MAX, so the result won't exceed that value.
+ QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(QWIDGETSIZE_MAX, 50));
+
+ // QSizePolicy::Preferred
+ anchor->setSizePolicy(QSizePolicy::Preferred);
+ QApplication::processEvents();
+
+ QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(50, 50));
+ QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(60, 50));
+ // The layout has a maximum size of QWIDGETSIZE_MAX, so the result won't exceed that value.
+ QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(QWIDGETSIZE_MAX, 50));
+
+ // QSizePolicy::Maximum
+ anchor->setSizePolicy(QSizePolicy::Maximum);
+ QApplication::processEvents();
+
+ QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(50, 50));
+ QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(60, 50));
+ QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(60, 50));
+
+ // QSizePolicy::Ignored
+ anchor->setSizePolicy(QSizePolicy::Ignored);
+ QApplication::processEvents();
+
+ QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(50, 50));
+ QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(50, 50));
+ QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(QWIDGETSIZE_MAX, 50));
+
+ if (hasSimplification) {
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
+
delete p;
delete view;
}
@@ -1341,248 +1611,285 @@ void tst_QGraphicsAnchorLayout::conflicts()
delete p;
}
-void tst_QGraphicsAnchorLayout::expandingSequence()
+void tst_QGraphicsAnchorLayout::floatConflict()
{
- QSizeF min(10, 10);
- QSizeF pref(50, 10);
- QSizeF max(100, 10);
-
- QGraphicsWidget *a = createItem(min, pref, max, "a");
- QGraphicsWidget *b = createItem(min, pref, max, "b");
+ QGraphicsWidget *a = createItem(QSizeF(80,10), QSizeF(90,10), QSizeF(100,10), "a");
+ QGraphicsWidget *b = createItem(QSizeF(80,10), QSizeF(90,10), QSizeF(100,10), "b");
- b->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ QGraphicsAnchorLayout *l;
+ QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window);
- QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+ l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
+ p->setLayout(l);
+
// horizontal
- setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
- setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft, 0);
- setAnchor(l, b, Qt::AnchorRight, l, Qt::AnchorRight, 0);
+ // with this anchor we have two floating items
+ setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft);
- // vertical
- l->addAnchors(l, a, Qt::Vertical);
- l->addAnchors(l, b, Qt::Vertical);
+ // Just checking if the layout is handling well the removal of floating items
+ delete l->anchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
+ QCOMPARE(l->count(), 0);
+ QCOMPARE(layoutHasConflict(l), false);
- QCOMPARE(l->count(), 2);
+ // setting back the same anchor
+ setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft);
- QGraphicsWidget p;
- p.setLayout(l);
+ // We don't support floating items but they should be counted as if they are in the layout
+ QCOMPARE(l->count(), 2);
+ // Although, we have an invalid situation
+ QCOMPARE(layoutHasConflict(l), true);
- QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize);
- QCOMPARE(layoutMinimumSize.width(), qreal(20));
+ // Semi-floats are supported
+ setAnchor(l, a, Qt::AnchorLeft, l, Qt::AnchorLeft);
+ QCOMPARE(l->count(), 2);
- QSizeF layoutExpandedSize(pref.width() + max.width(), layoutMinimumSize.height());
- p.resize(layoutExpandedSize);
+ // Vertically the layout has floating items. Therefore, we have a conflict
+ QCOMPARE(layoutHasConflict(l), true);
- QCOMPARE(a->geometry().size(), pref);
- QCOMPARE(b->geometry().size(), max);
+ // No more floating items
+ setAnchor(l, b, Qt::AnchorRight, l, Qt::AnchorRight);
+ setAnchor(l, a, Qt::AnchorTop, l, Qt::AnchorTop);
+ setAnchor(l, a, Qt::AnchorBottom, l, Qt::AnchorBottom);
+ setAnchor(l, b, Qt::AnchorTop, l, Qt::AnchorTop);
+ setAnchor(l, b, Qt::AnchorBottom, l, Qt::AnchorBottom);
+ QCOMPARE(layoutHasConflict(l), false);
- QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
- QCOMPARE(layoutMaximumSize.width(), qreal(200));
+ delete p;
}
-void tst_QGraphicsAnchorLayout::expandingSequenceFairDistribution()
+void tst_QGraphicsAnchorLayout::infiniteMaxSizes()
{
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+ l->setContentsMargins(0, 0, 0, 0);
+ l->setSpacing(0);
+
QSizeF min(10, 10);
QSizeF pref(50, 10);
- QSizeF max(100, 10);
+ QSizeF max(QWIDGETSIZE_MAX, 10);
QGraphicsWidget *a = createItem(min, pref, max, "a");
QGraphicsWidget *b = createItem(min, pref, max, "b");
QGraphicsWidget *c = createItem(min, pref, max, "c");
QGraphicsWidget *d = createItem(min, pref, max, "d");
+ QGraphicsWidget *e = createItem(min, pref, max, "e");
- b->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
- d->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
-
- QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
- l->setContentsMargins(0, 0, 0, 0);
-
- // horizontal
+ //<!-- Trunk -->
setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft, 0);
setAnchor(l, b, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
setAnchor(l, c, Qt::AnchorRight, d, Qt::AnchorLeft, 0);
setAnchor(l, d, Qt::AnchorRight, l, Qt::AnchorRight, 0);
+ setAnchor(l, b, Qt::AnchorHorizontalCenter, e, Qt::AnchorLeft, 0);
+ setAnchor(l, e, Qt::AnchorRight, c, Qt::AnchorHorizontalCenter, 0);
- // vertical
- l->addAnchors(l, a, Qt::Vertical);
- l->addAnchors(l, b, Qt::Vertical);
- l->addAnchors(l, c, Qt::Vertical);
- l->addAnchors(l, d, Qt::Vertical);
+ QGraphicsWidget p;
+ p.setLayout(l);
- QCOMPARE(l->count(), 4);
+ QCOMPARE(int(p.effectiveSizeHint(Qt::MaximumSize).width()),
+ QWIDGETSIZE_MAX);
+
+ p.resize(200, 10);
+ QCOMPARE(a->geometry(), QRectF(0, 0, 50, 10));
+ QCOMPARE(b->geometry(), QRectF(50, 0, 50, 10));
+ QCOMPARE(c->geometry(), QRectF(100, 0, 50, 10));
+ QCOMPARE(d->geometry(), QRectF(150, 0, 50, 10));
+
+ p.resize(1000, 10);
+ QCOMPARE(a->geometry(), QRectF(0, 0, 250, 10));
+ QCOMPARE(b->geometry(), QRectF(250, 0, 250, 10));
+ QCOMPARE(c->geometry(), QRectF(500, 0, 250, 10));
+ QCOMPARE(d->geometry(), QRectF(750, 0, 250, 10));
+
+ p.resize(40000, 10);
+ QCOMPARE(a->geometry(), QRectF(0, 0, 10000, 10));
+ QCOMPARE(b->geometry(), QRectF(10000, 0, 10000, 10));
+ QCOMPARE(c->geometry(), QRectF(20000, 0, 10000, 10));
+ QCOMPARE(d->geometry(), QRectF(30000, 0, 10000, 10));
+}
+
+void tst_QGraphicsAnchorLayout::simplifiableUnfeasible()
+{
+ QGraphicsWidget *a = createItem(QSizeF(70.0, 100.0),
+ QSizeF(100.0, 100.0),
+ QSizeF(100.0, 100.0), "A");
+
+ QGraphicsWidget *b = createItem(QSizeF(110.0, 100.0),
+ QSizeF(150.0, 100.0),
+ QSizeF(190.0, 100.0), "B");
+
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+ l->setContentsMargins(0, 0, 0, 0);
+ l->setSpacing(0);
+
+ l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop);
+ l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop);
+ l->addAnchor(b, Qt::AnchorBottom, l, Qt::AnchorBottom);
+
+ l->addAnchors(l, a, Qt::Horizontal);
+ l->addAnchor(l, Qt::AnchorLeft, b, Qt::AnchorLeft);
+ l->addAnchor(b, Qt::AnchorRight, a, Qt::AnchorRight);
+
+ QCOMPARE(l->count(), 2);
QGraphicsWidget p;
p.setLayout(l);
- QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize);
- QCOMPARE(layoutMinimumSize.width(), qreal(40));
-
- QSizeF layoutPartialExpandedSize((2 * pref.width()) + (2 * (pref.width() + 10)),
- layoutMinimumSize.height());
- p.resize(layoutPartialExpandedSize);
+ l->invalidate();
+ QVERIFY(layoutHasConflict(l));
+ if (hasSimplification)
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
- QCOMPARE(a->geometry().size(), pref);
- QCOMPARE(b->geometry().size(), pref + QSizeF(10, 0));
- QCOMPARE(c->geometry().size(), pref);
- QCOMPARE(d->geometry().size(), pref + QSizeF(10, 0));
+ // Now we make it valid
+ b->setMinimumWidth(100);
- QSizeF layoutExpandedSize((2 * pref.width()) + (2 * max.width()),
- layoutMinimumSize.height());
- p.resize(layoutExpandedSize);
+ l->invalidate();
+ QVERIFY(!layoutHasConflict(l));
+ if (hasSimplification)
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
- QCOMPARE(a->geometry().size(), pref);
- QCOMPARE(b->geometry().size(), max);
- QCOMPARE(c->geometry().size(), pref);
- QCOMPARE(d->geometry().size(), max);
+ // And make it invalid again
+ a->setPreferredWidth(70);
+ a->setMaximumWidth(70);
- QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
- QCOMPARE(layoutMaximumSize.width(), qreal(400));
-
- // Now we change D to have more "room for growth" from its preferred size
- // to its maximum size. We expect a proportional fair distribution. Note that
- // this seems to not conform with what QGraphicsLinearLayout does.
- d->setMaximumSize(QSizeF(150, 10));
-
- QSizeF newLayoutExpandedSize((2 * pref.width()) + (max.width() + 150),
- layoutMinimumSize.height());
- p.resize(newLayoutExpandedSize);
-
- QCOMPARE(a->geometry().size(), pref);
- QCOMPARE(b->geometry().size(), max);
- QCOMPARE(c->geometry().size(), pref);
- QCOMPARE(d->geometry().size(), QSizeF(150, 10));
-
- QSizeF newLayoutPartialExpandedSize((4 * pref.width()) + 75,
- layoutMinimumSize.height());
- p.resize(newLayoutPartialExpandedSize);
-
- QCOMPARE(a->geometry().size(), pref);
- QCOMPARE(b->geometry().size(), pref + QSizeF(25, 0));
- QCOMPARE(c->geometry().size(), pref);
- QCOMPARE(d->geometry().size(), pref + QSizeF(50, 0));
+ l->invalidate();
+ QVERIFY(layoutHasConflict(l));
+ if (hasSimplification)
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
}
-void tst_QGraphicsAnchorLayout::expandingParallel()
+/*
+ Test whether the anchor direction can prevent it from
+ being simplificated
+*/
+void tst_QGraphicsAnchorLayout::simplificationVsOrder()
{
QSizeF min(10, 10);
- QSizeF pref(50, 10);
- QSizeF max(100, 10);
- QSizeF max2(100, 50);
+ QSizeF pref(20, 10);
+ QSizeF max(50, 10);
- QGraphicsWidget *a = createItem(min, pref, max, "a");
- QGraphicsWidget *b = createItem(min, pref, max, "b");
- QGraphicsWidget *c = createItem(min, pref, max2, "c");
-
- b->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ QGraphicsWidget *a = createItem(min, pref, max, "A");
+ QGraphicsWidget *b = createItem(min, pref, max, "B");
+ QGraphicsWidget *c = createItem(min, pref, max, "C");
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
- l->setContentsMargins(0, 0, 0, 0);
- // horizontal
- setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
- setAnchor(l, l, Qt::AnchorLeft, b, Qt::AnchorLeft, 0);
+ // Bulk anchors
+ l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
+ l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
+ l->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft);
+ l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight);
- setAnchor(l, a, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
- setAnchor(l, b, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
+ // Problematic anchor, direction b->c
+ QGraphicsAnchor *anchor = l->addAnchor(b, Qt::AnchorRight, c, Qt::AnchorRight);
+ anchor->setSpacing(5);
- setAnchor(l, c, Qt::AnchorRight, l, Qt::AnchorRight, 0);
+ l->effectiveSizeHint(Qt::MinimumSize);
+ if (hasSimplification) {
+ QCOMPARE(usedSimplex(l, Qt::Horizontal), false);
+ QCOMPARE(usedSimplex(l, Qt::Vertical), false);
+ }
- // vertical
- l->addAnchors(l, c, Qt::Vertical);
- setAnchor(l, l, Qt::AnchorTop, a, Qt::AnchorTop, 0);
- setAnchor(l, a, Qt::AnchorBottom, c, Qt::AnchorVerticalCenter, 0);
- setAnchor(l, b, Qt::AnchorTop, c, Qt::AnchorVerticalCenter, 0);
- setAnchor(l, b, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
+ // Problematic anchor, direction c->b
+ delete anchor;
+ anchor = l->addAnchor(c, Qt::AnchorRight, b, Qt::AnchorRight);
+ anchor->setSpacing(5);
+
+ l->effectiveSizeHint(Qt::MinimumSize);
+ if (hasSimplification) {
+ QEXPECT_FAIL("", "Sequential anchors cannot handle children of opposite directions", Continue);
+ QCOMPARE(usedSimplex(l, Qt::Horizontal), false);
+ QCOMPARE(usedSimplex(l, Qt::Vertical), false);
+ }
+}
- QCOMPARE(l->count(), 3);
+void tst_QGraphicsAnchorLayout::parallelSimplificationOfCenter()
+{
+ QSizeF min(10, 10);
+ QSizeF pref(20, 10);
+ QSizeF max(50, 10);
- QGraphicsWidget p;
- p.setLayout(l);
+ QGraphicsWidget *a = createItem(min, pref, max, "A");
+ QGraphicsWidget *b = createItem(min, pref, max, "B");
- QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize);
- QCOMPARE(layoutMinimumSize.width(), qreal(20));
+ QGraphicsWidget parent;
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&parent);
+ l->setContentsMargins(0, 0, 0, 0);
- QSizeF layoutExpandedSize(pref.width() + max.width(), layoutMinimumSize.height());
- p.resize(layoutExpandedSize);
+ l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
+ l->addAnchor(l, Qt::AnchorRight, a, Qt::AnchorRight);
- QCOMPARE(a->geometry().size(), max);
- QCOMPARE(b->geometry().size(), max);
- QCOMPARE(c->geometry().size(), QSizeF(pref.width(), 20));
+ l->addAnchor(a, Qt::AnchorHorizontalCenter, b, Qt::AnchorLeft);
+ l->addAnchor(b, Qt::AnchorRight, a, Qt::AnchorRight);
- QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
- QCOMPARE(layoutMaximumSize.width(), qreal(200));
+ parent.resize(l->effectiveSizeHint(Qt::PreferredSize));
- //
- // Change the parallel connection to a paralell connection of b with a center...
- //
- QGraphicsAnchor *anchor = l->anchor(b, Qt::AnchorRight, c, Qt::AnchorLeft);
- delete anchor;
- setAnchor(l, b, Qt::AnchorRight, a, Qt::AnchorHorizontalCenter, 0);
- a->setMaximumSize(max + QSizeF(100, 0));
+ QCOMPARE(a->geometry(), QRectF(0, 0, 40, 10));
+ QCOMPARE(b->geometry(), QRectF(20, 0, 20, 10));
+}
- QSizeF newLayoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize);
- QCOMPARE(newLayoutMinimumSize.width(), qreal(30));
+/*
+ Test whether redundance of anchors (in this case by using addCornerAnchors), will
+ prevent simplification to take place when it should.
+*/
+void tst_QGraphicsAnchorLayout::simplificationVsRedundance()
+{
+ QSizeF min(10, 10);
+ QSizeF pref(20, 10);
+ QSizeF max(50, 30);
- QSizeF newLayoutExpandedSize = layoutExpandedSize + QSizeF(100, 0);
- p.resize(newLayoutExpandedSize);
+ QGraphicsWidget *a = createItem(min, pref, max, "A");
+ QGraphicsWidget *b = createItem(min, pref, max, "B");
+ QGraphicsWidget *c = createItem(min, pref, max, "C");
- QCOMPARE(a->geometry().size(), max + QSizeF(100, 0));
- QCOMPARE(b->geometry().size(), max);
- QCOMPARE(c->geometry().size(), QSizeF(pref.width(), 20));
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
- QSizeF newLayoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
- QCOMPARE(newLayoutMaximumSize.width(), qreal(300));
-}
+ l->addCornerAnchors(a, Qt::TopLeftCorner, l, Qt::TopLeftCorner);
+ l->addCornerAnchors(a, Qt::BottomLeftCorner, l, Qt::BottomLeftCorner);
-void tst_QGraphicsAnchorLayout::floatConflict()
-{
- QGraphicsWidget *a = createItem(QSizeF(80,10), QSizeF(90,10), QSizeF(100,10), "a");
- QGraphicsWidget *b = createItem(QSizeF(80,10), QSizeF(90,10), QSizeF(100,10), "b");
+ l->addCornerAnchors(b, Qt::TopLeftCorner, a, Qt::TopRightCorner);
+ l->addCornerAnchors(b, Qt::TopRightCorner, l, Qt::TopRightCorner);
- QGraphicsAnchorLayout *l;
- QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window);
+ l->addCornerAnchors(c, Qt::TopLeftCorner, b, Qt::BottomLeftCorner);
+ l->addCornerAnchors(c, Qt::BottomLeftCorner, a, Qt::BottomRightCorner);
+ l->addCornerAnchors(c, Qt::TopRightCorner, b, Qt::BottomRightCorner);
+ l->addCornerAnchors(c, Qt::BottomRightCorner, l, Qt::BottomRightCorner);
- l = new QGraphicsAnchorLayout;
- l->setContentsMargins(0, 0, 0, 0);
+ l->effectiveSizeHint(Qt::MinimumSize);
- p->setLayout(l);
+ QCOMPARE(layoutHasConflict(l), false);
- // horizontal
- // with this anchor we have two floating items
- setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft);
+ if (!hasSimplification)
+ QEXPECT_FAIL("", "Test depends on simplification.", Abort);
- // Just checking if the layout is handling well the removal of floating items
- delete l->anchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
- QCOMPARE(l->count(), 0);
- QCOMPARE(layoutHasConflict(l), false);
+ QCOMPARE(usedSimplex(l, Qt::Horizontal), false);
+ QCOMPARE(usedSimplex(l, Qt::Vertical), false);
+}
- // setting back the same anchor
- setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft);
+/*
+ Avoid regression where the saved prefSize would be lost. This was
+ solved by saving the original spacing in the QGraphicsAnchorPrivate class
+*/
+void tst_QGraphicsAnchorLayout::spacingPersistency()
+{
+ QGraphicsWidget w;
+ QGraphicsWidget *a = createItem();
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&w);
- // We don't support floating items but they should be counted as if they are in the layout
- QCOMPARE(l->count(), 2);
- // Although, we have an invalid situation
- QCOMPARE(layoutHasConflict(l), true);
+ l->addAnchors(l, a, Qt::Horizontal);
+ QGraphicsAnchor *anchor = l->anchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
- // Semi-floats are supported
- setAnchor(l, a, Qt::AnchorLeft, l, Qt::AnchorLeft);
- QCOMPARE(l->count(), 2);
+ anchor->setSpacing(-30);
+ QCOMPARE(anchor->spacing(), -30.0);
- // Vertically the layout has floating items. Therefore, we have a conflict
- QCOMPARE(layoutHasConflict(l), true);
+ anchor->setSpacing(30);
+ QCOMPARE(anchor->spacing(), 30.0);
- // No more floating items
- setAnchor(l, b, Qt::AnchorRight, l, Qt::AnchorRight);
- setAnchor(l, a, Qt::AnchorTop, l, Qt::AnchorTop);
- setAnchor(l, a, Qt::AnchorBottom, l, Qt::AnchorBottom);
- setAnchor(l, b, Qt::AnchorTop, l, Qt::AnchorTop);
- setAnchor(l, b, Qt::AnchorBottom, l, Qt::AnchorBottom);
- QCOMPARE(layoutHasConflict(l), false);
+ anchor->setSizePolicy(QSizePolicy::Ignored);
+ w.effectiveSizeHint(Qt::PreferredSize);
- delete p;
+ QCOMPARE(anchor->spacing(), 30.0);
}
QTEST_MAIN(tst_QGraphicsAnchorLayout)
diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index 148b2c8905..bca59c3578 100644
--- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -162,10 +162,14 @@ Q_DECLARE_METATYPE(AnchorItemSizeHintList)
class TestWidget : public QGraphicsWidget
{
public:
- inline TestWidget(QGraphicsItem *parent = 0)
+ inline TestWidget(QGraphicsItem *parent = 0, const QString &name = QString())
: QGraphicsWidget(parent)
{
setContentsMargins( 0,0,0,0 );
+ if (name.isEmpty())
+ setData(0, QString::fromAscii("w%1").arg(int(this)));
+ else
+ setData(0, name);
}
~TestWidget()
{
@@ -419,7 +423,6 @@ void tst_QGraphicsAnchorLayout1::testAddAndRemoveAnchor()
layout->setAnchor(layout, Qt::AnchorLeft, widget5, Qt::AnchorTop, 10);
QCOMPARE( layout->count(), 4 );
- // ###: NOT SUPPORTED
// anchor two edges of a widget (to define width / height)
QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself");
layout->setAnchor(widget5, Qt::AnchorLeft, widget5, Qt::AnchorRight, 10);
@@ -435,7 +438,7 @@ void tst_QGraphicsAnchorLayout1::testAddAndRemoveAnchor()
layout->removeAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft);
QCOMPARE( layout->count(), 4 );
- QCOMPARE( (int)widget1->parentLayoutItem(), 0 );
+ QVERIFY( !widget1->parentLayoutItem() );
// test that item is not removed from layout if other anchors remain set
layout->setAnchor(widget2, Qt::AnchorLeft, widget3, Qt::AnchorRight, 10);
@@ -516,8 +519,6 @@ void tst_QGraphicsAnchorLayout1::testIsValid()
widget->setLayout(layout);
widget->setGeometry(QRectF(0,0,100,100));
- // ###: this shall change once isValid() is ready
- // QCOMPARE(layout->isValid(), false);
QCOMPARE(layout->isValid(), true);
delete widget;
}
@@ -694,9 +695,8 @@ void tst_QGraphicsAnchorLayout1::testSpecialCases()
layout2->setAnchor(widget1, Qt::AnchorRight, layout2, Qt::AnchorRight, 1);
layout2->setAnchor(widget1, Qt::AnchorBottom, layout2, Qt::AnchorBottom, 1);
- // ###: uncomment when simplification bug is solved
- //widget->setGeometry(QRectF(0,0,100,100));
- //QCOMPARE(widget1->geometry(), QRectF(51,2,47,96));
+ widget->setGeometry(QRectF(0,0,100,100));
+ QCOMPARE(widget1->geometry(), QRectF(51,2,47,96));
delete widget;
}
@@ -896,9 +896,6 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout_data()
<< BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorRight, 20)
;
- // ### SIMPLIFICATION BUG FOR ITEM 1
- // ### remove this when bug is solved
-
theResult
<< BasicResult(0, QRectF(10, 10, 180, 80) )
<< BasicResult(1, QRectF(10, 80, 10, 10) )
@@ -1664,6 +1661,18 @@ inline QGraphicsLayoutItem *getItem(
return widgets[index];
}
+static QRectF truncate(QRectF original)
+{
+ QRectF result;
+
+ result.setX(qRound(original.x() * 1000000) / 1000000.0);
+ result.setY(qRound(original.y() * 1000000) / 1000000.0);
+ result.setWidth(qRound(original.width() * 1000000) / 1000000.0);
+ result.setHeight(qRound(original.height() * 1000000) / 1000000.0);
+
+ return result;
+}
+
void tst_QGraphicsAnchorLayout1::testBasicLayout()
{
QFETCH(QSizeF, size);
@@ -1684,7 +1693,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
// Create dummy widgets
QList<QGraphicsWidget *> widgets;
for (int i = 0; i < widgetCount; ++i) {
- TestWidget *w = new TestWidget;
+ TestWidget *w = new TestWidget(0, QString::fromAscii("W%1").arg(i));
widgets << w;
}
@@ -1704,21 +1713,18 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
widget->setLayout(layout);
widget->setContentsMargins(0,0,0,0);
- widget->setMinimumSize(size);
- widget->setMaximumSize(size);
-
-// QTest::qWait(500); // layouting is asynchronous..
+ widget->resize(size);
+ QCOMPARE(widget->size(), size);
// Validate
for (int i = 0; i < result.count(); ++i) {
- if (i == 1)
- QEXPECT_FAIL("Two, mixed", "Works with simplification disabled.", Continue);
const BasicLayoutTestResult item = result[i];
- QCOMPARE(widgets[item.index]->geometry(), item.rect);
+ QRectF expected = truncate(item.rect);
+ QRectF actual = truncate(widgets[item.index]->geometry());
+
+ QCOMPARE(actual, expected);
}
- // ###: not supported yet
-/*
// Test mirrored mode
widget->setLayoutDirection(Qt::RightToLeft);
layout->activate();
@@ -1730,10 +1736,13 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
if (mirroredRect.isValid()){
mirroredRect.moveLeft(size.width()-item.rect.width()-item.rect.left());
}
- QCOMPARE(widgets[item.index]->geometry(), mirroredRect);
+ QRectF expected = truncate(mirroredRect);
+ QRectF actual = truncate(widgets[item.index]->geometry());
+
+ QCOMPARE(actual, expected);
delete widgets[item.index];
}
-*/
+
delete widget;
}
@@ -2214,8 +2223,8 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor()
widget->setLayout(layout);
widget->setContentsMargins(0,0,0,0);
- widget->setMinimumSize(size);
- widget->setMaximumSize(size);
+ widget->resize(size);
+ QCOMPARE(widget->size(), size);
// Validate
for (int i = 0; i < result.count(); ++i) {
@@ -2432,6 +2441,8 @@ void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy_data()
QTest::newRow("double size policy: expanding-preferred") << sizePolicy1 << sizePolicy2 << width1 << width2;
}
+ // QGAL handling of ignored flag is different
+ if (0)
{
QSizePolicy sizePolicy1( QSizePolicy::Ignored, QSizePolicy::Ignored );
QSizePolicy sizePolicy2( QSizePolicy::Preferred, QSizePolicy::Preferred );
@@ -2499,9 +2510,6 @@ void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy_data()
void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy()
{
- // ### Size policy is not yet supported
- return;
-
QFETCH(QSizePolicy, policy1);
QFETCH(QSizePolicy, policy2);
QFETCH(qreal, width1);
@@ -3055,8 +3063,8 @@ void tst_QGraphicsAnchorLayout1::testComplexCases()
widget->setLayout(layout);
widget->setContentsMargins(0,0,0,0);
- widget->setMinimumSize(size);
- widget->setMaximumSize(size);
+ widget->resize(size);
+ QCOMPARE(widget->size(), size);
// QTest::qWait(500); // layouting is asynchronous..
diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
index 0201bc4179..d21692431f 100644
--- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -49,6 +49,7 @@
#include <QtGui/qstyleoption.h>
#include "../../shared/util.h"
+#include <private/qgraphicseffect_p.h>
//TESTED_CLASS=
//TESTED_FILES=
@@ -131,16 +132,16 @@ public:
int margin() const
{ return m_margin; }
- void draw(QPainter *painter, QGraphicsEffectSource *source)
+ void draw(QPainter *painter)
{
++numRepaints;
if (doNothingInDraw)
return;
- m_source = source;
+ m_source = source();
m_painter = painter;
- m_styleOption = source->styleOption();
+ m_styleOption = source()->styleOption();
m_opacity = painter->opacity();
- source->draw(painter);
+ drawSource(painter);
}
void sourceChanged(QGraphicsEffect::ChangeFlags flags)
@@ -379,7 +380,8 @@ void tst_QGraphicsEffect::grayscale()
item->setPen(Qt::NoPen);
item->setBrush(QColor(122, 193, 66)); // Qt light green
- QGraphicsGrayscaleEffect *effect = new QGraphicsGrayscaleEffect;
+ QGraphicsColorizeEffect *effect = new QGraphicsColorizeEffect;
+ effect->setColor(Qt::black);
item->setGraphicsEffect(effect);
QPainter painter;
diff --git a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
index 855950bdab..9991ab46fe 100644
--- a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
+++ b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
@@ -46,6 +46,8 @@
#include <QtGui/qgraphicsitem.h>
#include <QtGui/qstyleoption.h>
+#include <private/qgraphicseffect_p.h>
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -54,13 +56,12 @@ class CustomItem : public QGraphicsRectItem
public:
CustomItem(qreal x, qreal y, qreal width, qreal height)
: QGraphicsRectItem(x, y, width, height), numRepaints(0),
- m_painter(0), m_styleOption(0)
+ m_painter(0)
{}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
m_painter = painter;
- m_styleOption = option;
++numRepaints;
QGraphicsRectItem::paint(painter, option, widget);
}
@@ -69,12 +70,10 @@ public:
{
numRepaints = 0;
m_painter = 0;
- m_styleOption = 0;
}
int numRepaints;
QPainter *m_painter;
- const QStyleOption *m_styleOption;
};
class CustomEffect : public QGraphicsEffect
@@ -84,7 +83,7 @@ public:
: QGraphicsEffect(), numRepaints(0), m_margin(10), m_sourceChanged(false),
m_sourceBoundingRectChanged(false), doNothingInDraw(false),
storeDeviceDependentStuff(false),
- m_painter(0), m_styleOption(0), m_source(0)
+ m_painter(0), m_source(0)
{}
QRectF boundingRectFor(const QRectF &rect) const
@@ -96,7 +95,6 @@ public:
m_sourceChanged = false;
m_sourceBoundingRectChanged = false;
m_painter = 0;
- m_styleOption = 0;
m_source = 0;
deviceCoordinatesPixmap = QPixmap();
deviceRect = QRect();
@@ -112,20 +110,19 @@ public:
int margin() const
{ return m_margin; }
- void draw(QPainter *painter, QGraphicsEffectSource *source)
+ void draw(QPainter *painter)
{
++numRepaints;
if (storeDeviceDependentStuff) {
- deviceCoordinatesPixmap = source->pixmap(Qt::DeviceCoordinates);
- deviceRect = source->deviceRect();
- sourceDeviceBoundingRect = source->boundingRect(Qt::DeviceCoordinates);
+ deviceCoordinatesPixmap = source()->pixmap(Qt::DeviceCoordinates);
+ deviceRect = QRect(0, 0, painter->device()->width(), painter->device()->height());
+ sourceDeviceBoundingRect = source()->boundingRect(Qt::DeviceCoordinates);
}
if (doNothingInDraw)
return;
- m_source = source;
+ m_source = source();
m_painter = painter;
- m_styleOption = source->styleOption();
- source->draw(painter);
+ source()->draw(painter);
}
void sourceChanged()
@@ -141,7 +138,6 @@ public:
bool doNothingInDraw;
bool storeDeviceDependentStuff;
QPainter *m_painter;
- const QStyleOption *m_styleOption;
QGraphicsEffectSource *m_source;
QPixmap deviceCoordinatesPixmap;
QRect deviceRect;
@@ -166,6 +162,9 @@ private slots:
void deviceRect();
void pixmap();
+ void pixmapPadding_data();
+ void pixmapPadding();
+
private:
QGraphicsView *view;
QGraphicsScene *scene;
@@ -224,8 +223,6 @@ void tst_QGraphicsEffectSource::styleOption()
QTest::qWait(50);
QCOMPARE(item->numRepaints, 1);
QCOMPARE(effect->numRepaints, 1);
- QVERIFY(effect->m_styleOption);
- QCOMPARE(effect->m_styleOption, item->m_styleOption);
}
void tst_QGraphicsEffectSource::isPixmap()
@@ -288,10 +285,6 @@ void tst_QGraphicsEffectSource::boundingRect()
void tst_QGraphicsEffectSource::deviceRect()
{
- QTest::ignoreMessage(QtWarningMsg, "QGraphicsEffectSource::deviceRect: Not yet implemented, lacking device context");
- QCOMPARE(effect->source()->deviceRect(), QRect());
-
- // We can at least check that the rect was correct in QGraphicsEffect::draw.
effect->storeDeviceDependentStuff = true;
effect->source()->update();
QTest::qWait(50);
@@ -318,6 +311,102 @@ void tst_QGraphicsEffectSource::pixmap()
QCOMPARE(pixmap1, pixmap2);
}
+class PaddingEffect : public QGraphicsEffect
+{
+public:
+ PaddingEffect(QObject *parent) : QGraphicsEffect(parent)
+ {
+ }
+
+ QRectF boundingRectFor(const QRectF &src) const {
+ return src.adjusted(-10, -10, 10, 10);
+ }
+
+ void draw(QPainter *) {
+ pix = source()->pixmap(coordinateMode, &offset, padMode);
+ }
+
+ QPixmap pix;
+ QPoint offset;
+ QGraphicsEffect::PixmapPadMode padMode;
+ Qt::CoordinateSystem coordinateMode;
+};
+
+void tst_QGraphicsEffectSource::pixmapPadding_data()
+{
+ QTest::addColumn<int>("coordinateMode");
+ QTest::addColumn<int>("padMode");
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QPoint>("offset");
+ QTest::addColumn<uint>("ulPixel");
+
+ QTest::newRow("log,nopad") << int(Qt::LogicalCoordinates)
+ << int(QGraphicsEffect::NoPad)
+ << QSize(10, 10) << QPoint(0, 0)
+ << 0xffff0000u;
+
+ QTest::newRow("log,transparent") << int(Qt::LogicalCoordinates)
+ << int(QGraphicsEffect::PadToTransparentBorder)
+ << QSize(14, 14) << QPoint(-2, -2)
+ << 0x00000000u;
+
+ QTest::newRow("log,effectrect") << int(Qt::LogicalCoordinates)
+ << int(QGraphicsEffect::PadToEffectiveBoundingRect)
+ << QSize(30, 30) << QPoint(-10, -10)
+ << 0x00000000u;
+
+ QTest::newRow("dev,nopad") << int(Qt::DeviceCoordinates)
+ << int(QGraphicsEffect::NoPad)
+ << QSize(20, 20) << QPoint(40, 40)
+ << 0xffff0000u;
+
+ QTest::newRow("dev,transparent") << int(Qt::DeviceCoordinates)
+ << int(QGraphicsEffect::PadToTransparentBorder)
+ << QSize(24, 24) << QPoint(38, 38)
+ << 0x00000000u;
+
+ QTest::newRow("dev,effectrect") << int(Qt::DeviceCoordinates)
+ << int(QGraphicsEffect::PadToEffectiveBoundingRect)
+ << QSize(40, 40) << QPoint(30, 30)
+ << 0x00000000u;
+
+}
+
+void tst_QGraphicsEffectSource::pixmapPadding()
+{
+ QPixmap dummyTarget(100, 100);
+ QPainter dummyPainter(&dummyTarget);
+ dummyPainter.translate(40, 40);
+ dummyPainter.scale(2, 2);
+
+ QPixmap pm(10, 10);
+ pm.fill(Qt::red);
+
+ QGraphicsScene *scene = new QGraphicsScene();
+ PaddingEffect *effect = new PaddingEffect(scene);
+ QGraphicsPixmapItem *pmItem = new QGraphicsPixmapItem(pm);
+ scene->addItem(pmItem);
+ pmItem->setGraphicsEffect(effect);
+
+ QFETCH(int, coordinateMode);
+ QFETCH(int, padMode);
+ QFETCH(QPoint, offset);
+ QFETCH(QSize, size);
+ QFETCH(uint, ulPixel);
+
+ effect->padMode = (QGraphicsEffect::PixmapPadMode) padMode;
+ effect->coordinateMode = (Qt::CoordinateSystem) coordinateMode;
+
+ scene->render(&dummyPainter, scene->itemsBoundingRect(), scene->itemsBoundingRect());
+
+ QCOMPARE(effect->pix.size(), size);
+ QCOMPARE(effect->offset, offset);
+ QCOMPARE(effect->pix.toImage().pixel(0, 0), ulPixel);
+
+ // ### Fix corruption in scene destruction, then enable...
+ // delete scene;
+}
+
QTEST_MAIN(tst_QGraphicsEffectSource)
#include "tst_qgraphicseffectsource.moc"
diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index 554292fab7..cd1eedd79e 100644
--- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -104,6 +104,7 @@ private slots:
void defaultStretchFactors();
void geometries_data();
void geometries();
+ void avoidRecursionInInsertItem();
void task236367_maxSizeHint();
};
@@ -398,7 +399,7 @@ void tst_QGraphicsGridLayout::columnAlignment()
widget->resize(widget->effectiveSizeHint(Qt::MaximumSize));
view.show();
widget->show();
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
// Check default
QCOMPARE(layout->columnAlignment(0), 0);
QCOMPARE(layout->columnAlignment(1), 0);
@@ -413,7 +414,7 @@ void tst_QGraphicsGridLayout::columnAlignment()
layout->setAlignment(layout->itemAt(1,1), Qt::AlignRight);
layout->setAlignment(layout->itemAt(1,2), Qt::AlignLeft);
- QApplication::processEvents(); // process LayoutRequest
+ QApplication::sendPostedEvents(0, 0); // process LayoutRequest
/*
+----------+------------+---------+
| Left | HCenter | Right |
@@ -845,7 +846,7 @@ void tst_QGraphicsGridLayout::rowAlignment()
widget->resize(300, 400);
view.show();
widget->show();
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
// Check default
QCOMPARE(layout->rowAlignment(0), 0);
QCOMPARE(layout->rowAlignment(1), 0);
@@ -868,7 +869,7 @@ void tst_QGraphicsGridLayout::rowAlignment()
layout->setAlignment(layout->itemAt(1,0), Qt::AlignTop);
layout->setAlignment(layout->itemAt(2,0), Qt::AlignHCenter);
- QApplication::processEvents(); // process LayoutRequest
+ QApplication::sendPostedEvents(0, 0); // process LayoutRequest
QCOMPARE(layout->alignment(layout->itemAt(0,0)), Qt::AlignRight); //Qt::AlignRight | Qt::AlignBottom
QCOMPARE(layout->itemAt(0,0)->geometry(), QRectF(50, 50, 50, 50));
@@ -1833,7 +1834,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors()
desc.apply(layout, item);
}
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
widget->show();
view.show();
@@ -1841,7 +1842,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors()
if (newSize.isValid())
widget->resize(newSize);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
for (i = 0; i < expectedSizes.count(); ++i) {
QSizeF itemSize = layout->itemAt(i)->geometry().size();
QCOMPARE(itemSize, expectedSizes.at(i));
@@ -1993,7 +1994,7 @@ void tst_QGraphicsGridLayout::alignment2()
desc.apply(layout, item);
}
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
widget->show();
view.resize(400,300);
@@ -2001,7 +2002,7 @@ void tst_QGraphicsGridLayout::alignment2()
if (newSize.isValid())
widget->resize(newSize);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
for (i = 0; i < expectedGeometries.count(); ++i) {
QRectF itemRect = layout->itemAt(i)->geometry();
QCOMPARE(itemRect, expectedGeometries.at(i));
@@ -2081,6 +2082,16 @@ void tst_QGraphicsGridLayout::geometries()
delete widget;
}
+void tst_QGraphicsGridLayout::avoidRecursionInInsertItem()
+{
+ QGraphicsWidget window(0, Qt::Window);
+ QGraphicsGridLayout *layout = new QGraphicsGridLayout(&window);
+ QCOMPARE(layout->count(), 0);
+ QTest::ignoreMessage(QtWarningMsg, "QGraphicsGridLayout::addItem: cannot insert itself");
+ layout->addItem(layout, 0, 0);
+ QCOMPARE(layout->count(), 0);
+}
+
void tst_QGraphicsGridLayout::task236367_maxSizeHint()
{
QGraphicsWidget *widget = new QGraphicsWidget;
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 49b76aca29..db80db6baf 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -82,6 +82,14 @@ Q_DECLARE_METATYPE(QRectF)
#define Q_CHECK_PAINTEVENTS
#endif
+#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+// On mac (cocoa) we always get full update.
+// So check that the expected region is contained inside the actual
+#define COMPARE_REGIONS(ACTUAL, EXPECTED) QVERIFY((EXPECTED).subtracted(ACTUAL).isEmpty())
+#else
+#define COMPARE_REGIONS QTRY_COMPARE
+#endif
+
static void sendMousePress(QGraphicsScene *scene, const QPointF &point, Qt::MouseButton button = Qt::LeftButton)
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);
@@ -364,6 +372,7 @@ private slots:
void itemUsesExtendedStyleOption();
void itemSendsGeometryChanges();
void moveItem();
+ void moveLineItem();
void sorting_data();
void sorting();
void itemHasNoContents();
@@ -382,6 +391,7 @@ private slots:
void moveWhileDeleting();
void ensureDirtySceneTransform();
void focusScope();
+ void focusScope2();
void stackBefore();
void sceneModality();
void panelModality();
@@ -390,6 +400,8 @@ private slots:
void modality_mouseGrabber();
void modality_clickFocus();
void modality_keyEvents();
+ void itemIsInFront();
+ void scenePosChange();
// task specific tests below me
void task141694_textItemEnsureVisible();
@@ -401,6 +413,7 @@ private slots:
void task243707_addChildBeforeParent();
void task197802_childrenVisibility();
void QTBUG_4233_updateCachedWithSceneRect();
+ void QTBUG_5418_textItemSetDefaultColor();
private:
QList<QGraphicsItem *> paintedItems;
@@ -3100,7 +3113,7 @@ void tst_QGraphicsItem::boundingRects()
void tst_QGraphicsItem::boundingRects2()
{
QGraphicsPixmapItem pixmap(QPixmap::fromImage(QImage(100, 100, QImage::Format_ARGB32_Premultiplied)));
- QCOMPARE(pixmap.boundingRect(), QRectF(-0.5, -0.5, 101, 101));
+ QCOMPARE(pixmap.boundingRect(), QRectF(0, 0, 100, 100));
QGraphicsLineItem line(0, 0, 100, 0);
line.setPen(QPen(Qt::black, 1));
@@ -4030,7 +4043,7 @@ void tst_QGraphicsItem::defaultItemTest_QGraphicsPixmapItem()
item.setOffset(QPointF(-10, -10));
QCOMPARE(item.offset(), QPointF(-10, -10));
- QCOMPARE(item.boundingRect(), QRectF(-10.5, -10.5, 301, 201));
+ QCOMPARE(item.boundingRect(), QRectF(-10, -10, 300, 200));
}
void tst_QGraphicsItem::defaultItemTest_QGraphicsTextItem()
@@ -4065,8 +4078,11 @@ void tst_QGraphicsItem::defaultItemTest_QGraphicsTextItem()
QCOMPARE(text->pos(), QPointF(10, 10));
+ text->setTextInteractionFlags(Qt::NoTextInteraction);
+ QVERIFY(!(text->flags() & QGraphicsItem::ItemAcceptsInputMethod));
text->setTextInteractionFlags(Qt::TextEditorInteraction);
QCOMPARE(text->textInteractionFlags(), Qt::TextInteractionFlags(Qt::TextEditorInteraction));
+ QVERIFY(text->flags() & QGraphicsItem::ItemAcceptsInputMethod);
{
QGraphicsSceneMouseEvent event2(QEvent::GraphicsSceneMouseMove);
@@ -4218,6 +4234,8 @@ protected:
break;
case QGraphicsItem::ItemOpacityHasChanged:
break;
+ case QGraphicsItem::ItemScenePositionHasChanged:
+ break;
}
return itemChangeReturnValue.isValid() ? itemChangeReturnValue : value;
}
@@ -6290,7 +6308,7 @@ void tst_QGraphicsItem::opacityZeroUpdates()
QRegion expectedRegion = parentDeviceBoundingRect.adjusted(-2, -2, 2, 2);
expectedRegion += childDeviceBoundingRect.adjusted(-2, -2, 2, 2);
- QTRY_COMPARE(view.paintedRegion, expectedRegion);
+ COMPARE_REGIONS(view.paintedRegion, expectedRegion);
}
class StacksBehindParentHelper : public QGraphicsRectItem
@@ -7117,7 +7135,7 @@ void tst_QGraphicsItem::update()
qApp->processEvents();
QCOMPARE(item->repaints, 1);
QCOMPARE(view.repaints, 1);
- QCOMPARE(view.paintedRegion, expectedRegion + expectedRegion.translated(50, 50));
+ COMPARE_REGIONS(view.paintedRegion, expectedRegion + expectedRegion.translated(50, 50));
// Make sure moving a parent item triggers an update on the children
// (even though the parent itself is outside the viewport).
@@ -7392,7 +7410,7 @@ void tst_QGraphicsItem::moveItem()
QRegion expectedParentRegion = parentDeviceBoundingRect; // old position
parentDeviceBoundingRect.translate(20, 20);
expectedParentRegion += parentDeviceBoundingRect; // new position
- QCOMPARE(view.paintedRegion, expectedParentRegion);
+ COMPARE_REGIONS(view.paintedRegion, expectedParentRegion);
RESET_COUNTERS
@@ -7402,7 +7420,7 @@ void tst_QGraphicsItem::moveItem()
QCOMPARE(child->repaints, 1);
QCOMPARE(view.repaints, 1);
const QRegion expectedChildRegion = expectedParentRegion.translated(20, 20);
- QCOMPARE(view.paintedRegion, expectedChildRegion);
+ COMPARE_REGIONS(view.paintedRegion, expectedChildRegion);
RESET_COUNTERS
@@ -7413,7 +7431,7 @@ void tst_QGraphicsItem::moveItem()
QCOMPARE(grandChild->repaints, 1);
QCOMPARE(view.repaints, 1);
const QRegion expectedGrandChildRegion = expectedParentRegion.translated(40, 40);
- QCOMPARE(view.paintedRegion, expectedGrandChildRegion);
+ COMPARE_REGIONS(view.paintedRegion, expectedGrandChildRegion);
RESET_COUNTERS
@@ -7426,7 +7444,40 @@ void tst_QGraphicsItem::moveItem()
expectedParentRegion.translate(20, 20);
expectedParentRegion += expectedChildRegion.translated(20, 20);
expectedParentRegion += expectedGrandChildRegion.translated(20, 20);
- QCOMPARE(view.paintedRegion, expectedParentRegion);
+ COMPARE_REGIONS(view.paintedRegion, expectedParentRegion);
+}
+
+void tst_QGraphicsItem::moveLineItem()
+{
+ QGraphicsScene scene;
+ scene.setSceneRect(0, 0, 200, 200);
+ QGraphicsLineItem *item = new QGraphicsLineItem(0, 0, 100, 0);
+ item->setPos(50, 50);
+ scene.addItem(item);
+
+ MyGraphicsView view(&scene);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(200);
+ view.reset();
+
+ const QRect itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform())
+ .mapRect(item->boundingRect()).toRect();
+ QRegion expectedRegion = itemDeviceBoundingRect.adjusted(-2, -2, 2, 2); // antialiasing
+
+ // Make sure the calculated region is correct.
+ item->update();
+ QTest::qWait(10);
+ QTRY_COMPARE(view.paintedRegion, expectedRegion);
+ view.reset();
+
+ // Old position: (50, 50)
+ item->setPos(50, 100);
+ expectedRegion += expectedRegion.translated(0, 50);
+ QTest::qWait(10);
+ QCOMPARE(view.paintedRegion, expectedRegion);
}
void tst_QGraphicsItem::sorting_data()
@@ -7632,20 +7683,6 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem()
QCOMPARE(items.size(), 1);
QCOMPARE(items.at(0), static_cast<QGraphicsItem *>(item3));
- item1->repaints = 0;
- item2->repaints = 0;
- item3->repaints = 0;
-
- view.viewport()->update(75, 75, 20, 20);
- QTest::qWait(50);
-
- // item1 is the effect source and must therefore be repainted.
- // item2 intersects with the exposed region
- // item3 is just another child outside the exposed region
- QCOMPARE(item1->repaints, 1);
- QCOMPARE(item2->repaints, 1);
- QCOMPARE(item3->repaints, 0);
-
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
QTest::qWait(100);
@@ -8422,7 +8459,7 @@ void tst_QGraphicsItem::focusScope()
QVERIFY(!scope2->focusScopeItem());
scope3->setParentItem(scope2);
QCOMPARE(scope2->focusScopeItem(), (QGraphicsItem *)scope3);
- QCOMPARE(scope2->focusItem(), (QGraphicsItem *)scope2);
+ QCOMPARE(scope2->focusItem(), (QGraphicsItem *)scope3);
QGraphicsRectItem *scope1 = new QGraphicsRectItem;
scope1->setData(0, "scope1");
@@ -8431,9 +8468,9 @@ void tst_QGraphicsItem::focusScope()
QVERIFY(!scope1->focusScopeItem());
scope2->setParentItem(scope1);
- QCOMPARE(scope1->focusItem(), (QGraphicsItem *)scope1);
- QCOMPARE(scope2->focusItem(), (QGraphicsItem *)0);
- QCOMPARE(scope3->focusItem(), (QGraphicsItem *)0);
+ QCOMPARE(scope1->focusItem(), (QGraphicsItem *)scope3);
+ QCOMPARE(scope2->focusItem(), (QGraphicsItem *)scope3);
+ QCOMPARE(scope3->focusItem(), (QGraphicsItem *)scope3);
QCOMPARE(scope1->focusScopeItem(), (QGraphicsItem *)scope2);
QCOMPARE(scope2->focusScopeItem(), (QGraphicsItem *)scope3);
QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)0);
@@ -8484,11 +8521,13 @@ void tst_QGraphicsItem::focusScope()
rect5->setFocus();
rect5->setParentItem(rect4);
QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)rect5);
- QVERIFY(!rect5->hasFocus());
+ QVERIFY(rect5->hasFocus());
rect4->setParentItem(0);
+ QVERIFY(rect5->hasFocus());
QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)0);
- QVERIFY(scope3->hasFocus());
+ QCOMPARE(scope3->focusItem(), (QGraphicsItem *)0);
+ QVERIFY(!scope3->hasFocus());
QGraphicsRectItem *rectA = new QGraphicsRectItem;
QGraphicsRectItem *scopeA = new QGraphicsRectItem(rectA);
@@ -8499,7 +8538,7 @@ void tst_QGraphicsItem::focusScope()
scopeB->setFocus();
scene.addItem(rectA);
- QVERIFY(!rect5->hasFocus());
+ QVERIFY(rect5->hasFocus());
QVERIFY(!scopeB->hasFocus());
scopeA->setFocus();
@@ -8507,6 +8546,76 @@ void tst_QGraphicsItem::focusScope()
QCOMPARE(scopeB->focusItem(), (QGraphicsItem *)scopeB);
}
+void tst_QGraphicsItem::focusScope2()
+{
+ QGraphicsRectItem *child1 = new QGraphicsRectItem;
+ child1->setFlags(QGraphicsItem::ItemIsFocusable);
+ child1->setFocus();
+ QCOMPARE(child1->focusItem(), (QGraphicsItem *)child1);
+
+ QGraphicsRectItem *child2 = new QGraphicsRectItem;
+ child2->setFlags(QGraphicsItem::ItemIsFocusable);
+
+ QGraphicsRectItem *rootFocusScope = new QGraphicsRectItem;
+ rootFocusScope->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsFocusScope);
+ rootFocusScope->setFocus();
+ QCOMPARE(rootFocusScope->focusItem(), (QGraphicsItem *)rootFocusScope);
+
+ child1->setParentItem(rootFocusScope);
+ child2->setParentItem(rootFocusScope);
+
+ QCOMPARE(rootFocusScope->focusScopeItem(), (QGraphicsItem *)child1);
+ QCOMPARE(rootFocusScope->focusItem(), (QGraphicsItem *)child1);
+
+ QGraphicsRectItem *siblingChild1 = new QGraphicsRectItem;
+ siblingChild1->setFlags(QGraphicsItem::ItemIsFocusable);
+ siblingChild1->setFocus();
+
+ QGraphicsRectItem *siblingChild2 = new QGraphicsRectItem;
+ siblingChild2->setFlags(QGraphicsItem::ItemIsFocusable);
+
+ QGraphicsRectItem *siblingFocusScope = new QGraphicsRectItem;
+ siblingFocusScope->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsFocusScope);
+
+ siblingChild1->setParentItem(siblingFocusScope);
+ siblingChild2->setParentItem(siblingFocusScope);
+
+ QCOMPARE(siblingFocusScope->focusScopeItem(), (QGraphicsItem *)siblingChild1);
+ QCOMPARE(siblingFocusScope->focusItem(), (QGraphicsItem *)0);
+
+ QGraphicsItem *root = new QGraphicsRectItem;
+ rootFocusScope->setParentItem(root);
+ siblingFocusScope->setParentItem(root);
+
+ QCOMPARE(root->focusItem(), (QGraphicsItem *)child1);
+
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ QEvent activate(QEvent::WindowActivate);
+ qApp->sendEvent(&scene, &activate);
+ scene.setFocus();
+
+ QCOMPARE(scene.focusItem(), (QGraphicsItem *)child1);
+
+ // You cannot set focus on a descendant of a focus scope directly;
+ // this will only change the scope's focus scope item pointer. If
+ // you want to give true input focus, you must set it directly on
+ // the scope itself
+ siblingChild2->setFocus();
+ QVERIFY(!siblingChild2->hasFocus());
+ QVERIFY(!siblingChild2->focusItem());
+ QCOMPARE(siblingFocusScope->focusScopeItem(), (QGraphicsItem *)siblingChild2);
+ QCOMPARE(siblingFocusScope->focusItem(), (QGraphicsItem *)0);
+
+ // Set focus on the scope; focus is forwarded to the focus scope item.
+ siblingFocusScope->setFocus();
+ QVERIFY(siblingChild2->hasFocus());
+ QVERIFY(siblingChild2->focusItem());
+ QCOMPARE(siblingFocusScope->focusScopeItem(), (QGraphicsItem *)siblingChild2);
+ QCOMPARE(siblingFocusScope->focusItem(), (QGraphicsItem *)siblingChild2);
+}
+
void tst_QGraphicsItem::stackBefore()
{
QGraphicsRectItem parent;
@@ -8526,24 +8635,24 @@ void tst_QGraphicsItem::stackBefore()
QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child1 << child3 << child4 << child2));
// Move child2 before child1
- child2->stackBefore(child1);
+ child2->stackBefore(child1); // 2134
QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4));
- child2->stackBefore(child2);
+ child2->stackBefore(child2); // 2134
QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4));
- child1->setZValue(1);
+ child1->setZValue(1); // 2341
QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child3 << child4 << child1));
- child1->stackBefore(child2); // no effect
+ child1->stackBefore(child2); // 2341
QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child3 << child4 << child1));
- child1->setZValue(0);
- QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4));
- child4->stackBefore(child1);
- QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child4 << child1 << child3));
- child4->setZValue(1);
- QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4));
- child3->stackBefore(child1);
- QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child3 << child1 << child4));
- child4->setZValue(0);
- QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child2 << child4 << child3 << child1));
+ child1->setZValue(0); // 1234
+ QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child1 << child2 << child3 << child4));
+ child4->stackBefore(child1); // 4123
+ QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child4 << child1 << child2 << child3));
+ child4->setZValue(1); // 1234 (4123)
+ QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child1 << child2 << child3 << child4));
+ child3->stackBefore(child1); // 3124 (4312)
+ QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child3 << child1 << child2 << child4));
+ child4->setZValue(0); // 4312
+ QCOMPARE(parent.childItems(), (QList<QGraphicsItem *>() << child4 << child3 << child1 << child2));
// Make them all toplevels
child1->setParentItem(0);
@@ -8565,24 +8674,24 @@ void tst_QGraphicsItem::stackBefore()
QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child1 << child3 << child4 << child2));
// Move child2 before child1
- child2->stackBefore(child1);
+ child2->stackBefore(child1); // 2134
QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4));
- child2->stackBefore(child2);
+ child2->stackBefore(child2); // 2134
QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4));
- child1->setZValue(1);
+ child1->setZValue(1); // 2341
QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child3 << child4 << child1));
- child1->stackBefore(child2); // no effect
+ child1->stackBefore(child2); // 2341
QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child3 << child4 << child1));
- child1->setZValue(0);
- QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4));
- child4->stackBefore(child1);
- QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child4 << child1 << child3));
- child4->setZValue(1);
- QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child1 << child3 << child4));
- child3->stackBefore(child1);
- QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child3 << child1 << child4));
- child4->setZValue(0);
- QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child4 << child3 << child1));
+ child1->setZValue(0); // 1234
+ QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child1 << child2 << child3 << child4));
+ child4->stackBefore(child1); // 4123
+ QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child4 << child1 << child2 << child3));
+ child4->setZValue(1); // 1234 (4123)
+ QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child1 << child2 << child3 << child4));
+ child3->stackBefore(child1); // 3124 (4312)
+ QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child3 << child1 << child2 << child4));
+ child4->setZValue(0); // 4312
+ QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child4 << child3 << child1 << child2));
}
void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect()
@@ -9533,5 +9642,175 @@ void tst_QGraphicsItem::modality_keyEvents()
QCOMPARE(rect1Spy.counts[QEvent::KeyRelease], 0);
}
+void tst_QGraphicsItem::itemIsInFront()
+{
+ QGraphicsScene scene;
+ QGraphicsRectItem *rect1 = new QGraphicsRectItem;
+ rect1->setData(0, "rect1");
+ scene.addItem(rect1);
+
+ QGraphicsRectItem *rect1child1 = new QGraphicsRectItem(rect1);
+ rect1child1->setZValue(1);
+ rect1child1->setData(0, "rect1child1");
+
+ QGraphicsRectItem *rect1child2 = new QGraphicsRectItem(rect1);
+ rect1child2->setParentItem(rect1);
+ rect1child2->setData(0, "rect1child2");
+
+ QGraphicsRectItem *rect1child1_1 = new QGraphicsRectItem(rect1child1);
+ rect1child1_1->setData(0, "rect1child1_1");
+
+ QGraphicsRectItem *rect1child1_2 = new QGraphicsRectItem(rect1child1);
+ rect1child1_2->setFlag(QGraphicsItem::ItemStacksBehindParent);
+ rect1child1_2->setData(0, "rect1child1_2");
+
+ QGraphicsRectItem *rect2 = new QGraphicsRectItem;
+ rect2->setData(0, "rect2");
+ scene.addItem(rect2);
+
+ QGraphicsRectItem *rect2child1 = new QGraphicsRectItem(rect2);
+ rect2child1->setData(0, "rect2child1");
+
+ QCOMPARE(qt_closestItemFirst(rect1, rect1), false);
+ QCOMPARE(qt_closestItemFirst(rect1, rect2), false);
+ QCOMPARE(qt_closestItemFirst(rect1child1, rect2child1), false);
+ QCOMPARE(qt_closestItemFirst(rect1child1, rect1child2), true);
+ QCOMPARE(qt_closestItemFirst(rect1child1_1, rect1child2), true);
+ QCOMPARE(qt_closestItemFirst(rect1child1_1, rect1child1), true);
+ QCOMPARE(qt_closestItemFirst(rect1child1_2, rect1child2), true);
+ QCOMPARE(qt_closestItemFirst(rect1child1_2, rect1child1), false);
+ QCOMPARE(qt_closestItemFirst(rect1child1_2, rect1), true);
+ QCOMPARE(qt_closestItemFirst(rect1child1_2, rect2), false);
+ QCOMPARE(qt_closestItemFirst(rect1child1_2, rect2child1), false);
+}
+
+class ScenePosChangeTester : public ItemChangeTester
+{
+public:
+ ScenePosChangeTester()
+ { }
+ ScenePosChangeTester(QGraphicsItem *parent) : ItemChangeTester(parent)
+ { }
+};
+
+void tst_QGraphicsItem::scenePosChange()
+{
+ ScenePosChangeTester* root = new ScenePosChangeTester;
+ ScenePosChangeTester* child1 = new ScenePosChangeTester(root);
+ ScenePosChangeTester* grandChild1 = new ScenePosChangeTester(child1);
+ ScenePosChangeTester* child2 = new ScenePosChangeTester(root);
+ ScenePosChangeTester* grandChild2 = new ScenePosChangeTester(child2);
+
+ child1->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
+ grandChild2->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
+
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ // ignore uninteresting changes
+ child1->clear();
+ child2->clear();
+ grandChild1->clear();
+ grandChild2->clear();
+
+ // move whole tree
+ root->moveBy(1.0, 1.0);
+ QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1);
+ QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
+ QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
+ QCOMPARE(grandChild2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1);
+
+ // move subtree
+ child2->moveBy(1.0, 1.0);
+ QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1);
+ QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
+ QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
+ QCOMPARE(grandChild2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 2);
+
+ // reparent
+ grandChild2->setParentItem(child1);
+ child1->moveBy(1.0, 1.0);
+ QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 2);
+ QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
+ QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
+ QCOMPARE(grandChild2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 3);
+
+ // change flags
+ grandChild1->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
+ grandChild2->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
+ QCoreApplication::processEvents(); // QGraphicsScenePrivate::_q_updateScenePosDescendants()
+ child1->moveBy(1.0, 1.0);
+ QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 3);
+ QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1);
+ QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
+ QCOMPARE(grandChild2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 3);
+
+ // remove
+ scene.removeItem(grandChild1);
+ delete grandChild2; grandChild2 = 0;
+ QCoreApplication::processEvents(); // QGraphicsScenePrivate::_q_updateScenePosDescendants()
+ root->moveBy(1.0, 1.0);
+ QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 4);
+ QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1);
+ QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
+}
+
+void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
+{
+ struct Item : public QGraphicsTextItem
+ {
+ bool painted;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *opt, QWidget *wid)
+ {
+ painted = true;
+ QGraphicsTextItem::paint(painter, opt, wid);
+ }
+ };
+
+ Item *i = new Item;
+ i->painted = false;
+ i->setPlainText("I AM A TROLL");
+
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ scene.addItem(i);
+ QApplication::processEvents();
+ QTRY_VERIFY(i->painted);
+ QApplication::processEvents();
+
+ i->painted = false;
+ QColor col(Qt::red);
+ i->setDefaultTextColor(col);
+ QApplication::processEvents();
+ QTRY_VERIFY(i->painted); //check that changing the color force an update
+
+ i->painted = false;
+ QImage image(400, 200, QImage::Format_RGB32);
+ image.fill(0);
+ QPainter painter(&image);
+ scene.render(&painter);
+ painter.end();
+ QVERIFY(i->painted);
+
+ int numRedPixel = 0;
+ QRgb rgb = col.rgb();
+ for (int y = 0; y < image.height(); ++y) {
+ for (int x = 0; x < image.width(); ++x) {
+ // Because of antialiasing we allow a certain range of errors here.
+ QRgb pixel = image.pixel(x, y);
+ if (qAbs((int)(pixel & 0xff) - (int)(rgb & 0xff)) +
+ qAbs((int)((pixel & 0xff00) >> 8) - (int)((rgb & 0xff00) >> 8)) +
+ qAbs((int)((pixel & 0xff0000) >> 16) - (int)((rgb & 0xff0000) >> 16)) <= 50) {
+ if (++numRedPixel >= 10) {
+ return;
+ }
+ }
+ }
+ }
+ QCOMPARE(numRedPixel, -1); //color not found, FAIL!
+}
+
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"
diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 4f28df44cf..d3087dc635 100644
--- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -101,6 +101,7 @@ private slots:
void updateGeometry();
void layoutDirection();
void removeLayout();
+ void avoidRecursionInInsertItem();
// Task specific tests
void task218400_insertStretchCrash();
@@ -146,7 +147,7 @@ void tst_QGraphicsLinearLayout::initTestCase()
// since the style will influence the results, we have to ensure
// that the tests are run using the same style on all platforms
#ifdef Q_WS_S60
- QApplication::setStyle(new QWindowsStyle);
+ QApplication::setStyle(new QWindowsStyle);
#else
QApplication::setStyle(new QPlastiqueStyle);
#endif
@@ -332,6 +333,7 @@ void tst_QGraphicsLinearLayout::alignment()
widget->resize(newSize);
view.show();
widget->show();
+ QTest::qWaitForWindowShown(&view);
QApplication::processEvents();
int x = 0;
@@ -662,16 +664,16 @@ void tst_QGraphicsLinearLayout::invalidate()
widget->show();
layout.setContentsMargins(1, 2, 3, 4);
- qApp->processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(layout.layoutRequest, 1);
layout.setOrientation(Qt::Vertical);
- qApp->processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(layout.layoutRequest, 2);
for (int i = 0; i < count; ++i)
layout.invalidate(); // Event is compressed, should only get one layoutrequest
- qApp->processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(layout.layoutRequest, count ? 3 : 2);
delete widget;
}
@@ -1431,6 +1433,16 @@ void tst_QGraphicsLinearLayout::removeLayout()
QCOMPARE(pushButton->geometry(), r2);
}
+void tst_QGraphicsLinearLayout::avoidRecursionInInsertItem()
+{
+ QGraphicsWidget window(0, Qt::Window);
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(&window);
+ QCOMPARE(layout->count(), 0);
+ QTest::ignoreMessage(QtWarningMsg, "QGraphicsLinearLayout::insertItem: cannot insert itself");
+ layout->insertItem(0, layout);
+ QCOMPARE(layout->count(), 0);
+}
+
void tst_QGraphicsLinearLayout::task218400_insertStretchCrash()
{
QGraphicsScene *scene = new QGraphicsScene;
diff --git a/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp b/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp
index a9fd55a564..194665d675 100644
--- a/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp
+++ b/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp
@@ -46,6 +46,7 @@
#include <qgraphicssceneevent.h>
#include <qgraphicsview.h>
#include <qstyleoption.h>
+#include <private/qobject_p.h>
#include "../../shared/util.h"
class tst_QGraphicsObject : public QObject {
@@ -65,6 +66,7 @@ private slots:
void opacity();
void enabled();
void visible();
+ void deleted();
};
@@ -249,6 +251,46 @@ void tst_QGraphicsObject::visible()
QVERIFY(object.property("visible") == true);
}
+class DeleteTester : public QGraphicsObject
+{
+public:
+ DeleteTester(bool *w, bool *pw, QGraphicsItem *parent = 0)
+ : QGraphicsObject(parent), wasDeleted(w), parentWasDeleted(pw)
+ { }
+
+ ~DeleteTester()
+ {
+ *wasDeleted = QObjectPrivate::get(this)->wasDeleted;
+ if (QGraphicsItem *p = parentItem()) {
+ if (QGraphicsObject *o = p->toGraphicsObject())
+ *parentWasDeleted = QObjectPrivate::get(o)->wasDeleted;
+ }
+ }
+
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0)
+ { }
+ QRectF boundingRect() const
+ { return QRectF(); }
+
+ bool *wasDeleted;
+ bool *parentWasDeleted;
+};
+
+void tst_QGraphicsObject::deleted()
+{
+ bool item1_parentWasDeleted = false;
+ bool item1_wasDeleted = false;
+ bool item2_parentWasDeleted = false;
+ bool item2_wasDeleted = false;
+ DeleteTester *item1 = new DeleteTester(&item1_wasDeleted, &item1_parentWasDeleted);
+ DeleteTester *item2 = new DeleteTester(&item2_wasDeleted, &item2_parentWasDeleted, item1);
+ delete item1;
+
+ QVERIFY(!item1_wasDeleted); // destructor not called yet
+ QVERIFY(!item1_parentWasDeleted); // no parent
+ QVERIFY(!item2_wasDeleted); // destructor not called yet
+ QVERIFY(item2_parentWasDeleted);
+}
QTEST_MAIN(tst_QGraphicsObject)
#include "tst_qgraphicsobject.moc"
diff --git a/tests/auto/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp b/tests/auto/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp
index e25aef0dfe..5a62dc03a5 100644
--- a/tests/auto/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp
+++ b/tests/auto/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp
@@ -165,7 +165,7 @@ void tst_QGraphicsPixmapItem::boundingRect_data()
QTest::addColumn<QPixmap>("pixmap");
QTest::addColumn<QRectF>("boundingRect");
QTest::newRow("null") << QPixmap() << QRectF();
- QTest::newRow("10x10") << QPixmap(10, 10) << QRectF(-0.5, -0.5, 11, 11);
+ QTest::newRow("10x10") << QPixmap(10, 10) << QRectF(0, 0, 10, 10);
}
// public QRectF boundingRect() const
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 58d7896a8d..36ee22c96a 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -1286,7 +1286,9 @@ void tst_QGraphicsProxyWidget::paintEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
+ QApplication::setActiveWindow(&view);
QTest::qWaitForWindowShown(&view);
+ QTRY_VERIFY(view.isActiveWindow());
SubQGraphicsProxyWidget proxy;
@@ -1297,14 +1299,14 @@ void tst_QGraphicsProxyWidget::paintEvent()
w->show();
QTest::qWaitForWindowShown(w);
QApplication::processEvents();
- QTest::qWait(50);
+ QTest::qWait(30);
proxy.setWidget(w);
scene.addItem(&proxy);
//make sure we flush all the paint events
- QTest::qWait(70);
+ QTest::qWait(30);
QTRY_VERIFY(proxy.paintCount > 1);
- QTest::qWait(70);
+ QTest::qWait(30);
proxy.paintCount = 0;
w->update();
@@ -1532,7 +1534,7 @@ void tst_QGraphicsProxyWidget::setWidget_simple()
// Properties
// QCOMPARE(proxy.focusPolicy(), lineEdit->focusPolicy());
- QCOMPARE(proxy.palette(), lineEdit->palette());
+ // QCOMPARE(proxy.palette(), lineEdit->palette());
#ifndef QT_NO_CURSOR
QCOMPARE(proxy.cursor().shape(), lineEdit->cursor().shape());
#endif
@@ -2006,8 +2008,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
edit1->setText("QLineEdit 1");
QLineEdit *edit2 = new QLineEdit;
edit2->setText("QLineEdit 2");
+ QFontComboBox *fontComboBox = new QFontComboBox;
QVBoxLayout *vlayout = new QVBoxLayout;
vlayout->addWidget(edit1);
+ vlayout->addWidget(fontComboBox);
vlayout->addWidget(edit2);
QGroupBox *box = new QGroupBox("QGroupBox");
@@ -2019,8 +2023,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
edit1_2->setText("QLineEdit 1_2");
QLineEdit *edit2_2 = new QLineEdit;
edit2_2->setText("QLineEdit 2_2");
+ QFontComboBox *fontComboBox2 = new QFontComboBox;
vlayout = new QVBoxLayout;
vlayout->addWidget(edit1_2);
+ vlayout->addWidget(fontComboBox2);
vlayout->addWidget(edit2_2);
QGroupBox *box_2 = new QGroupBox("QGroupBox 2");
@@ -2061,8 +2067,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
EventSpy eventSpy(edit1);
EventSpy eventSpy2(edit2);
+ EventSpy eventSpy3(fontComboBox);
EventSpy eventSpy1_2(edit1_2);
EventSpy eventSpy2_2(edit2_2);
+ EventSpy eventSpy2_3(fontComboBox2);
EventSpy eventSpyBox(box);
// Tab into group box
@@ -2083,11 +2091,24 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy.counts[QEvent::FocusOut], 0);
+ // Tab to the font combobox
+ QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
+ QApplication::processEvents();
+ fontComboBox->hasFocus();
+ QVERIFY(!edit2->hasFocus());
+ QCOMPARE(eventSpy3.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy3.counts[QEvent::FocusOut], 0);
+ QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy.counts[QEvent::FocusOut], 1);
+
// Tab into line edit 2
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
QApplication::processEvents();
edit2->hasFocus();
QVERIFY(!edit1->hasFocus());
+ QCOMPARE(eventSpy2.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy2.counts[QEvent::FocusOut], 0);
+ QCOMPARE(eventSpy3.counts[QEvent::FocusOut], 1);
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy.counts[QEvent::FocusOut], 1);
@@ -2105,6 +2126,16 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 0);
+ // Tab into right font combobox
+ QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
+ QApplication::processEvents();
+ QVERIFY(!edit1_2->hasFocus());
+ fontComboBox2->hasFocus();
+ QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 1);
+ QCOMPARE(eventSpy2_3.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy2_3.counts[QEvent::FocusOut], 0);
+
// Tab into right bottom line edit
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
QApplication::processEvents();
@@ -2112,6 +2143,8 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
edit2_2->hasFocus();
QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 1);
+ QCOMPARE(eventSpy2_3.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy2_3.counts[QEvent::FocusOut], 1);
QCOMPARE(eventSpy2_2.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy2_2.counts[QEvent::FocusOut], 0);
@@ -2128,6 +2161,12 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QVERIFY(!rightDial->hasFocus());
edit2_2->hasFocus();
+ // Backtab into the right font combobox
+ QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
+ QApplication::processEvents();
+ QVERIFY(!edit2_2->hasFocus());
+ fontComboBox2->hasFocus();
+
// Backtab into line edit 1
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
QApplication::processEvents();
@@ -2146,10 +2185,16 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QVERIFY(!rightDial->hasFocus());
edit2->hasFocus();
- // Backtab into line edit 1
+ // Backtab into the font combobox
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
QApplication::processEvents();
QVERIFY(!edit2->hasFocus());
+ fontComboBox->hasFocus();
+
+ // Backtab into line edit 1
+ QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
+ QApplication::processEvents();
+ QVERIFY(!fontComboBox->hasFocus());
edit1->hasFocus();
// Backtab into line box
@@ -2529,20 +2574,22 @@ void tst_QGraphicsProxyWidget::changingCursor_basic()
proxy->setWidget(widget);
proxy->show();
scene.addItem(proxy);
+ QApplication::setActiveWindow(&view);
QTest::qWaitForWindowShown(&view);
QApplication::processEvents();
+ QTRY_VERIFY(view.isActiveWindow());
// in
QTest::mouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center())));
sendMouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center())));
- QTest::qWait(125);
- QCOMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor);
+ QTest::qWait(12);
+ QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor);
// out
QTest::mouseMove(view.viewport(), QPoint(1, 1));
sendMouseMove(view.viewport(), QPoint(1, 1));
- QTest::qWait(125);
- QCOMPARE(view.viewport()->cursor().shape(), Qt::ArrowCursor);
+ QTest::qWait(12);
+ QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::ArrowCursor);
#endif
}
@@ -2702,10 +2749,12 @@ void tst_QGraphicsProxyWidget::windowOpacity()
widget->resize(100, 100);
QGraphicsProxyWidget *proxy = scene.addWidget(widget);
proxy->setCacheMode(QGraphicsItem::ItemCoordinateCache);
+
+ QApplication::setActiveWindow(&view);
view.show();
QTest::qWaitForWindowShown(&view);
QApplication::sendPostedEvents();
- QTest::qWait(50);
+ QTRY_VERIFY(view.isActiveWindow());
qRegisterMetaType<QList<QRectF> >("QList<QRectF>");
QSignalSpy signalSpy(&scene, SIGNAL(changed(const QList<QRectF> &)));
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 0589994841..a49c2c1379 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -225,6 +225,7 @@ private slots:
void focusItem();
void focusItemLostFocus();
void setFocusItem();
+ void setFocusItem_inactive();
void mouseGrabberItem();
void hoverEvents_siblings();
void hoverEvents_parentChild();
@@ -267,6 +268,7 @@ private slots:
void initialFocus_data();
void initialFocus();
void polishItems();
+ void isActive();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -1453,6 +1455,13 @@ void tst_QGraphicsScene::focusItemLostFocus()
item->clearFocus();
}
+class ClearTestItem : public QGraphicsRectItem
+{
+public:
+ ~ClearTestItem() { qDeleteAll(items); }
+ QList<QGraphicsItem *> items;
+};
+
void tst_QGraphicsScene::clear()
{
QGraphicsScene scene;
@@ -1463,6 +1472,19 @@ void tst_QGraphicsScene::clear()
scene.clear();
QVERIFY(scene.items().isEmpty());
QCOMPARE(scene.sceneRect(), QRectF(0, 0, 100, 100));
+
+ ClearTestItem *firstItem = new ClearTestItem;
+ QGraphicsItem *secondItem = new QGraphicsRectItem;
+ firstItem->items += secondItem;
+
+ scene.setItemIndexMethod(QGraphicsScene::NoIndex);
+ scene.addItem(firstItem);
+ scene.addItem(secondItem);
+ QCOMPARE(scene.items().at(0), firstItem);
+ QCOMPARE(scene.items().at(1), secondItem);
+ // must not crash even if firstItem deletes secondItem
+ scene.clear();
+ QVERIFY(scene.items().isEmpty());
}
void tst_QGraphicsScene::setFocusItem()
@@ -1514,6 +1536,26 @@ void tst_QGraphicsScene::setFocusItem()
QVERIFY(!item2->hasFocus());
}
+void tst_QGraphicsScene::setFocusItem_inactive()
+{
+ QGraphicsScene scene;
+ QGraphicsItem *item = scene.addText("Qt");
+ QVERIFY(!scene.focusItem());
+ QVERIFY(!scene.hasFocus());
+ scene.setFocusItem(item);
+ QVERIFY(!scene.hasFocus());
+ QVERIFY(!scene.focusItem());
+ item->setFlag(QGraphicsItem::ItemIsFocusable);
+
+ for (int i = 0; i < 3; ++i) {
+ scene.setFocusItem(item);
+ QCOMPARE(scene.focusItem(), item);
+ QVERIFY(!item->hasFocus());
+ }
+
+}
+
+
void tst_QGraphicsScene::mouseGrabberItem()
{
QGraphicsScene scene;
@@ -3110,6 +3152,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems()
QVERIFY(!view->viewport()->hasFocus());
QVERIFY(!scene.hasFocus());
QVERIFY(!item->hasFocus());
+ QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(item));
// Check that the correct item regains focus.
widget.show();
@@ -3117,8 +3160,10 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems()
widget.activateWindow();
QTest::qWaitForWindowShown(&widget);
QTRY_VERIFY(view->hasFocus());
+ QTRY_VERIFY(scene.isActive());
QVERIFY(view->viewport()->hasFocus());
QVERIFY(scene.hasFocus());
+ QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(item));
QVERIFY(item->hasFocus());
}
@@ -3910,5 +3955,230 @@ void tst_QGraphicsScene::polishItems()
QMetaObject::invokeMethod(&scene,"_q_polishItems");
}
+void tst_QGraphicsScene::isActive()
+{
+ QGraphicsScene scene1;
+ QVERIFY(!scene1.isActive());
+ QGraphicsScene scene2;
+ QVERIFY(!scene2.isActive());
+
+ {
+ QWidget toplevel1;
+ QHBoxLayout *layout = new QHBoxLayout;
+ toplevel1.setLayout(layout);
+ QGraphicsView *view1 = new QGraphicsView(&scene1);
+ QGraphicsView *view2 = new QGraphicsView(&scene2);
+ layout->addWidget(view1);
+ layout->addWidget(view2);
+
+ QVERIFY(!scene1.isActive());
+ QVERIFY(!scene2.isActive());
+
+ view1->setVisible(false);
+
+ toplevel1.show();
+ QApplication::setActiveWindow(&toplevel1);
+ QTest::qWaitForWindowShown(&toplevel1);
+ QTRY_COMPARE(QApplication::activeWindow(), &toplevel1);
+
+ QVERIFY(!scene1.isActive()); //it is hidden;
+ QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
+
+ view1->show();
+ QVERIFY(scene1.isActive());
+ QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
+
+ view2->hide();
+
+ QVERIFY(scene1.isActive());
+ QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ toplevel1.hide();
+ QTest::qWait(50);
+ QTRY_VERIFY(!scene1.isActive());
+ QTRY_VERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ toplevel1.show();
+ QApplication::setActiveWindow(&toplevel1);
+ QApplication::processEvents();
+ QTRY_COMPARE(QApplication::activeWindow(), &toplevel1);
+
+ QTRY_VERIFY(scene1.isActive());
+ QTRY_VERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ view2->show();
+ QVERIFY(scene1.isActive());
+ QVERIFY(scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+ }
+
+ QVERIFY(!scene1.isActive());
+ QVERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+
+ {
+ QWidget toplevel2;
+ QHBoxLayout *layout = new QHBoxLayout;
+ toplevel2.setLayout(layout);
+ QGraphicsView *view1 = new QGraphicsView(&scene1);
+ QGraphicsView *view2 = new QGraphicsView();
+ layout->addWidget(view1);
+ layout->addWidget(view2);
+
+ QVERIFY(!scene1.isActive());
+ QVERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ toplevel2.show();
+ QApplication::setActiveWindow(&toplevel2);
+ QTest::qWaitForWindowShown(&toplevel2);
+ QTRY_COMPARE(QApplication::activeWindow(), &toplevel2);
+
+ QVERIFY(scene1.isActive());
+ QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ view2->setScene(&scene2);
+
+ QVERIFY(scene1.isActive());
+ QVERIFY(scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ view1->setScene(&scene2);
+ QVERIFY(!scene1.isActive());
+ QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
+
+ view1->hide();
+ QVERIFY(!scene1.isActive());
+ QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
+
+ view1->setScene(&scene1);
+ QVERIFY(!scene1.isActive());
+ QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
+
+ view1->show();
+ QVERIFY(scene1.isActive());
+ QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
+
+ view2->hide();
+ QVERIFY(scene1.isActive());
+ QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ QGraphicsView topLevelView;
+ topLevelView.show();
+ QApplication::setActiveWindow(&topLevelView);
+ topLevelView.setFocus();
+ QTest::qWaitForWindowShown(&topLevelView);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&topLevelView));
+
+ QVERIFY(!scene1.isActive());
+ QVERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ topLevelView.setScene(&scene1);
+ QVERIFY(scene1.isActive());
+ QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ view2->show();
+ QVERIFY(scene1.isActive());
+ QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ view1->hide();
+ QVERIFY(scene1.isActive());
+ QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ QApplication::setActiveWindow(&toplevel2);
+ QTRY_COMPARE(QApplication::activeWindow(), &toplevel2);
+
+ QVERIFY(!scene1.isActive());
+ QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
+ }
+
+ QVERIFY(!scene1.isActive());
+ QVERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ {
+ QWidget toplevel3;
+ QHBoxLayout *layout = new QHBoxLayout;
+ toplevel3.setLayout(layout);
+ QGraphicsView *view1 = new QGraphicsView(&scene1);
+ QGraphicsView *view2 = new QGraphicsView(&scene2);
+ layout->addWidget(view1);
+
+ QVERIFY(!scene1.isActive());
+ QVERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+
+ toplevel3.show();
+ QApplication::setActiveWindow(&toplevel3);
+ QTest::qWaitForWindowShown(&toplevel3);
+ QTRY_COMPARE(QApplication::activeWindow(), &toplevel3);
+
+ QVERIFY(scene1.isActive());
+ QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ layout->addWidget(view2);
+ QApplication::processEvents();
+ QVERIFY(scene1.isActive());
+ QVERIFY(scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+ view1->setParent(0);
+ QVERIFY(!scene1.isActive());
+ QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
+ delete view1;
+ }
+
+ QVERIFY(!scene1.isActive());
+ QVERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
+}
+
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"
diff --git a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
index 1109e5e9d5..7d98748e84 100644
--- a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
+++ b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
@@ -45,6 +45,8 @@
#include <private/qgraphicsscenebsptreeindex_p.h>
#include <private/qgraphicssceneindex_p.h>
#include <private/qgraphicsscenelinearindex_p.h>
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -66,6 +68,7 @@ private slots:
void movingItems();
void connectedToSceneRectChanged();
void items();
+ void removeItems();
void clear();
private:
@@ -268,6 +271,63 @@ void tst_QGraphicsSceneIndex::items()
QCOMPARE(scene.items().size(), 3);
}
+class RectWidget : public QGraphicsWidget
+{
+ Q_OBJECT
+public:
+ RectWidget(QGraphicsItem *parent = 0) : QGraphicsWidget(parent)
+ {
+ }
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ {
+ painter->setBrush(brush);
+ painter->drawRect(boundingRect());
+ }
+public:
+ QBrush brush;
+};
+
+void tst_QGraphicsSceneIndex::removeItems()
+{
+ QGraphicsScene scene;
+
+ RectWidget *parent = new RectWidget;
+ parent->brush = QBrush(QColor(Qt::magenta));
+ parent->setGeometry(250, 250, 400, 400);
+
+ RectWidget *widget = new RectWidget(parent);
+ widget->brush = QBrush(QColor(Qt::blue));
+ widget->setGeometry(10, 10, 200, 200);
+
+ RectWidget *widgetChild1 = new RectWidget(widget);
+ widgetChild1->brush = QBrush(QColor(Qt::green));
+ widgetChild1->setGeometry(20, 20, 100, 100);
+
+ RectWidget *widgetChild2 = new RectWidget(widgetChild1);
+ widgetChild2->brush = QBrush(QColor(Qt::yellow));
+ widgetChild2->setGeometry(25, 25, 50, 50);
+
+ scene.addItem(parent);
+
+ QGraphicsView view(&scene);
+ view.resize(600, 600);
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+
+ QApplication::processEvents();
+
+ scene.removeItem(widgetChild1);
+
+ delete widgetChild1;
+
+ //We move the parent
+ scene.items(295, 295, 50, 50);
+
+ //This should not crash
+}
+
void tst_QGraphicsSceneIndex::clear()
{
class MyItem : public QGraphicsItem
@@ -298,7 +358,7 @@ void tst_QGraphicsSceneIndex::clear()
MyItem *item = new MyItem;
scene.addItem(item);
qApp->processEvents();
- QCOMPARE(item->numPaints, 1);
+ QTRY_COMPARE(item->numPaints, 1);
}
QTEST_MAIN(tst_QGraphicsSceneIndex)
diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
index b407fef2a2..9b15ab1ad2 100644
--- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
+++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
@@ -59,6 +59,8 @@ private slots:
void rotation();
void rotation3d_data();
void rotation3d();
+ void rotation3dArbitraryAxis_data();
+ void rotation3dArbitraryAxis();
};
@@ -255,11 +257,24 @@ void tst_QGraphicsTransform::rotation3d()
QVERIFY(fuzzyCompare(transform2D(rotation), expected));
+ // Check that "rotation" produces the 4x4 form of the 3x3 matrix.
+ // i.e. third row and column are 0 0 1 0.
+ t.setToIdentity();
+ rotation.applyTo(&t);
+ QMatrix4x4 r(expected);
+ if (sizeof(qreal) == sizeof(float) && angle == 268) {
+ // This test fails, on only this angle, when qreal == float
+ // because the deg2rad value in QTransform is not accurate
+ // enough to match what QMatrix4x4 is doing.
+ } else {
+ QVERIFY(qFuzzyCompare(t, r));
+ }
+
//now let's check that a null vector will not change the transform
rotation.setAxis(QVector3D(0, 0, 0));
rotation.setOrigin(QVector3D(10, 10, 0));
- t.setIdentity();
+ t.setToIdentity();
rotation.applyTo(&t);
QVERIFY(t.isIdentity());
@@ -276,6 +291,58 @@ void tst_QGraphicsTransform::rotation3d()
QVERIFY(transform2D(rotation).isIdentity());
}
+void tst_QGraphicsTransform::rotation3dArbitraryAxis_data()
+{
+ QTest::addColumn<QVector3D>("axis");
+ QTest::addColumn<qreal>("angle");
+
+ QVector3D axis1 = QVector3D(1.0f, 1.0f, 1.0f);
+ QVector3D axis2 = QVector3D(2.0f, -3.0f, 0.5f);
+ QVector3D axis3 = QVector3D(-2.0f, 0.0f, -0.5f);
+ QVector3D axis4 = QVector3D(0.0001f, 0.0001f, 0.0001f);
+ QVector3D axis5 = QVector3D(0.01f, 0.01f, 0.01f);
+
+ for (int angle = 0; angle <= 360; angle++) {
+ QTest::newRow("test rotation on (1, 1, 1)") << axis1 << qreal(angle);
+ QTest::newRow("test rotation on (2, -3, .5)") << axis2 << qreal(angle);
+ QTest::newRow("test rotation on (-2, 0, -.5)") << axis3 << qreal(angle);
+ QTest::newRow("test rotation on (.0001, .0001, .0001)") << axis4 << qreal(angle);
+ QTest::newRow("test rotation on (.01, .01, .01)") << axis5 << qreal(angle);
+ }
+}
+
+void tst_QGraphicsTransform::rotation3dArbitraryAxis()
+{
+ QFETCH(QVector3D, axis);
+ QFETCH(qreal, angle);
+
+ QGraphicsRotation rotation;
+ rotation.setAxis(axis);
+
+ QMatrix4x4 t;
+ rotation.applyTo(&t);
+
+ QVERIFY(t.isIdentity());
+ QVERIFY(transform2D(rotation).isIdentity());
+
+ rotation.setAngle(angle);
+
+ // Compute the expected answer using QMatrix4x4 and a projection.
+ // These two steps are performed in one hit by QGraphicsRotation.
+ QMatrix4x4 exp;
+ exp.rotate(angle, axis);
+ QTransform expected = exp.toTransform(1024.0f);
+
+ QVERIFY(fuzzyCompare(transform2D(rotation), expected));
+
+ // Check that "rotation" produces the 4x4 form of the 3x3 matrix.
+ // i.e. third row and column are 0 0 1 0.
+ t.setToIdentity();
+ rotation.applyTo(&t);
+ QMatrix4x4 r(expected);
+ QVERIFY(qFuzzyCompare(t, r));
+}
+
QTEST_MAIN(tst_QGraphicsTransform)
#include "tst_qgraphicstransform.moc"
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 8acaa72eb5..1ff06c2f6f 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -194,6 +194,8 @@ private slots:
void acceptDrops();
void optimizationFlags();
void optimizationFlags_dontSavePainterState();
+ void optimizationFlags_dontSavePainterState2_data();
+ void optimizationFlags_dontSavePainterState2();
void levelOfDetail_data();
void levelOfDetail();
void scrollBarRanges_data();
@@ -2210,9 +2212,11 @@ void tst_QGraphicsView::viewportUpdateMode()
// The view gets two updates for the update scene updates.
QTRY_VERIFY(!view.lastUpdateRegions.isEmpty());
+#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
QCOMPARE(view.lastUpdateRegions.last().rects().size(), 2);
QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), QSize(15, 15));
QCOMPARE(view.lastUpdateRegions.last().rects().at(1).size(), QSize(15, 15));
+#endif
// Set full update mode.
view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
@@ -2453,6 +2457,57 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState()
QTest::qWaitForWindowShown(&painter2);
}
+void tst_QGraphicsView::optimizationFlags_dontSavePainterState2_data()
+{
+ QTest::addColumn<bool>("savePainter");
+ QTest::newRow("With painter state protection") << true;
+ QTest::newRow("Without painter state protection") << false;
+}
+
+void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
+{
+ QFETCH(bool, savePainter);
+
+ class MyScene : public QGraphicsScene
+ {
+ public:
+ void drawBackground(QPainter *p, const QRectF &)
+ { transformInDrawBackground = p->worldTransform(); }
+
+ void drawForeground(QPainter *p, const QRectF &)
+ { transformInDrawForeground = p->worldTransform(); }
+
+ QTransform transformInDrawBackground;
+ QTransform transformInDrawForeground;
+ };
+
+ MyScene scene;
+ // Add transformed dummy items to make sure the painter's worldTransform() is changed in drawItems.
+ scene.addRect(0, 0, 20, 20)->setTransform(QTransform::fromScale(2, 2));
+ scene.addRect(50, 50, 20, 20)->setTransform(QTransform::fromTranslate(200, 200));
+
+ CustomView view(&scene);
+ if (!savePainter)
+ view.setOptimizationFlag(QGraphicsView::DontSavePainterState);
+ view.rotate(45);
+ view.scale(1.5, 1.5);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+
+ // Make sure the view is repainted; otherwise the tests below will fail.
+ view.viewport()->repaint();
+ QTest::qWait(200);
+ QVERIFY(view.painted);
+
+ // Make sure the painter's world transform is preserved after drawItems.
+ const QTransform expectedTransform = view.viewportTransform();
+ QVERIFY(!expectedTransform.isIdentity());
+ QCOMPARE(scene.transformInDrawForeground, expectedTransform);
+ QCOMPARE(scene.transformInDrawBackground, expectedTransform);
+}
+
class LodItem : public QGraphicsRectItem
{
public:
@@ -3431,10 +3486,12 @@ void tst_QGraphicsView::exposeRegion()
// Make sure it triggers correct repaint on the view.
QTRY_COMPARE(view.lastUpdateRegions.size(), 1);
- QTRY_COMPARE(view.lastUpdateRegions.at(0), expectedExposeRegion);
+ COMPARE_REGIONS(view.lastUpdateRegions.at(0), expectedExposeRegion);
// Make sure the item didn't get any repaints.
+#ifndef QT_MAC_USE_COCOA
QCOMPARE(item->paints, 0);
+#endif
}
void tst_QGraphicsView::update_data()
@@ -3543,6 +3600,7 @@ void tst_QGraphicsView::inputMethodSensitivity()
item->setFlag(QGraphicsItem::ItemIsFocusable);
scene.addItem(item);
scene.setFocusItem(item);
+ QCOMPARE(scene.focusItem(), item);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true);
item->setFlag(QGraphicsItem::ItemAcceptsInputMethod, false);
@@ -3557,27 +3615,35 @@ void tst_QGraphicsView::inputMethodSensitivity()
scene.addItem(item2);
scene.setFocusItem(item2);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false);
+ QCOMPARE(scene.focusItem(), item2);
scene.setFocusItem(item);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true);
+ QCOMPARE(scene.focusItem(), item);
view.setScene(0);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false);
+ QCOMPARE(scene.focusItem(), item);
view.setScene(&scene);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true);
+ QCOMPARE(scene.focusItem(), item);
scene.setFocusItem(item2);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false);
+ QCOMPARE(scene.focusItem(), item2);
view.setScene(0);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false);
+ QCOMPARE(scene.focusItem(), item2);
scene.setFocusItem(item);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false);
+ QCOMPARE(scene.focusItem(), item);
view.setScene(&scene);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true);
+ QCOMPARE(scene.focusItem(), item);
}
class InputContextTester : public QInputContext
@@ -3660,6 +3726,10 @@ void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged()
void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins()
{
+#if defined(Q_OS_WINCE)
+ QSKIP("Qt/CE does not implement mouse tracking at this point", SkipAll);
+#endif
+
QGraphicsScene scene(-100, -100, 200, 200);
scene.addRect(QRectF(-50, -50, 100, 100), QPen(Qt::black), QBrush(Qt::blue));
@@ -3727,7 +3797,7 @@ void tst_QGraphicsView::task259503_scrollingArtifacts()
{
// qDebug() << event->region();
// qDebug() << updateRegion;
- QEXPECT_FAIL("", "The event region doesn't include the original item position region. See task #259503.", Continue);
+ QEXPECT_FAIL("", "The event region doesn't include the original item position region. See QTBUG-4416", Continue);
QCOMPARE(event->region(), updateRegion);
}
}
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview_2.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview_2.cpp
index 9567f9ef60..1bfaf51a91 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview_2.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview_2.cpp
@@ -43,6 +43,20 @@
#include <QRectF>
#include <QTransform>
+#ifdef Q_OS_WINCE
+#include <qguifunctions_wince.h>
+
+bool qt_wince_is_high_dpi() {
+ HDC deviceContext = GetDC(0);
+ int dpi = GetDeviceCaps(deviceContext, LOGPIXELSX);
+ ReleaseDC(0, deviceContext);
+ if ((dpi < 1000) && (dpi > 0))
+ return dpi > 96;
+ else
+ return false;
+}
+#endif
+
Q_DECLARE_METATYPE(QList<int>)
Q_DECLARE_METATYPE(QList<QRectF>)
Q_DECLARE_METATYPE(QMatrix)
@@ -51,7 +65,7 @@ Q_DECLARE_METATYPE(QPointF)
Q_DECLARE_METATYPE(QRectF)
Q_DECLARE_METATYPE(Qt::ScrollBarPolicy)
-static void _scrollBarRanges_data_1()
+static void _scrollBarRanges_data_1(int offset)
{
// No motif, flat frame
QTest::newRow("1") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
@@ -59,73 +73,73 @@ static void _scrollBarRanges_data_1()
<< 0 << 0 << 0 << 0 << false << false;
QTest::newRow("2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16) << 0 << 16 << false << false;
+ << 0 << (50 + offset) << 0 << offset << false << false;
QTest::newRow("3") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16) << 0 << (100 + 16) << false << false;
+ << 0 << (50 + offset) << 0 << (100 + offset) << false << false;
QTest::newRow("4") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
<< 0 << 0 << 0 << 0 << false << false;
QTest::newRow("5") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16-50) << -100 << (-100 + 16) << false << false;
+ << -100 << (offset -50) << -100 << (-100 + offset) << false << false;
QTest::newRow("6") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16-50) << -100 << 16 << false << false;
+ << -100 << (offset -50) << -100 << offset << false << false;
QTest::newRow("7") << QSize(150, 100) << QRectF(0, 0, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << 17 << 0 << 17 << false << false;
+ << 0 << (offset + 1) << 0 << offset + 1 << false << false;
QTest::newRow("8") << QSize(150, 100) << QRectF(0, 0, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17) << 0 << 17 << false << false;
+ << 0 << (50 + offset + 1) << 0 << offset + 1 << false << false;
QTest::newRow("9") << QSize(150, 100) << QRectF(0, 0, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17) << 0 << (100 + 17) << false << false;
+ << 0 << (50 + offset + 1) << 0 << (100 + offset + 1) << false << false;
QTest::newRow("10") << QSize(150, 100) << QRectF(-101, -101, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -101 << (-100 + 16) << -101 << (-100 + 16) << false << false;
+ << -101 << (-100 + offset) << -101 << (-100 + offset) << false << false;
QTest::newRow("11") << QSize(150, 100) << QRectF(-101, -101, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16-50) << -101 << (-100 + 16) << false << false;
+ << (-101) << (offset + -50) << -101 << (-100 + offset) << false << false;
QTest::newRow("12") << QSize(150, 100) << QRectF(-101, -101, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16-50) << (-101) << 16 << false << false;
+ << (-101) << (offset -50) << (-101) << offset << false << false;
QTest::newRow("13") << QSize(150, 100) << QRectF(0, 0, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (16 + 16) << 0 << (16 + 16) << false << false;
+ << 0 << (offset + 16) << 0 << (offset + 16) << false << false;
QTest::newRow("14") << QSize(150, 100) << QRectF(0, 0, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16) << 0 << (16 + 16) << false << false;
+ << 0 << (50 + offset + 16) << 0 << (offset + 16) << false << false;
QTest::newRow("15") << QSize(150, 100) << QRectF(0, 0, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16) << 0 << (100 + 16 + 16) << false << false;
+ << 0 << (50 + offset + 16) << 0 << (100 + offset + 16) << false << false;
QTest::newRow("16") << QSize(150, 100) << QRectF(-116, -116, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (-100 + 16) << (-100 - 16) << (-100 + 16) << false << false;
+ << (-100 - 16) << (-100 + offset) << (-100 - 16 ) << (-100 + offset) << false << false;
QTest::newRow("17") << QSize(150, 100) << QRectF(-116, -116, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16-50) << (-100 - 16) << (-100 + 16) << false << false;
+ << (-100 - 16) << (offset -50) << (-100 - 16) << (-100 + offset) << false << false;
QTest::newRow("18") << QSize(150, 100) << QRectF(-116, -116, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16-50) << (-100 - 16) << 16 << false << false;
+ << (-100 - 16) << (offset -50) << (-100 - 16) << offset << false << false;
QTest::newRow("1 x2") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (150 + 16) << 0 << (100 + 16) << false << false;
+ << 0 << (150 + offset) << 0 << (100 + offset) << false << false;
QTest::newRow("2 x2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16) << 0 << (100 + 16) << false << false;
+ << 0 << (250 + offset) << 0 << (100 + offset) << false << false;
QTest::newRow("3 x2") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16) << 0 << (300 + 16) << false << false;
+ << 0 << (250 + offset) << 0 << (300 + offset) << false << false;
QTest::newRow("4 x2") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (-50 + 16) << -200 << (-100 + 16) << false << false;
+ << -200 << (-50 + offset) << -200 << (-100 + offset) << false << false;
QTest::newRow("5 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16) << -200 << (-100 + 16) << false << false;
+ << -200 << (50 + offset) << -200 << (-100 + offset) << false << false;
QTest::newRow("6 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16) << -200 << (100 + 16) << false << false;
+ << -200 << (50 + offset) << -200 << (100 + offset) << false << false;
QTest::newRow("1 No ScrollBars") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
<< Qt::ScrollBarAlwaysOff << Qt::ScrollBarAlwaysOff
<< 0 << 0 << 0 << 0 << false << false;
@@ -272,7 +286,7 @@ static void _scrollBarRanges_data_1()
<< -200 << (50 + 16) << -200 << (100 + 16) << false << false;
}
-static void _scrollBarRanges_data_2()
+static void _scrollBarRanges_data_2(int offset)
{
// Motif, flat frame
QTest::newRow("Motif, 1") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
@@ -280,73 +294,73 @@ static void _scrollBarRanges_data_2()
<< 0 << 0 << 0 << 0 << true << false;
QTest::newRow("Motif, 2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16) << 0 << 16 << true << false;
+ << 0 << (50 + offset) << 0 << offset << true << false;
QTest::newRow("Motif, 3") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16) << 0 << (100 + 16) << true << false;
+ << 0 << (50 + offset) << 0 << (100 + offset) << true << false;
QTest::newRow("Motif, 4") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
<< 0 << 0 << 0 << 0 << true << false;
QTest::newRow("Motif, 5") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16-50) << -100 << (-100 + 16) << true << false;
+ << -100 << (offset-50) << -100 << (-100 + offset) << true << false;
QTest::newRow("Motif, 6") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16-50) << -100 << 16 << true << false;
+ << -100 << (offset-50) << -100 << offset << true << false;
QTest::newRow("Motif, 7") << QSize(150, 100) << QRectF(0, 0, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << 17 << 0 << 17 << true << false;
+ << 0 << offset + 1 << 0 << offset + 1 << true << false;
QTest::newRow("Motif, 8") << QSize(150, 100) << QRectF(0, 0, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17) << 0 << 17 << true << false;
+ << 0 << (50 + offset + 1) << 0 << offset + 1 << true << false;
QTest::newRow("Motif, 9") << QSize(150, 100) << QRectF(0, 0, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17) << 0 << (100 + 17) << true << false;
+ << 0 << (50 + offset + 1) << 0 << (100 + offset + 1) << true << false;
QTest::newRow("Motif, 10") << QSize(150, 100) << QRectF(-101, -101, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -101 << (-100 + 16) << -101 << (-100 + 16) << true << false;
+ << -101 << (-100 + offset) << -101 << (-100 + offset) << true << false;
QTest::newRow("Motif, 11") << QSize(150, 100) << QRectF(-101, -101, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16-50) << -101 << (-100 + 16) << true << false;
+ << (-101) << (offset-50) << -101 << (-100 + offset) << true << false;
QTest::newRow("Motif, 12") << QSize(150, 100) << QRectF(-101, -101, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16-50) << (-101) << 16 << true << false;
+ << (-101) << (offset-50) << (-101) << offset << true << false;
QTest::newRow("Motif, 13") << QSize(150, 100) << QRectF(0, 0, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (16 + 16) << 0 << (16 + 16) << true << false;
+ << 0 << (offset + 16) << 0 << (offset + 16) << true << false;
QTest::newRow("Motif, 14") << QSize(150, 100) << QRectF(0, 0, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16) << 0 << (16 + 16) << true << false;
+ << 0 << (50 + offset + 16) << 0 << (offset + 16) << true << false;
QTest::newRow("Motif, 15") << QSize(150, 100) << QRectF(0, 0, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16) << 0 << (100 + 16 + 16) << true << false;
+ << 0 << (50 + offset + 16) << 0 << (100 + offset + 16) << true << false;
QTest::newRow("Motif, 16") << QSize(150, 100) << QRectF(-116, -116, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (-100 + 16) << (-100 - 16) << (-100 + 16) << true << false;
+ << (-100 - 16) << (-100 + offset) << (-100 - 16) << (-100 + offset) << true << false;
QTest::newRow("Motif, 17") << QSize(150, 100) << QRectF(-116, -116, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16-50) << (-100 - 16) << (-100 + 16) << true << false;
+ << (-100 - 16) << (offset-50) << (-100 - 16) << (-100 + offset) << true << false;
QTest::newRow("Motif, 18") << QSize(150, 100) << QRectF(-116, -116, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16-50) << (-100 - 16) << 16 << true << false;
+ << (-100 - 16) << (offset-50) << (-100 - 16) << offset << true << false;
QTest::newRow("Motif, 1 x2") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (150 + 16) << 0 << (100 + 16) << true << false;
+ << 0 << (150 + offset) << 0 << (100 + offset) << true << false;
QTest::newRow("Motif, 2 x2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16) << 0 << (100 + 16) << true << false;
+ << 0 << (250 + offset) << 0 << (100 + offset) << true << false;
QTest::newRow("Motif, 3 x2") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16) << 0 << (300 + 16) << true << false;
+ << 0 << (250 + offset) << 0 << (300 + offset) << true << false;
QTest::newRow("Motif, 4 x2") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (-50 + 16) << -200 << (-100 + 16) << true << false;
+ << -200 << (-50 + offset) << -200 << (-100 + offset) << true << false;
QTest::newRow("Motif, 5 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16) << -200 << (-100 + 16) << true << false;
+ << -200 << (50 + offset) << -200 << (-100 + offset) << true << false;
QTest::newRow("Motif, 6 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16) << -200 << (100 + 16) << true << false;
+ << -200 << (50 + offset) << -200 << (100 + offset) << true << false;
QTest::newRow("Motif, 1 No ScrollBars") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
<< Qt::ScrollBarAlwaysOff << Qt::ScrollBarAlwaysOff
<< 0 << 0 << 0 << 0 << true << false;
@@ -493,7 +507,7 @@ static void _scrollBarRanges_data_2()
<< -200 << (50 + 16) << -200 << (100 + 16) << true << false;
}
-static void _scrollBarRanges_data_3()
+static void _scrollBarRanges_data_3(int offset)
{
// No motif, styled panel
QTest::newRow("Styled, 1") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
@@ -501,73 +515,73 @@ static void _scrollBarRanges_data_3()
<< 0 << 0 << 0 << 0 << false << true;
QTest::newRow("Styled, 2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16) << 0 << 16 << false << true;
+ << 0 << (50 + offset) << 0 << offset << false << true;
QTest::newRow("Styled, 3") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16) << 0 << (100 + 16) << false << true;
+ << 0 << (50 + offset) << 0 << (100 + offset) << false << true;
QTest::newRow("Styled, 4") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
<< 0 << 0 << 0 << 0 << false << true;
QTest::newRow("Styled, 5") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16-50) << -100 << (-100 + 16) << false << true;
+ << -100 << (offset-50) << -100 << (-100 + offset) << false << true;
QTest::newRow("Styled, 6") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16-50) << -100 << 16 << false << true;
+ << -100 << (offset-50) << -100 << offset << false << true;
QTest::newRow("Styled, 7") << QSize(150, 100) << QRectF(0, 0, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << 17 << 0 << 17 << false << true;
+ << 0 << offset + 1 << 0 << offset + 1 << false << true;
QTest::newRow("Styled, 8") << QSize(150, 100) << QRectF(0, 0, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17) << 0 << 17 << false << true;
+ << 0 << (50 + offset + 1) << 0 << offset + 1 << false << true;
QTest::newRow("Styled, 9") << QSize(150, 100) << QRectF(0, 0, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17) << 0 << (100 + 17) << false << true;
+ << 0 << (50 + offset + 1) << 0 << (100 + offset + 1) << false << true;
QTest::newRow("Styled, 10") << QSize(150, 100) << QRectF(-101, -101, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -101 << (-100 + 16) << -101 << (-100 + 16) << false << true;
+ << -101 << (-100 + offset) << -101 << (-100 + offset) << false << true;
QTest::newRow("Styled, 11") << QSize(150, 100) << QRectF(-101, -101, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16-50) << -101 << (-100 + 16) << false << true;
+ << (-101) << (offset-50) << -101 << (-100 + offset) << false << true;
QTest::newRow("Styled, 12") << QSize(150, 100) << QRectF(-101, -101, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16-50) << (-101) << 16 << false << true;
+ << (-101) << (offset-50) << (-101) << offset << false << true;
QTest::newRow("Styled, 13") << QSize(150, 100) << QRectF(0, 0, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (16 + 16) << 0 << (16 + 16) << false << true;
+ << 0 << (offset + 16) << 0 << (offset + 16) << false << true;
QTest::newRow("Styled, 14") << QSize(150, 100) << QRectF(0, 0, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16) << 0 << (16 + 16) << false << true;
+ << 0 << (50 + offset + 16) << 0 << (offset + 16) << false << true;
QTest::newRow("Styled, 15") << QSize(150, 100) << QRectF(0, 0, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16) << 0 << (100 + 16 + 16) << false << true;
+ << 0 << (50 + offset + 16) << 0 << (100 + offset + 16) << false << true;
QTest::newRow("Styled, 16") << QSize(150, 100) << QRectF(-116, -116, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (-100 + 16) << (-100 - 16) << (-100 + 16) << false << true;
+ << (-100 - 16) << (-100 + offset) << (-100 - 16) << (-100 + offset) << false << true;
QTest::newRow("Styled, 17") << QSize(150, 100) << QRectF(-116, -116, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16-50) << (-100 - 16) << (-100 + 16) << false << true;
+ << (-100 - 16) << (offset-50) << (-100 - 16) << (-100 + offset) << false << true;
QTest::newRow("Styled, 18") << QSize(150, 100) << QRectF(-116, -116, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16-50) << (-100 - 16) << 16 << false << true;
+ << (-100 - 16) << (offset-50) << (-100 - 16) << offset << false << true;
QTest::newRow("Styled, 1 x2") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (150 + 16) << 0 << (100 + 16) << false << true;
+ << 0 << (150 + offset) << 0 << (100 + offset) << false << true;
QTest::newRow("Styled, 2 x2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16) << 0 << (100 + 16) << false << true;
+ << 0 << (250 + offset) << 0 << (100 + offset) << false << true;
QTest::newRow("Styled, 3 x2") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16) << 0 << (300 + 16) << false << true;
+ << 0 << (250 + offset) << 0 << (300 + offset) << false << true;
QTest::newRow("Styled, 4 x2") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (-50 + 16) << -200 << (-100 + 16) << false << true;
+ << -200 << (-50 + offset) << -200 << (-100 + offset) << false << true;
QTest::newRow("Styled, 5 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16) << -200 << (-100 + 16) << false << true;
+ << -200 << (50 + offset) << -200 << (-100 + offset) << false << true;
QTest::newRow("Styled, 6 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16) << -200 << (100 + 16) << false << true;
+ << -200 << (50 + offset) << -200 << (100 + offset) << false << true;
QTest::newRow("Styled, 1 No ScrollBars") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
<< Qt::ScrollBarAlwaysOff << Qt::ScrollBarAlwaysOff
<< 0 << 0 << 0 << 0 << false << true;
@@ -714,7 +728,7 @@ static void _scrollBarRanges_data_3()
<< -200 << (50 + 16) << -200 << (100 + 16) << false << true;
}
-static void _scrollBarRanges_data_4()
+static void _scrollBarRanges_data_4(int offset)
{
// Motif, styled panel
QTest::newRow("Motif, Styled, 1") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
@@ -722,73 +736,73 @@ static void _scrollBarRanges_data_4()
<< 0 << 0 << 0 << 0 << true << true;
QTest::newRow("Motif, Styled, 2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 4) << 0 << (16 + 4) << true << true;
+ << 0 << (50 + offset + 4) << 0 << (offset + 4) << true << true;
QTest::newRow("Motif, Styled, 3") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 4) << 0 << (100 + 16 + 4) << true << true;
+ << 0 << (50 + offset + 4) << 0 << (100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 4") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
<< 0 << 0 << 0 << 0 << true << true;
QTest::newRow("Motif, Styled, 5") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16 + 4 - 50) << -100 << (-100 + 16 + 4) << true << true;
+ << -100 << (offset + 4 - 50) << -100 << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 6") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16 + 4 - 50) << -100 << (16 + 4) << true << true;
+ << -100 << (offset + 4 - 50) << -100 << (offset + 4) << true << true;
QTest::newRow("Motif, Styled, 7") << QSize(150, 100) << QRectF(0, 0, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (17 + 4) << 0 << (17 + 4) << true << true;
+ << 0 << (offset + 1 + 4) << 0 << (offset + 1 + 4) << true << true;
QTest::newRow("Motif, Styled, 8") << QSize(150, 100) << QRectF(0, 0, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17 + 4) << 0 << (17 + 4) << true << true;
+ << 0 << (50 + offset + 1 + 4) << 0 << (offset + 1 + 4) << true << true;
QTest::newRow("Motif, Styled, 9") << QSize(150, 100) << QRectF(0, 0, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17 + 4) << 0 << (100 + 17 + 4) << true << true;
+ << 0 << (50 + offset + 1 + 4) << 0 << (100 + offset + 1 + 4) << true << true;
QTest::newRow("Motif, Styled, 10") << QSize(150, 100) << QRectF(-101, -101, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -101 << (-100 + 16 + 4) << -101 << (-100 + 16 + 4) << true << true;
+ << -101 << (-100 + offset + 4) << -101 << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 11") << QSize(150, 100) << QRectF(-101, -101, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16 + 4 - 50) << -101 << (-100 + 16 + 4) << true << true;
+ << (-101) << (offset + 4 - 50) << -101 << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 12") << QSize(150, 100) << QRectF(-101, -101, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16 + 4 - 50) << (-101) << (16 + 4) << true << true;
+ << (-101) << (offset + 4 - 50) << (-101) << (offset + 4) << true << true;
QTest::newRow("Motif, Styled, 13") << QSize(150, 100) << QRectF(0, 0, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (16 + 16 + 4) << 0 << (16 + 16 + 4) << true << true;
+ << 0 << (offset + 16 + 4) << 0 << (offset + 16 + 4) << true << true;
QTest::newRow("Motif, Styled, 14") << QSize(150, 100) << QRectF(0, 0, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16 + 4) << 0 << (16 + 16 + 4) << true << true;
+ << 0 << (50 + offset + 16 + 4) << 0 << (offset + 16 + 4) << true << true;
QTest::newRow("Motif, Styled, 15") << QSize(150, 100) << QRectF(0, 0, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16 + 4) << 0 << (100 + 16 + 16 + 4) << true << true;
+ << 0 << (50 + offset + 16 + 4) << 0 << (100 + offset + 16 + 4) << true << true;
QTest::newRow("Motif, Styled, 16") << QSize(150, 100) << QRectF(-116, -116, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (-100 + 16 + 4) << (-100 - 16) << (-100 + 16 + 4) << true << true;
+ << (-100 - 16) << (-100 + offset + 4) << (-100 - 16) << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 17") << QSize(150, 100) << QRectF(-116, -116, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16 + 4 - 50) << (-100 - 16) << (-100 + 16 + 4) << true << true;
+ << (-100 - 16) << (offset + 4 - 50) << (-100 - 16) << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 18") << QSize(150, 100) << QRectF(-116, -116, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16 + 4 - 50) << (-100 - 16) << (16 + 4) << true << true;
+ << (-100 - 16) << (offset + 4 - 50) << (-100 - 16) << (offset + 4) << true << true;
QTest::newRow("Motif, Styled, 1 x2") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (150 + 16 + 4) << 0 << (100 + 16 + 4) << true << true;
+ << 0 << (150 + offset + 4) << 0 << (100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 2 x2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16 + 4) << 0 << (100 + 16 + 4) << true << true;
+ << 0 << (250 + offset + 4) << 0 << (100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 3 x2") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16 + 4) << 0 << (300 + 16 + 4) << true << true;
+ << 0 << (250 + offset + 4) << 0 << (300 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 4 x2") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (-50 + 16 + 4) << -200 << (-100 + 16 + 4) << true << true;
+ << -200 << (-50 + offset + 4) << -200 << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 5 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16 + 4) << -200 << (-100 + 16 + 4) << true << true;
+ << -200 << (50 + offset + 4) << -200 << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 6 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16 + 4) << -200 << (100 + 16 + 4) << true << true;
+ << -200 << (50 + offset + 4) << -200 << (100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 1 No ScrollBars") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
<< Qt::ScrollBarAlwaysOff << Qt::ScrollBarAlwaysOff
<< 0 << 0 << 0 << 0 << true << true;
@@ -949,8 +963,14 @@ void _scrollBarRanges_data()
QTest::addColumn<bool>("useMotif");
QTest::addColumn<bool>("useStyledPanel");
- _scrollBarRanges_data_1();
- _scrollBarRanges_data_2();
- _scrollBarRanges_data_3();
- _scrollBarRanges_data_4();
+ int offset = 16;
+#ifdef Q_OS_WINCE
+ if (qt_wince_is_high_dpi())
+ offset *= 2;
+#endif
+
+ _scrollBarRanges_data_1(offset);
+ _scrollBarRanges_data_2(offset);
+ _scrollBarRanges_data_3(offset);
+ _scrollBarRanges_data_4(offset);
}
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 6b5ad09351..829e55c4b3 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -160,6 +160,7 @@ private slots:
void widgetSendsGeometryChanges();
void respectHFW();
void addChildInpolishEvent();
+ void polishEvent();
// Task fixes
void task236127_bspTreeIndexFails();
@@ -2768,6 +2769,32 @@ void tst_QGraphicsWidget::addChildInpolishEvent()
QCOMPARE(PolishWidget::numberOfPolish, 2);
}
+void tst_QGraphicsWidget::polishEvent()
+{
+ class MyGraphicsWidget : public QGraphicsWidget
+ { public:
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
+ { events << QEvent::Paint; }
+ void polishEvent()
+ { events << QEvent::Polish; }
+ QList<QEvent::Type> events;
+ };
+
+ QGraphicsScene scene;
+
+ MyGraphicsWidget *widget = new MyGraphicsWidget;
+ scene.addItem(widget);
+
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ // Make sure the item is painted.
+ QTRY_VERIFY(widget->events.contains(QEvent::Paint));
+
+ // Make sure the item got polish before paint.
+ QCOMPARE(widget->events.at(0), QEvent::Polish);
+}
QTEST_MAIN(tst_QGraphicsWidget)
#include "tst_qgraphicswidget.moc"
diff --git a/tests/auto/qgridlayout/tst_qgridlayout.cpp b/tests/auto/qgridlayout/tst_qgridlayout.cpp
index 7c320be2ef..313dc95058 100644
--- a/tests/auto/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/qgridlayout/tst_qgridlayout.cpp
@@ -268,7 +268,7 @@ void tst_QGridLayout::setMinAndMaxSize()
leftChild.setMinimumSize(100, 100);
leftChild.setMaximumSize(200, 200);
layout.addWidget(&leftChild, 0, 0);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.minimumSize(), leftChild.minimumSize());
QCOMPARE(widget.maximumSize(), leftChild.maximumSize());
@@ -277,7 +277,7 @@ void tst_QGridLayout::setMinAndMaxSize()
rightChild.setMinimumSize(100, 100);
rightChild.setMaximumSize(200, 200);
layout.addWidget(&rightChild, 0, 2);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.minimumWidth(),
leftChild.minimumWidth() + rightChild.minimumWidth());
@@ -293,7 +293,7 @@ void tst_QGridLayout::setMinAndMaxSize()
layout.setColumnMinimumWidth(1, colMin);
QCOMPARE(layout.columnMinimumWidth(1), colMin);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.minimumWidth(),
leftChild.minimumWidth() + rightChild.minimumWidth() + colMin);
QCOMPARE(widget.maximumWidth(),
@@ -306,7 +306,7 @@ void tst_QGridLayout::setMinAndMaxSize()
layout.setColumnStretch(1,1);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.minimumWidth(),
leftChild.minimumWidth() + rightChild.minimumWidth() + colMin);
QCOMPARE(widget.maximumWidth(), QLAYOUTSIZE_MAX);
@@ -318,7 +318,7 @@ void tst_QGridLayout::setMinAndMaxSize()
layout.setColumnStretch(1,0);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.minimumWidth(),
leftChild.minimumWidth() + rightChild.minimumWidth() + colMin);
QCOMPARE(widget.maximumWidth(),
@@ -335,7 +335,7 @@ void tst_QGridLayout::setMinAndMaxSize()
static const int spacerS = 250;
QSpacerItem *spacer = new QSpacerItem(spacerS, spacerS);
layout.addItem(spacer, 0, 1);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.minimumWidth(),
leftChild.minimumWidth() + rightChild.minimumWidth() + spacerS);
@@ -348,7 +348,7 @@ void tst_QGridLayout::setMinAndMaxSize()
spacer->changeSize(spacerS, spacerS, QSizePolicy::Fixed, QSizePolicy::Minimum);
layout.invalidate();
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.minimumWidth(),
leftChild.minimumWidth() + rightChild.minimumWidth() + spacerS);
QCOMPARE(widget.maximumWidth(),
@@ -358,13 +358,13 @@ void tst_QGridLayout::setMinAndMaxSize()
layout.removeItem(spacer);
rightChild.hide();
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.minimumSize(), leftChild.minimumSize());
QCOMPARE(widget.maximumSize(), leftChild.maximumSize());
rightChild.show();
layout.removeWidget(&rightChild);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.minimumSize(), leftChild.minimumSize());
QCOMPARE(widget.maximumSize(), leftChild.maximumSize());
@@ -373,7 +373,7 @@ void tst_QGridLayout::setMinAndMaxSize()
bottomChild.setMinimumSize(100, 100);
bottomChild.setMaximumSize(200, 200);
layout.addWidget(&bottomChild, 1, 0);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.minimumHeight(),
leftChild.minimumHeight() + bottomChild.minimumHeight());
@@ -385,13 +385,13 @@ void tst_QGridLayout::setMinAndMaxSize()
qMax(leftChild.maximumWidth(), bottomChild.maximumWidth()));
bottomChild.hide();
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.minimumSize(), leftChild.minimumSize());
QCOMPARE(widget.maximumSize(), leftChild.maximumSize());
bottomChild.show();
layout.removeWidget(&bottomChild);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.minimumSize(), leftChild.minimumSize());
QCOMPARE(widget.maximumSize(), leftChild.maximumSize());
}
@@ -423,7 +423,7 @@ void tst_QGridLayout::spacingAndSpacers()
SizeHinter leftChild(100,100);
leftChild.setPalette(QPalette(Qt::red));
layout.addWidget(&leftChild, 0, 0);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
expectedSizeHint = leftChild.sizeHint();
QCOMPARE(widget.sizeHint(), expectedSizeHint);
@@ -431,7 +431,7 @@ void tst_QGridLayout::spacingAndSpacers()
SizeHinter rightChild(200,100);
rightChild.setPalette(QPalette(Qt::green));
layout.addWidget(&rightChild, 0, 2);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(rightChild.sizeHint(), QSize(200,100));
expectedSizeHint += QSize(rightChild.sizeHint().width(), 0);
@@ -440,11 +440,11 @@ void tst_QGridLayout::spacingAndSpacers()
layout.setColumnMinimumWidth(1, 100);
widget.adjustSize();
expectedSizeHint += QSize(100,0);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.sizeHint(), expectedSizeHint);
rightChild.hide();
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
expectedSizeHint -= QSize(rightChild.sizeHint().width(), 0);
QCOMPARE(widget.sizeHint(), expectedSizeHint);
@@ -459,12 +459,12 @@ void tst_QGridLayout::spacingAndSpacers()
leftChild.setMaximumWidth(200);
rightChild.setMaximumWidth(200);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.maximumWidth(), leftChild.maximumWidth() + rightChild.maximumWidth());
#endif
layout.removeWidget(&rightChild);
- QApplication::processEvents();
+ QApplication::sendPostedEvents(0, 0);
QCOMPARE(widget.sizeHint(), expectedSizeHint);
@@ -920,9 +920,9 @@ void tst_QGridLayout::minMaxSize()
#if defined(Q_WS_X11)
qt_x11_wait_for_window_manager(m_toplevel); // wait for the show
#endif
- QTest::qWait(20);
+ QTest::qWait(40);
m_toplevel->adjustSize();
- QTest::qWait(120); // wait for the implicit adjustSize
+ QTest::qWait(240); // wait for the implicit adjustSize
// If the following fails we might have to wait longer.
// If that does not help there is likely a problem with the implicit adjustSize in show()
if (!fixedSize.isValid()) {
diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp
index 920231d83d..c13e829832 100644
--- a/tests/auto/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/qheaderview/tst_qheaderview.cpp
@@ -682,9 +682,12 @@ void tst_QHeaderView::visualIndexAt()
void tst_QHeaderView::length()
{
-#ifdef Q_OS_WINCE
+#if defined(Q_OS_WINCE)
QFont font(QLatin1String("Tahoma"), 7);
view->setFont(font);
+#elif defined(Q_OS_SYMBIAN)
+ QFont font(QLatin1String("Series 60 Sans"), 6);
+ view->setFont(font);
#endif
view->setStretchLastSection(true);
view->show();
@@ -1836,7 +1839,7 @@ void tst_QHeaderView::preserveHiddenSectionWidth()
model.insertRow(1);
view.showSection(2);
QCOMPARE(view.sectionSize(0), 100);
- QCOMPARE(view.sectionSize(1), 30);
+ QCOMPARE(view.sectionSize(1), view.defaultSectionSize());
QCOMPARE(view.sectionSize(2), 50);
}
diff --git a/tests/auto/qhttp/tst_qhttp.cpp b/tests/auto/qhttp/tst_qhttp.cpp
index f6d5e3e5fc..0ea0d15fdc 100644
--- a/tests/auto/qhttp/tst_qhttp.cpp
+++ b/tests/auto/qhttp/tst_qhttp.cpp
@@ -484,6 +484,7 @@ void tst_QHttp::post_data()
QTest::addColumn<bool>("useProxy");
QTest::addColumn<QString>("host");
QTest::addColumn<int>("port");
+ QTest::addColumn<bool>("ssl");
QTest::addColumn<QString>("path");
QTest::addColumn<QByteArray>("result");
@@ -491,25 +492,48 @@ void tst_QHttp::post_data()
md5sum = "d41d8cd98f00b204e9800998ecf8427e";
QTest::newRow("empty-data")
<< QString() << false << false
- << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
+ << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
QTest::newRow("empty-device")
<< QString() << true << false
- << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
+ << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
QTest::newRow("proxy-empty-data")
<< QString() << false << true
- << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
+ << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
md5sum = "b3e32ac459b99d3f59318f3ac31e4bee";
QTest::newRow("data") << "rfc3252.txt" << false << false
- << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi"
+ << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi"
<< md5sum;
QTest::newRow("device") << "rfc3252.txt" << true << false
- << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi"
+ << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi"
<< md5sum;
QTest::newRow("proxy-data") << "rfc3252.txt" << false << true
- << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi"
+ << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi"
<< md5sum;
+#ifndef QT_NO_OPENSSL
+ md5sum = "d41d8cd98f00b204e9800998ecf8427e";
+ QTest::newRow("empty-data-ssl")
+ << QString() << false << false
+ << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
+ QTest::newRow("empty-device-ssl")
+ << QString() << true << false
+ << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
+ QTest::newRow("proxy-empty-data-ssl")
+ << QString() << false << true
+ << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
+ md5sum = "b3e32ac459b99d3f59318f3ac31e4bee";
+ QTest::newRow("data-ssl") << "rfc3252.txt" << false << false
+ << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi"
+ << md5sum;
+ QTest::newRow("device-ssl") << "rfc3252.txt" << true << false
+ << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi"
+ << md5sum;
+ QTest::newRow("proxy-data-ssl") << "rfc3252.txt" << false << true
+ << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi"
+ << md5sum;
+#endif
+
// the following test won't work. See task 185996
/*
QTest::newRow("proxy-device") << "rfc3252.txt" << true << true
@@ -525,14 +549,19 @@ void tst_QHttp::post()
QFETCH(bool, useProxy);
QFETCH(QString, host);
QFETCH(int, port);
+ QFETCH(bool, ssl);
QFETCH(QString, path);
http = newHttp(useProxy);
+#ifndef QT_NO_OPENSSL
+ QObject::connect(http, SIGNAL(sslErrors(const QList<QSslError> &)),
+ http, SLOT(ignoreSslErrors()));
+#endif
QCOMPARE(http->currentId(), 0);
QCOMPARE((int)http->state(), (int)QHttp::Unconnected);
if (useProxy)
addRequest(QHttpRequestHeader(), http->setProxy(QtNetworkSettings::serverName(), 3129));
- addRequest(QHttpRequestHeader(), http->setHost(host, port));
+ addRequest(QHttpRequestHeader(), http->setHost(host, (ssl ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp), port));
// add the POST request
QFile file(SRCDIR + source);
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp
index e15ae8a645..da4e85d074 100644
--- a/tests/auto/qimage/tst_qimage.cpp
+++ b/tests/auto/qimage/tst_qimage.cpp
@@ -104,7 +104,7 @@ private slots:
void setPixel_data();
void setPixel();
- void setNumColors();
+ void setColorCount();
void setColor();
void rasterClipping();
@@ -155,7 +155,7 @@ void tst_QImage::create()
#endif
//QImage image(7000000, 7000000, 8, 256, QImage::IgnoreEndian);
QImage image(7000000, 7000000, QImage::Format_Indexed8);
- image.setNumColors(256);
+ image.setColorCount(256);
cr = !image.isNull();
#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE)
} catch (...) {
@@ -242,7 +242,7 @@ void tst_QImage::convertBitOrder()
QSKIP("Qt compiled without Qt3Support", SkipAll);
#else
QImage i(9,5,1,2,QImage::LittleEndian);
- qMemSet(i.bits(), 0, i.numBytes());
+ qMemSet(i.bits(), 0, i.byteCount());
i.setDotsPerMeterX(9);
i.setDotsPerMeterY(5);
@@ -258,7 +258,7 @@ void tst_QImage::convertBitOrder()
QVERIFY(i.dotsPerMeterY() == ni.dotsPerMeterY());
QVERIFY(i.depth() == ni.depth());
QVERIFY(i.size() == ni.size());
- QVERIFY(i.numColors() == ni.numColors());
+ QVERIFY(i.colorCount() == ni.colorCount());
#endif
}
@@ -365,7 +365,7 @@ void tst_QImage::setAlphaChannel()
QImage alphaChannel;
if (gray) {
alphaChannel = QImage(width, height, QImage::Format_Indexed8);
- alphaChannel.setNumColors(256);
+ alphaChannel.setColorCount(256);
for (int i=0; i<256; ++i)
alphaChannel.setColor(i, qRgb(i, i, i));
alphaChannel.fill(alpha);
@@ -927,7 +927,7 @@ void tst_QImage::rotate()
original.fill(qRgb(255,255,255));
if (format == QImage::Format_Indexed8) {
- original.setNumColors(256);
+ original.setColorCount(256);
for (int i = 0; i < 255; ++i)
original.setColor(i, qRgb(0, i, i));
}
@@ -1196,23 +1196,23 @@ void tst_QImage::convertToFormatPreserveText()
}
#endif // QT_NO_IMAGE_TEXT
-void tst_QImage::setNumColors()
+void tst_QImage::setColorCount()
{
QImage img(0, 0, QImage::Format_Indexed8);
- QTest::ignoreMessage(QtWarningMsg, "QImage::setNumColors: null image");
- img.setNumColors(256);
- QCOMPARE(img.numColors(), 0);
+ QTest::ignoreMessage(QtWarningMsg, "QImage::setColorCount: null image");
+ img.setColorCount(256);
+ QCOMPARE(img.colorCount(), 0);
}
void tst_QImage::setColor()
{
QImage img(0, 0, QImage::Format_Indexed8);
img.setColor(0, qRgba(18, 219, 108, 128));
- QCOMPARE(img.numColors(), 0);
+ QCOMPARE(img.colorCount(), 0);
QImage img2(1, 1, QImage::Format_Indexed8);
img2.setColor(0, qRgba(18, 219, 108, 128));
- QCOMPARE(img2.numColors(), 1);
+ QCOMPARE(img2.colorCount(), 1);
}
/* Just some sanity checking that we don't draw outside the buffer of
diff --git a/tests/auto/qimagereader/images/grayscale-ref.tif b/tests/auto/qimagereader/images/grayscale-ref.tif
new file mode 100644
index 0000000000..960531ea86
--- /dev/null
+++ b/tests/auto/qimagereader/images/grayscale-ref.tif
Binary files differ
diff --git a/tests/auto/qimagereader/images/grayscale.tif b/tests/auto/qimagereader/images/grayscale.tif
new file mode 100644
index 0000000000..5f4e11429d
--- /dev/null
+++ b/tests/auto/qimagereader/images/grayscale.tif
Binary files differ
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index 05b506ce1e..15b1c1c540 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -157,6 +157,8 @@ private slots:
void tiffOrientation_data();
void tiffOrientation();
+
+ void tiffGrayscale();
#endif
void autoDetectImageFormat();
@@ -1376,6 +1378,13 @@ void tst_QImageReader::tiffOrientation()
QCOMPARE(expectedImage, orientedImage);
}
+void tst_QImageReader::tiffGrayscale()
+{
+ QImage actualImage(prefix + "grayscale.tif");
+ QImage expectedImage(prefix + "grayscale-ref.tif");
+
+ QCOMPARE(expectedImage, actualImage.convertToFormat(expectedImage.format()));
+}
#endif
void tst_QImageReader::dotsPerMeter_data()
diff --git a/tests/auto/qimagewriter/tst_qimagewriter.cpp b/tests/auto/qimagewriter/tst_qimagewriter.cpp
index 584a0602bb..5997f39924 100644
--- a/tests/auto/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/qimagewriter/tst_qimagewriter.cpp
@@ -391,16 +391,27 @@ void tst_QImageWriter::readWriteNonDestructive_data()
{
QTest::addColumn<QImage::Format>("format");
QTest::addColumn<QImage::Format>("expectedFormat");
- QTest::newRow("tiff mono") << QImage::Format_Mono << QImage::Format_Mono;
- QTest::newRow("tiff indexed") << QImage::Format_Indexed8 << QImage::Format_Indexed8;
- QTest::newRow("tiff rgb32") << QImage::Format_ARGB32 << QImage::Format_ARGB32;
+ QTest::addColumn<bool>("grayscale");
+ QTest::newRow("tiff mono") << QImage::Format_Mono << QImage::Format_Mono << false;
+ QTest::newRow("tiff indexed") << QImage::Format_Indexed8 << QImage::Format_Indexed8 << false;
+ QTest::newRow("tiff rgb32") << QImage::Format_ARGB32 << QImage::Format_ARGB32 << false;
+ QTest::newRow("tiff grayscale") << QImage::Format_Indexed8 << QImage::Format_Indexed8 << true;
}
void tst_QImageWriter::readWriteNonDestructive()
{
QFETCH(QImage::Format, format);
QFETCH(QImage::Format, expectedFormat);
+ QFETCH(bool, grayscale);
QImage image = QImage(prefix + "colorful.bmp").convertToFormat(format);
+
+ if (grayscale) {
+ QVector<QRgb> colors;
+ for (int i = 0; i < 256; ++i)
+ colors << qRgb(i, i, i);
+ image.setColorTable(colors);
+ }
+
QVERIFY(image.save(prefix + "gen-readWriteNonDestructive.tiff"));
QImage image2 = QImage(prefix + "gen-readWriteNonDestructive.tiff");
@@ -546,7 +557,7 @@ void tst_QImageWriter::saveWithNoFormat()
QFETCH(QImageWriter::ImageWriterError, error);
QImage niceImage(64, 64, QImage::Format_ARGB32);
- qMemSet(niceImage.bits(), 0, niceImage.numBytes());
+ qMemSet(niceImage.bits(), 0, niceImage.byteCount());
QImageWriter writer(fileName /* , 0 - no format! */);
if (error != 0) {
diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
index 426887d7cf..a2770d49d3 100644
--- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
@@ -877,7 +877,7 @@ void tst_QItemDelegate::decoration()
}
case QVariant::Image: {
QImage img(size, QImage::Format_Mono);
- qMemSet(img.bits(), 0, img.numBytes());
+ qMemSet(img.bits(), 0, img.byteCount());
value = img;
break;
}
diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 77c259c460..269afbddf8 100644
--- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -92,6 +92,7 @@ private slots:
void task252069_rowIntersectsSelection();
void task232634_childrenDeselectionSignal();
void task260134_layoutChangedWithAllSelected();
+ void QTBUG5671_layoutChangedWithAllSelected();
private:
QAbstractItemModel *model;
@@ -2025,24 +2026,24 @@ void tst_QItemSelectionModel::task220420_selectedIndexes()
class QtTestTableModel: public QAbstractTableModel
{
Q_OBJECT
-
+
public:
QtTestTableModel(int rows = 0, int columns = 0, QObject *parent = 0)
: QAbstractTableModel(parent),
row_count(rows),
column_count(columns) {}
-
+
int rowCount(const QModelIndex& = QModelIndex()) const { return row_count; }
int columnCount(const QModelIndex& = QModelIndex()) const { return column_count; }
bool isEditable(const QModelIndex &) const { return true; }
-
+
QVariant data(const QModelIndex &idx, int role) const
{
if (role == Qt::DisplayRole || role == Qt::EditRole)
return QString("[%1,%2]").arg(idx.row()).arg(idx.column());
return QVariant();
}
-
+
int row_count;
int column_count;
friend class tst_QItemSelectionModel;
@@ -2055,7 +2056,7 @@ void tst_QItemSelectionModel::task240734_layoutChanged()
QItemSelectionModel selectionModel(&model);
selectionModel.select(model.index(0,0), QItemSelectionModel::Select);
QCOMPARE(selectionModel.selectedIndexes().count() , 1);
-
+
emit model.layoutAboutToBeChanged();
model.row_count = 5;
emit model.layoutChanged();
@@ -2107,7 +2108,7 @@ void tst_QItemSelectionModel::merge_data()
<< QItemSelection(model->index(2, 2) , model->index(3, 4))
<< int(QItemSelectionModel::Deselect)
<< QItemSelection(model->index(2, 1) , model->index(3, 1));
-
+
QItemSelection r1(model->index(2, 1) , model->index(3, 1));
r1.select(model->index(2, 4) , model->index(3, 4));
QTest::newRow("Toggle")
@@ -2274,5 +2275,57 @@ void tst_QItemSelectionModel::task260134_layoutChangedWithAllSelected()
}
+void tst_QItemSelectionModel::QTBUG5671_layoutChangedWithAllSelected()
+{
+ 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
+ {
+ return !filtering || !( source_row & 1 );
+ }
+ };
+
+ //same as task260134_layoutChangedWithAllSelected but with a sightly bigger model
+
+ enum { cNumRows=30, cNumCols=20 };
+
+ QStandardItemModel model(cNumRows, cNumCols);
+ MyFilterModel proxy;
+ proxy.filtering = true;
+ proxy.setSourceModel(&model);
+ QItemSelectionModel selection(&proxy);
+
+ // Populate the tree view.
+ for (unsigned int i = 0; i < cNumCols; i++)
+ model.setHeaderData( i, Qt::Horizontal, QString::fromLatin1("Column %1").arg(i));
+
+ for (unsigned int r = 0; r < cNumRows; r++) {
+ for (unsigned int c = 0; c < cNumCols; c++) {
+ model.setData(model.index(r, c, QModelIndex()),
+ QString::fromLatin1("r:%1/c:%2").arg(r, c));
+ }
+ }
+
+
+ QCOMPARE(model.rowCount(), int(cNumRows));
+ QCOMPARE(proxy.rowCount(), int(cNumRows/2));
+
+ selection.select( QItemSelection(proxy.index(0,0), proxy.index(proxy.rowCount() - 1, proxy.columnCount() - 1)), QItemSelectionModel::Select);
+
+ QList<QPersistentModelIndex> indexList;
+ foreach(const QModelIndex &id, selection.selectedIndexes())
+ indexList << id;
+
+ proxy.filtering = false;
+ proxy.invalidate();
+ QCOMPARE(proxy.rowCount(), int(cNumRows));
+
+ //let's check the selection hasn't changed
+ QCOMPARE(selection.selectedIndexes().count(), indexList.count());
+ foreach(QPersistentModelIndex index, indexList)
+ QVERIFY(selection.isSelected(index));
+}
+
QTEST_MAIN(tst_QItemSelectionModel)
#include "tst_qitemselectionmodel.moc"
diff --git a/tests/auto/qkeysequence/tst_qkeysequence.cpp b/tests/auto/qkeysequence/tst_qkeysequence.cpp
index 1c257bf01a..bc9ae6cc47 100644
--- a/tests/auto/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/qkeysequence/tst_qkeysequence.cpp
@@ -119,6 +119,7 @@ private slots:
void symetricConstructors_data();
void symetricConstructors();
void checkMultipleNames();
+ void mnemonic_data();
void mnemonic();
void toString_data();
void toString();
@@ -133,6 +134,7 @@ private slots:
void translated_data();
void translated();
+
void initTestCase();
private:
QTranslator *ourTranslator;
@@ -299,7 +301,7 @@ void tst_QKeySequence::standardKeys_data()
QTest::newRow("findNext") << (int)QKeySequence::FindNext<< QString("F3");
QTest::newRow("findPrevious") << (int)QKeySequence::FindPrevious << QString("SHIFT+F3");
QTest::newRow("close") << (int)QKeySequence::Close<< QString("CTRL+F4");
- QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H");
+ QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H");
#endif
QTest::newRow("bold") << (int)QKeySequence::Bold << QString("CTRL+B");
QTest::newRow("italic") << (int)QKeySequence::Italic << QString("CTRL+I");
@@ -357,17 +359,50 @@ void tst_QKeySequence::keyBindings()
}
+
+void tst_QKeySequence::mnemonic_data()
+{
+ QTest::addColumn<QString>("string");
+ QTest::addColumn<QString>("key");
+ QTest::addColumn<bool>("warning");
+
+ QTest::newRow("1") << QString::fromLatin1("&bonjour") << QString::fromLatin1("ALT+B") << false;
+ QTest::newRow("2") << QString::fromLatin1("&&bonjour") << QString() << false;
+ QTest::newRow("3") << QString::fromLatin1("&&bon&jour") << QString::fromLatin1("ALT+J") << false;
+ QTest::newRow("4") << QString::fromLatin1("&&bon&jo&ur") << QString::fromLatin1("ALT+J") << true;
+ QTest::newRow("5") << QString::fromLatin1("b&on&&jour") << QString::fromLatin1("ALT+O") << false;
+ QTest::newRow("6") << QString::fromLatin1("bonjour") << QString() << false;
+ QTest::newRow("7") << QString::fromLatin1("&&&bonjour") << QString::fromLatin1("ALT+B") << false;
+ QTest::newRow("8") << QString::fromLatin1("bonjour&&&") << QString() << false;
+ QTest::newRow("9") << QString::fromLatin1("bo&&nj&o&&u&r") << QString::fromLatin1("ALT+O") << true;
+ QTest::newRow("10") << QString::fromLatin1("BON&JOUR") << QString::fromLatin1("ALT+J") << false;
+ QTest::newRow("11") << QString::fromUtf8("bonjour") << QString() << false;
+}
+
void tst_QKeySequence::mnemonic()
{
#ifdef Q_WS_MAC
QSKIP("mnemonics are not used on Mac OS X", SkipAll);
#endif
- QKeySequence k = QKeySequence::mnemonic("&Foo");
- QVERIFY(k == QKeySequence("ALT+F"));
- k = QKeySequence::mnemonic("&& &x");
- QVERIFY(k == QKeySequence("ALT+X"));
+ QFETCH(QString, string);
+ QFETCH(QString, key);
+ QFETCH(bool, warning);
+
+#ifndef QT_NO_DEBUG
+ if (warning) {
+ QString str = QString::fromLatin1("QKeySequence::mnemonic: \"%1\" contains multiple occurences of '&'").arg(string);
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(str));
+ // qWarning(qPrintable(str));
+ }
+#endif
+ QKeySequence seq = QKeySequence::mnemonic(string);
+ QKeySequence res = QKeySequence(key);
+
+ QCOMPARE(seq, res);
}
+
+
void tst_QKeySequence::toString_data()
{
QTest::addColumn<QString>("strSequence");
diff --git a/tests/auto/qlabel/qlabel.pro b/tests/auto/qlabel/qlabel.pro
index 6d55c13729..297f868b3e 100644
--- a/tests/auto/qlabel/qlabel.pro
+++ b/tests/auto/qlabel/qlabel.pro
@@ -1,19 +1,10 @@
load(qttest_p4)
-SOURCES += tst_qlabel.cpp
-
-wince*:{
- DEFINES += SRCDIR=\\\"\\\"
-} else:!symbian {
- DEFINES += SRCDIR=\\\"$$PWD/\\\"
-}
-
-wince*|symbian {
- addFiles.sources = *.png testdata
+SOURCES += tst_qlabel.cpp
+wince*::DEFINES += SRCDIR=\\\"\\\"
+else:!symbian:DEFINES += SRCDIR=\\\"$$PWD/\\\"
+wince*|symbian {
+ addFiles.sources = *.png \
+ testdata
addFiles.path = .
DEPLOYMENT += addFiles
}
-
-
-
-
-
diff --git a/tests/auto/qlabel/tst_qlabel.cpp b/tests/auto/qlabel/tst_qlabel.cpp
index dd03ef3ce3..6b7e1063a6 100644
--- a/tests/auto/qlabel/tst_qlabel.cpp
+++ b/tests/auto/qlabel/tst_qlabel.cpp
@@ -50,6 +50,8 @@
#include <qlineedit.h>
#include <qmovie.h>
#include <qpicture.h>
+#include <qmessagebox.h>
+#include <private/qlabel_p.h>
//TESTED_CLASS=
//TESTED_FILES=
@@ -112,6 +114,12 @@ private slots:
void task226479_movieResize();
void emptyPixmap();
+ void unicodeText_data();
+ void unicodeText();
+
+ void mnemonic_data();
+ void mnemonic();
+
private:
QLabel *testWidget;
QPointer<Widget> test_box;
@@ -220,6 +228,7 @@ void tst_QLabel::setBuddy()
QVERIFY( !test_edit->hasFocus() );
QTest::keyClick( test_box, 't', Qt::AltModifier );
QVERIFY( test_edit->hasFocus() );
+ delete test_box;
}
void tst_QLabel::text()
@@ -241,6 +250,7 @@ void tst_QLabel::setText_data()
QTest::newRow( QString(prefix + "data1").toLatin1() ) << QString("This is the first line\nThis is the second line") << QString("Courier");
QTest::newRow( QString(prefix + "data2").toLatin1() ) << QString("This is the first line\nThis is the second line\nThis is the third line") << QString("Helvetica");
QTest::newRow( QString(prefix + "data3").toLatin1() ) << QString("This is <b>bold</b> richtext") << QString("Courier");
+ QTest::newRow( QString(prefix + "data4").toLatin1() ) << QString("I Have a &shortcut") << QString("Helvetica");
}
void tst_QLabel::setText()
@@ -324,14 +334,14 @@ void tst_QLabel::eventPropagation_data()
QTest::addColumn<bool>("propagation");
QTest::newRow("plain text1") << QString("plain text") << int(Qt::LinksAccessibleByMouse) << int(Qt::NoFocus) << true;
- QTest::newRow("plain text2") << QString("plain text") << (int)Qt::TextSelectableByKeyboard << (int)Qt::ClickFocus << false;
+ QTest::newRow("plain text2") << QString("plain text") << (int)Qt::TextSelectableByKeyboard << (int)Qt::ClickFocus << true;
QTest::newRow("plain text3") << QString("plain text") << (int)Qt::TextSelectableByMouse << (int)Qt::ClickFocus << false;
QTest::newRow("plain text4") << QString("plain text") << (int)Qt::NoTextInteraction << (int)Qt::NoFocus << true;
- QTest::newRow("rich text1") << QString("<b>rich text</b>") << (int)Qt::LinksAccessibleByMouse << (int)Qt::NoFocus << false;
- QTest::newRow("rich text2") << QString("<b>rich text</b>") << (int)Qt::TextSelectableByKeyboard << (int)Qt::ClickFocus << false;
+ QTest::newRow("rich text1") << QString("<b>rich text</b>") << (int)Qt::LinksAccessibleByMouse << (int)Qt::NoFocus << true;
+ QTest::newRow("rich text2") << QString("<b>rich text</b>") << (int)Qt::TextSelectableByKeyboard << (int)Qt::ClickFocus << true;
QTest::newRow("rich text3") << QString("<b>rich text</b>") << (int)Qt::TextSelectableByMouse << (int)Qt::ClickFocus << false;
QTest::newRow("rich text4") << QString("<b>rich text</b>") << (int)Qt::NoTextInteraction << (int)Qt::NoFocus << true;
- QTest::newRow("rich text4") << QString("<b>rich text</b>") << (int)Qt::LinksAccessibleByKeyboard << (int)Qt::StrongFocus << false;
+ QTest::newRow("rich text4") << QString("<b>rich text</b>") << (int)Qt::LinksAccessibleByKeyboard << (int)Qt::StrongFocus << true;
if (!test_box)
test_box = new Widget;
@@ -451,5 +461,104 @@ void tst_QLabel::emptyPixmap()
QCOMPARE(label1.sizeHint(), label4.sizeHint());
}
+/**
+ Test for QTBUG-4848 - unicode data corrupting QLabel display
+*/
+void tst_QLabel::unicodeText_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("languageName");
+
+ /*
+ The "glass" phrase in Thai was the initial report for bug QTBUG-4848, was
+ originally found on http://www.columbia.edu/kermit/utf8.html.
+
+ The phrase is from an internet tradition regarding a striking phrase
+ that is translated into many different languages. The utf8 strings
+ below were generated by using http://translate.google.com.
+
+ The glass phrase in Thai contains the ้ว character which manifests bug
+ QTBUG-4848
+
+ The last long phrase is an excerpt from Churchills "on the beaches"
+ speech, also translated using http://translate.google.com.
+ */
+
+ QTest::newRow("english") << QString::fromUtf8("I can eat glass and it doesn't hurt me.") << QString("english");
+ QTest::newRow("thai") << QString::fromUtf8("ฉันจะกินแก้วและไม่เจ็บฉัน") << QString("thai");
+ QTest::newRow("chinese") << QString::fromUtf8("我可以吃玻璃,并没有伤害我。") << QString("chinese");
+ QTest::newRow("arabic") << QString::fromUtf8("أستطيع أكل الزجاج ، وأنه لا يؤذيني.") << QString("arabic");
+ QTest::newRow("russian") << QString::fromUtf8("Я могу есть стекло, и не больно.") << QString("russian");
+ QTest::newRow("korean") << QString::fromUtf8("유리를 먹을 수있는, 그리고 그게 날 다치게하지 않습니다.") << QString("korean");
+ QTest::newRow("greek") << QString::fromUtf8("Μπορώ να φάτε γυαλί και δεν μου κάνει κακό.") << QString("greek");
+ QTest::newRow("german") << QString::fromUtf8("Ich kann Glas essen und es macht mich nicht heiß.") << QString("german");
+
+ QTest::newRow("thai_long") << QString::fromUtf8("เราจะต่อสู้ในทะเลและมหาสมุทร. เราจะต่อสู้ด้วยความมั่นใจเติบโตและความเจริญเติบโตในอากาศเราจะปกป้องเกาะของเราค่าใช้จ่ายใดๆอาจ."
+ "เราจะต่อสู้บนชายหาดเราจะต่อสู้ในบริเวณเชื่อมโยงไปถึงเราจะต่อสู้ในช่องและในถนนที่เราจะต่อสู้ในภูเขานั้นเราจะไม่ยอม.")
+ << QString("thai_long");
+}
+
+void tst_QLabel::unicodeText()
+{
+ const QString testDataPath("testdata/unicodeText");
+ QFETCH(QString, text);
+ QFETCH(QString, languageName);
+ QFrame frame;
+ QVBoxLayout *layout = new QVBoxLayout();
+ QLabel *label = new QLabel(text, &frame);
+ layout->addWidget(label);
+ layout->setMargin(8);
+ frame.setLayout(layout);
+ frame.show();
+ QTest::qWaitForWindowShown(&frame);
+ QVERIFY(frame.isVisible()); // was successfully sized and shown
+ testWidget->show();
+}
+
+void tst_QLabel::mnemonic_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("expectedDocText");
+ QTest::addColumn<QString>("expectedShortcutCursor");
+
+ QTest::newRow("1") << QString("Normal") << QString("Normal") << QString();
+ QTest::newRow("2") << QString("&Simple") << QString("Simple") << QString("S");
+ QTest::newRow("3") << QString("Also &simple") << QString("Also simple") << QString("s");
+ QTest::newRow("4") << QString("&&With &Double &&amp;") << QString("&With Double &amp;") << QString("D");
+ QTest::newRow("5") << QString("Hep&&Hop") << QString("Hep&Hop") << QString("");
+ QTest::newRow("6") << QString("Hep&&&Hop") << QString("Hep&Hop") << QString("H");
+}
+
+
+void tst_QLabel::mnemonic()
+{
+ // this test that the mnemonics appears correctly when the label has a text control.
+
+ QFETCH(QString, text);
+ QFETCH(QString, expectedDocText);
+ QFETCH(QString, expectedShortcutCursor);
+
+ QWidget w;
+ QHBoxLayout *hbox = new QHBoxLayout;
+ QLabel *lab = new QLabel(text);
+ //lab->setText("plop &plop");
+ QLineEdit *lineedit = new QLineEdit;
+ lab->setBuddy(lineedit);
+ lab->setTextInteractionFlags(Qt::TextSelectableByMouse);
+
+ hbox->addWidget(lab);
+ hbox->addWidget(lineedit);
+ hbox->addWidget(new QLineEdit);
+ w.setLayout(hbox);
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+
+ QLabelPrivate *d = static_cast<QLabelPrivate *>(QObjectPrivate::get(lab));
+ QVERIFY(d->control);
+ QCOMPARE(d->control->document()->toPlainText(), expectedDocText);
+ QCOMPARE(d->shortcutCursor.selectedText(), expectedShortcutCursor);
+}
+
+
QTEST_MAIN(tst_QLabel)
#include "tst_qlabel.moc"
diff --git a/tests/auto/qlayout/tst_qlayout.cpp b/tests/auto/qlayout/tst_qlayout.cpp
index 9d6110dfa7..efe14c37ca 100644
--- a/tests/auto/qlayout/tst_qlayout.cpp
+++ b/tests/auto/qlayout/tst_qlayout.cpp
@@ -83,6 +83,7 @@ private slots:
void layoutItemRect();
void warnIfWrongParent();
void controlTypes();
+ void adjustSizeShouldMakeSureLayoutIsActivated();
};
tst_QLayout::tst_QLayout()
@@ -110,8 +111,8 @@ void tst_QLayout::getSetCheck()
class SizeHinterFrame : public QFrame
{
public:
- SizeHinterFrame(const QSize &s)
- : QFrame(0), sh(s) {
+ SizeHinterFrame(const QSize &sh, const QSize &msh = QSize())
+ : QFrame(0), sh(sh), msh(msh) {
setFrameStyle(QFrame::Box | QFrame::Plain);
}
@@ -119,9 +120,11 @@ public:
void setSizeHint(const QSize &s) { sh = s; }
QSize sizeHint() const { return sh; }
+ QSize minimumSizeHint() const { return msh; }
private:
QSize sh;
+ QSize msh;
};
@@ -333,5 +336,26 @@ void tst_QLayout::controlTypes()
}
+void tst_QLayout::adjustSizeShouldMakeSureLayoutIsActivated()
+{
+ QWidget main;
+
+ QVBoxLayout *const layout = new QVBoxLayout(&main);
+ layout->setMargin(0);
+ SizeHinterFrame *frame = new SizeHinterFrame(QSize(200, 10), QSize(200, 8));
+ frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ layout->addWidget(frame);
+
+ SizeHinterFrame *frame2 = new SizeHinterFrame(QSize(200, 10), QSize(200, 8));
+ frame2->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ layout->addWidget(frame2);
+
+ main.show();
+
+ frame2->hide();
+ main.adjustSize();
+ QCOMPARE(main.size(), QSize(200, 10));
+}
+
QTEST_MAIN(tst_QLayout)
#include "tst_qlayout.moc"
diff --git a/tests/auto/qlcdnumber/tst_qlcdnumber.cpp b/tests/auto/qlcdnumber/tst_qlcdnumber.cpp
index c18ce24175..3f52c708db 100644
--- a/tests/auto/qlcdnumber/tst_qlcdnumber.cpp
+++ b/tests/auto/qlcdnumber/tst_qlcdnumber.cpp
@@ -74,14 +74,14 @@ tst_QLCDNumber::~tst_QLCDNumber()
void tst_QLCDNumber::getSetCheck()
{
QLCDNumber obj1;
- // int QLCDNumber::numDigits()
- // void QLCDNumber::setNumDigits(int)
- obj1.setNumDigits(0);
- QCOMPARE(0, obj1.numDigits());
- obj1.setNumDigits(INT_MIN);
- QCOMPARE(0, obj1.numDigits()); // Range<0, 99>
- obj1.setNumDigits(INT_MAX);
- QCOMPARE(99, obj1.numDigits()); // Range<0, 99>
+ // int QLCDNumber::digitCount()
+ // void QLCDNumber::setDigitCount(int)
+ obj1.setDigitCount(0);
+ QCOMPARE(0, obj1.digitCount());
+ obj1.setDigitCount(INT_MIN);
+ QCOMPARE(0, obj1.digitCount()); // Range<0, 99>
+ obj1.setDigitCount(INT_MAX);
+ QCOMPARE(99, obj1.digitCount()); // Range<0, 99>
}
QTEST_MAIN(tst_QLCDNumber)
diff --git a/tests/auto/qlibrary/lib2/lib2.pro b/tests/auto/qlibrary/lib2/lib2.pro
index 436d7baa12..fc00af86e8 100644
--- a/tests/auto/qlibrary/lib2/lib2.pro
+++ b/tests/auto/qlibrary/lib2/lib2.pro
@@ -37,9 +37,9 @@ symbian-abld: {
symbian-sbsv2: {
TARGET.CAPABILITY=ALL -TCB
QMAKE_POST_LINK = \
- $(GNUCP) $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dl2 && \
- $(GNUCP) $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/system.trolltech.test.mylib.dll && \
- if test $(PLATFORM) != WINSCW;then $(GNUCP) $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $${PWD}/../tst/mylib.dl2; fi
+ $(GNUCP) $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dl2 && \
+ $(GNUCP) $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/system.trolltech.test.mylib.dll && \
+ if test $(PLATFORM) != WINSCW;then $(GNUCP) $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $${PWD}/../tst/mylib.dl2; fi
}
#no special install rule for the library used by test
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 8368114601..b4dfbbad47 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -260,6 +260,7 @@ private slots:
void task233101_cursorPosAfterInputMethod();
void task241436_passwordEchoOnEditRestoreEchoMode();
void task248948_redoRemovedSelection();
+ void taskQTBUG_4401_enterKeyClearsPassword();
protected slots:
#ifdef QT3_SUPPORT
@@ -3304,41 +3305,45 @@ void tst_QLineEdit::task174640_editingFinished()
layout->addWidget(le2);
mw.show();
- QTest::qWait(200);
+ QApplication::setActiveWindow(&mw);
mw.activateWindow();
+ QTest::qWaitForWindowShown(&mw);
QSignalSpy editingFinishedSpy(le1, SIGNAL(editingFinished()));
le1->setFocus();
- QTest::qWait(200);
- QVERIFY(le1->hasFocus());
+ QTest::qWait(20);
+ QTRY_VERIFY(le1->hasFocus());
QCOMPARE(editingFinishedSpy.count(), 0);
le2->setFocus();
- QTest::qWait(200);
- QVERIFY(le2->hasFocus());
+ QTest::qWait(20);
+ QTRY_VERIFY(le2->hasFocus());
QCOMPARE(editingFinishedSpy.count(), 1);
editingFinishedSpy.clear();
le1->setFocus();
- QTest::qWait(200);
- QVERIFY(le1->hasFocus());
+ QTest::qWait(20);
+ QTRY_VERIFY(le1->hasFocus());
QMenu *testMenu1 = new QMenu(le1);
testMenu1->addAction("foo");
testMenu1->addAction("bar");
testMenu1->show();
- QTest::qWait(200);
+ QTest::qWaitForWindowShown(testMenu1);
+ QTest::qWait(20);
mw.activateWindow();
+
delete testMenu1;
QCOMPARE(editingFinishedSpy.count(), 0);
- QVERIFY(le1->hasFocus());
+ QTRY_VERIFY(le1->hasFocus());
QMenu *testMenu2 = new QMenu(le2);
testMenu2->addAction("foo2");
testMenu2->addAction("bar2");
testMenu2->show();
- QTest::qWait(200);
+ QTest::qWaitForWindowShown(testMenu2);
+ QTest::qWait(20);
mw.activateWindow();
delete testMenu2;
QCOMPARE(editingFinishedSpy.count(), 1);
@@ -3528,5 +3533,20 @@ void tst_QLineEdit::task248948_redoRemovedSelection()
QCOMPARE(testWidget->text(), QLatin1String("ab"));
}
+void tst_QLineEdit::taskQTBUG_4401_enterKeyClearsPassword()
+{
+ QString password("Wanna guess?");
+
+ testWidget->setText(password);
+ testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
+ testWidget->setFocus();
+ testWidget->selectAll();
+ QApplication::setActiveWindow(testWidget);
+ QTRY_VERIFY(testWidget->hasFocus());
+
+ QTest::keyPress(testWidget, Qt::Key_Enter);
+ QTRY_COMPARE(testWidget->text(), password);
+}
+
QTEST_MAIN(tst_QLineEdit)
#include "tst_qlineedit.moc"
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index 7599ce6a06..1c8fecf96b 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -116,6 +116,12 @@ private slots:
void keyboardSearch();
void shiftSelectionWithNonUniformItemSizes();
void clickOnViewportClearsSelection();
+ void task262152_setModelColumnNavigate();
+ void taskQTBUG_2233_scrollHiddenItems_data();
+ void taskQTBUG_2233_scrollHiddenItems();
+ void taskQTBUG_633_changeModelData();
+ void taskQTBUG_435_deselectOnViewportClick();
+ void taskQTBUG_2678_spacingAndWrappedText();
};
// Testing get/set functions
@@ -1129,6 +1135,7 @@ void tst_QListView::selection()
#endif
v.show();
+ QTest::qWaitForWindowShown(&v);
QApplication::processEvents();
v.setSelection(selectionRect, QItemSelectionModel::ClearAndSelect);
@@ -1181,6 +1188,7 @@ void tst_QListView::scrollTo()
lv.setModel(&model);
lv.setFixedSize(100, 200);
lv.show();
+ QTest::qWaitForWindowShown(&lv);
//by default, the list view scrolls per item and has no wrapping
QModelIndex index = model.index(6,0);
@@ -1767,6 +1775,121 @@ void tst_QListView::clickOnViewportClearsSelection()
}
+void tst_QListView::task262152_setModelColumnNavigate()
+{
+ QListView view;
+ QStandardItemModel model(3,2);
+ model.setItem(0,1,new QStandardItem("[0,1]"));
+ model.setItem(1,1,new QStandardItem("[1,1]"));
+ model.setItem(2,1,new QStandardItem("[2,1]"));
+
+ view.setModel(&model);
+ view.setModelColumn(1);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QTest::qWait(120);
+ QTest::keyClick(&view, Qt::Key_Down);
+ QTest::qWait(30);
+ QTRY_COMPARE(view.currentIndex(), model.index(1,1));
+ QTest::keyClick(&view, Qt::Key_Down);
+ QTest::qWait(30);
+ QTRY_COMPARE(view.currentIndex(), model.index(2,1));
+
+}
+
+void tst_QListView::taskQTBUG_2233_scrollHiddenItems_data()
+{
+ QTest::addColumn<int>("flow");
+
+ QTest::newRow("TopToBottom") << static_cast<int>(QListView::TopToBottom);
+ QTest::newRow("LeftToRight") << static_cast<int>(QListView::LeftToRight);
+}
+
+void tst_QListView::taskQTBUG_2233_scrollHiddenItems()
+{
+ QFETCH(int, flow);
+ const int rowCount = 200;
+
+ QListView view;
+ QStringListModel model(&view);
+ QStringList list;
+ for (int i = 0; i < rowCount; ++i)
+ list << QString::fromAscii("Item %1").arg(i);
+
+ model.setStringList(list);
+ view.setModel(&model);
+ view.setViewMode(QListView::ListMode);
+ for (int i = 0; i < rowCount / 2; ++i)
+ view.setRowHidden(2 * i, true);
+ view.setFlow(static_cast<QListView::Flow>(flow));
+ view.resize(130, 130);
+
+ for (int i = 0; i < 10; ++i) {
+ (view.flow() == QListView::TopToBottom
+ ? view.verticalScrollBar()
+ : view.horizontalScrollBar())->setValue(i);
+ QModelIndex index = view.indexAt(QPoint(0,0));
+ QVERIFY(index.isValid());
+ QCOMPARE(index.row(), 2 * i + 1);
+ }
+}
+
+void tst_QListView::taskQTBUG_633_changeModelData()
+{
+ QListView view;
+ view.setFlow(QListView::LeftToRight);
+ QStandardItemModel model(5,1);
+ for (int i = 0; i < model.rowCount(); ++i) {
+ model.setData( model.index(i, 0), QString::number(i));
+ }
+
+ view.setModel(&model);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ model.setData( model.index(1, 0), QLatin1String("long long text"));
+ QTest::qWait(100); //leave time for relayouting the items
+ QRect rectLongText = view.visualRect(model.index(1,0));
+ QRect rect2 = view.visualRect(model.index(2,0));
+ QVERIFY( ! rectLongText.intersects(rect2) );
+}
+
+void tst_QListView::taskQTBUG_435_deselectOnViewportClick()
+{
+ QListView view;
+ QStringListModel model( QStringList() << "1" << "2" << "3" << "4");
+ view.setModel(&model);
+ view.setSelectionMode(QAbstractItemView::ExtendedSelection);
+ view.selectAll();
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), model.rowCount());
+
+
+ QPoint p = view.visualRect(model.index(model.rowCount() - 1)).center() + QPoint(0, 20);
+ //first the left button
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p);
+ QVERIFY(!view.selectionModel()->hasSelection());
+
+ view.selectAll();
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), model.rowCount());
+
+ //and now the right button
+ QTest::mouseClick(view.viewport(), Qt::RightButton, 0, p);
+ QVERIFY(!view.selectionModel()->hasSelection());
+}
+
+void tst_QListView::taskQTBUG_2678_spacingAndWrappedText()
+{
+ static const QString lorem("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
+ QStringListModel model(QStringList() << lorem << lorem << "foo" << lorem << "bar" << lorem << lorem);
+ QListView w;
+ w.setModel(&model);
+ w.setViewMode(QListView::ListMode);
+ w.setWordWrap(true);
+ w.setSpacing(10);
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+ QCOMPARE(w.horizontalScrollBar()->minimum(), w.horizontalScrollBar()->maximum());
+}
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"
diff --git a/tests/auto/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp
index e825c8f474..cb8f1e90b5 100644
--- a/tests/auto/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp
@@ -46,6 +46,7 @@
#include <qlist.h>
#include <qlistwidget.h>
+#include <private/qlistwidget_p.h>
//TESTED_CLASS=
//TESTED_FILES=
@@ -95,6 +96,8 @@ private slots:
void insertItem();
void insertItems_data();
void insertItems();
+ void moveItemsPriv_data();
+ void moveItemsPriv();
void itemAssignment();
void item_data();
@@ -849,6 +852,62 @@ void tst_QListWidget::removeItems()
}
+void tst_QListWidget::moveItemsPriv_data()
+{
+ QTest::addColumn<int>("rowCount");
+ QTest::addColumn<int>("srcRow");
+ QTest::addColumn<int>("dstRow");
+ QTest::addColumn<bool>("shouldHaveSignaled");
+
+ QTest::newRow("Empty") << 0 << 0 << 0 << false;
+ QTest::newRow("Overflow src") << 5 << 5 << 2 << false;
+ QTest::newRow("Underflow src") << 5 << -1 << 2 << false;
+ QTest::newRow("Overflow dst") << 5 << 2 << 5 << false;
+ QTest::newRow("Underflow dst") << 5 << 2 << -1 << false;
+ QTest::newRow("Same place") << 5 << 2 << 2 << false;
+ QTest::newRow("Up") << 5 << 4 << 2 << true;
+ QTest::newRow("Down") << 5 << 2 << 4 << true;
+}
+
+void tst_QListWidget::moveItemsPriv()
+{
+ QFETCH(int, rowCount);
+ QFETCH(int, srcRow);
+ QFETCH(int, dstRow);
+ QFETCH(bool, shouldHaveSignaled);
+
+ for (int r = 0; r < rowCount; ++r)
+ new QListWidgetItem(QString::number(r), testWidget);
+
+ QListModel *model = qobject_cast<QListModel *>(testWidget->model());
+ QVERIFY(model);
+ QSignalSpy beginMoveSpy(model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
+ QSignalSpy movedSpy(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ model->move(srcRow, dstRow);
+
+ if (shouldHaveSignaled) {
+ if (srcRow < dstRow)
+ QCOMPARE(testWidget->item(dstRow - 1)->text(), QString::number(srcRow));
+ else
+ QCOMPARE(testWidget->item(dstRow)->text(), QString::number(srcRow));
+
+ QCOMPARE(beginMoveSpy.count(), 1);
+ const QList<QVariant> &beginMoveArgs = beginMoveSpy.takeFirst();
+ QCOMPARE(beginMoveArgs.at(1).toInt(), srcRow);
+ QCOMPARE(beginMoveArgs.at(2).toInt(), srcRow);
+ QCOMPARE(beginMoveArgs.at(4).toInt(), dstRow);
+
+ QCOMPARE(movedSpy.count(), 1);
+ const QList<QVariant> &movedArgs = movedSpy.takeFirst();
+ QCOMPARE(movedArgs.at(1).toInt(), srcRow);
+ QCOMPARE(movedArgs.at(2).toInt(), srcRow);
+ QCOMPARE(movedArgs.at(4).toInt(), dstRow);
+ } else {
+ QCOMPARE(beginMoveSpy.count(), 0);
+ QCOMPARE(movedSpy.count(), 0);
+ }
+}
+
void tst_QListWidget::itemStreaming_data()
{
QTest::addColumn<QString>("text");
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index be39d0075f..5ead049215 100644
--- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
@@ -587,14 +587,16 @@ void tst_QLocalSocket::readBufferOverflow()
char buffer[dataBufferSize];
memset(buffer, 0, dataBufferSize);
serverSocket->write(buffer, dataBufferSize);
- serverSocket->flush();
+ serverSocket->waitForBytesWritten();
+ // wait until the first 128 bytes are ready to read
QVERIFY(client.waitForReadyRead());
QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize));
-#if defined(QT_LOCALSOCKET_TCP) || defined(Q_OS_SYMBIAN)
- QTest::qWait(250);
-#endif
+ // wait until the second 128 bytes are ready to read
+ QVERIFY(client.waitForReadyRead());
QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize));
+ // no more bytes available
+ QVERIFY(client.bytesAvailable() == 0);
}
// QLocalSocket/Server can take a name or path, check that it works as expected
@@ -976,7 +978,7 @@ void tst_QLocalSocket::writeOnlySocket()
#if defined(Q_OS_SYMBIAN)
QTest::qWait(250);
#endif
- QVERIFY(server.waitForNewConnection());
+ QVERIFY(server.waitForNewConnection(200));
QLocalSocket* serverSocket = server.nextPendingConnection();
QVERIFY(serverSocket);
diff --git a/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp
index ff5e00f084..d6d217f2bb 100644
--- a/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp
+++ b/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp
@@ -151,14 +151,8 @@ private slots:
void convertGeneric();
- void extractAxisRotation_data();
- void extractAxisRotation();
-
- void extractTranslation_data();
- void extractTranslation();
-
- void inferSpecialType_data();
- void inferSpecialType();
+ void optimize_data();
+ void optimize();
void columnsAndRows();
@@ -515,13 +509,13 @@ void tst_QMatrixNxN::create2x2()
m5 = m3;
QVERIFY(isSame(m5, uniqueValues2));
- m5.setIdentity();
+ m5.setToIdentity();
QVERIFY(isIdentity(m5));
QMatrix2x2 m6(uniqueValues2);
QVERIFY(isSame(m6, uniqueValues2));
qreal vals[4];
- m6.toValueArray(vals);
+ m6.copyDataTo(vals);
for (int index = 0; index < 4; ++index)
QCOMPARE(vals[index], uniqueValues2[index]);
}
@@ -550,13 +544,13 @@ void tst_QMatrixNxN::create3x3()
m5 = m3;
QVERIFY(isSame(m5, uniqueValues3));
- m5.setIdentity();
+ m5.setToIdentity();
QVERIFY(isIdentity(m5));
QMatrix3x3 m6(uniqueValues3);
QVERIFY(isSame(m6, uniqueValues3));
qreal vals[9];
- m6.toValueArray(vals);
+ m6.copyDataTo(vals);
for (int index = 0; index < 9; ++index)
QCOMPARE(vals[index], uniqueValues3[index]);
}
@@ -585,13 +579,13 @@ void tst_QMatrixNxN::create4x4()
m5 = m3;
QVERIFY(isSame(m5, uniqueValues4));
- m5.setIdentity();
+ m5.setToIdentity();
QVERIFY(isIdentity(m5));
QMatrix4x4 m6(uniqueValues4);
QVERIFY(isSame(m6, uniqueValues4));
qreal vals[16];
- m6.toValueArray(vals);
+ m6.copyDataTo(vals);
for (int index = 0; index < 16; ++index)
QCOMPARE(vals[index], uniqueValues4[index]);
@@ -627,13 +621,13 @@ void tst_QMatrixNxN::create4x3()
m5 = m3;
QVERIFY(isSame(m5, uniqueValues4x3));
- m5.setIdentity();
+ m5.setToIdentity();
QVERIFY(isIdentity(m5));
QMatrix4x3 m6(uniqueValues4x3);
QVERIFY(isSame(m6, uniqueValues4x3));
qreal vals[12];
- m6.toValueArray(vals);
+ m6.copyDataTo(vals);
for (int index = 0; index < 12; ++index)
QCOMPARE(vals[index], uniqueValues4x3[index]);
}
@@ -802,7 +796,7 @@ void tst_QMatrixNxN::transposed4x3()
QMatrix4x3 m3(uniqueValues4x3);
QMatrix3x4 m4 = m3.transposed();
qreal values[12];
- m4.toValueArray(values);
+ m4.copyDataTo(values);
for (int index = 0; index < 12; ++index)
QCOMPARE(values[index], transposedValues3x4[index]);
}
@@ -1296,7 +1290,7 @@ void tst_QMatrixNxN::multiply4x3()
QGenericMatrix<3, 3, qreal> m4;
m4 = m1 * m2;
qreal values[9];
- m4.toValueArray(values);
+ m4.copyDataTo(values);
for (int index = 0; index < 9; ++index)
QCOMPARE(values[index], ((const qreal *)m3Values)[index]);
}
@@ -1898,7 +1892,7 @@ void tst_QMatrixNxN::inverted4x4()
}
// Test again, after inferring the special matrix type.
- m1.inferSpecialType();
+ m1.optimize();
m2 = m1.inverted(&inv);
QVERIFY(isSame(m2, (const qreal *)m2Values));
QCOMPARE(inv, invertible);
@@ -1913,12 +1907,12 @@ void tst_QMatrixNxN::orthonormalInverse4x4()
m2.rotate(45.0, 1.0, 0.0, 0.0);
m2.translate(10.0, 0.0, 0.0);
- // Use inferSpecialType() to drop the internal flags that
+ // Use optimize() to drop the internal flags that
// mark the matrix as orthonormal. This will force inverted()
// to compute m3.inverted() the long way. We can then compare
// the result to what the faster algorithm produces on m2.
QMatrix4x4 m3 = m2;
- m3.inferSpecialType();
+ m3.optimize();
bool invertible;
QVERIFY(qFuzzyCompare(m2.inverted(&invertible), m3.inverted()));
QVERIFY(invertible);
@@ -1926,7 +1920,7 @@ void tst_QMatrixNxN::orthonormalInverse4x4()
QMatrix4x4 m4;
m4.rotate(45.0, 0.0, 1.0, 0.0);
QMatrix4x4 m5 = m4;
- m5.inferSpecialType();
+ m5.optimize();
QVERIFY(qFuzzyCompare(m4.inverted(), m5.inverted()));
QMatrix4x4 m6;
@@ -1934,7 +1928,7 @@ void tst_QMatrixNxN::orthonormalInverse4x4()
m1.translate(-20.0, 20.0, 15.0);
m1.rotate(25, 1.0, 0.0, 0.0);
QMatrix4x4 m7 = m6;
- m7.inferSpecialType();
+ m7.optimize();
QVERIFY(qFuzzyCompare(m6.inverted(), m7.inverted()));
}
@@ -2081,7 +2075,7 @@ void tst_QMatrixNxN::scale4x4()
m8.scale(x);
QVERIFY(isSame(m8, (const qreal *)resultValues));
- m8.inferSpecialType();
+ m8.optimize();
m8.scale(1.0f);
QVERIFY(isSame(m8, (const qreal *)resultValues));
@@ -2412,7 +2406,7 @@ void tst_QMatrixNxN::rotate4x4()
if (x != 0 || y != 0 || z != 0) {
QQuaternion q = QQuaternion::fromAxisAndAngle(QVector3D(x, y, z), angle);
- QVector3D vq = q.rotateVector(v1);
+ QVector3D vq = q.rotatedVector(v1);
QVERIFY(fuzzyCompare(vq.x(), v1x));
QVERIFY(fuzzyCompare(vq.y(), v1y));
QVERIFY(fuzzyCompare(vq.z(), v1z));
@@ -2509,7 +2503,7 @@ void tst_QMatrixNxN::normalMatrix()
// Perform the test again, after inferring special matrix types.
// This tests the optimized paths in the normalMatrix() function.
- m1.inferSpecialType();
+ m1.optimize();
n1 = m1.normalMatrix();
if (invertible)
@@ -2850,120 +2844,6 @@ void tst_QMatrixNxN::convertGeneric()
QVERIFY(isSame(m11, conv4x4));
}
-void tst_QMatrixNxN::extractAxisRotation_data()
-{
- QTest::addColumn<float>("x");
- QTest::addColumn<float>("y");
- QTest::addColumn<float>("z");
- QTest::addColumn<float>("angle");
-
- QTest::newRow("1, 0, 0, 0 deg") << 1.0f << 0.0f << 0.0f << 0.0f;
- QTest::newRow("1, 0, 0, 90 deg") << 1.0f << 0.0f << 0.0f << 90.0f;
- QTest::newRow("1, 0, 0, 270 deg") << 1.0f << 0.0f << 0.0f << 270.0f;
- QTest::newRow("1, 0, 0, 45 deg") << 1.0f << 0.0f << 0.0f << 45.0f;
- QTest::newRow("1, 0, 0, 120 deg") << 1.0f << 0.0f << 0.0f << 120.0f;
- QTest::newRow("1, 0, 0, 300 deg") << 1.0f << 0.0f << 0.0f << 300.0f;
-
- QTest::newRow("0, 1, 0, 90 deg") << 0.0f << 1.0f << 0.0f << 90.0f;
- QTest::newRow("0, 1, 0, 270 deg") << 0.0f << 1.0f << 0.0f << 270.0f;
- QTest::newRow("0, 1, 0, 45 deg") << 0.0f << 1.0f << 0.0f << 45.0f;
- QTest::newRow("0, 1, 0, 120 deg") << 0.0f << 1.0f << 0.0f << 120.0f;
- QTest::newRow("0, 1, 0, 300 deg") << 0.0f << 1.0f << 0.0f << 300.0f;
-
- QTest::newRow("0, 0, 1, 90 deg") << 0.0f << 0.0f << 1.0f << 90.0f;
- QTest::newRow("0, 0, 1, 270 deg") << 0.0f << 0.0f << 1.0f << 270.0f;
- QTest::newRow("0, 0, 1, 45 deg") << 0.0f << 0.0f << 1.0f << 45.0f;
- QTest::newRow("0, 0, 1, 120 deg") << 0.0f << 0.0f << 1.0f << 120.0f;
- QTest::newRow("0, 0, 1, 300 deg") << 0.0f << 0.0f << 1.0f << 300.0f;
-
- QTest::newRow("1, 1, 1, 90 deg") << 1.0f << 1.0f << 1.0f << 90.0f;
- QTest::newRow("1, 1, 1, 270 deg") << 1.0f << 1.0f << 1.0f << 270.0f;
- QTest::newRow("1, 1, 1, 45 deg") << 1.0f << 1.0f << 1.0f << 45.0f;
- QTest::newRow("1, 1, 1, 120 deg") << 1.0f << 1.0f << 1.0f << 120.0f;
- QTest::newRow("1, 1, 1, 300 deg") << 1.0f << 1.0f << 1.0f << 300.0f;
-}
-
-void tst_QMatrixNxN::extractAxisRotation()
-{
- QFETCH(float, x);
- QFETCH(float, y);
- QFETCH(float, z);
- QFETCH(float, angle);
-
- QMatrix4x4 m;
- QVector3D origAxis(x, y, z);
-
- m.rotate(angle, x, y, z);
-
- origAxis.normalize();
- QVector3D extractedAxis;
- qreal extractedAngle;
-
- m.extractAxisRotation(extractedAngle, extractedAxis);
-
- if (angle > 180) {
- QVERIFY(fuzzyCompare(360.0f - angle, extractedAngle));
- QVERIFY(fuzzyCompare(extractedAxis, -origAxis));
- } else {
- QVERIFY(fuzzyCompare(angle, extractedAngle));
- QVERIFY(fuzzyCompare(extractedAxis, origAxis));
- }
-}
-
-void tst_QMatrixNxN::extractTranslation_data()
-{
- QTest::addColumn<QMatrix4x4>("rotation");
- QTest::addColumn<float>("x");
- QTest::addColumn<float>("y");
- QTest::addColumn<float>("z");
-
- static QMatrix4x4 m1;
-
- QTest::newRow("identity, 100, 50, 25")
- << m1 << 100.0f << 50.0f << 250.0f;
-
- m1.rotate(45.0, 1.0, 0.0, 0.0);
- QTest::newRow("rotX 45 + 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f;
-
- m1.setIdentity();
- m1.rotate(45.0, 0.0, 1.0, 0.0);
- QTest::newRow("rotY 45 + 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f;
-
- m1.setIdentity();
- m1.rotate(75, 0.0, 0.0, 1.0);
- m1.rotate(25, 1.0, 0.0, 0.0);
- m1.rotate(45, 0.0, 1.0, 0.0);
- QTest::newRow("rotZ 75, rotX 25, rotY 45, 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f;
-}
-
-void tst_QMatrixNxN::extractTranslation()
-{
- QFETCH(QMatrix4x4, rotation);
- QFETCH(float, x);
- QFETCH(float, y);
- QFETCH(float, z);
-
- rotation.translate(x, y, z);
-
- QVector3D vec = rotation.extractTranslation();
-
- QVERIFY(fuzzyCompare(vec.x(), x));
- QVERIFY(fuzzyCompare(vec.y(), y));
- QVERIFY(fuzzyCompare(vec.z(), z));
-
- QMatrix4x4 lookAt;
- QVector3D eye(1.5f, -2.5f, 2.5f);
- lookAt.lookAt(eye,
- QVector3D(10.0f, 10.0f, 10.0f),
- QVector3D(0.0f, 1.0f, 0.0f));
-
- QVector3D extEye = lookAt.extractTranslation();
-
- QVERIFY(fuzzyCompare(eye.x(), -extEye.x()));
- QVERIFY(fuzzyCompare(eye.y(), -extEye.y()));
- QVERIFY(fuzzyCompare(eye.z(), -extEye.z()));
-}
-
// Copy of "flagBits" in qmatrix4x4.h.
enum {
Identity = 0x0001, // Identity matrix
@@ -2981,7 +2861,7 @@ struct Matrix4x4
};
// Test the inferring of special matrix types.
-void tst_QMatrixNxN::inferSpecialType_data()
+void tst_QMatrixNxN::optimize_data()
{
QTest::addColumn<void *>("mValues");
QTest::addColumn<int>("flagBits");
@@ -3029,13 +2909,13 @@ void tst_QMatrixNxN::inferSpecialType_data()
QTest::newRow("below")
<< (void *)belowValues << (int)General;
}
-void tst_QMatrixNxN::inferSpecialType()
+void tst_QMatrixNxN::optimize()
{
QFETCH(void *, mValues);
QFETCH(int, flagBits);
QMatrix4x4 m((const qreal *)mValues);
- m.inferSpecialType();
+ m.optimize();
QCOMPARE(reinterpret_cast<Matrix4x4 *>(&m)->flagBits, flagBits);
}
@@ -3362,7 +3242,7 @@ void tst_QMatrixNxN::mapVector()
QFETCH(void *, mValues);
QMatrix4x4 m1((const qreal *)mValues);
- m1.inferSpecialType();
+ m1.optimize();
QVector3D v(3.5f, -1.0f, 2.5f);
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index 4eb149f6a6..f0f69a4348 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -101,11 +101,13 @@ private slots:
void menuSizeHint();
void task258920_mouseBorder();
void setFixedWidth();
+ void deleteActionInTriggered();
protected slots:
void onActivated(QAction*);
void onHighlighted(QAction*);
void onStatusMessageChanged(const QString &);
void onStatusTipTimer();
+ void deleteAction(QAction *a) { delete a; }
private:
void createActions();
QMenu *menus[2], *lastMenu;
@@ -675,7 +677,13 @@ void tst_QMenu::activeSubMenuPosition()
#ifdef Q_OS_WINCE_WM
QSKIP("Not true for Windows Mobile Soft Keys", SkipSingle);
#endif
+
+#ifdef Q_OS_SYMBIAN
+ // On Symbian, QS60Style::pixelMetric(QStyle::PM_SubMenuOverlap) is different with other styles.
+ QVERIFY(sub->pos().x() < main->pos().x());
+#else
QVERIFY(sub->pos().x() > main->pos().x());
+#endif
QCOMPARE(sub->activeAction(), subAction);
}
@@ -778,6 +786,11 @@ void tst_QMenu::menuSizeHint()
int maxWidth =0;
QRect result;
foreach(QAction *action, menu.actions()) {
+#ifdef QT_SOFTKEYS_ENABLED
+ // Softkey actions are not widgets and have no geometry.
+ if (menu.actionGeometry(action).topLeft() == QPoint(0,0))
+ continue;
+#endif
maxWidth = qMax(maxWidth, menu.actionGeometry(action).width());
result |= menu.actionGeometry(action);
QCOMPARE(result.x(), left + hmargin + panelWidth);
@@ -816,6 +829,9 @@ void tst_QMenu::task258920_mouseBorder()
QSKIP("Mouse move related signals for Windows Mobile unavailable", SkipAll);
#endif
Menu258920 menu;
+ // On Symbian, styleHint(QStyle::SH_Menu_MouseTracking) in QS60Style is false.
+ // For other styles which inherit from QWindowsStyle, the value is true.
+ menu.setMouseTracking(true);
QAction *action = menu.addAction("test");
menu.popup(QApplication::desktop()->availableGeometry().center());
@@ -844,6 +860,17 @@ void tst_QMenu::setFixedWidth()
QCOMPARE(menu.sizeHint().width(), menu.minimumWidth());
}
+void tst_QMenu::deleteActionInTriggered()
+{
+ // should not crash
+ QMenu m;
+ QObject::connect(&m, SIGNAL(triggered(QAction*)), this, SLOT(deleteAction(QAction*)));
+ QWeakPointer<QAction> a = m.addAction("action");
+ a.data()->trigger();
+ QVERIFY(!a);
+}
+
+
QTEST_MAIN(tst_QMenu)
diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp
index 07aa9f42da..4291c3eeb9 100644
--- a/tests/auto/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/qmenubar/tst_qmenubar.cpp
@@ -86,6 +86,18 @@ private:
uint sel_count;
};
+class Menu : public QMenu
+{
+ Q_OBJECT
+ public slots:
+ void addActions()
+ {
+ //this will change the geometry of the menu
+ addAction("action1");
+ addAction("action2");
+ }
+};
+
class tst_QMenuBar : public QObject
{
Q_OBJECT
@@ -1442,7 +1454,7 @@ void tst_QMenuBar::check_menuPosition()
#ifdef Q_OS_WINCE_WM
QSKIP("Qt/CE uses native menubar", SkipAll);
#endif
- QMenu menu;
+ Menu menu;
#ifdef QT3_SUPPORT
initComplexMenubar();
#else
@@ -1496,6 +1508,21 @@ void tst_QMenuBar::check_menuPosition()
menu.close();
}
+ //in RTL, the menu should be stuck at the right of the action geometry
+ {
+ Qt::LayoutDirection dir = qApp->layoutDirection();
+ qApp->setLayoutDirection(Qt::RightToLeft);
+ menu.clear();
+ QObject::connect(&menu, SIGNAL(aboutToShow()), &menu, SLOT(addActions()));
+ QRect mbItemRect = mw->menuBar()->actionGeometry(menu_action);
+ mbItemRect.moveTo(mw->menuBar()->mapToGlobal(mbItemRect.topLeft()));
+ QTest::keyClick(mw, Qt::Key_M, Qt::AltModifier );
+ QVERIFY(menu.isActiveWindow());
+ QCOMPARE(menu.geometry().right(), mbItemRect.right());
+ menu.close();
+ qApp->setLayoutDirection(dir);
+ }
+
}
void tst_QMenuBar::task223138_triggered()
diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
index 3c4ddd497c..94857d7b4d 100644
--- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
+++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
@@ -234,7 +234,7 @@ void tst_QNetworkCookie::parseSingleCookie_data()
QTest::newRow("path-with-utf8-2") << "a=b;path=/R%C3%A9sum%C3%A9" << cookie;
cookie.setPath(QString());
- cookie.setDomain(".qt.nokia.com");
+ cookie.setDomain("qt.nokia.com");
QTest::newRow("plain-domain1") << "a=b;domain=qt.nokia.com" << cookie;
QTest::newRow("plain-domain2") << "a=b; domain=qt.nokia.com " << cookie;
QTest::newRow("plain-domain3") << "a=b;domain=QT.NOKIA.COM" << cookie;
@@ -247,32 +247,25 @@ void tst_QNetworkCookie::parseSingleCookie_data()
QTest::newRow("dot-domain4") << "a=b; Domain = .QT.NOKIA.COM" << cookie;
cookie.setDomain(QString::fromUtf8(".d\303\270gn\303\245pent.troll.no"));
- QTest::newRow("idn-domain1") << "a=b;domain=xn--dgnpent-gxa2o.troll.no" << cookie;
- QTest::newRow("idn-domain2") << "a=b;domain=d\303\270gn\303\245pent.troll.no" << cookie;
- QTest::newRow("idn-domain3") << "a=b;domain=XN--DGNPENT-GXA2O.TROLL.NO" << cookie;
- QTest::newRow("idn-domain4") << "a=b;domain=D\303\230GN\303\205PENT.troll.NO" << cookie;
- QTest::newRow("idn-domain5") << "a=b;domain = D\303\230GN\303\205PENT.troll.NO" << cookie;
-
- cookie.setDomain(QString::fromUtf8(".d\303\270gn\303\245pent.troll.no"));
- QTest::newRow("dot-idn-domain1") << "a=b;domain=.xn--dgnpent-gxa2o.troll.no" << cookie;
- QTest::newRow("dot-idn-domain2") << "a=b;domain=.d\303\270gn\303\245pent.troll.no" << cookie;
- QTest::newRow("dot-idn-domain3") << "a=b;domain=.XN--DGNPENT-GXA2O.TROLL.NO" << cookie;
- QTest::newRow("dot-idn-domain4") << "a=b;domain=.D\303\230GN\303\205PENT.troll.NO" << cookie;
+ QTest::newRow("idn-domain1") << "a=b;domain=.xn--dgnpent-gxa2o.troll.no" << cookie;
+ QTest::newRow("idn-domain2") << "a=b;domain=.d\303\270gn\303\245pent.troll.no" << cookie;
+ QTest::newRow("idn-domain3") << "a=b;domain=.XN--DGNPENT-GXA2O.TROLL.NO" << cookie;
+ QTest::newRow("idn-domain4") << "a=b;domain=.D\303\230GN\303\205PENT.troll.NO" << cookie;
cookie.setDomain(".qt.nokia.com");
cookie.setPath("/");
- QTest::newRow("two-fields") << "a=b;domain=qt.nokia.com;path=/" << cookie;
- QTest::newRow("two-fields2") << "a=b; domain=qt.nokia.com; path=/" << cookie;
- QTest::newRow("two-fields3") << "a=b; domain=qt.nokia.com ; path=/ " << cookie;
- QTest::newRow("two-fields4") << "a=b;path=/; domain=qt.nokia.com" << cookie;
- QTest::newRow("two-fields5") << "a=b; path=/ ; domain=qt.nokia.com" << cookie;
- QTest::newRow("two-fields6") << "a=b; path= / ; domain =qt.nokia.com" << cookie;
+ QTest::newRow("two-fields") << "a=b;domain=.qt.nokia.com;path=/" << cookie;
+ QTest::newRow("two-fields2") << "a=b; domain=.qt.nokia.com; path=/" << cookie;
+ QTest::newRow("two-fields3") << "a=b; domain=.qt.nokia.com ; path=/ " << cookie;
+ QTest::newRow("two-fields4") << "a=b;path=/; domain=.qt.nokia.com" << cookie;
+ QTest::newRow("two-fields5") << "a=b; path=/ ; domain=.qt.nokia.com" << cookie;
+ QTest::newRow("two-fields6") << "a=b; path= / ; domain =.qt.nokia.com" << cookie;
cookie.setSecure(true);
- QTest::newRow("three-fields") << "a=b;domain=qt.nokia.com;path=/;secure" << cookie;
- QTest::newRow("three-fields2") << "a=b;secure;path=/;domain=qt.nokia.com" << cookie;
- QTest::newRow("three-fields3") << "a=b;secure;domain=qt.nokia.com; path=/" << cookie;
- QTest::newRow("three-fields4") << "a = b;secure;domain=qt.nokia.com; path=/" << cookie;
+ QTest::newRow("three-fields") << "a=b;domain=.qt.nokia.com;path=/;secure" << cookie;
+ QTest::newRow("three-fields2") << "a=b;secure;path=/;domain=.qt.nokia.com" << cookie;
+ QTest::newRow("three-fields3") << "a=b;secure;domain=.qt.nokia.com; path=/" << cookie;
+ QTest::newRow("three-fields4") << "a = b;secure;domain=.qt.nokia.com; path=/" << cookie;
cookie = QNetworkCookie();
cookie.setName("a");
@@ -664,7 +657,7 @@ void tst_QNetworkCookie::parseMultipleCookies_data()
cookie.setName("baz");
cookie.setDomain(".qt.nokia.com");
list.prepend(cookie);
- QTest::newRow("complex-2") << "baz=bar; path=/; domain=qt.nokia.com, c=d,a=,foo=bar; path=/" << list;
+ QTest::newRow("complex-2") << "baz=bar; path=/; domain=.qt.nokia.com, c=d,a=,foo=bar; path=/" << list;
// cookies obtained from the network:
cookie = QNetworkCookie("id", "51706646077999719");
diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
index 9b9c56a5f9..ff7e78e544 100644
--- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
+++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
@@ -120,7 +120,7 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data()
cookie.setName("a");
cookie.setPath("/");
- cookie.setDomain("www.foo.tld");
+ cookie.setDomain(".foo.tld");
result += cookie;
QTest::newRow("just-add") << preset << cookie << "http://www.foo.tld" << result << true;
@@ -148,6 +148,20 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data()
cookie.setPath("/");
QTest::newRow("diff-path-order") << preset << cookie << "http://www.foo.tld" << result << true;
+ preset.clear();
+ result.clear();
+ QNetworkCookie finalCookie = cookie;
+ cookie.setDomain("foo.tld");
+ finalCookie.setDomain(".foo.tld");
+ result += finalCookie;
+ QTest::newRow("should-add-dot-prefix") << preset << cookie << "http://www.foo.tld" << result << true;
+
+ result.clear();
+ cookie.setDomain("");
+ finalCookie.setDomain("www.foo.tld");
+ result += finalCookie;
+ QTest::newRow("should-set-default-domain") << preset << cookie << "http://www.foo.tld" << result << true;
+
// security test:
result.clear();
preset.clear();
@@ -159,7 +173,7 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data()
QTest::newRow("security-path-1") << preset << cookie << "http://www.foo.tld" << result << false;
// setting the defaults:
- QNetworkCookie finalCookie = cookie;
+ finalCookie = cookie;
finalCookie.setPath("/something/");
cookie.setPath("");
cookie.setDomain("");
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 7adb67f115..bd83c47370 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -225,14 +225,11 @@ private Q_SLOTS:
void ioPostToHttpUploadProgress();
void ioPostToHttpEmtpyUploadProgress();
+ void lastModifiedHeaderForFile();
+ void lastModifiedHeaderForHttp();
+
void rateControl_data();
void rateControl();
- void downloadPerformance();
- void uploadPerformance();
- void performanceControlRate();
- void httpUploadPerformance();
- void httpDownloadPerformance_data();
- void httpDownloadPerformance();
void downloadProgress_data();
void downloadProgress();
@@ -413,93 +410,6 @@ public slots:
}
};
-class FixedSizeDataGenerator : public QIODevice
-{
- Q_OBJECT
- enum { Idle, Started, Stopped } state;
-public:
- FixedSizeDataGenerator(qint64 size) : state(Idle)
- { open(ReadOnly | Unbuffered);
- toBeGeneratedTotalCount = toBeGeneratedCount = size;
- }
-
- virtual qint64 bytesAvailable() const
- {
- return state == Started ? toBeGeneratedCount + QIODevice::bytesAvailable() : 0;
- }
-
- virtual bool isSequential() const{
- return false;
- }
-
- virtual bool reset() const{
- return false;
- }
-
- qint64 size() const {
- return toBeGeneratedTotalCount;
- }
-
-public slots:
- void start() { state = Started; emit readyRead(); }
-
-protected:
- virtual qint64 readData(char *data, qint64 maxlen)
- {
- memset(data, '@', maxlen);
-
- if (toBeGeneratedCount <= 0) {
- return -1;
- }
-
- qint64 n = qMin(maxlen, toBeGeneratedCount);
- toBeGeneratedCount -= n;
-
- if (toBeGeneratedCount <= 0) {
- // make sure this is a queued connection!
- emit readChannelFinished();
- }
-
- return n;
- }
- virtual qint64 writeData(const char *, qint64)
- { return -1; }
-
- qint64 toBeGeneratedCount;
- qint64 toBeGeneratedTotalCount;
-};
-
-
-class DataGenerator: public QIODevice
-{
- Q_OBJECT
- enum { Idle, Started, Stopped } state;
-public:
- DataGenerator() : state(Idle)
- { open(ReadOnly); }
-
- virtual bool isSequential() const { return true; }
- virtual qint64 bytesAvailable() const { return state == Started ? 1024*1024 : 0; }
-
-public slots:
- void start() { state = Started; emit readyRead(); }
- void stop() { state = Stopped; emit readyRead(); }
-
-protected:
- virtual qint64 readData(char *data, qint64 maxlen)
- {
- if (state == Stopped)
- return -1; // EOF
-
- // return as many bytes as are wanted
- memset(data, '@', maxlen);
- return maxlen;
- }
- virtual qint64 writeData(const char *, qint64)
- { return -1; }
-};
-
-
class SocketPair: public QObject
{
@@ -692,255 +602,6 @@ protected:
}
};
-class TimedSender: public QThread
-{
- Q_OBJECT
- qint64 totalBytes;
- QSemaphore ready;
- QByteArray dataToSend;
- QTcpSocket *client;
- int timeout;
- int port;
-public:
- int transferRate;
- TimedSender(int ms)
- : totalBytes(0), timeout(ms), port(-1), transferRate(-1)
- {
- dataToSend = QByteArray(16*1024, '@');
- start();
- ready.acquire();
- }
-
- inline int serverPort() const { return port; }
-
-private slots:
- void writeMore()
- {
- while (client->bytesToWrite() < 128 * 1024) {
- writePacket(dataToSend);
- }
- }
-
-protected:
- void run()
- {
- QTcpServer server;
- server.listen();
- port = server.serverPort();
- ready.release();
-
- server.waitForNewConnection(-1);
- client = server.nextPendingConnection();
-
- writeMore();
- connect(client, SIGNAL(bytesWritten(qint64)), SLOT(writeMore()), Qt::DirectConnection);
-
- QEventLoop eventLoop;
- QTimer::singleShot(timeout, &eventLoop, SLOT(quit()));
-
- QTime timer;
- timer.start();
- eventLoop.exec();
- disconnect(client, SIGNAL(bytesWritten(qint64)), this, 0);
-
- // wait for the connection to shut down
- client->disconnectFromHost();
- if (!client->waitForDisconnected(10000))
- return;
-
- transferRate = totalBytes * 1000 / timer.elapsed();
- qDebug() << "TimedSender::run" << "receive rate:" << (transferRate / 1024) << "kB/s in"
- << timer.elapsed() << "ms";
- }
-
- void writePacket(const QByteArray &array)
- {
- client->write(array);
- totalBytes += array.size();
- }
-};
-
-class ThreadedDataReader: public QThread
-{
- Q_OBJECT
- // used to make the constructor only return after the tcp server started listening
- QSemaphore ready;
- QTcpSocket *client;
- int timeout;
- int port;
-public:
- qint64 transferRate;
- ThreadedDataReader()
- : port(-1), transferRate(-1)
- {
- start();
- ready.acquire();
- }
-
- inline int serverPort() const { return port; }
-
-protected:
- void run()
- {
- QTcpServer server;
- server.listen();
- port = server.serverPort();
- ready.release();
-
- server.waitForNewConnection(-1);
- client = server.nextPendingConnection();
-
- QEventLoop eventLoop;
- DataReader reader(client, false);
- QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit()));
-
- QTime timer;
- timer.start();
- eventLoop.exec();
- qint64 elapsed = timer.elapsed();
-
- transferRate = reader.totalBytes * 1000 / elapsed;
- qDebug() << "ThreadedDataReader::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec";
- }
-};
-
-class ThreadedDataReaderHttpServer: public QThread
-{
- Q_OBJECT
- // used to make the constructor only return after the tcp server started listening
- QSemaphore ready;
- QTcpSocket *client;
- int timeout;
- int port;
-public:
- qint64 transferRate;
- ThreadedDataReaderHttpServer()
- : port(-1), transferRate(-1)
- {
- start();
- ready.acquire();
- }
-
- inline int serverPort() const { return port; }
-
-protected:
- void run()
- {
- QTcpServer server;
- server.listen();
- port = server.serverPort();
- ready.release();
-
- server.waitForNewConnection(-1);
- client = server.nextPendingConnection();
- client->write("HTTP/1.0 200 OK\r\n");
- client->write("Content-length: 0\r\n");
- client->write("\r\n");
- client->flush();
-
- QCoreApplication::processEvents();
-
- QEventLoop eventLoop;
- DataReader reader(client, false);
- QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit()));
-
- QTime timer;
- timer.start();
- eventLoop.exec();
- qint64 elapsed = timer.elapsed();
-
- transferRate = reader.totalBytes * 1000 / elapsed;
- qDebug() << "ThreadedDataReaderHttpServer::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec";
- }
-};
-
-class HttpDownloadPerformanceClient : QObject {
- Q_OBJECT;
- QIODevice *device;
- public:
- HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){
- connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
- }
-
- public slots:
- void readyReadSlot() {
- device->readAll();
- }
-
-};
-
-class HttpDownloadPerformanceServer : QObject {
- Q_OBJECT;
- qint64 dataSize;
- qint64 dataSent;
- QTcpServer server;
- QTcpSocket *client;
- bool serverSendsContentLength;
- bool chunkedEncoding;
-
-public:
- HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0),
- client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) {
- server.listen();
- connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot()));
- }
-
- int serverPort() {
- return server.serverPort();
- }
-
-public slots:
-
- void newConnectionSlot() {
- client = server.nextPendingConnection();
- client->setParent(this);
- connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
- connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64)));
- }
-
- void readyReadSlot() {
- client->readAll();
- client->write("HTTP/1.0 200 OK\n");
- if (serverSendsContentLength)
- client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii());
- if (chunkedEncoding)
- client->write(QString("Transfer-Encoding: chunked\n").toAscii());
- client->write("Connection: close\n\n");
- }
-
- void bytesWrittenSlot(qint64 amount) {
- Q_UNUSED(amount);
- if (dataSent == dataSize && client) {
- // close eventually
-
- // chunked encoding: we have to send a last "empty" chunk
- if (chunkedEncoding)
- client->write(QString("0\r\n\r\n").toAscii());
-
- client->disconnectFromHost();
- server.close();
- client = 0;
- return;
- }
-
- // send data
- if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) {
- qint64 amount = qMin(qint64(16*1024), dataSize - dataSent);
- QByteArray data(amount, '@');
-
- if (chunkedEncoding) {
- client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii());
- client->write(data.constData(), amount);
- client->write(QString("\r\n").toAscii());
- } else {
- client->write(data.constData(), amount);
- }
-
- dataSent += amount;
- }
- }
-};
-
tst_QNetworkReply::tst_QNetworkReply()
{
@@ -2961,12 +2622,7 @@ void tst_QNetworkReply::ioPostToHttpFromSocket()
QSignalSpy authenticationRequiredSpy(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)));
QSignalSpy proxyAuthenticationRequiredSpy(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
-#ifdef Q_OS_SYMBIAN
QTestEventLoop::instance().enterLoop(6);
-#else
- QTestEventLoop::instance().enterLoop(3);
-#endif
-
disconnect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
disconnect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
@@ -3311,6 +2967,40 @@ void tst_QNetworkReply::ioPostToHttpEmtpyUploadProgress()
server.close();
}
+void tst_QNetworkReply::lastModifiedHeaderForFile()
+{
+ QFileInfo fileInfo(SRCDIR "./bigfile");
+ QUrl url = QUrl::fromLocalFile(fileInfo.filePath());
+
+ QNetworkRequest request(url);
+ QNetworkReplyPtr reply = manager.head(request);
+ QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64)));
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QDateTime header = reply->header(QNetworkRequest::LastModifiedHeader).toDateTime();
+ QCOMPARE(header, fileInfo.lastModified());
+}
+
+void tst_QNetworkReply::lastModifiedHeaderForHttp()
+{
+ // Tue, 22 May 2007 12:04:57 GMT according to webserver
+ QUrl url = "http://" + QtNetworkSettings::serverName() + "/gif/fluke.gif";
+
+ QNetworkRequest request(url);
+ QNetworkReplyPtr reply = manager.head(request);
+ QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64)));
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QDateTime header = reply->header(QNetworkRequest::LastModifiedHeader).toDateTime();
+ QDateTime realDate = QDateTime::fromString("2007-05-22T12:04:57", Qt::ISODate);
+ realDate.setTimeSpec(Qt::UTC);
+
+ QCOMPARE(header, realDate);
+}
void tst_QNetworkReply::rateControl_data()
{
@@ -3365,142 +3055,6 @@ void tst_QNetworkReply::rateControl()
QVERIFY(sender.transferRate <= maxRate);
}
-void tst_QNetworkReply::downloadPerformance()
-{
- // unlike the above function, this one tries to send as fast as possible
- // and measures how fast it was.
- TimedSender sender(5000);
- QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(sender.serverPort()) + "/?bare=1");
- QNetworkReplyPtr reply = manager.get(request);
- DataReader reader(reply, false);
-
- QTime loopTime;
- connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
- loopTime.start();
- QTestEventLoop::instance().enterLoop(40);
- int elapsedTime = loopTime.elapsed();
- sender.wait();
-
- qint64 receivedBytes = reader.totalBytes;
- qDebug() << "tst_QNetworkReply::downloadPerformance" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and"
- << elapsedTime << "ms";
-}
-
-void tst_QNetworkReply::uploadPerformance()
-{
- ThreadedDataReader reader;
- DataGenerator generator;
-
-
- QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1");
- QNetworkReplyPtr reply = manager.put(request, &generator);
- generator.start();
- connect(&reader, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
- QTimer::singleShot(5000, &generator, SLOT(stop()));
-
- QTestEventLoop::instance().enterLoop(30);
- QCOMPARE(reply->error(), QNetworkReply::NoError);
- QVERIFY(!QTestEventLoop::instance().timeout());
-}
-
-void tst_QNetworkReply::httpUploadPerformance()
-{
-#ifdef Q_OS_SYMBIAN
- // SHow some mercy for non-desktop platform/s
- enum {UploadSize = 4*1024*1024}; // 4 MB
-#else
- enum {UploadSize = 128*1024*1024}; // 128 MB
-#endif
- ThreadedDataReaderHttpServer reader;
- FixedSizeDataGenerator generator(UploadSize);
-
- QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1"));
- request.setHeader(QNetworkRequest::ContentLengthHeader,UploadSize);
-
- QNetworkReplyPtr reply = manager.put(request, &generator);
-
- connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
-
- QTime time;
- generator.start();
- time.start();
- QTestEventLoop::instance().enterLoop(40);
- QCOMPARE(reply->error(), QNetworkReply::NoError);
- QVERIFY(!QTestEventLoop::instance().timeout());
-
- qint64 elapsed = time.elapsed();
- qDebug() << "tst_QNetworkReply::httpUploadPerformance" << elapsed << "msec, "
- << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec";
-
- reader.exit();
- reader.wait();
-}
-
-
-void tst_QNetworkReply::performanceControlRate()
-{
- // this is a control comparison for the other two above
- // it does the same thing, but instead bypasses the QNetworkAccess system
- qDebug() << "The following are the maximum transfer rates that we can get in this system"
- " (bypassing QNetworkAccess)";
-
- TimedSender sender(5000);
- QTcpSocket sink;
- sink.connectToHost("127.0.0.1", sender.serverPort());
- DataReader reader(&sink, false);
-
- QTime loopTime;
- connect(&sink, SIGNAL(disconnected()), &QTestEventLoop::instance(), SLOT(exitLoop()));
- loopTime.start();
- QTestEventLoop::instance().enterLoop(40);
- int elapsedTime = loopTime.elapsed();
- sender.wait();
-
- qint64 receivedBytes = reader.totalBytes;
- qDebug() << "tst_QNetworkReply::performanceControlRate" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and"
- << elapsedTime << "ms";
-}
-
-void tst_QNetworkReply::httpDownloadPerformance_data()
-{
- QTest::addColumn<bool>("serverSendsContentLength");
- QTest::addColumn<bool>("chunkedEncoding");
-
- QTest::newRow("Server sends no Content-Length") << false << false;
- QTest::newRow("Server sends Content-Length") << true << false;
- QTest::newRow("Server uses chunked encoding") << false << true;
-
-}
-
-void tst_QNetworkReply::httpDownloadPerformance()
-{
- QFETCH(bool, serverSendsContentLength);
- QFETCH(bool, chunkedEncoding);
-#ifdef Q_OS_SYMBIAN
- // Show some mercy to non-desktop platform/s
- enum {UploadSize = 4*1024*1024}; // 4 MB
-#else
- enum {UploadSize = 128*1024*1024}; // 128 MB
-#endif
- HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding);
-
- QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1"));
- QNetworkReplyPtr reply = manager.get(request);
-
- connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
- HttpDownloadPerformanceClient client(reply);
-
- QTime time;
- time.start();
- QTestEventLoop::instance().enterLoop(40);
- QCOMPARE(reply->error(), QNetworkReply::NoError);
- QVERIFY(!QTestEventLoop::instance().timeout());
-
- qint64 elapsed = time.elapsed();
- qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, "
- << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec";
-}
-
void tst_QNetworkReply::downloadProgress_data()
{
QTest::addColumn<int>("loopCount");
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index e4f267d584..8b713496e6 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -101,6 +101,8 @@ private slots:
void saveAndRestore_data();
void saveAndRestore();
+ void drawBorderPixmap();
+
void drawLine_data();
void drawLine();
void drawLine_clipped();
@@ -238,8 +240,13 @@ private slots:
void taskQT4444_dontOverflowDashOffset();
+ void painterBegin();
+ void setPenColorOnImage();
+ void setPenColorOnPixmap();
+
private:
void fillData();
+ void setPenColor(QPainter& p);
QColor baseColor( int k, int intensity=255 );
QImage getResImage( const QString &dir, const QString &addition, const QString &extension );
QBitmap getBitmap( const QString &dir, const QString &filename, bool mask );
@@ -968,6 +975,18 @@ void tst_QPainter::initFrom()
delete widget;
}
+void tst_QPainter::drawBorderPixmap()
+{
+ QPixmap src(79,79);
+ src.fill(Qt::transparent);
+
+ QImage pm(200,200,QImage::Format_RGB32);
+ QPainter p(&pm);
+ p.setTransform(QTransform(-1,0,0,-1,173.5,153.5));
+ qDrawBorderPixmap(&p, QRect(0,0,75,105), QMargins(39,39,39,39), src, QRect(0,0,79,79), QMargins(39,39,39,39),
+ QTileRules(Qt::StretchTile,Qt::StretchTile), 0);
+}
+
void tst_QPainter::drawLine_data()
{
QTest::addColumn<QLine>("line");
@@ -2913,7 +2932,7 @@ void tst_QPainter::monoImages()
QImage img(2, 2, format);
- if (img.numColors() > 0) {
+ if (img.colorCount() > 0) {
img.setColor(0, QColor(colorPairs[j][0]).rgba());
img.setColor(1, QColor(colorPairs[j][1]).rgba());
}
@@ -2935,7 +2954,7 @@ void tst_QPainter::monoImages()
// should not change the image
QCOMPARE(original, img);
- if (img.numColors() == 0)
+ if (img.colorCount() == 0)
continue;
for (int k = 0; k < 2; ++k) {
@@ -4191,9 +4210,9 @@ void tst_QPainter::extendedBlendModes()
QVERIFY(testCompositionMode(255, 255, 255, QPainter::CompositionMode_SoftLight));
QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_SoftLight));
- QVERIFY(testCompositionMode(127, 127, 127, QPainter::CompositionMode_SoftLight));
- QVERIFY(testCompositionMode( 63, 63, 86, QPainter::CompositionMode_SoftLight));
- QVERIFY(testCompositionMode(127, 63, 63, QPainter::CompositionMode_SoftLight));
+ QVERIFY(testCompositionMode(127, 127, 126, QPainter::CompositionMode_SoftLight));
+ QVERIFY(testCompositionMode( 63, 63, 39, QPainter::CompositionMode_SoftLight));
+ QVERIFY(testCompositionMode(127, 63, 62, QPainter::CompositionMode_SoftLight));
QVERIFY(testCompositionMode(255, 255, 0, QPainter::CompositionMode_Difference));
QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_Difference));
@@ -4312,5 +4331,79 @@ void tst_QPainter::taskQT4444_dontOverflowDashOffset()
QVERIFY(true); // Don't crash
}
+void tst_QPainter::painterBegin()
+{
+ QImage nullImage;
+ QImage indexed8Image(16, 16, QImage::Format_Indexed8);
+ QImage rgb32Image(16, 16, QImage::Format_RGB32);
+ QImage argb32Image(16, 16, QImage::Format_ARGB32_Premultiplied);
+
+ QPainter p;
+
+ // Painting on null image should fail.
+ QVERIFY(!p.begin(&nullImage));
+
+ // Check that the painter is not messed up by using it on another image.
+ QVERIFY(p.begin(&rgb32Image));
+ QVERIFY(p.end());
+
+ // If painting on indexed8 image fails, the painter state should still be OK.
+ if (p.begin(&indexed8Image))
+ QVERIFY(p.end());
+ QVERIFY(p.begin(&rgb32Image));
+ QVERIFY(p.end());
+
+ // Try opening a painter on the two different images.
+ QVERIFY(p.begin(&rgb32Image));
+ QVERIFY(!p.begin(&argb32Image));
+ QVERIFY(p.end());
+
+ // Try opening two painters on the same image.
+ QVERIFY(p.begin(&rgb32Image));
+ QPainter q;
+ QVERIFY(!q.begin(&rgb32Image));
+ QVERIFY(!q.end());
+ QVERIFY(p.end());
+
+ // Try ending an inactive painter.
+ QVERIFY(!p.end());
+}
+
+void tst_QPainter::setPenColor(QPainter& p)
+{
+ p.setPen(Qt::NoPen);
+
+ // Setting color, then style
+ // Should work even though the pen is "NoPen with color", temporarily.
+ QPen newPen(p.pen());
+ newPen.setColor(Qt::red);
+ QCOMPARE(p.pen().style(), newPen.style());
+ QCOMPARE(p.pen().style(), Qt::NoPen);
+ p.setPen(newPen);
+
+ QCOMPARE(p.pen().color().name(), QString("#ff0000"));
+
+ QPen newPen2(p.pen());
+ newPen2.setStyle(Qt::SolidLine);
+ p.setPen(newPen2);
+
+ QCOMPARE(p.pen().color().name(), QString("#ff0000"));
+}
+
+void tst_QPainter::setPenColorOnImage()
+{
+ QImage img(QSize(10, 10), QImage::Format_ARGB32_Premultiplied);
+ QPainter p(&img);
+ setPenColor(p);
+}
+
+void tst_QPainter::setPenColorOnPixmap()
+{
+ QPixmap pix(10, 10);
+ QPainter p(&pix);
+ setPenColor(p);
+}
+
QTEST_MAIN(tst_QPainter)
+
#include "tst_qpainter.moc"
diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
index 8578d361a6..a26e0eb61f 100644
--- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
+++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
@@ -56,8 +56,7 @@ public:
virtual ~tst_QParallelAnimationGroup();
public Q_SLOTS:
- void init();
- void cleanup();
+ void initTestCase();
private slots:
void construction();
@@ -86,13 +85,13 @@ tst_QParallelAnimationGroup::~tst_QParallelAnimationGroup()
{
}
-void tst_QParallelAnimationGroup::init()
+void tst_QParallelAnimationGroup::initTestCase()
{
qRegisterMetaType<QAbstractAnimation::State>("QAbstractAnimation::State");
-}
-
-void tst_QParallelAnimationGroup::cleanup()
-{
+#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAC) || defined(Q_WS_WINCE)
+ // give the Symbian and mac app start event queue time to clear
+ QTest::qWait(1000);
+#endif
}
void tst_QParallelAnimationGroup::construction()
@@ -120,8 +119,8 @@ class TestAnimation : public QVariantAnimation
Q_OBJECT
public:
virtual void updateCurrentValue(const QVariant &value) { Q_UNUSED(value)};
- virtual void updateState(QAbstractAnimation::State oldState,
- QAbstractAnimation::State newState)
+ virtual void updateState(QAbstractAnimation::State newState,
+ QAbstractAnimation::State oldState)
{
Q_UNUSED(oldState)
Q_UNUSED(newState)
@@ -136,8 +135,8 @@ public:
TestAnimation2(int duration, QAbstractAnimation *animation) : QVariantAnimation(animation), m_duration(duration) {}
virtual void updateCurrentValue(const QVariant &value) { Q_UNUSED(value)};
- virtual void updateState(QAbstractAnimation::State oldState,
- QAbstractAnimation::State newState)
+ virtual void updateState(QAbstractAnimation::State newState,
+ QAbstractAnimation::State oldState)
{
Q_UNUSED(oldState)
Q_UNUSED(newState)
@@ -224,33 +223,33 @@ void tst_QParallelAnimationGroup::setCurrentTime()
QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped);
QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped);
- QCOMPARE(group.currentTime(), 1);
- QCOMPARE(a1_p_o1->currentTime(), 1);
- QCOMPARE(a1_p_o2->currentTime(), 1);
- QCOMPARE(a1_p_o3->currentTime(), 1);
- QCOMPARE(notTimeDriven->currentTime(), 1);
- QCOMPARE(loopsForever->currentTime(), 1);
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 1);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 1);
+ QCOMPARE(loopsForever->currentLoopTime(), 1);
// Current time = 250
group.setCurrentTime(250);
- QCOMPARE(group.currentTime(), 250);
- QCOMPARE(a1_p_o1->currentTime(), 250);
- QCOMPARE(a1_p_o2->currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 0);
QCOMPARE(a1_p_o2->currentLoop(), 1);
- QCOMPARE(a1_p_o3->currentTime(), 250);
- QCOMPARE(notTimeDriven->currentTime(), 250);
- QCOMPARE(loopsForever->currentTime(), 0);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 250);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
QCOMPARE(loopsForever->currentLoop(), 1);
// Current time = 251
group.setCurrentTime(251);
- QCOMPARE(group.currentTime(), 251);
- QCOMPARE(a1_p_o1->currentTime(), 250);
- QCOMPARE(a1_p_o2->currentTime(), 1);
+ QCOMPARE(group.currentLoopTime(), 251);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 1);
QCOMPARE(a1_p_o2->currentLoop(), 1);
- QCOMPARE(a1_p_o3->currentTime(), 250);
- QCOMPARE(notTimeDriven->currentTime(), 251);
- QCOMPARE(loopsForever->currentTime(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 251);
+ QCOMPARE(loopsForever->currentLoopTime(), 1);
}
void tst_QParallelAnimationGroup::stateChanged()
@@ -279,18 +278,18 @@ void tst_QParallelAnimationGroup::stateChanged()
group.start();
//all the animations should be started
QCOMPARE(spy1.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running);
QCOMPARE(spy2.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running);
QCOMPARE(spy3.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running);
QCOMPARE(spy4.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running);
group.setCurrentTime(1500); //anim1 should be finished
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(spy1.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped);
QCOMPARE(spy2.count(), 1); //no change
QCOMPARE(spy3.count(), 1); //no change
QCOMPARE(spy4.count(), 1); //no change
@@ -299,7 +298,7 @@ void tst_QParallelAnimationGroup::stateChanged()
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(spy1.count(), 2); //no change
QCOMPARE(spy2.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped);
QCOMPARE(spy3.count(), 1); //no change
QCOMPARE(spy4.count(), 1); //no change
@@ -308,9 +307,9 @@ void tst_QParallelAnimationGroup::stateChanged()
QCOMPARE(spy1.count(), 2); //no change
QCOMPARE(spy2.count(), 2); //no change
QCOMPARE(spy3.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped);
QCOMPARE(spy4.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped);
//cleanup
spy1.clear();
@@ -327,22 +326,22 @@ void tst_QParallelAnimationGroup::stateChanged()
QCOMPARE(spy1.count(), 0);
QCOMPARE(spy2.count(), 0);
QCOMPARE(spy3.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running);
QCOMPARE(spy4.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running);
group.setCurrentTime(1500); //anim2 should be started
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(spy1.count(), 0); //no change
QCOMPARE(spy2.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running);
QCOMPARE(spy3.count(), 1); //no change
QCOMPARE(spy4.count(), 1); //no change
group.setCurrentTime(500); //anim1 is finally also started
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(spy1.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running);
QCOMPARE(spy2.count(), 1); //no change
QCOMPARE(spy3.count(), 1); //no change
QCOMPARE(spy4.count(), 1); //no change
@@ -350,13 +349,13 @@ void tst_QParallelAnimationGroup::stateChanged()
group.setCurrentTime(0); //everything should be stopped
QCOMPARE(group.state(), QAnimationGroup::Stopped);
QCOMPARE(spy1.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped);
QCOMPARE(spy2.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped);
QCOMPARE(spy3.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped);
QCOMPARE(spy4.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped);
}
void tst_QParallelAnimationGroup::clearGroup()
@@ -376,9 +375,9 @@ void tst_QParallelAnimationGroup::clearGroup()
children[i] = group.animationAt(i);
}
- group.clearAnimations();
+ group.clear();
QCOMPARE(group.animationCount(), 0);
- QCOMPARE(group.currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 0);
for (int i = 0; i < animationCount; ++i)
QVERIFY(children[i].isNull());
}
@@ -461,9 +460,9 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup()
QCOMPARE(groupStateChangedSpy.count(), 1);
QCOMPARE(childStateChangedSpy.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
// starting directly a running child will not have any effect
@@ -486,10 +485,6 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup()
void tst_QParallelAnimationGroup::deleteChildrenWithRunningGroup()
{
-#if defined(Q_OS_SYMBIAN)
- // give the Symbian app start event queue time to clear
- QTest::qWait(1000);
-#endif
// test if children can be activated when their group is stopped
QParallelAnimationGroup group;
@@ -506,13 +501,13 @@ void tst_QParallelAnimationGroup::deleteChildrenWithRunningGroup()
QCOMPARE(anim1->state(), QAnimationGroup::Running);
QTest::qWait(80);
- QVERIFY(group.currentTime() > 0);
+ QVERIFY(group.currentLoopTime() > 0);
delete anim1;
QVERIFY(group.animationCount() == 0);
QCOMPARE(group.duration(), 0);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
- QCOMPARE(group.currentTime(), 0); //that's the invariant
+ QCOMPARE(group.currentLoopTime(), 0); //that's the invariant
}
void tst_QParallelAnimationGroup::startChildrenWithStoppedGroup()
@@ -627,11 +622,11 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild()
anim2.start();
anim2.pause();
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(1).first()),
QAnimationGroup::Paused);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
@@ -641,15 +636,15 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild()
group.start();
QCOMPARE(stateChangedSpy1.count(), 3);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(2).first()),
QAnimationGroup::Running);
QCOMPARE(stateChangedSpy2.count(), 4);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()),
QAnimationGroup::Running);
QCOMPARE(group.state(), QAnimationGroup::Running);
@@ -692,19 +687,19 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation()
group.start();
QCOMPARE(stateChangedSpy1.count(), 2);
QCOMPARE(finishedSpy1.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(stateChangedSpy2.count(), 1);
QCOMPARE(finishedSpy2.count(), 0);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
QAnimationGroup::Running);
QCOMPARE(stateChangedSpy3.count(), 1);
QCOMPARE(finishedSpy3.count(), 0);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy3.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy3.at(0).first()),
QAnimationGroup::Running);
@@ -767,9 +762,9 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations()
group.start();
QCOMPARE(stateChangedSpy.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(group.state(), QAnimationGroup::Running);
@@ -920,9 +915,9 @@ void tst_QParallelAnimationGroup::loopCount()
group.setCurrentTime(currentGroupTime);
- QCOMPARE(anim1.currentTime(), expected1.time);
- QCOMPARE(anim2.currentTime(), expected2.time);
- QCOMPARE(anim3.currentTime(), expected3.time);
+ QCOMPARE(anim1.currentLoopTime(), expected1.time);
+ QCOMPARE(anim2.currentLoopTime(), expected2.time);
+ QCOMPARE(anim3.currentLoopTime(), expected3.time);
if (expected1.state >=0)
QCOMPARE(int(anim1.state()), expected1.state);
@@ -973,22 +968,22 @@ void tst_QParallelAnimationGroup::pauseResume()
QCOMPARE(anim->state(), QAnimationGroup::Running);
QCOMPARE(spy.count(), 1);
spy.clear();
- const int currentTime = group.currentTime();
- QCOMPARE(anim->currentTime(), currentTime);
+ const int currentTime = group.currentLoopTime();
+ QCOMPARE(anim->currentLoopTime(), currentTime);
group.pause();
QCOMPARE(group.state(), QAnimationGroup::Paused);
- QCOMPARE(group.currentTime(), currentTime);
+ QCOMPARE(group.currentLoopTime(), currentTime);
QCOMPARE(anim->state(), QAnimationGroup::Paused);
- QCOMPARE(anim->currentTime(), currentTime);
+ QCOMPARE(anim->currentLoopTime(), currentTime);
QCOMPARE(spy.count(), 1);
spy.clear();
group.resume();
QCOMPARE(group.state(), QAnimationGroup::Running);
- QCOMPARE(group.currentTime(), currentTime);
+ QCOMPARE(group.currentLoopTime(), currentTime);
QCOMPARE(anim->state(), QAnimationGroup::Running);
- QCOMPARE(anim->currentTime(), currentTime);
+ QCOMPARE(anim->currentLoopTime(), currentTime);
QCOMPARE(spy.count(), 1);
group.stop();
@@ -996,10 +991,10 @@ void tst_QParallelAnimationGroup::pauseResume()
new TestAnimation2(500, &group);
group.start();
QCOMPARE(spy.count(), 1); //the animation should have been started
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Running);
group.setCurrentTime(250); //end of first animation
QCOMPARE(spy.count(), 2); //the animation should have been stopped
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Stopped);
group.pause();
QCOMPARE(spy.count(), 2); //this shouldn't have changed
group.resume();
diff --git a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp
index 62b43c4f0a..4d0a7a7c65 100644
--- a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp
+++ b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp
@@ -93,8 +93,7 @@ public:
virtual ~tst_QPauseAnimation();
public Q_SLOTS:
- void init();
- void cleanup();
+ void initTestCase();
private slots:
void changeDirectionWhileRunning();
@@ -117,20 +116,15 @@ tst_QPauseAnimation::~tst_QPauseAnimation()
{
}
-void tst_QPauseAnimation::init()
+void tst_QPauseAnimation::initTestCase()
{
qRegisterMetaType<QAbstractAnimation::State>("QAbstractAnimation::State");
qRegisterMetaType<QAbstractAnimation::DeletionPolicy>("QAbstractAnimation::DeletionPolicy");
}
-void tst_QPauseAnimation::cleanup()
-{
-}
-
void tst_QPauseAnimation::changeDirectionWhileRunning()
{
- QUnifiedTimer *timer = QUnifiedTimer::instance();
- timer->setConsistentTiming(true);
+ EnableConsistentTiming enabled;
TestablePauseAnimation animation;
animation.setDuration(400);
@@ -140,8 +134,6 @@ void tst_QPauseAnimation::changeDirectionWhileRunning()
animation.setDirection(QAbstractAnimation::Backward);
QTest::qWait(animation.totalDuration() + 50);
QVERIFY(animation.state() == QAbstractAnimation::Stopped);
-
- timer->setConsistentTiming(false);
}
void tst_QPauseAnimation::noTimerUpdates_data()
@@ -157,8 +149,7 @@ void tst_QPauseAnimation::noTimerUpdates_data()
void tst_QPauseAnimation::noTimerUpdates()
{
- QUnifiedTimer *timer = QUnifiedTimer::instance();
- timer->setConsistentTiming(true);
+ EnableConsistentTiming enabled;
QFETCH(int, duration);
QFETCH(int, loopCount);
@@ -168,16 +159,19 @@ void tst_QPauseAnimation::noTimerUpdates()
animation.setLoopCount(loopCount);
animation.start();
QTest::qWait(animation.totalDuration() + 100);
- QVERIFY(animation.state() == QAbstractAnimation::Stopped);
- QCOMPARE(animation.m_updateCurrentTimeCount, 2);
- timer->setConsistentTiming(false);
+#ifdef Q_OS_WIN
+ if (animation.state() != QAbstractAnimation::Stopped)
+ QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort);
+#endif
+
+ QVERIFY(animation.state() == QAbstractAnimation::Stopped);
+ QCOMPARE(animation.m_updateCurrentTimeCount, 1 + loopCount);
}
void tst_QPauseAnimation::mulitplePauseAnimations()
{
- QUnifiedTimer *timer = QUnifiedTimer::instance();
- timer->setConsistentTiming(true);
+ EnableConsistentTiming enabled;
TestablePauseAnimation animation;
animation.setDuration(200);
@@ -188,16 +182,26 @@ void tst_QPauseAnimation::mulitplePauseAnimations()
animation.start();
animation2.start();
QTest::qWait(animation.totalDuration() + 100);
+
+#ifdef Q_OS_WIN
+ if (animation.state() != QAbstractAnimation::Stopped)
+ QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort);
+#endif
+
QVERIFY(animation.state() == QAbstractAnimation::Stopped);
QVERIFY(animation2.state() == QAbstractAnimation::Running);
QCOMPARE(animation.m_updateCurrentTimeCount, 2);
QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
QTest::qWait(550);
+
+#ifdef Q_OS_WIN
+ if (animation2.state() != QAbstractAnimation::Stopped)
+ QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort);
+#endif
+
QVERIFY(animation2.state() == QAbstractAnimation::Stopped);
QCOMPARE(animation2.m_updateCurrentTimeCount, 3);
-
- timer->setConsistentTiming(false);
}
void tst_QPauseAnimation::pauseAndPropertyAnimations()
@@ -243,7 +247,7 @@ void tst_QPauseAnimation::pauseResume()
animation.pause();
QVERIFY(animation.state() == QAbstractAnimation::Paused);
animation.start();
- QTest::qWait(250);
+ QTest::qWait(300);
QVERIFY(animation.state() == QAbstractAnimation::Stopped);
QCOMPARE(animation.m_updateCurrentTimeCount, 3);
}
@@ -260,6 +264,9 @@ void tst_QPauseAnimation::sequentialPauseGroup()
animation3.setDuration(200);
group.start();
+ QCOMPARE(animation1.m_updateCurrentTimeCount, 1);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 0);
+ QCOMPARE(animation3.m_updateCurrentTimeCount, 0);
QVERIFY(group.state() == QAbstractAnimation::Running);
QVERIFY(animation1.state() == QAbstractAnimation::Running);
@@ -267,6 +274,9 @@ void tst_QPauseAnimation::sequentialPauseGroup()
QVERIFY(animation3.state() == QAbstractAnimation::Stopped);
group.setCurrentTime(250);
+ QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 1);
+ QCOMPARE(animation3.m_updateCurrentTimeCount, 0);
QVERIFY(group.state() == QAbstractAnimation::Running);
QVERIFY(animation1.state() == QAbstractAnimation::Stopped);
@@ -275,6 +285,9 @@ void tst_QPauseAnimation::sequentialPauseGroup()
QVERIFY(animation3.state() == QAbstractAnimation::Stopped);
group.setCurrentTime(500);
+ QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation3.m_updateCurrentTimeCount, 1);
QVERIFY(group.state() == QAbstractAnimation::Running);
QVERIFY(animation1.state() == QAbstractAnimation::Stopped);
@@ -399,6 +412,7 @@ void tst_QPauseAnimation::multipleSequentialGroups()
void tst_QPauseAnimation::zeroDuration()
{
TestablePauseAnimation animation;
+ animation.setDuration(0);
animation.start();
QTest::qWait(animation.totalDuration() + 100);
QVERIFY(animation.state() == QAbstractAnimation::Stopped);
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 36c151814a..d7f042edea 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -166,6 +166,7 @@ private slots:
void fromImage_crash();
void fromData();
+ void loadFromDataNullValues();
void preserveDepth();
};
@@ -292,7 +293,7 @@ void tst_QPixmap::setAlphaChannel()
QRgb expected = alpha == 0 ? 0 : qRgba(red, green, blue, alpha);
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
- if (result.numColors() > 0) {
+ if (result.colorCount() > 0) {
ok &= result.pixelIndex(x, y) == expected;
} else {
ok &= result.pixel(x, y) == expected;
@@ -329,7 +330,7 @@ void tst_QPixmap::fromImage()
QImage image(37, 16, format);
- if (image.numColors() == 2) {
+ if (image.colorCount() == 2) {
image.setColor(0, QColor(Qt::color0).rgba());
image.setColor(1, QColor(Qt::color1).rgba());
}
@@ -730,7 +731,7 @@ void tst_QPixmap::testMetrics()
void tst_QPixmap::createMaskFromColor()
{
QImage image(3, 3, QImage::Format_Indexed8);
- image.setNumColors(10);
+ image.setColorCount(10);
image.setColor(0, 0xffffffff);
image.setColor(1, 0xff000000);
image.setColor(2, 0xffff0000);
@@ -1133,6 +1134,8 @@ void tst_QPixmap::fromSymbianCFbsBitmap_data()
QTest::newRow("EColor4K big") << EColor4K << largeWidth << largeHeight << QColor(Qt::red);
QTest::newRow("EColor64K small") << EColor64K << smallWidth << smallHeight << QColor(Qt::green);
QTest::newRow("EColor64K big") << EColor64K << largeWidth << largeHeight << QColor(Qt::green);
+ QTest::newRow("EColor16M small") << EColor16M << smallWidth << smallHeight << QColor(Qt::yellow);
+ QTest::newRow("EColor16M big") << EColor16M << largeWidth << largeHeight << QColor(Qt::yellow);
QTest::newRow("EColor16MU small") << EColor16MU << smallWidth << smallHeight << QColor(Qt::red);
QTest::newRow("EColor16MU big") << EColor16MU << largeWidth << largeHeight << QColor(Qt::red);
QTest::newRow("EColor16MA small opaque") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0);
@@ -1144,7 +1147,7 @@ void tst_QPixmap::fromSymbianCFbsBitmap_data()
// QTest::newRow("EColor16MA small trans") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0, 0);
// QTest::newRow("EColor16MA big trans") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0, 0);
-#if !defined(__SERIES60_31__) && !defined(__S60_32__)
+#if !defined(__SERIES60_31__)
QTest::newRow("EColor16MAP small") << EColor16MAP << smallWidth << smallHeight << QColor(Qt::red);
QTest::newRow("EColor16MAP big") << EColor16MAP << largeWidth << largeHeight << QColor(Qt::red);
#endif
@@ -1436,6 +1439,26 @@ void tst_QPixmap::fromData()
QCOMPARE(img.pixel(0, 1), QRgb(0xff000000));
}
+void tst_QPixmap::loadFromDataNullValues()
+{
+ {
+ QPixmap pixmap;
+ pixmap.loadFromData(QByteArray());
+ QVERIFY(pixmap.isNull());
+ }
+ {
+ QPixmap pixmap;
+ pixmap.loadFromData(0, 123);
+ QVERIFY(pixmap.isNull());
+ }
+ {
+ QPixmap pixmap;
+ const uchar bla[] = "bla";
+ pixmap.loadFromData(bla, 0);
+ QVERIFY(pixmap.isNull());
+ }
+}
+
void tst_QPixmap::task_246446()
{
// This crashed without the bugfix in 246446
diff --git a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
index 5a9bad752c..751c7dcb24 100644
--- a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
+++ b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
@@ -383,7 +383,7 @@ void tst_QPixmapFilter::dropShadowBoundingRectFor()
QPixmapDropShadowFilter filter;
filter.setBlurRadius(0);
- QCOMPARE(filter.blurRadius(), 0);
+ QCOMPARE(filter.blurRadius(), 0.);
const QRectF rect1(0, 0, 50, 50);
const QRectF rect2(30, 20, 10, 40);
@@ -407,7 +407,7 @@ void tst_QPixmapFilter::dropShadowBoundingRectFor()
filter.setBlurRadius(2);
filter.setOffset(QPointF(0,0));
- int delta = 2 * 2;
+ qreal delta = 2;
QCOMPARE(filter.boundingRectFor(rect1), rect1.adjusted(-delta, -delta, delta, delta));
QCOMPARE(filter.boundingRectFor(rect2), rect2.adjusted(-delta, -delta, delta, delta));
QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(-delta, -delta, delta, delta));
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index 51ef2dad1a..f41fff128a 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -130,6 +130,7 @@ private slots:
void valueChanged();
void twoAnimations();
void deletedInUpdateCurrentTime();
+ void totalDuration();
};
tst_QPropertyAnimation::tst_QPropertyAnimation()
@@ -224,7 +225,7 @@ void tst_QPropertyAnimation::setCurrentTime()
animation.setLoopCount(loopCount);
animation.setCurrentTime(currentTime);
- QCOMPARE(animation.currentTime(), testCurrentTime);
+ QCOMPARE(animation.currentLoopTime(), testCurrentTime);
QCOMPARE(animation.currentLoop(), testCurrentLoop);
}
@@ -279,7 +280,7 @@ void tst_QPropertyAnimation::statesAndSignals()
QCOMPARE(anim->state(), QAnimationGroup::Stopped);
QCOMPARE(runningSpy.count(), 1); //anim must have stopped
QCOMPARE(finishedSpy.count(), 0);
- QCOMPARE(anim->currentTime(), 0);
+ QCOMPARE(anim->currentLoopTime(), 0);
QCOMPARE(anim->currentLoop(), 0);
QCOMPARE(currentLoopSpy.count(), 2);
runningSpy.clear();
@@ -290,7 +291,7 @@ void tst_QPropertyAnimation::statesAndSignals()
QCOMPARE(runningSpy.count(), 2); //started and stopped again
runningSpy.clear();
QCOMPARE(finishedSpy.count(), 1);
- QCOMPARE(anim->currentTime(), 100);
+ QCOMPARE(anim->currentLoopTime(), 100);
QCOMPARE(anim->currentLoop(), 2);
QCOMPARE(currentLoopSpy.count(), 4);
@@ -311,7 +312,7 @@ void tst_QPropertyAnimation::statesAndSignals()
QCOMPARE(anim->currentLoop(), 2);
QCOMPARE(runningSpy.count(), 1); // anim has stopped
QCOMPARE(finishedSpy.count(), 2);
- QCOMPARE(anim->currentTime(), 100);
+ QCOMPARE(anim->currentLoopTime(), 100);
delete anim;
}
@@ -494,7 +495,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning()
anim->setEndValue(100);
QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
anim->start(QVariantAnimation::DeleteWhenStopped);
- QTest::qWait(anim->duration() + 50);
+ QTest::qWait(anim->duration() + 100);
QCOMPARE(runningSpy.count(), 2); //started and then stopped
QVERIFY(!anim);
}
@@ -658,7 +659,7 @@ void tst_QPropertyAnimation::playForwardBackward()
anim.setStartValue(0);
anim.setEndValue(100);
anim.start();
- QTest::qWait(anim.duration() + 50);
+ QTest::qWait(anim.duration() + 100);
QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
QCOMPARE(anim.currentTime(), anim.duration());
@@ -666,7 +667,7 @@ void tst_QPropertyAnimation::playForwardBackward()
anim.setDirection(QVariantAnimation::Backward);
anim.start();
QCOMPARE(anim.state(), QAbstractAnimation::Running);
- QTest::qWait(anim.duration() + 50);
+ QTest::qWait(anim.duration() + 100);
QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
QCOMPARE(anim.currentTime(), 0);
@@ -675,7 +676,7 @@ void tst_QPropertyAnimation::playForwardBackward()
anim.start();
QCOMPARE(anim.state(), QAbstractAnimation::Running);
QCOMPARE(anim.currentTime(), anim.duration());
- QTest::qWait(anim.duration() + 50);
+ QTest::qWait(anim.duration() + 100);
QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
QCOMPARE(anim.currentTime(), 0);
}
@@ -863,16 +864,16 @@ void tst_QPropertyAnimation::zeroDurationStart()
//let's check the first state change
const QVariantList firstChange = spy.first();
//old state
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(firstChange.first()), QAbstractAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(firstChange.last()), QAbstractAnimation::Stopped);
//new state
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(firstChange.last()), QAbstractAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(firstChange.first()), QAbstractAnimation::Running);
//let's check the first state change
const QVariantList secondChange = spy.last();
//old state
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(secondChange.first()), QAbstractAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(secondChange.last()), QAbstractAnimation::Running);
//new state
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(secondChange.last()), QAbstractAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(secondChange.first()), QAbstractAnimation::Stopped);
}
#define Pause 1
@@ -1092,7 +1093,7 @@ void tst_QPropertyAnimation::valueChanged()
QSignalSpy spy(&anim, SIGNAL(valueChanged(QVariant)));
anim.start();
- QTest::qWait(anim.duration() + 50);
+ QTest::qWait(anim.duration() + 100);
QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
QCOMPARE(anim.currentTime(), anim.duration());
@@ -1143,7 +1144,7 @@ void tst_QPropertyAnimation::twoAnimations()
o1.anim.start();
o2.anim.start();
- QTest::qWait(o1.anim.duration() + 50);
+ QTest::qWait(o1.anim.duration() + 100);
QCOMPARE(o1.anim.state(), QAbstractAnimation::Stopped);
QCOMPARE(o2.anim.state(), QAbstractAnimation::Stopped);
@@ -1170,9 +1171,9 @@ public:
innerAnim->start();
}
- void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState)
+ void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
- QPropertyAnimation::updateState(oldState, newState);
+ QPropertyAnimation::updateState(newState, oldState);
if (newState == QAbstractAnimation::Stopped)
delete innerAnim;
}
@@ -1193,11 +1194,24 @@ void tst_QPropertyAnimation::deletedInUpdateCurrentTime()
MyComposedAnimation composedAnimation(&o, "value", "realValue");
composedAnimation.start();
QCOMPARE(composedAnimation.state(), QAbstractAnimation::Running);
- QTest::qWait(composedAnimation.duration() + 50);
+ QTest::qWait(composedAnimation.duration() + 100);
QCOMPARE(composedAnimation.state(), QAbstractAnimation::Stopped);
QCOMPARE(o.value(), 1000);
}
+void tst_QPropertyAnimation::totalDuration()
+{
+ QPropertyAnimation anim;
+ QCOMPARE(anim.totalDuration(), 250);
+ anim.setLoopCount(2);
+ QCOMPARE(anim.totalDuration(), 2*250);
+ anim.setLoopCount(-1);
+ QCOMPARE(anim.totalDuration(), -1);
+ anim.setDuration(0);
+ QCOMPARE(anim.totalDuration(), 0);
+}
+
+
QTEST_MAIN(tst_QPropertyAnimation)
#include "tst_qpropertyanimation.moc"
diff --git a/tests/auto/qregexp/tst_qregexp.cpp b/tests/auto/qregexp/tst_qregexp.cpp
index 86d831e8ad..e3053865cf 100644
--- a/tests/auto/qregexp/tst_qregexp.cpp
+++ b/tests/auto/qregexp/tst_qregexp.cpp
@@ -628,7 +628,7 @@ void tst_QRegExp::capturedTexts()
QRegExp rx7("([A-Za-z_])([A-Za-z_0-9]*)");
rx7.setCaseSensitivity(Qt::CaseSensitive);
rx7.setPatternSyntax(QRegExp::RegExp);
- QCOMPARE(rx7.numCaptures(), 2);
+ QCOMPARE(rx7.captureCount(), 2);
int pos = rx7.indexIn("(10 + delta4) * 32");
QCOMPARE(pos, 6);
@@ -1177,36 +1177,36 @@ void tst_QRegExp::prepareEngineOptimization()
QCOMPARE(rx1.capturedTexts(), QStringList() << "" << "" << "" << "");
QCOMPARE(rx1.matchedLength(), -1);
QCOMPARE(rx1.matchedLength(), -1);
- QCOMPARE(rx1.numCaptures(), 3);
+ QCOMPARE(rx1.captureCount(), 3);
QCOMPARE(rx1.exactMatch("foo"), true);
QCOMPARE(rx1.matchedLength(), 3);
QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o");
- QCOMPARE(rx1.numCaptures(), 3);
+ QCOMPARE(rx1.captureCount(), 3);
QCOMPARE(rx1.matchedLength(), 3);
QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o");
QCOMPARE(rx1.pos(3), 2);
QCOMPARE(rx1.exactMatch("foo"), true);
- QCOMPARE(rx1.numCaptures(), 3);
+ QCOMPARE(rx1.captureCount(), 3);
QCOMPARE(rx1.matchedLength(), 3);
QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o");
QCOMPARE(rx1.pos(3), 2);
QRegExp rx2 = rx1;
- QCOMPARE(rx1.numCaptures(), 3);
+ QCOMPARE(rx1.captureCount(), 3);
QCOMPARE(rx1.matchedLength(), 3);
QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o");
QCOMPARE(rx1.pos(3), 2);
- QCOMPARE(rx2.numCaptures(), 3);
+ QCOMPARE(rx2.captureCount(), 3);
QCOMPARE(rx2.matchedLength(), 3);
QCOMPARE(rx2.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o");
QCOMPARE(rx2.pos(3), 2);
QCOMPARE(rx1.exactMatch("fo"), true);
- QCOMPARE(rx1.numCaptures(), 3);
+ QCOMPARE(rx1.captureCount(), 3);
QCOMPARE(rx1.matchedLength(), 2);
QCOMPARE(rx1.capturedTexts(), QStringList() << "fo" << "f" << "o" << "");
QCOMPARE(rx1.pos(2), 1);
@@ -1245,25 +1245,25 @@ void tst_QRegExp::prepareEngineOptimization()
rx11.setPatternSyntax(QRegExp::Wildcard);
QVERIFY(!rx11.isValid());
- QCOMPARE(rx11.numCaptures(), 0);
+ QCOMPARE(rx11.captureCount(), 0);
QCOMPARE(rx11.matchedLength(), -1);
rx11.setPatternSyntax(QRegExp::RegExp);
QVERIFY(!rx11.isValid());
- QCOMPARE(rx11.numCaptures(), 0);
+ QCOMPARE(rx11.captureCount(), 0);
QCOMPARE(rx11.matchedLength(), -1);
rx11.setPattern("(foo)");
QVERIFY(rx11.isValid());
- QCOMPARE(rx11.numCaptures(), 1);
+ QCOMPARE(rx11.captureCount(), 1);
QCOMPARE(rx11.matchedLength(), -1);
QCOMPARE(rx11.indexIn("ofoo"), 1);
- QCOMPARE(rx11.numCaptures(), 1);
+ QCOMPARE(rx11.captureCount(), 1);
QCOMPARE(rx11.matchedLength(), 3);
rx11.setPatternSyntax(QRegExp::RegExp);
- QCOMPARE(rx11.numCaptures(), 1);
+ QCOMPARE(rx11.captureCount(), 1);
QCOMPARE(rx11.matchedLength(), 3);
/*
@@ -1278,11 +1278,11 @@ void tst_QRegExp::prepareEngineOptimization()
QCOMPARE(rx11.matchedLength(), 3);
rx11.setPatternSyntax(QRegExp::Wildcard);
- QCOMPARE(rx11.numCaptures(), 0);
+ QCOMPARE(rx11.captureCount(), 0);
QCOMPARE(rx11.matchedLength(), -1);
rx11.setPatternSyntax(QRegExp::RegExp);
- QCOMPARE(rx11.numCaptures(), 1);
+ QCOMPARE(rx11.captureCount(), 1);
QCOMPARE(rx11.matchedLength(), -1);
}
diff --git a/tests/auto/qregion/tst_qregion.cpp b/tests/auto/qregion/tst_qregion.cpp
index e5a3151120..582b5e8df3 100644
--- a/tests/auto/qregion/tst_qregion.cpp
+++ b/tests/auto/qregion/tst_qregion.cpp
@@ -88,8 +88,8 @@ private slots:
void operator_xor_data();
void operator_xor();
- void numRects_data();
- void numRects();
+ void rectCount_data();
+ void rectCount();
void isEmpty_data();
void isEmpty();
@@ -554,7 +554,7 @@ void tst_QRegion::operator_plus()
qDebug() << "expected" << expected;
}
QCOMPARE(r1 + r2, expected);
- if (r2.numRects() == 1) {
+ if (r2.rectCount() == 1) {
if (r1 + r2.boundingRect() != expected) {
qDebug() << "r1 + QRect(r2)" << (r1 + r2.boundingRect());
qDebug() << "expected" << expected;
@@ -567,7 +567,7 @@ void tst_QRegion::operator_plus()
qDebug() << "expected" << expected;
}
QCOMPARE(r2 + r1, expected);
- if (r1.numRects() == 1) {
+ if (r1.rectCount() == 1) {
if (r1 + r2.boundingRect() != expected) {
qDebug() << "r2 + QRect(r1)" << (r2 + r1.boundingRect());
qDebug() << "expected" << expected;
@@ -582,7 +582,7 @@ void tst_QRegion::operator_plus()
qDebug() << "expected" << expected;
}
QCOMPARE(result1, expected);
- if (r2.numRects() == 1) {
+ if (r2.rectCount() == 1) {
result1 = r1;
result1 += r2.boundingRect();
if (result1 != expected) {
@@ -599,7 +599,7 @@ void tst_QRegion::operator_plus()
qDebug() << "expected" << expected;
}
QCOMPARE(result2, expected);
- if (r1.numRects() == 1) {
+ if (r1.rectCount() == 1) {
result2 = r2;
result2 += r1.boundingRect();
if (result2 != expected) {
@@ -802,7 +802,7 @@ void tst_QRegion::operator_xor()
QCOMPARE(dest, expected);
}
-void tst_QRegion::numRects_data()
+void tst_QRegion::rectCount_data()
{
QTest::addColumn<QRegion>("region");
QTest::addColumn<int>("expected");
@@ -818,12 +818,12 @@ void tst_QRegion::numRects_data()
QTest::newRow("2 rects") << dest << rects.size();
}
-void tst_QRegion::numRects()
+void tst_QRegion::rectCount()
{
QFETCH(QRegion, region);
QFETCH(int, expected);
- QCOMPARE(region.numRects(), expected);
+ QCOMPARE(region.rectCount(), expected);
}
void tst_QRegion::isEmpty_data()
@@ -850,7 +850,7 @@ void tst_QRegion::isEmpty()
QVERIFY(region.isEmpty());
QCOMPARE(region, QRegion());
- QCOMPARE(region.numRects(), 0);
+ QCOMPARE(region.rectCount(), 0);
QCOMPARE(region.boundingRect(), QRect());
QVERIFY(region.rects().isEmpty());
}
diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp
index aeead150e9..b99760e834 100644
--- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp
+++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp
@@ -313,30 +313,128 @@ void tst_QScopedPointer::objectSize()
QCOMPARE(sizeof(QScopedPointer<int>), sizeof(void *));
}
-void tst_QScopedPointer::comparison()
+struct RefCounted
{
- int *a = new int(42);
- int *b = new int(43);
+ RefCounted()
+ : ref(0)
+ {
+ instanceCount.ref();
+ }
+
+ RefCounted(RefCounted const &)
+ : ref(0)
+ {
+ instanceCount.ref();
+ }
+
+ ~RefCounted()
+ {
+ QVERIFY( ref == 0 );
+ instanceCount.deref();
+ }
+
+ RefCounted &operator=(RefCounted const &)
+ {
+ return *this;
+ }
- QScopedPointer<int> pa(a);
- QScopedPointer<int> pa2(a);
- QScopedPointer<int> pb(b);
+ QAtomicInt ref;
+ static QAtomicInt instanceCount;
+};
+
+QAtomicInt RefCounted::instanceCount = 0;
+
+template <class A1, class A2, class B>
+void scopedPointerComparisonTest(const A1 &a1, const A2 &a2, const B &b)
+{
// test equality on equal pointers
- QVERIFY(pa == pa2);
- QVERIFY(pa2 == pa);
+ QVERIFY(a1 == a2);
+ QVERIFY(a2 == a1);
+
+ // test inequality on equal pointers
+ QVERIFY(!(a1 != a2));
+ QVERIFY(!(a2 != a1));
+
+ // test equality on unequal pointers
+ QVERIFY(!(a1 == b));
+ QVERIFY(!(a2 == b));
+ QVERIFY(!(b == a1));
+ QVERIFY(!(b == a2));
+
+ // test inequality on unequal pointers
+ QVERIFY(b != a1);
+ QVERIFY(b != a2);
+ QVERIFY(a1 != b);
+ QVERIFY(a2 != b);
+}
+
+void tst_QScopedPointer::comparison()
+{
+ QCOMPARE( int(RefCounted::instanceCount), 0 );
+
+ {
+ RefCounted *a = new RefCounted;
+ RefCounted *b = new RefCounted;
+
+ QCOMPARE( int(RefCounted::instanceCount), 2 );
- // test unequality on equal pointers
- QVERIFY(!(pa != pa2));
- QVERIFY(!(pa2 != pa));
+ QScopedPointer<RefCounted> pa1(a);
+ QScopedPointer<RefCounted> pa2(a);
+ QScopedPointer<RefCounted> pb(b);
- // test on unequal pointers
- QVERIFY(!(pa == pb));
- QVERIFY(!(pb == pa));
- QVERIFY(pb != pa);
- QVERIFY(pa != pb);
+ scopedPointerComparisonTest(pa1, pa1, pb);
+ scopedPointerComparisonTest(pa2, pa2, pb);
+ scopedPointerComparisonTest(pa1, pa2, pb);
+
+ pa2.take();
+
+ QCOMPARE( int(RefCounted::instanceCount), 2 );
+ }
+
+ QCOMPARE( int(RefCounted::instanceCount), 0 );
+
+ {
+ RefCounted *a = new RefCounted[42];
+ RefCounted *b = new RefCounted[43];
+
+ QCOMPARE( int(RefCounted::instanceCount), 85 );
+
+ QScopedArrayPointer<RefCounted> pa1(a);
+ QScopedArrayPointer<RefCounted> pa2(a);
+ QScopedArrayPointer<RefCounted> pb(b);
+
+ scopedPointerComparisonTest(pa1, pa2, pb);
+
+ pa2.take();
+
+ QCOMPARE( int(RefCounted::instanceCount), 85 );
+ }
+
+ QCOMPARE( int(RefCounted::instanceCount), 0 );
+
+ {
+ // QScopedSharedPointer is an internal helper class -- it is unsupported!
+
+ RefCounted *a = new RefCounted;
+ RefCounted *b = new RefCounted;
+
+ QCOMPARE( int(RefCounted::instanceCount), 2 );
+
+ QSharedDataPointer<RefCounted> pa1(a);
+ QSharedDataPointer<RefCounted> pa2(a);
+ QSharedDataPointer<RefCounted> pb(b);
+
+ QCOMPARE( int(a->ref), 2 );
+ QCOMPARE( int(b->ref), 1 );
+ QCOMPARE( int(RefCounted::instanceCount), 2 );
+
+ scopedPointerComparisonTest(pa1, pa2, pb);
+
+ QCOMPARE( int(RefCounted::instanceCount), 2 );
+ }
- pa2.take();
+ QCOMPARE( int(RefCounted::instanceCount), 0 );
}
QTEST_MAIN(tst_QScopedPointer)
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 25ee00f5ef..8eaad78470 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -44,6 +44,7 @@
#include <qscriptengine.h>
#include <qscriptengineagent.h>
+#include <qscriptprogram.h>
#include <qscriptvalueiterator.h>
#include <qgraphicsitem.h>
#include <qstandarditemmodel.h>
@@ -52,6 +53,7 @@
Q_DECLARE_METATYPE(QList<int>)
Q_DECLARE_METATYPE(QObjectList)
+Q_DECLARE_METATYPE(QScriptProgram)
//TESTED_CLASS=
//TESTED_FILES=
@@ -151,6 +153,7 @@ private slots:
void installTranslatorFunctions();
void functionScopes();
void nativeFunctionScopes();
+ void evaluateProgram();
void qRegExpInport_data();
void qRegExpInport();
@@ -4289,6 +4292,152 @@ void tst_QScriptEngine::nativeFunctionScopes()
}
}
+static QScriptValue createProgram(QScriptContext *ctx, QScriptEngine *eng)
+{
+ QString code = ctx->argument(0).toString();
+ QScriptProgram result(code);
+ return qScriptValueFromValue(eng, result);
+}
+
+void tst_QScriptEngine::evaluateProgram()
+{
+ QScriptEngine eng;
+
+ {
+ QString code("1 + 2");
+ QString fileName("hello.js");
+ int lineNumber(123);
+ QScriptProgram program(code, fileName, lineNumber);
+ QVERIFY(!program.isNull());
+ QCOMPARE(program.sourceCode(), code);
+ QCOMPARE(program.fileName(), fileName);
+ QCOMPARE(program.firstLineNumber(), lineNumber);
+
+ QScriptValue expected = eng.evaluate(code);
+ for (int x = 0; x < 10; ++x) {
+ QScriptValue ret = eng.evaluate(program);
+ QVERIFY(ret.equals(expected));
+ }
+
+ // operator=
+ QScriptProgram sameProgram = program;
+ QVERIFY(sameProgram == program);
+ QVERIFY(eng.evaluate(sameProgram).equals(expected));
+
+ // copy constructor
+ QScriptProgram sameProgram2(program);
+ QVERIFY(sameProgram2 == program);
+ QVERIFY(eng.evaluate(sameProgram2).equals(expected));
+
+ QScriptProgram differentProgram("2 + 3");
+ QVERIFY(differentProgram != program);
+ QVERIFY(!eng.evaluate(differentProgram).equals(expected));
+ }
+
+ // Program that accesses variable in the scope
+ {
+ QScriptProgram program("a");
+ QVERIFY(!program.isNull());
+ {
+ QScriptValue ret = eng.evaluate(program);
+ QVERIFY(ret.isError());
+ QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: Can't find variable: a"));
+ }
+
+ QScriptValue obj = eng.newObject();
+ obj.setProperty("a", 123);
+ QScriptContext *ctx = eng.currentContext();
+ ctx->pushScope(obj);
+ {
+ QScriptValue ret = eng.evaluate(program);
+ QVERIFY(!ret.isError());
+ QVERIFY(ret.equals(obj.property("a")));
+ }
+
+ obj.setProperty("a", QScriptValue());
+ {
+ QScriptValue ret = eng.evaluate(program);
+ QVERIFY(ret.isError());
+ }
+
+ QScriptValue obj2 = eng.newObject();
+ obj2.setProperty("a", 456);
+ ctx->pushScope(obj2);
+ {
+ QScriptValue ret = eng.evaluate(program);
+ QVERIFY(!ret.isError());
+ QVERIFY(ret.equals(obj2.property("a")));
+ }
+
+ ctx->popScope();
+ }
+
+ // Program that creates closure
+ {
+ QScriptProgram program("(function() { var count = 0; return function() { return count++; }; })");
+ QVERIFY(!program.isNull());
+ QScriptValue createCounter = eng.evaluate(program);
+ QVERIFY(createCounter.isFunction());
+ QScriptValue counter = createCounter.call();
+ QVERIFY(counter.isFunction());
+ {
+ QScriptValue ret = counter.call();
+ QVERIFY(ret.isNumber());
+ }
+ QScriptValue counter2 = createCounter.call();
+ QVERIFY(counter2.isFunction());
+ QVERIFY(!counter2.equals(counter));
+ {
+ QScriptValue ret = counter2.call();
+ QVERIFY(ret.isNumber());
+ }
+ }
+
+ // Program created in a function call, then executed later
+ {
+ QScriptValue fun = eng.newFunction(createProgram);
+ QScriptProgram program = qscriptvalue_cast<QScriptProgram>(
+ fun.call(QScriptValue(), QScriptValueList() << "a + 1"));
+ QVERIFY(!program.isNull());
+ eng.globalObject().setProperty("a", QScriptValue());
+ {
+ QScriptValue ret = eng.evaluate(program);
+ QVERIFY(ret.isError());
+ QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: Can't find variable: a"));
+ }
+ eng.globalObject().setProperty("a", 122);
+ {
+ QScriptValue ret = eng.evaluate(program);
+ QVERIFY(!ret.isError());
+ QVERIFY(ret.isNumber());
+ QCOMPARE(ret.toInt32(), 123);
+ }
+ }
+
+ // Same program run in different engines
+ {
+ QString code("1 + 2");
+ QScriptProgram program(code);
+ QVERIFY(!program.isNull());
+ double expected = eng.evaluate(program).toNumber();
+ for (int x = 0; x < 2; ++x) {
+ QScriptEngine eng2;
+ for (int y = 0; y < 2; ++y) {
+ double ret = eng2.evaluate(program).toNumber();
+ QCOMPARE(ret, expected);
+ }
+ }
+ }
+
+ // No program
+ {
+ QScriptProgram program;
+ QVERIFY(program.isNull());
+ QScriptValue ret = eng.evaluate(program);
+ QVERIFY(!ret.isValid());
+ }
+}
+
static QRegExp minimal(QRegExp r) { r.setMinimal(true); return r; }
void tst_QScriptEngine::qRegExpInport_data()
@@ -4336,7 +4485,7 @@ void tst_QScriptEngine::qRegExpInport()
QScriptValue result = func.call(QScriptValue(), QScriptValueList() << string << rexp);
rx.indexIn(string);
- for (int i = 0; i <= rx.numCaptures(); i++) {
+ for (int i = 0; i <= rx.captureCount(); i++) {
QCOMPARE(result.property(i).toString(), rx.cap(i));
}
}
diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
index 283e489161..032c34b298 100644
--- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
+++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
@@ -44,6 +44,7 @@
#include <QtScript/qscriptengineagent.h>
#include <QtScript/qscriptengine.h>
+#include <QtScript/qscriptprogram.h>
#include <qscriptvalueiterator.h>
//TESTED_CLASS=
@@ -109,6 +110,10 @@ private slots:
void extension_invoctaion();
void extension();
void isEvaluatingInExtension();
+ void hasUncaughtException();
+ void evaluateProgram();
+ void evaluateProgram_SyntaxError();
+ void evaluateNullProgram();
private:
double m_testProperty;
@@ -2182,5 +2187,124 @@ void tst_QScriptEngineAgent::isEvaluatingInExtension()
QVERIFY(spy->wasEvaluating);
}
+class NewSpy :public QScriptEngineAgent
+{
+ bool m_result;
+public:
+ NewSpy(QScriptEngine* eng) : QScriptEngineAgent(eng), m_result(false) {}
+ void functionExit (qint64, const QScriptValue &scriptValue)
+ {
+ if (engine()->hasUncaughtException()) m_result = true;
+ }
+
+ bool isPass() { return m_result; }
+ void reset() { m_result = false; }
+};
+
+void tst_QScriptEngineAgent::hasUncaughtException()
+{
+ QScriptEngine eng;
+ NewSpy* spy = new NewSpy(&eng);
+ eng.setAgent(spy);
+ QScriptValue scriptValue;
+
+ // Check unhandled exception.
+ eng.evaluate("function init () {Unknown.doSth ();}");
+ scriptValue = QScriptValue(eng.globalObject().property("init")).call();
+ QVERIFY(eng.hasUncaughtException());
+ QVERIFY2(spy->isPass(), "At least one of a functionExit event should set hasUncaughtException flag.");
+ spy->reset();
+
+ // Check catched exception.
+ eng.evaluate("function innerFoo() { throw new Error('ciao') }");
+ eng.evaluate("function foo() {try { innerFoo() } catch (e) {} }");
+ scriptValue = QScriptValue(eng.globalObject().property("foo")).call();
+ QVERIFY(!eng.hasUncaughtException());
+ QVERIFY2(spy->isPass(), "At least one of a functionExit event should set hasUncaughtException flag.");
+}
+
+void tst_QScriptEngineAgent::evaluateProgram()
+{
+ QScriptEngine eng;
+ QScriptProgram program("1 + 2", "foo.js", 123);
+ ScriptEngineSpy *spy = new ScriptEngineSpy(&eng);
+ qint64 scriptId = -1;
+ for (int x = 0; x < 10; ++x) {
+ spy->clear();
+ (void)eng.evaluate(program);
+ QCOMPARE(spy->count(), (x == 0) ? 4 : 3);
+
+ if (x == 0) {
+ // script is only loaded on first execution
+ QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad);
+ scriptId = spy->at(0).scriptId;
+ QVERIFY(scriptId != -1);
+ QCOMPARE(spy->at(0).script, program.sourceCode());
+ QCOMPARE(spy->at(0).fileName, program.fileName());
+ QCOMPARE(spy->at(0).lineNumber, program.firstLineNumber());
+ spy->removeFirst();
+ }
+
+ QCOMPARE(spy->at(0).type, ScriptEngineEvent::FunctionEntry); // evaluate()
+ QCOMPARE(spy->at(0).scriptId, scriptId);
+
+ QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange);
+ QCOMPARE(spy->at(1).scriptId, scriptId);
+ QCOMPARE(spy->at(1).lineNumber, program.firstLineNumber());
+
+ QCOMPARE(spy->at(2).type, ScriptEngineEvent::FunctionExit); // evaluate()
+ QCOMPARE(spy->at(2).scriptId, scriptId);
+ QVERIFY(spy->at(2).value.isNumber());
+ QCOMPARE(spy->at(2).value.toNumber(), qsreal(3));
+ }
+}
+
+void tst_QScriptEngineAgent::evaluateProgram_SyntaxError()
+{
+ QScriptEngine eng;
+ QScriptProgram program("this is not valid syntax", "foo.js", 123);
+ ScriptEngineSpy *spy = new ScriptEngineSpy(&eng);
+ qint64 scriptId = -1;
+ for (int x = 0; x < 10; ++x) {
+ spy->clear();
+ (void)eng.evaluate(program);
+ QCOMPARE(spy->count(), (x == 0) ? 8 : 7);
+
+ if (x == 0) {
+ // script is only loaded on first execution
+ QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad);
+ scriptId = spy->at(0).scriptId;
+ QVERIFY(scriptId != -1);
+ QCOMPARE(spy->at(0).script, program.sourceCode());
+ QCOMPARE(spy->at(0).fileName, program.fileName());
+ QCOMPARE(spy->at(0).lineNumber, program.firstLineNumber());
+ spy->removeFirst();
+ }
+
+ QCOMPARE(spy->at(0).type, ScriptEngineEvent::FunctionEntry); // evaluate()
+ QCOMPARE(spy->at(0).scriptId, scriptId);
+
+ QCOMPARE(spy->at(1).type, ScriptEngineEvent::ContextPush); // SyntaxError constructor
+ QCOMPARE(spy->at(2).type, ScriptEngineEvent::FunctionEntry); // SyntaxError constructor
+ QCOMPARE(spy->at(3).type, ScriptEngineEvent::FunctionExit); // SyntaxError constructor
+ QCOMPARE(spy->at(4).type, ScriptEngineEvent::ContextPop); // SyntaxError constructor
+
+ QCOMPARE(spy->at(5).type, ScriptEngineEvent::ExceptionThrow);
+ QVERIFY(spy->at(5).value.isError());
+ QCOMPARE(spy->at(5).value.toString(), QString::fromLatin1("SyntaxError: Parse error"));
+
+ QCOMPARE(spy->at(6).type, ScriptEngineEvent::FunctionExit); // evaluate()
+ QCOMPARE(spy->at(6).scriptId, scriptId);
+ }
+}
+
+void tst_QScriptEngineAgent::evaluateNullProgram()
+{
+ QScriptEngine eng;
+ ScriptEngineSpy *spy = new ScriptEngineSpy(&eng);
+ (void)eng.evaluate(QScriptProgram());
+ QCOMPARE(spy->count(), 0);
+}
+
QTEST_MAIN(tst_QScriptEngineAgent)
#include "tst_qscriptengineagent.moc"
diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
index 320a429d04..44adf7e45d 100644
--- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
+++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
@@ -317,6 +317,11 @@ public:
Q_INVOKABLE QObject* myInvokableReturningMyQObjectAsQObject()
{ m_qtFunctionInvoked = 57; return this; }
+ Q_INVOKABLE QObjectList findObjects() const
+ { return findChildren<QObject *>(); }
+ Q_INVOKABLE QList<int> myInvokableNumbers() const
+ { return QList<int>() << 1 << 2 << 3; }
+
void emitMySignal()
{ emit mySignal(); }
void emitMySignalWithIntArg(int arg)
@@ -493,6 +498,7 @@ protected slots:
}
private slots:
+ void registeredTypes();
void getSetStaticProperty();
void getSetDynamicProperty();
void getSetChildren();
@@ -543,6 +549,24 @@ void tst_QScriptExtQObject::cleanup()
delete m_myObject;
}
+// this test has to be first and test that some types are automatically registered
+void tst_QScriptExtQObject::registeredTypes()
+{
+ QScriptEngine e;
+ QObject *t = new MyQObject;
+ QObject *c = new QObject(t);
+ c->setObjectName ("child1");
+
+ e.globalObject().setProperty("MyTest", e.newQObject(t));
+
+ QScriptValue v1 = e.evaluate("MyTest.findObjects()[0].objectName;");
+ QCOMPARE(v1.toString(), c->objectName());
+
+ QScriptValue v2 = e.evaluate("MyTest.myInvokableNumbers()");
+ QCOMPARE(qscriptvalue_cast<QList<int> >(v2), (QList<int>() << 1 << 2 << 3));
+}
+
+
static QScriptValue getSetProperty(QScriptContext *ctx, QScriptEngine *)
{
if (ctx->argumentCount() != 0)
diff --git a/tests/auto/qscriptstring/tst_qscriptstring.cpp b/tests/auto/qscriptstring/tst_qscriptstring.cpp
index e1a4bc1457..1229f4ade3 100644
--- a/tests/auto/qscriptstring/tst_qscriptstring.cpp
+++ b/tests/auto/qscriptstring/tst_qscriptstring.cpp
@@ -59,6 +59,8 @@ public:
private slots:
void test();
void hash();
+ void toArrayIndex_data();
+ void toArrayIndex();
};
tst_QScriptString::tst_QScriptString()
@@ -155,5 +157,40 @@ void tst_QScriptString::hash()
QCOMPARE(stringToInt.value(foo), 123);
}
+void tst_QScriptString::toArrayIndex_data()
+{
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<bool>("expectSuccess");
+ QTest::addColumn<quint32>("expectedIndex");
+ QTest::newRow("foo") << QString::fromLatin1("foo") << false << quint32(0xffffffff);
+ QTest::newRow("empty") << QString::fromLatin1("") << false << quint32(0xffffffff);
+ QTest::newRow("0") << QString::fromLatin1("0") << true << quint32(0);
+ QTest::newRow("00") << QString::fromLatin1("00") << false << quint32(0xffffffff);
+ QTest::newRow("1") << QString::fromLatin1("1") << true << quint32(1);
+ QTest::newRow("123") << QString::fromLatin1("123") << true << quint32(123);
+ QTest::newRow("-1") << QString::fromLatin1("-1") << false << quint32(0xffffffff);
+ QTest::newRow("0a") << QString::fromLatin1("0a") << false << quint32(0xffffffff);
+ QTest::newRow("0x1") << QString::fromLatin1("0x1") << false << quint32(0xffffffff);
+ QTest::newRow("01") << QString::fromLatin1("01") << false << quint32(0xffffffff);
+ QTest::newRow("4294967294") << QString::fromLatin1("4294967294") << true << quint32(0xfffffffe);
+ QTest::newRow("4294967295") << QString::fromLatin1("4294967295") << false << quint32(0xffffffff);
+}
+
+void tst_QScriptString::toArrayIndex()
+{
+ QFETCH(QString, input);
+ QFETCH(bool, expectSuccess);
+ QFETCH(quint32, expectedIndex);
+ QScriptEngine engine;
+ for (int x = 0; x < 2; ++x) {
+ bool isArrayIndex;
+ bool *ptr = (x == 0) ? &isArrayIndex : (bool*)0;
+ quint32 result = engine.toStringHandle(input).toArrayIndex(ptr);
+ if (x == 0)
+ QCOMPARE(isArrayIndex, expectSuccess);
+ QCOMPARE(result, expectedIndex);
+ }
+}
+
QTEST_MAIN(tst_QScriptString)
#include "tst_qscriptstring.moc"
diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index aa6801a63b..28fccac428 100644
--- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -87,7 +87,7 @@ private slots:
void currentAnimation();
void currentAnimationWithZeroDuration();
void insertAnimation();
- void clearAnimations();
+ void clear();
void pauseResume();
};
@@ -134,8 +134,8 @@ class TestAnimation : public QVariantAnimation
Q_OBJECT
public:
virtual void updateCurrentValue(const QVariant &value) { Q_UNUSED(value)};
- virtual void updateState(QAbstractAnimation::State oldState,
- QAbstractAnimation::State newState)
+ virtual void updateState(QAbstractAnimation::State newState,
+ QAbstractAnimation::State oldState)
{
Q_UNUSED(oldState)
Q_UNUSED(newState)
@@ -208,119 +208,119 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence2->state(), QAnimationGroup::Stopped);
QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
- QCOMPARE(group.currentTime(), 1);
- QCOMPARE(sequence->currentTime(), 1);
- QCOMPARE(a1_s_o1->currentTime(), 1);
- QCOMPARE(a2_s_o1->currentTime(), 0);
- QCOMPARE(a3_s_o1->currentTime(), 0);
- QCOMPARE(a1_s_o2->currentTime(), 0);
- QCOMPARE(a1_s_o3->currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
// Current time = 250
group.setCurrentTime(250);
- QCOMPARE(group.currentTime(), 250);
- QCOMPARE(sequence->currentTime(), 250);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 0);
- QCOMPARE(a3_s_o1->currentTime(), 0);
- QCOMPARE(a1_s_o2->currentTime(), 0);
- QCOMPARE(a1_s_o3->currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(sequence->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
// Current time = 251
group.setCurrentTime(251);
- QCOMPARE(group.currentTime(), 251);
- QCOMPARE(sequence->currentTime(), 251);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 1);
+ QCOMPARE(group.currentLoopTime(), 251);
+ QCOMPARE(sequence->currentLoopTime(), 251);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 1);
QCOMPARE(a2_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentTime(), 0);
- QCOMPARE(sequence2->currentTime(), 0);
- QCOMPARE(a1_s_o2->currentTime(), 0);
- QCOMPARE(a1_s_o3->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
// Current time = 750
group.setCurrentTime(750);
- QCOMPARE(group.currentTime(), 750);
- QCOMPARE(sequence->currentTime(), 750);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 750);
+ QCOMPARE(sequence->currentLoopTime(), 750);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentTime(), 0);
- QCOMPARE(sequence2->currentTime(), 0);
- QCOMPARE(a1_s_o2->currentTime(), 0);
- QCOMPARE(a1_s_o3->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
// Current time = 1000
group.setCurrentTime(1000);
- QCOMPARE(group.currentTime(), 1000);
- QCOMPARE(sequence->currentTime(), 1000);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(group.currentLoopTime(), 1000);
+ QCOMPARE(sequence->currentLoopTime(), 1000);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentTime(), 0);
- QCOMPARE(sequence2->currentTime(), 0);
- QCOMPARE(a1_s_o2->currentTime(), 0);
- QCOMPARE(a1_s_o3->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
// Current time = 1010
group.setCurrentTime(1010);
- QCOMPARE(group.currentTime(), 1010);
- QCOMPARE(sequence->currentTime(), 1010);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(group.currentLoopTime(), 1010);
+ QCOMPARE(sequence->currentLoopTime(), 1010);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentTime(), 10);
- QCOMPARE(sequence2->currentTime(), 0);
- QCOMPARE(a1_s_o2->currentTime(), 0);
- QCOMPARE(a1_s_o3->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 10);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
// Current time = 1250
group.setCurrentTime(1250);
- QCOMPARE(group.currentTime(), 1250);
- QCOMPARE(sequence->currentTime(), 1250);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(group.currentLoopTime(), 1250);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentTime(), 250);
- QCOMPARE(sequence2->currentTime(), 0);
- QCOMPARE(a1_s_o2->currentTime(), 0);
- QCOMPARE(a1_s_o3->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
// Current time = 1500
group.setCurrentTime(1500);
- QCOMPARE(group.currentTime(), 1500);
- QCOMPARE(sequence->currentTime(), 1250);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(group.currentLoopTime(), 1500);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentTime(), 250);
- QCOMPARE(sequence2->currentTime(), 250);
- QCOMPARE(a1_s_o2->currentTime(), 250);
- QCOMPARE(a1_s_o3->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
// Current time = 1750
group.setCurrentTime(1750);
- QCOMPARE(group.currentTime(), 1750);
- QCOMPARE(sequence->currentTime(), 1250);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentTime(), 250);
- QCOMPARE(sequence2->currentTime(), 500);
- QCOMPARE(a1_s_o2->currentTime(), 250);
- QCOMPARE(a1_s_o3->currentTime(), 250);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 250);
// Current time = 2000
group.setCurrentTime(2000);
- QCOMPARE(group.currentTime(), 1750);
- QCOMPARE(sequence->currentTime(), 1250);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentTime(), 250);
- QCOMPARE(sequence2->currentTime(), 500);
- QCOMPARE(a1_s_o2->currentTime(), 250);
- QCOMPARE(a1_s_o3->currentTime(), 250);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 250);
}
void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation()
@@ -357,40 +357,40 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation()
QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped);
QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped);
- QCOMPARE(group.currentTime(), 1);
- QCOMPARE(sequence->currentTime(), 1);
- QCOMPARE(a1_s_o1->currentTime(), 1);
- QCOMPARE(a1_s_o2->currentTime(), 0);
- QCOMPARE(notTimeDriven->currentTime(), 0);
- QCOMPARE(loopsForever->currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 0);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
// Current time = 250
group.setCurrentTime(250);
- QCOMPARE(group.currentTime(), 250);
- QCOMPARE(sequence->currentTime(), 250);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a1_s_o2->currentTime(), 0);
- QCOMPARE(notTimeDriven->currentTime(), 0);
- QCOMPARE(loopsForever->currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(sequence->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 0);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
// Current time = 500
group.setCurrentTime(500);
- QCOMPARE(group.currentTime(), 500);
- QCOMPARE(sequence->currentTime(), 500);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a1_s_o2->currentTime(), 250);
- QCOMPARE(notTimeDriven->currentTime(), 0);
- QCOMPARE(loopsForever->currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 500);
+ QCOMPARE(sequence->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 0);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
QCOMPARE(group.currentAnimation(), notTimeDriven);
// Current time = 505
group.setCurrentTime(505);
- QCOMPARE(group.currentTime(), 505);
- QCOMPARE(sequence->currentTime(), 500);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a1_s_o2->currentTime(), 250);
- QCOMPARE(notTimeDriven->currentTime(), 5);
- QCOMPARE(loopsForever->currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 505);
+ QCOMPARE(sequence->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 5);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
QCOMPARE(group.currentAnimation(), notTimeDriven);
QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
@@ -400,12 +400,12 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation()
// Current time = 750 (end of notTimeDriven animation)
group.setCurrentTime(750);
- QCOMPARE(group.currentTime(), 750);
- QCOMPARE(sequence->currentTime(), 500);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a1_s_o2->currentTime(), 250);
- QCOMPARE(notTimeDriven->currentTime(), 250);
- QCOMPARE(loopsForever->currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 750);
+ QCOMPARE(sequence->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 250);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
QCOMPARE(group.currentAnimation(), loopsForever);
QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
@@ -415,13 +415,13 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation()
// Current time = 800 (as notTimeDriven was finished at 750, loopsforever should still run)
group.setCurrentTime(800);
- QCOMPARE(group.currentTime(), 800);
+ QCOMPARE(group.currentLoopTime(), 800);
QCOMPARE(group.currentAnimation(), loopsForever);
- QCOMPARE(sequence->currentTime(), 500);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a1_s_o2->currentTime(), 250);
- QCOMPARE(notTimeDriven->currentTime(), 250);
- QCOMPARE(loopsForever->currentTime(), 50);
+ QCOMPARE(sequence->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 250);
+ QCOMPARE(loopsForever->currentLoopTime(), 50);
loopsForever->stop(); // this should stop the group
@@ -466,26 +466,26 @@ void tst_QSequentialAnimationGroup::seekingForwards()
QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped);
- QCOMPARE(group.currentTime(), 1);
- QCOMPARE(sequence->currentTime(), 1);
- QCOMPARE(a1_s_o1->currentTime(), 1);
- QCOMPARE(a2_s_o1->currentTime(), 0);
- QCOMPARE(a3_s_o1->currentTime(), 0);
- QCOMPARE(sequence2->currentTime(), 0);
- QCOMPARE(a1_s_o2->currentTime(), 0);
- QCOMPARE(a1_s_o3->currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
// Current time = 1500
group.setCurrentTime(1500);
- QCOMPARE(group.currentTime(), 1500);
- QCOMPARE(sequence->currentTime(), 1250);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(group.currentLoopTime(), 1500);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentTime(), 250);
- QCOMPARE(sequence2->currentTime(), 250);
- QCOMPARE(a1_s_o2->currentTime(), 250);
- QCOMPARE(a1_s_o3->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
// this will restart the group
group.start();
@@ -499,15 +499,15 @@ void tst_QSequentialAnimationGroup::seekingForwards()
// Current time = 1750
group.setCurrentTime(1750);
- QCOMPARE(group.currentTime(), 1750);
- QCOMPARE(sequence->currentTime(), 1250);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentTime(), 250);
- QCOMPARE(sequence2->currentTime(), 500);
- QCOMPARE(a1_s_o2->currentTime(), 250);
- QCOMPARE(a1_s_o3->currentTime(), 250);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 250);
}
void tst_QSequentialAnimationGroup::seekingBackwards()
@@ -537,15 +537,15 @@ void tst_QSequentialAnimationGroup::seekingBackwards()
// Current time = 1600
group.setCurrentTime(1600);
- QCOMPARE(group.currentTime(), 1600);
- QCOMPARE(sequence->currentTime(), 1250);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(group.currentLoopTime(), 1600);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentTime(), 250);
- QCOMPARE(sequence2->currentTime(), 350);
- QCOMPARE(a1_s_o2->currentTime(), 250);
- QCOMPARE(a1_s_o3->currentTime(), 100);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 350);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 100);
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
@@ -556,22 +556,22 @@ void tst_QSequentialAnimationGroup::seekingBackwards()
// Seeking backwards, current time = 1
group.setCurrentTime(1);
- QCOMPARE(group.currentTime(), 1);
- QCOMPARE(sequence->currentTime(), 1);
- QCOMPARE(a1_s_o1->currentTime(), 1);
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
"hence they don't reset from their current animation", Continue);
- QCOMPARE(a2_s_o1->currentTime(), 0);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
"hence they don't reset from their current animation", Continue);
QCOMPARE(a2_s_o1->currentLoop(), 0);
QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
"hence they don't reset from their current animation", Continue);
- QCOMPARE(a3_s_o1->currentTime(), 0);
- QCOMPARE(sequence2->currentTime(), 0);
- QCOMPARE(a1_s_o2->currentTime(), 0);
- QCOMPARE(a1_s_o3->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(sequence->state(), QAnimationGroup::Running);
@@ -582,15 +582,15 @@ void tst_QSequentialAnimationGroup::seekingBackwards()
// Current time = 2000
group.setCurrentTime(2000);
- QCOMPARE(group.currentTime(), 1750);
- QCOMPARE(sequence->currentTime(), 1250);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentTime(), 250);
- QCOMPARE(sequence2->currentTime(), 500);
- QCOMPARE(a1_s_o2->currentTime(), 250);
- QCOMPARE(a1_s_o3->currentTime(), 250);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 250);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
@@ -612,7 +612,7 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates
}
QList<QVariant> args = spy.at(i);
QAbstractAnimation::State st = expectedStates.at(i);
- QAbstractAnimation::State actual = qVariantValue<QAbstractAnimation::State>(args.value(1));
+ QAbstractAnimation::State actual = qVariantValue<QAbstractAnimation::State>(args.first());
if (equals && actual != st) {
equals = false;
break;
@@ -672,14 +672,14 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
// Current time = 1751
group.setCurrentTime(1751);
- QCOMPARE(group.currentTime(), 1751);
- QCOMPARE(sequence->currentTime(), 751);
+ QCOMPARE(group.currentLoopTime(), 1751);
+ QCOMPARE(sequence->currentLoopTime(), 751);
QCOMPARE(sequence->currentLoop(), 1);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 1);
QCOMPARE(a3_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentTime(), 1);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 1);
QCOMPARE(group.state(), QAnimationGroup::Paused);
QCOMPARE(sequence->state(), QAnimationGroup::Paused);
@@ -696,20 +696,20 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
<< QAbstractAnimation::Running
<< QAbstractAnimation::Stopped)));
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(1).first()),
QAnimationGroup::Paused);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(2).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(3).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(3).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(4).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(4).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()),
QAnimationGroup::Paused);
group.resume();
@@ -720,17 +720,17 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped);
QCOMPARE(a3_s_o1->state(), QAnimationGroup::Running);
- QVERIFY(group.currentTime() >= 1751);
- QVERIFY(sequence->currentTime() >= 751);
+ QVERIFY(group.currentLoopTime() >= 1751);
+ QVERIFY(sequence->currentLoopTime() >= 751);
QCOMPARE(sequence->currentLoop(), 1);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 1);
QCOMPARE(a3_s_o1->currentLoop(), 0);
- QVERIFY(a3_s_o1->currentTime() >= 1);
+ QVERIFY(a3_s_o1->currentLoopTime() >= 1);
QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(2).first()),
QAnimationGroup::Running);
group.pause();
@@ -741,23 +741,23 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped);
QCOMPARE(a3_s_o1->state(), QAnimationGroup::Paused);
- QVERIFY(group.currentTime() >= 1751);
- QVERIFY(sequence->currentTime() >= 751);
+ QVERIFY(group.currentLoopTime() >= 1751);
+ QVERIFY(sequence->currentLoopTime() >= 751);
QCOMPARE(sequence->currentLoop(), 1);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 1);
QCOMPARE(a3_s_o1->currentLoop(), 0);
- QVERIFY(a3_s_o1->currentTime() >= 1);
+ QVERIFY(a3_s_o1->currentLoopTime() >= 1);
QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(3).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(3).first()),
QAnimationGroup::Paused);
group.stop();
QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(4).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(4).first()),
QAnimationGroup::Stopped);
}
@@ -797,20 +797,20 @@ void tst_QSequentialAnimationGroup::restart()
for (int i = 0; i < 3; i++) {
QCOMPARE(animsStateChanged[i]->count(), 4);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(1).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(2).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(3).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(3).first()),
QAnimationGroup::Stopped);
}
QCOMPARE(seqStateChangedSpy.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(seqCurrentAnimChangedSpy.count(), 6);
@@ -855,15 +855,15 @@ void tst_QSequentialAnimationGroup::looping()
// Current time = 1750
group.setCurrentTime(1750);
- QCOMPARE(group.currentTime(), 1750);
- QCOMPARE(sequence->currentTime(), 750);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 750);
QCOMPARE(sequence->currentLoop(), 1);
- QCOMPARE(a1_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 1);
// this animation is at the beginning because it is the current one inside sequence
QCOMPARE(a3_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
QCOMPARE(sequence->currentAnimation(), a3_s_o1);
QCOMPARE(group.state(), QAnimationGroup::Paused);
@@ -890,16 +890,16 @@ void tst_QSequentialAnimationGroup::looping()
// Looping, current time = duration + 1
group.setCurrentTime(group.duration() + 1);
- QCOMPARE(group.currentTime(), 1);
+ QCOMPARE(group.currentLoopTime(), 1);
QCOMPARE(group.currentLoop(), 1);
- QCOMPARE(sequence->currentTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
QCOMPARE(sequence->currentLoop(), 0);
- QCOMPARE(a1_s_o1->currentTime(), 1);
- QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
QCOMPARE(a2_s_o1->currentLoop(), 1);
// this animation is at the end because it was run on the previous loop
QCOMPARE(a3_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentTime(), 250);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
QCOMPARE(group.state(), QAnimationGroup::Paused);
QCOMPARE(sequence->state(), QAnimationGroup::Paused);
@@ -929,16 +929,13 @@ void tst_QSequentialAnimationGroup::startDelay()
group.addPause(125);
QCOMPARE(group.totalDuration(), 375);
- QEventLoop loop;
- QObject::connect(&group, SIGNAL(finished()), &loop, SLOT(quit()));
-
- QTime time;
- time.start();
group.start();
- loop.exec();
+ QCOMPARE(group.state(), QAnimationGroup::Running);
- QVERIFY(time.elapsed() >= 375);
- QVERIFY(time.elapsed() < 1000);
+ QTest::qWait(500);
+
+ QVERIFY(group.currentLoopTime() == 375);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
}
void tst_QSequentialAnimationGroup::clearGroup()
@@ -961,9 +958,9 @@ void tst_QSequentialAnimationGroup::clearGroup()
children[i] = group.animationAt(i);
}
- group.clearAnimations();
+ group.clear();
QCOMPARE(group.animationCount(), 0);
- QCOMPARE(group.currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 0);
for (int i = 0; i < animationCount; ++i)
QVERIFY(children[i].isNull());
}
@@ -1133,9 +1130,9 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup()
QCOMPARE(groupStateChangedSpy.count(), 1);
QCOMPARE(childStateChangedSpy.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
// starting directly a running child will not have any effect
@@ -1174,13 +1171,13 @@ void tst_QSequentialAnimationGroup::deleteChildrenWithRunningGroup()
QCOMPARE(anim1->state(), QAnimationGroup::Running);
QTest::qWait(100);
- QVERIFY(group.currentTime() > 0);
+ QVERIFY(group.currentLoopTime() > 0);
delete anim1;
QCOMPARE(group.animationCount(), 0);
QCOMPARE(group.duration(), 0);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
- QCOMPARE(group.currentTime(), 0); //that's the invariant
+ QCOMPARE(group.currentLoopTime(), 0); //that's the invariant
}
void tst_QSequentialAnimationGroup::startChildrenWithStoppedGroup()
@@ -1323,9 +1320,9 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild()
QCOMPARE(anim2->state(), QAnimationGroup::Running);
QCOMPARE(stateChangedSpy2.count(), 4);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()),
QAnimationGroup::Running);
group.stop();
@@ -1362,9 +1359,9 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation()
group.start();
QCOMPARE(stateChangedSpy.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(anim1->state(), QAnimationGroup::Stopped);
@@ -1429,14 +1426,14 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation()
group.start();
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running);
- QCOMPARE(group.currentTime(), 0);
- QCOMPARE(notTimeDriven.currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QCOMPARE(notTimeDriven.currentLoopTime(), 0);
QTest::qWait(300); //wait for the end of notTimeDriven
QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped);
- const int actualDuration = notTimeDriven.currentTime();
+ const int actualDuration = notTimeDriven.currentLoopTime();
QCOMPARE(group.state(), QAnimationGroup::Stopped);
- QCOMPARE(group.currentTime(), actualDuration);
+ QCOMPARE(group.currentLoopTime(), actualDuration);
QCOMPARE(spy.count(), 1);
//2nd case:
@@ -1447,7 +1444,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation()
group.setCurrentTime(300);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
- QCOMPARE(notTimeDriven.currentTime(), actualDuration);
+ QCOMPARE(notTimeDriven.currentLoopTime(), actualDuration);
QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation*>(&anim));
//3rd case:
@@ -1456,8 +1453,8 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation()
group.start();
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running);
- QCOMPARE(group.currentTime(), 0);
- QCOMPARE(notTimeDriven.currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QCOMPARE(notTimeDriven.currentLoopTime(), 0);
QCOMPARE(animStateChangedSpy.count(), 0);
@@ -1470,12 +1467,12 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation()
QTest::qWait(300); //wait for the end of anim
QCOMPARE(anim.state(), QAnimationGroup::Stopped);
- QCOMPARE(anim.currentTime(), anim.duration());
+ QCOMPARE(anim.currentLoopTime(), anim.duration());
//we should simply be at the end
QCOMPARE(spy.count(), 1);
QCOMPARE(animStateChangedSpy.count(), 2);
- QCOMPARE(group.currentTime(), notTimeDriven.currentTime() + anim.currentTime());
+ QCOMPARE(group.currentLoopTime(), notTimeDriven.currentLoopTime() + anim.currentLoopTime());
}
void tst_QSequentialAnimationGroup::addRemoveAnimation()
@@ -1484,48 +1481,48 @@ void tst_QSequentialAnimationGroup::addRemoveAnimation()
QSequentialAnimationGroup group;
QCOMPARE(group.duration(), 0);
- QCOMPARE(group.currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 0);
QAbstractAnimation *anim1 = new QPropertyAnimation;
group.addAnimation(anim1);
QCOMPARE(group.duration(), 250);
- QCOMPARE(group.currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 0);
QCOMPARE(group.currentAnimation(), anim1);
//let's append an animation
QAbstractAnimation *anim2 = new QPropertyAnimation;
group.addAnimation(anim2);
QCOMPARE(group.duration(), 500);
- QCOMPARE(group.currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 0);
QCOMPARE(group.currentAnimation(), anim1);
//let's prepend an animation
QAbstractAnimation *anim0 = new QPropertyAnimation;
- group.insertAnimationAt(0, anim0);
+ group.insertAnimation(0, anim0);
QCOMPARE(group.duration(), 750);
- QCOMPARE(group.currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 0);
QCOMPARE(group.currentAnimation(), anim0); //anim0 has become the new currentAnimation
group.setCurrentTime(300); //anim0 | anim1 | anim2
- QCOMPARE(group.currentTime(), 300);
+ QCOMPARE(group.currentLoopTime(), 300);
QCOMPARE(group.currentAnimation(), anim1);
- QCOMPARE(anim1->currentTime(), 50);
+ QCOMPARE(anim1->currentLoopTime(), 50);
group.removeAnimation(anim0); //anim1 | anim2
- QCOMPARE(group.currentTime(), 50);
+ QCOMPARE(group.currentLoopTime(), 50);
QCOMPARE(group.currentAnimation(), anim1);
- QCOMPARE(anim1->currentTime(), 50);
+ QCOMPARE(anim1->currentLoopTime(), 50);
group.setCurrentTime(0);
- group.insertAnimationAt(0, anim0); //anim0 | anim1 | anim2
+ group.insertAnimation(0, anim0); //anim0 | anim1 | anim2
group.setCurrentTime(300);
- QCOMPARE(group.currentTime(), 300);
+ QCOMPARE(group.currentLoopTime(), 300);
QCOMPARE(group.currentAnimation(), anim1);
- QCOMPARE(anim1->currentTime(), 50);
+ QCOMPARE(anim1->currentLoopTime(), 50);
group.removeAnimation(anim1); //anim0 | anim2
- QCOMPARE(group.currentTime(), 250);
+ QCOMPARE(group.currentLoopTime(), 250);
QCOMPARE(group.currentAnimation(), anim2);
- QCOMPARE(anim0->currentTime(), 250);
+ QCOMPARE(anim0->currentLoopTime(), 250);
}
void tst_QSequentialAnimationGroup::currentAnimation()
@@ -1598,15 +1595,15 @@ class SequentialAnimationGroup : public QSequentialAnimationGroup
{
Q_OBJECT
public slots:
- void clearAnimations()
+ void clear()
{
- QSequentialAnimationGroup::clearAnimations();
+ QSequentialAnimationGroup::clear();
}
void refill()
{
stop();
- clearAnimations();
+ clear();
new DummyPropertyAnimation(this);
start();
}
@@ -1614,11 +1611,11 @@ public slots:
};
-void tst_QSequentialAnimationGroup::clearAnimations()
+void tst_QSequentialAnimationGroup::clear()
{
SequentialAnimationGroup group;
QPointer<QAbstractAnimation> anim1 = new DummyPropertyAnimation(&group);
- group.connect(anim1, SIGNAL(finished()), SLOT(clearAnimations()));
+ group.connect(anim1, SIGNAL(finished()), SLOT(clear()));
new DummyPropertyAnimation(&group);
QCOMPARE(group.animationCount(), 2);
@@ -1626,7 +1623,7 @@ void tst_QSequentialAnimationGroup::clearAnimations()
QTest::qWait(anim1->duration() + 100);
QCOMPARE(group.animationCount(), 0);
QCOMPARE(group.state(), QAbstractAnimation::Stopped);
- QCOMPARE(group.currentTime(), 0);
+ QCOMPARE(group.currentLoopTime(), 0);
anim1 = new DummyPropertyAnimation(&group);
group.connect(anim1, SIGNAL(finished()), SLOT(refill()));
@@ -1652,22 +1649,22 @@ void tst_QSequentialAnimationGroup::pauseResume()
QCOMPARE(anim->state(), QAnimationGroup::Running);
QCOMPARE(spy.count(), 1);
spy.clear();
- const int currentTime = group.currentTime();
- QCOMPARE(anim->currentTime(), currentTime);
+ const int currentTime = group.currentLoopTime();
+ QCOMPARE(anim->currentLoopTime(), currentTime);
group.pause();
QCOMPARE(group.state(), QAnimationGroup::Paused);
- QCOMPARE(group.currentTime(), currentTime);
+ QCOMPARE(group.currentLoopTime(), currentTime);
QCOMPARE(anim->state(), QAnimationGroup::Paused);
- QCOMPARE(anim->currentTime(), currentTime);
+ QCOMPARE(anim->currentLoopTime(), currentTime);
QCOMPARE(spy.count(), 1);
spy.clear();
group.resume();
QCOMPARE(group.state(), QAnimationGroup::Running);
- QCOMPARE(group.currentTime(), currentTime);
+ QCOMPARE(group.currentLoopTime(), currentTime);
QCOMPARE(anim->state(), QAnimationGroup::Running);
- QCOMPARE(anim->currentTime(), currentTime);
+ QCOMPARE(anim->currentLoopTime(), currentTime);
QCOMPARE(spy.count(), 1);
}
diff --git a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp
index 832605e1a9..87e0533ba0 100644
--- a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp
+++ b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp
@@ -43,9 +43,19 @@
#include "qevent.h"
#include "qdialog.h"
+#include "qpushbutton.h"
#include "qdialogbuttonbox.h"
#include "private/qsoftkeymanager_p.h"
+#ifdef Q_OS_SYMBIAN
+#include "qsymbianevent.h"
+#endif
+
+#ifdef Q_WS_S60
+static const int s60CommandStart = 6000;
+#endif
+
+
class tst_QSoftKeyManager : public QObject
{
Q_OBJECT
@@ -63,6 +73,13 @@ private slots:
void updateSoftKeysCompressed();
void handleCommand();
void checkSoftkeyEnableStates();
+
+private: // utils
+ inline void simulateSymbianCommand(int command)
+ {
+ QSymbianEvent event1(QSymbianEvent::CommandEvent, command);
+ qApp->symbianProcessEvent(&event1);
+ };
};
class EventListener : public QObject
@@ -161,8 +178,8 @@ void tst_QSoftKeyManager::handleCommand()
// QTest::keyPress(&w, Qt::Key_Context1);
// QTest::keyPress(&w, Qt::Key_Context2);
- qApp->symbianHandleCommand(6000);
- qApp->symbianHandleCommand(6001);
+ simulateSymbianCommand(6000);
+ simulateSymbianCommand(6001);
QApplication::processEvents();
@@ -171,22 +188,52 @@ void tst_QSoftKeyManager::handleCommand()
}
/*
- This tests that softkey enable state follows the state of widget that owns the action
- to which the softkey is related to.
+ This tests that the state of a widget that owns softkey action is respected when handling the softkey
+ command.
*/
void tst_QSoftKeyManager::checkSoftkeyEnableStates()
{
- QWidget w1, w2;
- w1.setEnabled(false);
- w2.setEnabled(true);
+ QDialog w;
+ QDialogButtonBox *buttons = new QDialogButtonBox(
+ QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Help,
+ Qt::Horizontal,
+ &w);
+ QPushButton *pBDefaults = buttons->button(QDialogButtonBox::RestoreDefaults);
+ QPushButton *pBHelp = buttons->button(QDialogButtonBox::Help);
+ pBHelp->setEnabled(false);
+ w.show();
+ QApplication::processEvents();
- QAction *disabledAction = QSoftKeyManager::createAction(QSoftKeyManager::OkSoftKey, &w1);
- QAction *enabledAction = QSoftKeyManager::createAction(QSoftKeyManager::OkSoftKey, &w2);
+ QSignalSpy spy0(w.actions()[0], SIGNAL(triggered())); //restore defaults action
+ QSignalSpy spy1(w.actions()[1], SIGNAL(triggered())); //disabled help action
- QVERIFY(disabledAction->isEnabled()==false);
- QVERIFY(enabledAction->isEnabled()==true);
+ //Verify that enabled button gets all the action trigger signals and
+ //disabled button gets none.
+ for (int i = 0; i < 10; i++) {
+ //simulate "Restore Defaults" softkey press
+ simulateSymbianCommand(s60CommandStart);
+ //simulate "help" softkey press
+ simulateSymbianCommand(s60CommandStart + 1);
+ }
+ QApplication::processEvents();
+ QCOMPARE(spy0.count(), 10);
+ QCOMPARE(spy1.count(), 0);
+ spy0.clear();
+ spy1.clear();
+
+ for (int i = 0; i < 10; i++) {
+ //simulate "Restore Defaults" softkey press
+ simulateSymbianCommand(s60CommandStart);
+ //simulate "help" softkey press
+ simulateSymbianCommand(s60CommandStart + 1);
+ //switch enabled button to disabled and vice versa
+ pBHelp->setEnabled(!pBHelp->isEnabled());
+ pBDefaults->setEnabled(!pBDefaults->isEnabled());
+ }
+ QApplication::processEvents();
+ QCOMPARE(spy0.count(), 5);
+ QCOMPARE(spy1.count(), 5);
}
-
QTEST_MAIN(tst_QSoftKeyManager)
#include "tst_qsoftkeymanager.moc"
diff --git a/tests/auto/qsound/tst_qsound.cpp b/tests/auto/qsound/tst_qsound.cpp
index fdbf6a26b1..73eca983a1 100644
--- a/tests/auto/qsound/tst_qsound.cpp
+++ b/tests/auto/qsound/tst_qsound.cpp
@@ -55,20 +55,32 @@ public:
tst_QSound( QObject* parent=0) : QObject(parent) {}
private slots:
- void checkFinished();
+ void checkFinished();
+
+ // Manual tests
+ void staticPlay();
};
void tst_QSound::checkFinished()
{
- QSound sound(SRCDIR"4.wav");
- sound.setLoops(3);
- sound.play();
- QTest::qWait(5000);
+ QSound sound(SRCDIR"4.wav");
+ sound.setLoops(3);
+ sound.play();
+ QTest::qWait(5000);
#if defined(Q_WS_QWS)
- QEXPECT_FAIL("", "QSound buggy on embedded (task 122221)", Abort);
+ QEXPECT_FAIL("", "QSound buggy on embedded (task QTBUG-157)", Abort);
#endif
- QVERIFY(sound.isFinished() );
+ QVERIFY(sound.isFinished() );
+}
+
+void tst_QSound::staticPlay()
+{
+ QSKIP("Test disabled -- only for manual purposes", SkipAll);
+
+ // Check that you hear sound with static play also.
+ QSound::play(SRCDIR"4.wav");
+ QTest::qWait(2000);
}
QTEST_MAIN(tst_QSound);
diff --git a/tests/auto/qsplitter/tst_qsplitter.cpp b/tests/auto/qsplitter/tst_qsplitter.cpp
index cf1642113c..b832f3a61a 100644
--- a/tests/auto/qsplitter/tst_qsplitter.cpp
+++ b/tests/auto/qsplitter/tst_qsplitter.cpp
@@ -102,6 +102,8 @@ private slots:
void task187373_addAbstractScrollAreas();
void task187373_addAbstractScrollAreas_data();
void task169702_sizes();
+ void taskQTBUG_4101_ensureOneNonCollapsedWidget_data();
+ void taskQTBUG_4101_ensureOneNonCollapsedWidget();
private:
void removeThirdWidget();
@@ -1281,6 +1283,8 @@ class MyFriendlySplitter : public QSplitter
public:
MyFriendlySplitter(QWidget *parent = 0) : QSplitter(parent) {}
void setRubberBand(int pos) { QSplitter::setRubberBand(pos); }
+
+ friend class tst_QSplitter;
};
void tst_QSplitter::rubberBandNotInSplitter()
@@ -1403,5 +1407,35 @@ void tst_QSplitter::task169702_sizes()
QCOMPARE(testW->size().height(), testW->minimumSizeHint().height());
}
+void tst_QSplitter::taskQTBUG_4101_ensureOneNonCollapsedWidget_data()
+{
+ QTest::addColumn<bool>("testingHide");
+
+ QTest::newRow("last non collapsed hidden") << true;
+ QTest::newRow("last non collapsed deleted") << false;
+}
+
+void tst_QSplitter::taskQTBUG_4101_ensureOneNonCollapsedWidget()
+{
+ QFETCH(bool, testingHide);
+
+ MyFriendlySplitter s;
+ QLabel *l;
+ for (int i = 0; i < 5; ++i) {
+ l = new QLabel(QString("Label ") + QChar('A' + i));
+ l->setAlignment(Qt::AlignCenter);
+ s.addWidget(l);
+ s.moveSplitter(0, i); // Collapse all the labels except the last one.
+ }
+
+ s.show();
+ if (testingHide)
+ l->hide();
+ else
+ delete l;
+ QTest::qWait(100);
+ QVERIFY(s.sizes().at(0) > 0);
+}
+
QTEST_MAIN(tst_QSplitter)
#include "tst_qsplitter.moc"
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index 13d68ff9de..fe7c3eaaa5 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -1072,17 +1072,20 @@ void tst_QSqlDatabase::recordMySQL()
int revision = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 2, 2 ).toInt();
int vernum = (major << 16) + (minor << 8) + revision;
-#ifdef QT3_SUPPORT
/* The below is broken in mysql below 5.0.15
see http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html
specifically: Before MySQL 5.0.15, the pad value is space. Values are right-padded
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));
static const FieldDef fieldDefs[] = {
@@ -1231,6 +1234,7 @@ void tst_QSqlDatabase::recordSQLite()
FieldDef("integer", QVariant::Int, QVariant(13)),
FieldDef("int", QVariant::Int, QVariant(12)),
+ FieldDef("real", QVariant::String, QVariant(1.234567890123456)),
FieldDef()
};
@@ -2468,7 +2472,7 @@ void tst_QSqlDatabase::mysql_savepointtest()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 1 ).toInt()<4.1 )
+ if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 1 ).toDouble()<4.1 )
QSKIP( "Test requires MySQL >= 4.1", SkipSingle );
QSqlQuery q(db);
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp
index 546c1052a7..4264a70283 100644
--- a/tests/auto/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp
@@ -194,6 +194,11 @@ private slots:
void sqlServerReturn0_data() { generic_data(); }
void sqlServerReturn0();
+ void QTBUG_551_data() { generic_data("QOCI"); }
+ void QTBUG_551();
+
+ void QTBUG_5251_data() { generic_data("QPSQL"); }
+ void QTBUG_5251();
private:
// returns all database connections
@@ -323,6 +328,11 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db )
tablenames << qTableName("test141895");
tst_Databases::safeDropTables( db, tablenames );
+
+ if ( db.driverName().startsWith( "QOCI" ) ) {
+ QSqlQuery q( db );
+ q.exec( "DROP PACKAGE " + qTableName("pkg") );
+ }
}
void tst_QSqlQuery::createTestTables( QSqlDatabase db )
@@ -397,7 +407,7 @@ void tst_QSqlQuery::char1SelectUnicode()
QSKIP("Needs someone with more Unicode knowledge than I have to fix", SkipSingle);
if ( db.driver()->hasFeature( QSqlDriver::Unicode ) ) {
- QString uniStr( QChar( 0xfb50 ) );
+ QString uniStr( QChar(0x0915) ); // DEVANAGARI LETTER KA
QSqlQuery q( db );
if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 )
@@ -510,9 +520,7 @@ void tst_QSqlQuery::mysqlOutValues()
QVERIFY_SQL( q, exec( "create procedure " + qTableName( "qtestproc" ) + " () "
"BEGIN select * from " + qTableName( "qtest" ) + " order by id; END" ) );
QVERIFY_SQL( q, exec( "call " + qTableName( "qtestproc" ) + "()" ) );
- QEXPECT_FAIL("", "There's a mysql bug that means only selects think they return data when running in prepared mode", Continue);
QVERIFY_SQL( q, next() );
- QEXPECT_FAIL("", "There's a mysql bug that means only selects think they return data when running in prepared mode", Continue);
QCOMPARE( q.value( 1 ).toString(), QString( "VarChar1" ) );
QVERIFY_SQL( q, exec( "drop procedure " + qTableName( "qtestproc" ) ) );
@@ -1633,8 +1641,7 @@ void tst_QSqlQuery::prepare_bind_exec()
{
// new scope for SQLITE
- static const unsigned short utf8arr[] = { 0xfb50,0xfb60,0xfb70,0xfb80,0xfbe0,0xfbf0,0x00 };
- static const QString utf8str = QString::fromUtf16( utf8arr );
+ static const QString utf8str = QString::fromUtf8( "काचं शक्नोम्यत्तुम् । नोपहिनस्ति माम् ॥" );
static const QString values[6] = { "Harry", "Trond", "Mark", "Ma?rk", "?", ":id" };
@@ -1651,11 +1658,11 @@ void tst_QSqlQuery::prepare_bind_exec()
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) )
- createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int primary key, name nvarchar(20) null)";
- else if ( db.driverName().startsWith( "QMYSQL" ) && useUnicode )
- createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int not null primary key, name varchar(20) character set utf8)";
+ createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int primary key, name nvarchar(200) null)";
+ else if ( tst_Databases::isMySQL(db) && useUnicode )
+ createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int not null primary key, name varchar(200) character set utf8)";
else
- createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int not null primary key, name varchar(20))";
+ createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int not null primary key, name varchar(200))";
QVERIFY_SQL( q, exec( createQuery ) );
@@ -2851,5 +2858,82 @@ void tst_QSqlQuery::sqlServerReturn0()
QVERIFY_SQL(q, next());
}
+void tst_QSqlQuery::QTBUG_551()
+{
+ QFETCH( QString, dbName );
+ QSqlDatabase db = QSqlDatabase::database( dbName );
+ CHECK_DATABASE( db );
+ QSqlQuery q(db);
+ QString pkgname=qTableName("pkg");
+ QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE "+pkgname+" IS \n\
+ \n\
+ TYPE IntType IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;\n\
+ TYPE VCType IS TABLE OF VARCHAR2(60) INDEX BY BINARY_INTEGER;\n\
+ PROCEDURE P (Inp IN IntType, Outp OUT VCType);\n\
+ END "+pkgname+";"));
+
+ QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE BODY "+pkgname+" IS\n\
+ PROCEDURE P (Inp IN IntType, Outp OUT VCType)\n\
+ IS\n\
+ BEGIN\n\
+ Outp(1) := '1. Value is ' ||TO_CHAR(Inp(1));\n\
+ Outp(2) := '2. Value is ' ||TO_CHAR(Inp(2));\n\
+ Outp(3) := '3. Value is ' ||TO_CHAR(Inp(3));\n\
+ END p;\n\
+ END "+pkgname+";"));
+
+ QVariantList inLst, outLst, res_outLst;
+
+ q.prepare("begin "+pkgname+".p(:inp, :outp); end;");
+
+ QString StVal;
+ StVal.reserve(60);
+
+ // loading arrays
+ for (int Cnt=0; Cnt < 3; Cnt++) {
+ inLst << Cnt;
+ outLst << StVal;
+ }
+
+ q.bindValue(":inp", inLst);
+ q.bindValue(":outp", outLst, QSql::Out);
+
+ QVERIFY_SQL(q, execBatch(QSqlQuery::ValuesAsColumns) );
+ res_outLst = qVariantValue<QVariantList>(q.boundValues()[":outp"]);
+ QCOMPARE(res_outLst[0].toString(), QLatin1String("1. Value is 0"));
+ QCOMPARE(res_outLst[1].toString(), QLatin1String("2. Value is 1"));
+ QCOMPARE(res_outLst[2].toString(), QLatin1String("3. Value is 2"));
+}
+
+void tst_QSqlQuery::QTBUG_5251()
+{
+ QFETCH( QString, dbName );
+ QSqlDatabase db = QSqlDatabase::database( dbName );
+ CHECK_DATABASE( db );
+
+ if (!db.driverName().startsWith( "QPSQL" )) return;
+
+ QSqlQuery q(db);
+ q.exec("DROP TABLE " + qTableName("timetest"));
+ QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("timetest") + " (t TIME)"));
+ QVERIFY_SQL(q, exec("INSERT INTO " + qTableName("timetest") + " VALUES ('1:2:3.666')"));
+
+ QSqlTableModel timetestModel(0,db);
+ timetestModel.setEditStrategy(QSqlTableModel::OnManualSubmit);
+ timetestModel.setTable(qTableName("timetest"));
+ QVERIFY_SQL(timetestModel, select());
+
+ QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("01:02:03.666"));
+ QVERIFY_SQL(timetestModel,setData(timetestModel.index(0, 0), QTime(0,12,34,500)));
+ QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:12:34.500"));
+ QVERIFY_SQL(timetestModel, submitAll());
+ QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:12:34.500"));
+
+ QVERIFY_SQL(q, exec("UPDATE " + qTableName("timetest") + " SET t = '0:11:22.33'"));
+ QVERIFY_SQL(timetestModel, select());
+ QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:11:22.330"));
+
+}
+
QTEST_MAIN( tst_QSqlQuery )
#include "tst_qsqlquery.moc"
diff --git a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
index 3131f35788..02b48fab35 100644
--- a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
+++ b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
@@ -96,6 +96,7 @@ private slots:
void task_180617();
void task_180617_data() { generic_data(); }
+ void task_QTBUG_4963_setHeaderDataWithProxyModel();
private:
void generic_data(const QString &engine=QString());
@@ -428,6 +429,8 @@ void tst_QSqlQueryModel::setHeaderData()
QVERIFY(!model.setHeaderData(5, Qt::Vertical, "foo"));
QVERIFY(model.headerData(5, Qt::Vertical).isValid());
+ model.setQuery(QSqlQuery("select * from " + qTableName("test"), db));
+
qRegisterMetaType<Qt::Orientation>("Qt::Orientation");
QSignalSpy spy(&model, SIGNAL(headerDataChanged(Qt::Orientation, int, int)));
QVERIFY(model.setHeaderData(2, Qt::Horizontal, "bar"));
@@ -437,10 +440,8 @@ void tst_QSqlQueryModel::setHeaderData()
QCOMPARE(spy.value(0).value(1).toInt(), 2);
QCOMPARE(spy.value(0).value(2).toInt(), 2);
- QVERIFY(model.setHeaderData(7, Qt::Horizontal, "foo", Qt::ToolTipRole));
- QVERIFY(model.headerData(7, Qt::Horizontal, Qt::ToolTipRole).isValid());
-
- model.setQuery(QSqlQuery("select * from " + qTableName("test"), db));
+ QVERIFY(!model.setHeaderData(7, Qt::Horizontal, "foo", Qt::ToolTipRole));
+ QVERIFY(!model.headerData(7, Qt::Horizontal, Qt::ToolTipRole).isValid());
bool isToUpper = db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2");
QCOMPARE(model.headerData(0, Qt::Horizontal).toString(), isToUpper ? QString("ID") : QString("id"));
@@ -603,5 +604,14 @@ void tst_QSqlQueryModel::task_180617()
QCOMPARE(view.rowAt(0), -1);
}
+void tst_QSqlQueryModel::task_QTBUG_4963_setHeaderDataWithProxyModel()
+{
+ QSqlQueryModel plainModel;
+ QSortFilterProxyModel proxyModel;
+ proxyModel.setSourceModel(&plainModel);
+ QVERIFY(!plainModel.setHeaderData(0, Qt::Horizontal, QObject::tr("ID")));
+ // And it should not crash.
+}
+
QTEST_MAIN(tst_QSqlQueryModel)
#include "tst_qsqlquerymodel.moc"
diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
index cb24a9f36a..8c840cd1d5 100644
--- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
+++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
@@ -86,6 +86,7 @@ private slots:
void escapedRelations();
void escapedTableName();
void whiteSpaceInIdentifiers();
+ void psqlSchemaTest();
private:
void dropTestTables( QSqlDatabase db );
@@ -150,10 +151,11 @@ void tst_QSqlRelationalTableModel::initTestCase()
if (db.driverName().startsWith("QIBASE"))
db.exec("SET DIALECT 3");
else if (tst_Databases::isSqlServer(db)) {
- QSqlQuery q(db);
- QVERIFY_SQL(q, exec("SET ANSI_DEFAULTS ON"));
- QVERIFY_SQL(q, exec("SET IMPLICIT_TRANSACTIONS OFF"));
+ db.exec("SET ANSI_DEFAULTS ON");
+ db.exec("SET IMPLICIT_TRANSACTIONS OFF");
}
+ else if(tst_Databases::isPostgreSQL(db))
+ db.exec("set client_min_messages='warning'");
recreateTestTables(db);
}
}
@@ -181,6 +183,9 @@ void tst_QSqlRelationalTableModel::dropTestTables( QSqlDatabase db )
<< qTableName("CASETEST1" )
<< qTableName("casetest1" );
tst_Databases::safeDropTables( db, tableNames );
+
+ db.exec("DROP SCHEMA "+qTableName("QTBUG_5373")+" CASCADE");
+ db.exec("DROP SCHEMA "+qTableName("QTBUG_5373_s2")+" CASCADE");
}
void tst_QSqlRelationalTableModel::init()
@@ -1118,8 +1123,8 @@ void tst_QSqlRelationalTableModel::escapedTableName()
}
}
-void tst_QSqlRelationalTableModel::whiteSpaceInIdentifiers() {
-
+void tst_QSqlRelationalTableModel::whiteSpaceInIdentifiers()
+{
QFETCH_GLOBAL(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -1193,5 +1198,26 @@ void tst_QSqlRelationalTableModel::whiteSpaceInIdentifiers() {
QCOMPARE(model.data(model.index(0, 2)).toInt(), 6);
}
+void tst_QSqlRelationalTableModel::psqlSchemaTest()
+{
+ QFETCH_GLOBAL(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ if(!tst_Databases::isPostgreSQL(db)) {
+ QSKIP("Postgresql specific test", SkipSingle);
+ return;
+ }
+ QSqlRelationalTableModel model(0, db);
+ QSqlQuery q(db);
+ QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373")));
+ QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373_s2")));
+ QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373")+"."+qTableName("user")+"(userid int primary key, relatingid int)"));
+ QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373_s2")+"."+qTableName("user2")+"(userid2 int primary key, username2 char(40))"));
+ model.setTable(qTableName("QTBUG_5373")+"."+qTableName("user"));
+ model.setRelation(1, QSqlRelation(qTableName("QTBUG_5373_s2")+"."+qTableName("user2"), "userid2", "username2"));
+ QVERIFY_SQL(model, select());
+}
+
QTEST_MAIN(tst_QSqlRelationalTableModel)
#include "tst_qsqlrelationaltablemodel.moc"
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 6efe44052c..db46b66f4a 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -170,6 +170,7 @@ private slots:
void setEmptyKey();
void spontaneousWrite();
void setReadBufferSize();
+ void setReadBufferSize_task_250027();
void waitForMinusOne();
void verifyMode();
void verifyDepth();
@@ -182,6 +183,7 @@ private slots:
void ignoreSslErrorsListWithSlot_data();
void ignoreSslErrorsListWithSlot();
void readFromClosedSocket();
+ void writeBigChunk();
static void exitLoop()
{
@@ -1240,6 +1242,66 @@ void tst_QSslSocket::setReadBufferSize()
QVERIFY(receiver->bytesAvailable() > oldBytesAvailable);
}
+class SetReadBufferSize_task_250027_handler : public QObject {
+ Q_OBJECT
+public slots:
+ void readyReadSlot() {
+ QTestEventLoop::instance().exitLoop();
+ }
+ void waitSomeMore(QSslSocket *socket) {
+ QTime t;
+ t.start();
+ while (!socket->encryptedBytesAvailable()) {
+ QCoreApplication::processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents, 250);
+ if (t.elapsed() > 1000 || socket->state() != QAbstractSocket::ConnectedState)
+ return;
+ }
+ }
+};
+
+void tst_QSslSocket::setReadBufferSize_task_250027()
+{
+ // do not execute this when a proxy is set.
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ QSslSocketPtr socket = newSocket();
+ socket->setReadBufferSize(1000); // limit to 1 kb/sec
+ socket->ignoreSslErrors();
+ socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
+ socket->ignoreSslErrors();
+ QVERIFY(socket->waitForConnected(10*1000));
+ QVERIFY(socket->waitForEncrypted(10*1000));
+
+ // exit the event loop as soon as we receive a readyRead()
+ SetReadBufferSize_task_250027_handler setReadBufferSize_task_250027_handler;
+ connect(socket, SIGNAL(readyRead()), &setReadBufferSize_task_250027_handler, SLOT(readyReadSlot()));
+
+ // provoke a response by sending a request
+ socket->write("GET /gif/fluke.gif HTTP/1.0\n"); // this file is 27 KB
+ socket->write("Host: ");
+ socket->write(QtNetworkSettings::serverName().toLocal8Bit().constData());
+ socket->write("\n");
+ socket->write("Connection: close\n");
+ socket->write("\n");
+ socket->flush();
+
+ QTestEventLoop::instance().enterLoop(10);
+ setReadBufferSize_task_250027_handler.waitSomeMore(socket);
+ QByteArray firstRead = socket->readAll();
+ // First read should be some data, but not the whole file
+ QVERIFY(firstRead.size() > 0 && firstRead.size() < 20*1024);
+
+ QTestEventLoop::instance().enterLoop(10);
+ setReadBufferSize_task_250027_handler.waitSomeMore(socket);
+ QByteArray secondRead = socket->readAll();
+ // second read should be some more data
+ QVERIFY(secondRead.size() > 0);
+
+ socket->close();
+}
+
class SslServer3 : public QTcpServer
{
Q_OBJECT
@@ -1693,9 +1755,51 @@ void tst_QSslSocket::readFromClosedSocket()
socket->close();
QVERIFY(!socket->bytesAvailable());
QVERIFY(!socket->bytesToWrite());
- socket->waitForDisconnected();
- QVERIFY(!socket->bytesAvailable());
- QVERIFY(!socket->bytesToWrite());
+ QVERIFY(socket->state() == QAbstractSocket::UnconnectedState);
+}
+
+void tst_QSslSocket::writeBigChunk()
+{
+ if (!QSslSocket::supportsSsl())
+ return;
+
+ QSslSocketPtr socket = newSocket();
+ this->socket = socket;
+
+ connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot()));
+ socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
+
+ 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++) {
+ int r = qrand();
+ data.data()[i*sizeof(int)] = r;
+ }
+
+ QVERIFY(socket->waitForEncrypted(10000));
+ QString errorBefore = socket->errorString();
+
+ int ret = socket->write(data.constData(), data.size());
+ QVERIFY(data.size() == ret);
+
+ // spin the event loop once so QSslSocket::transmit() gets called
+ QCoreApplication::processEvents();
+ QString errorAfter = socket->errorString();
+
+ // no better way to do this right now since the error is the same as the default error.
+ if (socket->errorString().startsWith(QLatin1String("Unable to write data")))
+ {
+ qWarning() << socket->error() << socket->errorString();
+ QFAIL("Error while writing! Check if the OpenSSL BIO size is limited?!");
+ }
+ // also check the error string. If another error (than UnknownError) occured, it should be different than before
+ QVERIFY(errorBefore == errorAfter);
+
+ // check that everything has been written to OpenSSL
+ QVERIFY(socket->bytesToWrite() == 0);
+
+ socket->close();
}
#endif // QT_NO_OPENSSL
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 15163461d6..fd39515a98 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -117,6 +117,7 @@ private slots:
void cleanup();
void rootState();
+ void machineWithParent();
void addAndRemoveState();
void stateEntryAndExit();
void assignProperty();
@@ -124,6 +125,7 @@ private slots:
void postEvent();
void cancelDelayedEvent();
void postDelayedEventAndStop();
+ void stopAndPostEvent();
void stateFinished();
void parallelStates();
void parallelRootState();
@@ -160,7 +162,7 @@ private slots:
void defaultGlobalRestorePolicy();
void globalRestorePolicySetToRestore();
- void globalRestorePolicySetToDoNotRestore();
+ void globalRestorePolicySetToDontRestore();
void noInitialStateForInitialState();
@@ -182,7 +184,7 @@ private slots:
void twoAnimatedTransitions();
void playAnimationTwice();
void nestedTargetStateForAnimation();
- void polishedSignalTransitionsReuseAnimationGroup();
+ void propertiesAssignedSignalTransitionsReuseAnimationGroup();
void animatedGlobalRestoreProperty();
void specificTargetValueOfAnimation();
@@ -205,6 +207,8 @@ private slots:
void goToState();
void task260403_clonedSignals();
+ void postEventFromOtherThread();
+ void eventFilterForApplication();
};
tst_QStateMachine::tst_QStateMachine()
@@ -283,8 +287,8 @@ void tst_QStateMachine::transitionToRootState()
machine.addState(initialState);
machine.setInitialState(initialState);
- QAbstractTransition *trans = initialState->addTransition(new EventTransition(QEvent::User, &machine));
- QVERIFY(trans != 0);
+ QAbstractTransition *trans = new EventTransition(QEvent::User, &machine);
+ initialState->addTransition(trans);
QCOMPARE(trans->sourceState(), initialState);
QCOMPARE(trans->targetState(), static_cast<QAbstractState *>(&machine));
@@ -307,7 +311,7 @@ void tst_QStateMachine::transitionFromRootState()
QState *root = &machine;
QState *s1 = new QState(root);
EventTransition *trans = new EventTransition(QEvent::User, s1);
- QCOMPARE(root->addTransition(trans), static_cast<QAbstractTransition *>(trans));
+ root->addTransition(trans);
QCOMPARE(trans->sourceState(), root);
QCOMPARE(trans->targetState(), static_cast<QAbstractState *>(s1));
}
@@ -981,7 +985,7 @@ void tst_QStateMachine::customErrorStateNotInGraph()
void tst_QStateMachine::restoreProperties()
{
QStateMachine machine;
- QCOMPARE(machine.globalRestorePolicy(), QStateMachine::DoNotRestoreProperties);
+ QCOMPARE(machine.globalRestorePolicy(), QStateMachine::DontRestoreProperties);
machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
QObject *object = new QObject(&machine);
@@ -1043,6 +1047,14 @@ void tst_QStateMachine::rootState()
QCOMPARE(s2->parentState(), static_cast<QState*>(&machine));
}
+void tst_QStateMachine::machineWithParent()
+{
+ QObject object;
+ QStateMachine *machine = new QStateMachine(&object);
+ QCOMPARE(machine->parent(), &object);
+ QCOMPARE(machine->parentState(), (QObject*)0);
+}
+
void tst_QStateMachine::addAndRemoveState()
{
#ifdef QT_BUILD_INTERNAL
@@ -1144,7 +1156,7 @@ void tst_QStateMachine::stateEntryAndExit()
QCOMPARE(t->targetState(), (QAbstractState*)s2);
QCOMPARE(t->targetStates().size(), 1);
QCOMPARE(t->targetStates().at(0), (QAbstractState*)s2);
- QCOMPARE(s1->addTransition(t), (QAbstractTransition*)t);
+ s1->addTransition(t);
QCOMPARE(t->sourceState(), (QState*)s1);
QCOMPARE(t->machine(), &machine);
@@ -1162,7 +1174,7 @@ void tst_QStateMachine::stateEntryAndExit()
s2->removeTransition(trans);
QCOMPARE(trans->sourceState(), (QState*)0);
QCOMPARE(trans->targetState(), (QAbstractState*)s3);
- QCOMPARE(s2->addTransition(trans), trans);
+ s2->addTransition(trans);
QCOMPARE(trans->sourceState(), (QState*)s2);
}
@@ -1308,9 +1320,9 @@ void tst_QStateMachine::assignProperty()
QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
{
- QSignalSpy polishedSpy(s1, SIGNAL(polished()));
+ QSignalSpy propertiesAssignedSpy(s1, SIGNAL(propertiesAssigned()));
machine.start();
- QTRY_COMPARE(polishedSpy.count(), 1);
+ QTRY_COMPARE(propertiesAssignedSpy.count(), 1);
}
// nested states
@@ -1329,11 +1341,11 @@ void tst_QStateMachine::assignPropertyWithAnimation()
// Single animation
{
QStateMachine machine;
- QVERIFY(machine.animationsEnabled());
- machine.setAnimationsEnabled(false);
- QVERIFY(!machine.animationsEnabled());
- machine.setAnimationsEnabled(true);
- QVERIFY(machine.animationsEnabled());
+ QVERIFY(machine.isAnimated());
+ machine.setAnimated(false);
+ QVERIFY(!machine.isAnimated());
+ machine.setAnimated(true);
+ QVERIFY(machine.isAnimated());
QObject obj;
obj.setProperty("foo", 321);
obj.setProperty("bar", 654);
@@ -1360,7 +1372,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
QCOMPARE(trans->animations().size(), 1);
QCOMPARE(trans->animations().at(0), (QAbstractAnimation*)&anim);
QFinalState *s3 = new QFinalState(&machine);
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
@@ -1388,7 +1400,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
anim2.setDuration(150);
trans->addAnimation(&anim2);
QFinalState *s3 = new QFinalState(&machine);
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
@@ -1416,7 +1428,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
group.addAnimation(new QPropertyAnimation(&obj, "bar"));
trans->addAnimation(&group);
QFinalState *s3 = new QFinalState(&machine);
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
@@ -1462,10 +1474,10 @@ void tst_QStateMachine::assignPropertyWithAnimation()
anim2.setDuration(250);
trans->addAnimation(&anim2);
- s21->addTransition(s21, SIGNAL(polished()), s22);
+ s21->addTransition(s21, SIGNAL(propertiesAssigned()), s22);
QFinalState *s3 = new QFinalState(&machine);
- s22->addTransition(s2, SIGNAL(polished()), s3);
+ s22->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
@@ -1502,13 +1514,13 @@ void tst_QStateMachine::assignPropertyWithAnimation()
machine.setInitialState(group);
machine.start();
QTRY_COMPARE(machine.configuration().contains(s1), true);
- QSignalSpy polishedSpy(s2, SIGNAL(polished()));
+ QSignalSpy propertiesAssignedSpy(s2, SIGNAL(propertiesAssigned()));
emitter.emitSignalWithNoArg();
QTRY_COMPARE(machine.configuration().contains(s2), true);
- QVERIFY(polishedSpy.isEmpty());
+ QVERIFY(propertiesAssignedSpy.isEmpty());
emitter.emitSignalWithNoArg(); // will cause animations from s1-->s2 to abort
QTRY_COMPARE(machine.configuration().contains(s3), true);
- QVERIFY(polishedSpy.isEmpty());
+ QVERIFY(propertiesAssignedSpy.isEmpty());
QCOMPARE(obj.property("foo").toInt(), 911);
QCOMPARE(obj.property("bar").toInt(), 789);
}
@@ -1681,6 +1693,22 @@ void tst_QStateMachine::postDelayedEventAndStop()
QVERIFY(machine.configuration().contains(s1));
}
+void tst_QStateMachine::stopAndPostEvent()
+{
+ QStateMachine machine;
+ QState *s1 = new QState(&machine);
+ machine.setInitialState(s1);
+ QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ machine.start();
+ QTRY_COMPARE(startedSpy.count(), 1);
+ QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
+ machine.stop();
+ QCOMPARE(stoppedSpy.count(), 0);
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(stoppedSpy.count(), 1);
+ QCoreApplication::processEvents();
+}
+
void tst_QStateMachine::stateFinished()
{
QStateMachine machine;
@@ -2709,10 +2737,10 @@ void tst_QStateMachine::restorePolicyNotInherited()
}*/
-void tst_QStateMachine::globalRestorePolicySetToDoNotRestore()
+void tst_QStateMachine::globalRestorePolicySetToDontRestore()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::DoNotRestoreProperties);
+ machine.setGlobalRestorePolicy(QStateMachine::DontRestoreProperties);
QObject *propertyHolder = new QObject(&machine);
propertyHolder->setProperty("a", 1);
@@ -3062,7 +3090,7 @@ void tst_QStateMachine::twoAnimations()
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
machine.start();
@@ -3090,7 +3118,9 @@ void tst_QStateMachine::twoAnimatedTransitions()
QState *s2 = new QState(&machine);
s2->assignProperty(object, "foo", 5.0);
QPropertyAnimation *fooAnimation = new QPropertyAnimation(object, "foo", s2);
- s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(fooAnimation);
+ EventTransition *trans = new EventTransition(QEvent::User, s2);
+ s1->addTransition(trans);
+ trans->addAnimation(fooAnimation);
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
@@ -3099,7 +3129,9 @@ void tst_QStateMachine::twoAnimatedTransitions()
QState *s4 = new QState(&machine);
s4->assignProperty(object, "foo", 2.0);
QPropertyAnimation *fooAnimation2 = new QPropertyAnimation(object, "foo", s4);
- s3->addTransition(new EventTransition(QEvent::User, s4))->addAnimation(fooAnimation2);
+ trans = new EventTransition(QEvent::User, s4);
+ s3->addTransition(trans);
+ trans->addAnimation(fooAnimation2);
QState *s5 = new QState(&machine);
QObject::connect(s5, SIGNAL(entered()), QApplication::instance(), SLOT(quit()));
@@ -3134,7 +3166,9 @@ void tst_QStateMachine::playAnimationTwice()
QState *s2 = new QState(&machine);
s2->assignProperty(object, "foo", 5.0);
QPropertyAnimation *fooAnimation = new QPropertyAnimation(object, "foo", s2);
- s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(fooAnimation);
+ EventTransition *trans = new EventTransition(QEvent::User, s2);
+ s1->addTransition(trans);
+ trans->addAnimation(fooAnimation);
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
@@ -3142,7 +3176,9 @@ void tst_QStateMachine::playAnimationTwice()
QState *s4 = new QState(&machine);
s4->assignProperty(object, "foo", 2.0);
- s3->addTransition(new EventTransition(QEvent::User, s4))->addAnimation(fooAnimation);
+ trans = new EventTransition(QEvent::User, s4);
+ s3->addTransition(trans);
+ trans->addAnimation(fooAnimation);
QState *s5 = new QState(&machine);
QObject::connect(s5, SIGNAL(entered()), QApplication::instance(), SLOT(quit()));
@@ -3186,14 +3222,16 @@ void tst_QStateMachine::nestedTargetStateForAnimation()
QState *s2Child2 = new QState(s2);
s2Child2->assignProperty(object, "bar", 11.0);
- QAbstractTransition *at = s2Child->addTransition(new EventTransition(QEvent::User, s2Child2));
+ QAbstractTransition *at = new EventTransition(QEvent::User, s2Child2);
+ s2Child->addTransition(at);
QPropertyAnimation *animation = new QPropertyAnimation(object, "bar", s2);
animation->setDuration(2000);
connect(animation, SIGNAL(finished()), &counter, SLOT(slot()));
at->addAnimation(animation);
- at = s1->addTransition(new EventTransition(QEvent::User, s2));
+ at = new EventTransition(QEvent::User, s2);
+ s1->addTransition(at);
animation = new QPropertyAnimation(object, "foo", s2);
connect(animation, SIGNAL(finished()), &counter, SLOT(slot()));
@@ -3204,7 +3242,7 @@ void tst_QStateMachine::nestedTargetStateForAnimation()
at->addAnimation(animation);
QState *s3 = new QState(&machine);
- s2->addTransition(s2Child, SIGNAL(polished()), s3);
+ s2->addTransition(s2Child, SIGNAL(propertiesAssigned()), s3);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
@@ -3221,7 +3259,7 @@ void tst_QStateMachine::nestedTargetStateForAnimation()
QCOMPARE(counter.counter, 2);
}
-void tst_QStateMachine::polishedSignalTransitionsReuseAnimationGroup()
+void tst_QStateMachine::propertiesAssignedSignalTransitionsReuseAnimationGroup()
{
QStateMachine machine;
QObject *object = new QObject(&machine);
@@ -3238,9 +3276,9 @@ void tst_QStateMachine::polishedSignalTransitionsReuseAnimationGroup()
QParallelAnimationGroup animationGroup;
animationGroup.addAnimation(new QPropertyAnimation(object, "foo"));
QSignalSpy animationFinishedSpy(&animationGroup, SIGNAL(finished()));
- s1->addTransition(s1, SIGNAL(polished()), s2)->addAnimation(&animationGroup);
- s2->addTransition(s2, SIGNAL(polished()), s3)->addAnimation(&animationGroup);
- s3->addTransition(s3, SIGNAL(polished()), s4);
+ s1->addTransition(s1, SIGNAL(propertiesAssigned()), s2)->addAnimation(&animationGroup);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3)->addAnimation(&animationGroup);
+ s3->addTransition(s3, SIGNAL(propertiesAssigned()), s4);
machine.setInitialState(s1);
QSignalSpy machineFinishedSpy(&machine, SIGNAL(finished()));
@@ -3272,7 +3310,8 @@ void tst_QStateMachine::animatedGlobalRestoreProperty()
QState *s4 = new QState(&machine);
QObject::connect(s4, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
- QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
+ QAbstractTransition *at = new EventTransition(QEvent::User, s2);
+ s1->addTransition(at);
QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", s2);
connect(pa, SIGNAL(finished()), &counter, SLOT(slot()));
at->addAnimation(pa);
@@ -3314,7 +3353,9 @@ void tst_QStateMachine::specificTargetValueOfAnimation()
QPropertyAnimation *anim = new QPropertyAnimation(object, "foo");
anim->setEndValue(10.0);
- s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(anim);
+ EventTransition *trans = new EventTransition(QEvent::User, s2);
+ s1->addTransition(trans);
+ trans->addAnimation(anim);
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
@@ -3468,7 +3509,8 @@ void tst_QStateMachine::overrideDefaultAnimationWithSpecific()
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
- QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
+ QAbstractTransition *at = new EventTransition(QEvent::User, s2);
+ s1->addTransition(at);
QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo");
connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
@@ -4188,5 +4230,82 @@ void tst_QStateMachine::task260403_clonedSignals()
QCOMPARE(t1->eventSignalIndex, emitter.metaObject()->indexOfSignal("signalWithDefaultArg()"));
}
+class EventPosterThread : public QThread
+{
+ Q_OBJECT
+public:
+ EventPosterThread(QStateMachine *machine, QObject *parent = 0)
+ : QThread(parent), m_machine(machine), m_count(0)
+ {
+ moveToThread(this);
+ QObject::connect(m_machine, SIGNAL(started()),
+ this, SLOT(postEvent()));
+ }
+protected:
+ virtual void run()
+ {
+ exec();
+ }
+private Q_SLOTS:
+ void postEvent()
+ {
+ m_machine->postEvent(new QEvent(QEvent::User));
+ if (++m_count < 10000)
+ QTimer::singleShot(0, this, SLOT(postEvent()));
+ else
+ quit();
+ }
+private:
+ QStateMachine *m_machine;
+ int m_count;
+};
+
+void tst_QStateMachine::postEventFromOtherThread()
+{
+ QStateMachine machine;
+ EventPosterThread poster(&machine);
+ StringEventPoster *s1 = new StringEventPoster("foo", &machine);
+ s1->addTransition(new EventTransition(QEvent::User, s1));
+ QFinalState *f = new QFinalState(&machine);
+ s1->addTransition(&poster, SIGNAL(finished()), f);
+ machine.setInitialState(s1);
+
+ poster.start();
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+}
+
+void tst_QStateMachine::eventFilterForApplication()
+{
+ QStateMachine machine;
+
+ QState *s1 = new QState(&machine);
+ {
+ machine.setInitialState(s1);
+ }
+
+ QState *s2 = new QState(&machine);
+
+ QEventTransition *transition = new QEventTransition(QCoreApplication::instance(),
+ QEvent::ApplicationActivate);
+ transition->setTargetState(s2);
+ s1->addTransition(transition);
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ QCoreApplication::postEvent(QCoreApplication::instance(),
+ new QEvent(QEvent::ApplicationActivate));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s2));
+}
+
QTEST_MAIN(tst_QStateMachine)
#include "tst_qstatemachine.moc"
diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp
index 5dc1da7d32..2eb3152433 100644
--- a/tests/auto/qstring/tst_qstring.cpp
+++ b/tests/auto/qstring/tst_qstring.cpp
@@ -201,6 +201,7 @@ private slots:
void repeatedSignature() const;
void repeated() const;
void repeated_data() const;
+ void task262677remove();
};
typedef QList<int> IntList;
@@ -4669,6 +4670,14 @@ void tst_QString::repeated_data() const
<< 4;
}
+void tst_QString::task262677remove()
+{
+ QString driveName = QLatin1String("V:\\blahblah\\more_blahblah\\");
+ driveName.remove(2, INT_MAX); // should be "V:" - instead, it's "V::\\blahblah\\more_blahblah\\"
+ QVERIFY(driveName == QLatin1String("V:"));
+}
+
+
QTEST_APPLESS_MAIN(tst_QString)
#include "tst_qstring.moc"
diff --git a/tests/auto/qstringbuilder1/qstringbuilder1.pro b/tests/auto/qstringbuilder1/qstringbuilder1.pro
index 1ca9d456a8..5bb14d4290 100644
--- a/tests/auto/qstringbuilder1/qstringbuilder1.pro
+++ b/tests/auto/qstringbuilder1/qstringbuilder1.pro
@@ -3,7 +3,4 @@ load(qttest_p4)
QT = core
SOURCES += tst_qstringbuilder1.cpp
-HEADERS += ../qstringbuilder1/stringbuilder.h
-
-DEFINES += SCENARIO=1
diff --git a/tests/auto/qstringbuilder1/stringbuilder.cpp b/tests/auto/qstringbuilder1/stringbuilder.cpp
index 9fea137a58..9dc467e5cc 100644
--- a/tests/auto/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/qstringbuilder1/stringbuilder.cpp
@@ -39,62 +39,17 @@
**
****************************************************************************/
-// This is included in various .cpp files as a compile test for various scenarios
-// depending on NO_CAST_* and QT_USE_FAST_OPERATOR_PLUS and QT_USE_FAST_CONCATENATION
-
-#if SCENARIO == 1
-// this is the "no harm done" version. Only operator% is active,
-// with NO_CAST * defined
-#define P %
-#undef QT_USE_FAST_OPERATOR_PLUS
-#undef QT_USE_FAST_CONCATENATION
-#define QT_NO_CAST_FROM_ASCII
-#define QT_NO_CAST_TO_ASCII
-#endif
-
-
-#if SCENARIO == 2
-// this is the "full" version. Operator+ is replaced by a QStringBuilder
-// based version
-// with NO_CAST * defined
-#define P +
-#define QT_USE_FAST_OPERATOR_PLUS
-#define QT_USE_FAST_CONCATENATION
-#define QT_NO_CAST_FROM_ASCII
-#define QT_NO_CAST_TO_ASCII
-#endif
-
-#if SCENARIO == 3
-// this is the "no harm done" version. Only operator% is active,
-// with NO_CAST * _not_ defined
-#define P %
-#undef QT_USE_FAST_OPERATOR_PLUS
-#undef QT_USE_FAST_CONCATENATION
-#undef QT_NO_CAST_FROM_ASCII
-#undef QT_NO_CAST_TO_ASCII
-#endif
-
-#if SCENARIO == 4
-// this is the "full" version. Operator+ is replaced by a QStringBuilder
-// based version
-// with NO_CAST * _not_ defined
-#define P +
-#define QT_USE_FAST_OPERATOR_PLUS
-#define QT_USE_FAST_CONCATENATION
-#undef QT_NO_CAST_FROM_ASCII
-#undef QT_NO_CAST_TO_ASCII
-#endif
-
-#include <QtTest/QtTest>
-#include "stringbuilder.h"
-
-//TESTED_CLASS=QStringBuilder
-//TESTED_FILES=qstringbuilder.cpp
-
#define LITERAL "some literal"
-void tst_QStringBuilder::scenario()
+// "some literal", but replacing all vocals by their umlauted UTF-8 string :)
+#define UTF8_LITERAL "s\xc3\xb6m\xc3\xab l\xc3\xaft\xc3\xabr\xc3\xa4l"
+
+void runScenario()
{
+ // set codec for C strings to 0, enforcing Latin1
+ QTextCodec::setCodecForCStrings(0);
+ QVERIFY(!QTextCodec::codecForCStrings());
+
QLatin1Literal l1literal(LITERAL);
QLatin1String l1string(LITERAL);
QString string(l1string);
@@ -127,7 +82,24 @@ void tst_QStringBuilder::scenario()
QCOMPARE(r, r2);
r = string P ba;
QCOMPARE(r, r2);
+
+ // now test with codec for C strings set
+ QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
+ QVERIFY(QTextCodec::codecForCStrings());
+ QCOMPARE(QTextCodec::codecForCStrings()->name(), QByteArray("UTF-8"));
+
+ string = QString::fromUtf8(UTF8_LITERAL);
+ r2 = QString::fromUtf8(UTF8_LITERAL UTF8_LITERAL);
+ ba = UTF8_LITERAL;
+
+ r = string P UTF8_LITERAL;
+ QCOMPARE(r.size(), r2.size());
+ QCOMPARE(r, r2);
+ r = UTF8_LITERAL P string;
+ QCOMPARE(r, r2);
+ r = ba P string;
+ QCOMPARE(r, r2);
+ r = string P ba;
+ QCOMPARE(r, r2);
#endif
}
-
-QTEST_APPLESS_MAIN(tst_QStringBuilder)
diff --git a/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp b/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp
index bd2e4b0c65..d0a613c572 100644
--- a/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp
+++ b/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp
@@ -39,4 +39,35 @@
**
****************************************************************************/
-#include "../qstringbuilder1/stringbuilder.cpp"
+
+// SCENARIO 1
+// this is the "no harm done" version. Only operator% is active,
+// with NO_CAST * defined
+#define P %
+#undef QT_USE_FAST_OPERATOR_PLUS
+#undef QT_USE_FAST_CONCATENATION
+#define QT_NO_CAST_FROM_ASCII
+#define QT_NO_CAST_TO_ASCII
+
+
+#include <QtTest/QtTest>
+
+//TESTED_CLASS=QStringBuilder
+//TESTED_FILES=qstringbuilder.cpp
+
+#define LITERAL "some literal"
+
+void runScenario(); // Defined in stringbuilder.cpp #included below.
+
+class tst_QStringBuilder1 : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void scenario() { runScenario(); }
+};
+
+#include "stringbuilder.cpp"
+#include "tst_qstringbuilder1.moc"
+
+QTEST_APPLESS_MAIN(tst_QStringBuilder1)
diff --git a/tests/auto/qstringbuilder2/qstringbuilder2.pro b/tests/auto/qstringbuilder2/qstringbuilder2.pro
index c0b3ebc797..4152dc31e3 100644
--- a/tests/auto/qstringbuilder2/qstringbuilder2.pro
+++ b/tests/auto/qstringbuilder2/qstringbuilder2.pro
@@ -3,6 +3,3 @@ load(qttest_p4)
QT = core
SOURCES += tst_qstringbuilder2.cpp
-HEADERS += ../qstringbuilder1/stringbuilder.h
-
-DEFINES += SCENARIO=2
diff --git a/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp b/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp
index bd2e4b0c65..4470928def 100644
--- a/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp
+++ b/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp
@@ -39,4 +39,36 @@
**
****************************************************************************/
+
+// SCENARIO 2
+// this is the "full" version. Operator+ is replaced by a QStringBuilder
+// based version
+// with NO_CAST * defined
+#define P +
+#define QT_USE_FAST_OPERATOR_PLUS
+#define QT_USE_FAST_CONCATENATION
+#define QT_NO_CAST_FROM_ASCII
+#define QT_NO_CAST_TO_ASCII
+
+
+#include <QtTest/QtTest>
+
+//TESTED_CLASS=QStringBuilder
+//TESTED_FILES=qstringbuilder.cpp
+
+#define LITERAL "some literal"
+
+void runScenario(); // Defined in stringbuilder.cpp #included below.
+
+class tst_QStringBuilder2 : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void scenario() { runScenario(); }
+};
+
#include "../qstringbuilder1/stringbuilder.cpp"
+#include "tst_qstringbuilder2.moc"
+
+QTEST_APPLESS_MAIN(tst_QStringBuilder2)
diff --git a/tests/auto/qstringbuilder3/qstringbuilder3.pro b/tests/auto/qstringbuilder3/qstringbuilder3.pro
index 93d1a39e7e..b4d222591d 100644
--- a/tests/auto/qstringbuilder3/qstringbuilder3.pro
+++ b/tests/auto/qstringbuilder3/qstringbuilder3.pro
@@ -3,6 +3,3 @@ load(qttest_p4)
QT = core
SOURCES += tst_qstringbuilder3.cpp
-HEADERS += ../qstringbuilder1/stringbuilder.h
-
-DEFINES += SCENARIO=3
diff --git a/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp b/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp
index bd2e4b0c65..30f0181056 100644
--- a/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp
+++ b/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp
@@ -39,4 +39,35 @@
**
****************************************************************************/
+
+// SCENARIO 3
+// this is the "no harm done" version. Only operator% is active,
+// with NO_CAST * _not_ defined
+#define P %
+#undef QT_USE_FAST_OPERATOR_PLUS
+#undef QT_USE_FAST_CONCATENATION
+#undef QT_NO_CAST_FROM_ASCII
+#undef QT_NO_CAST_TO_ASCII
+
+
+#include <QtTest/QtTest>
+
+//TESTED_CLASS=QStringBuilder
+//TESTED_FILES=qstringbuilder.cpp
+
+#define LITERAL "some literal"
+
+void runScenario(); // Defined in stringbuilder.cpp #included below.
+
+class tst_QStringBuilder3 : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void scenario() { runScenario(); }
+};
+
#include "../qstringbuilder1/stringbuilder.cpp"
+#include "tst_qstringbuilder3.moc"
+
+QTEST_APPLESS_MAIN(tst_QStringBuilder3)
diff --git a/tests/auto/qstringbuilder4/qstringbuilder4.pro b/tests/auto/qstringbuilder4/qstringbuilder4.pro
index eeec447885..6ec522884b 100644
--- a/tests/auto/qstringbuilder4/qstringbuilder4.pro
+++ b/tests/auto/qstringbuilder4/qstringbuilder4.pro
@@ -3,6 +3,3 @@ load(qttest_p4)
QT = core
SOURCES += tst_qstringbuilder4.cpp
-HEADERS += ../qstringbuilder1/stringbuilder.h
-
-DEFINES += SCENARIO=4
diff --git a/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp b/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp
index 2159283bb5..95b4ec3a6e 100644
--- a/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp
+++ b/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtXmlPatterns module of the Qt Toolkit.
+** This file is part of the test suite module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,4 +39,36 @@
**
****************************************************************************/
+
+// SCENARIO 4
+// this is the "full" version. Operator+ is replaced by a QStringBuilder
+// based version
+// with NO_CAST * _not_ defined
+#define P +
+#define QT_USE_FAST_OPERATOR_PLUS
+#define QT_USE_FAST_CONCATENATION
+#undef QT_NO_CAST_FROM_ASCII
+#undef QT_NO_CAST_TO_ASCII
+
+
+#include <QtTest/QtTest>
+
+//TESTED_CLASS=QStringBuilder
+//TESTED_FILES=qstringbuilder.cpp
+
+#define LITERAL "some literal"
+
+void runScenario(); // Defined in stringbuilder.cpp #included below.
+
+class tst_QStringBuilder4 : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void scenario() { runScenario(); }
+};
+
#include "../qstringbuilder1/stringbuilder.cpp"
+#include "tst_qstringbuilder4.moc"
+
+QTEST_APPLESS_MAIN(tst_QStringBuilder4)
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index eab5a35657..f571e8a87d 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -41,6 +41,7 @@
#include <QtGui/QtGui>
+#include <private/qtablewidget_p.h>
#include <QtTest/QtTest>
#include "../../shared/util.h"
#include "private/qapplication_p.h"
@@ -58,6 +59,13 @@
} \
} while(0)
+#ifdef QT_BUILD_INTERNAL
+#define VERIFY_SPANS_CONSISTENCY(TEST_VIEW_) \
+ QVERIFY(static_cast<QTableViewPrivate*>(QObjectPrivate::get(TEST_VIEW_))->spans.checkConsistency())
+#else
+#define VERIFY_SPANS_CONSISTENCY(TEST_VIEW_) (void)false
+#endif
+
typedef QList<int> IntList;
Q_DECLARE_METATYPE(IntList)
@@ -188,11 +196,16 @@ private slots:
void task248688_autoScrollNavigation();
void task259308_scrollVerticalHeaderSwappedSections();
void task191545_dragSelectRows();
+ void taskQTBUG_5062_spansInconsistency();
+ void taskQTBUG_4516_clickOnRichTextLabel();
void mouseWheel_data();
void mouseWheel();
void addColumnWhileEditing();
+ void task234926_setHeaderSorting();
+
+ void changeHeaderData();
};
// Testing get/set functions
@@ -1194,6 +1207,13 @@ void tst_QTableView::moveCursorStrikesBack_data()
<< 0 << 5 << (IntList() << int(QtTestTableView::MoveNext))
<< 1 << 0;
+ QTest::newRow("Last column disabled. Task QTBUG-3878") << -1 << -1
+ << IntList()
+ << (IntList() << 6)
+ << QRect()
+ << 1 << 0 << (IntList() << int(QtTestTableView::MovePrevious))
+ << 0 << 5;
+
QTest::newRow("Span, anchor column hidden") << -1 << 1
<< IntList()
<< IntList()
@@ -1249,6 +1269,24 @@ void tst_QTableView::moveCursorStrikesBack_data()
<< QRect(1, 2, 2, 3)
<< 5 << 2 << (IntList() << int(QtTestTableView::MoveUp) << int(QtTestTableView::MoveUp))
<< 1 << 2;
+
+ IntList fullList;
+ for (int i = 0; i < 7; ++i)
+ fullList << i;
+
+ QTest::newRow("All disabled, wrap forward. Timeout => FAIL") << -1 << -1
+ << fullList
+ << fullList
+ << QRect()
+ << 1 << 0 << (IntList() << int(QtTestTableView::MoveNext))
+ << 1 << 0;
+
+ QTest::newRow("All disabled, wrap backwards. Timeout => FAIL") << -1 << -1
+ << fullList
+ << fullList
+ << QRect()
+ << 1 << 0 << (IntList() << int(QtTestTableView::MovePrevious))
+ << 1 << 0;
}
void tst_QTableView::moveCursorStrikesBack()
@@ -1271,11 +1309,6 @@ void tst_QTableView::moveCursorStrikesBack()
view.hideRow(hideRow);
view.hideColumn(hideColumn);
- foreach (int row, disableRows)
- model.disableRow(row);
- foreach (int column, disableColumns)
- model.disableColumn(column);
-
if (span.height() && span.width())
view.setSpan(span.top(), span.left(), span.height(), span.width());
view.show();
@@ -1283,6 +1316,11 @@ void tst_QTableView::moveCursorStrikesBack()
QModelIndex index = model.index(startRow, startColumn);
view.setCurrentIndex(index);
+ foreach (int row, disableRows)
+ model.disableRow(row);
+ foreach (int column, disableColumns)
+ model.disableColumn(column);
+
int newRow = -1;
int newColumn = -1;
foreach (int cursorMoveAction, cursorMoveActions) {
@@ -1991,8 +2029,9 @@ void tst_QTableView::resizeRowsToContents()
view.resizeRowsToContents();
QCOMPARE(resizedSpy.count(), model.rowCount());
- for (int r = 0; r < model.rowCount(); ++r)
+ for (int r = 0; r < model.rowCount(); ++r) {
QCOMPARE(view.rowHeight(r), rowHeight);
+ }
}
void tst_QTableView::resizeColumnsToContents_data()
@@ -2702,6 +2741,7 @@ void tst_QTableView::indexAt()
QtTestTableView view;
view.show();
+ QTest::qWaitForWindowShown(&view);
//some styles change the scroll mode in their polish
view.setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
@@ -2717,9 +2757,10 @@ void tst_QTableView::indexAt()
for (int c = 0; c < columnCount; ++c)
view.setColumnWidth(c, columnWidth);
- QTest::qWait(0); // ### needed to pass the test
+ QTest::qWait(20);
view.horizontalScrollBar()->setValue(horizontalScroll);
view.verticalScrollBar()->setValue(verticalScroll);
+ QTest::qWait(20);
QModelIndex index = view.indexAt(QPoint(x, y));
QCOMPARE(index.row(), expectedRow);
@@ -2870,6 +2911,8 @@ void tst_QTableView::span()
view.clearSpans();
QCOMPARE(view.rowSpan(row, column), 1);
QCOMPARE(view.columnSpan(row, column), 1);
+
+ VERIFY_SPANS_CONSISTENCY(&view);
}
typedef QVector<QRect> SpanList;
@@ -3005,6 +3048,8 @@ void tst_QTableView::spans()
QCOMPARE(view.columnSpan(pos.x(), pos.y()), expectedColumnSpan);
QCOMPARE(view.rowSpan(pos.x(), pos.y()), expectedRowSpan);
+
+ VERIFY_SPANS_CONSISTENCY(&view);
}
void tst_QTableView::spansAfterRowInsertion()
@@ -3039,6 +3084,8 @@ void tst_QTableView::spansAfterRowInsertion()
view.model()->insertRows(12, 2);
QCOMPARE(view.rowSpan(7, 3), 5);
QCOMPARE(view.columnSpan(7, 3), 3);
+
+ VERIFY_SPANS_CONSISTENCY(&view);
}
void tst_QTableView::spansAfterColumnInsertion()
@@ -3073,6 +3120,8 @@ void tst_QTableView::spansAfterColumnInsertion()
view.model()->insertColumns(12, 2);
QCOMPARE(view.rowSpan(3, 7), 3);
QCOMPARE(view.columnSpan(3, 7), 5);
+
+ VERIFY_SPANS_CONSISTENCY(&view);
}
void tst_QTableView::spansAfterRowRemoval()
@@ -3110,6 +3159,8 @@ void tst_QTableView::spansAfterRowRemoval()
QCOMPARE(view.columnSpan(span.top(), span.left()), span.width());
QCOMPARE(view.rowSpan(span.top(), span.left()), span.height());
}
+
+ VERIFY_SPANS_CONSISTENCY(&view);
}
void tst_QTableView::spansAfterColumnRemoval()
@@ -3148,6 +3199,8 @@ void tst_QTableView::spansAfterColumnRemoval()
QCOMPARE(view.columnSpan(span.left(), span.top()), span.height());
QCOMPARE(view.rowSpan(span.left(), span.top()), span.width());
}
+
+ VERIFY_SPANS_CONSISTENCY(&view);
}
class Model : public QAbstractTableModel {
@@ -3239,19 +3292,25 @@ void tst_QTableView::resizeToContents()
//now let's check the row/col sizes
for(int i = 0;i<table.columnCount();i++) {
- QVERIFY( table.columnWidth(i) == table2.columnWidth(i));
- QVERIFY( table2.columnWidth(i) == table3.columnWidth(i));
+ QCOMPARE( table.columnWidth(i), table2.columnWidth(i));
+ QCOMPARE( table2.columnWidth(i), table3.columnWidth(i));
}
for(int i = 0;i<table.rowCount();i++) {
- QVERIFY( table.rowHeight(i) == table2.rowHeight(i));
- QVERIFY( table2.rowHeight(i) == table3.rowHeight(i));
+ QCOMPARE( table.rowHeight(i), table2.rowHeight(i));
+ QCOMPARE( table2.rowHeight(i), table3.rowHeight(i));
}
}
+QT_BEGIN_NAMESPACE
+extern bool Q_GUI_EXPORT qt_tab_all_widgets; // qapplication.cpp
+QT_END_NAMESPACE
void tst_QTableView::tabFocus()
{
+ if (!qt_tab_all_widgets)
+ QSKIP("This test requires full keyboard control to be enabled.", SkipAll);
+
// QTableView enables tabKeyNavigation by default, but you should be able
// to change focus on an empty table view, or on a table view that doesn't
// have this property set.
@@ -3774,5 +3833,95 @@ void tst_QTableView::task191545_dragSelectRows()
}
}
+void tst_QTableView::task234926_setHeaderSorting()
+{
+ QStringListModel model;
+ QStringList data;
+ data << "orange" << "apple" << "banana" << "lemon" << "pumpkin";
+ QStringList sortedDataA = data;
+ QStringList sortedDataD = data;
+ qSort(sortedDataA);
+ qSort(sortedDataD.begin(), sortedDataD.end(), qGreater<QString>());
+ model.setStringList(data);
+ QTableView view;
+ view.setModel(&model);
+// view.show();
+ QTest::qWait(20);
+ QCOMPARE(model.stringList(), data);
+ view.setSortingEnabled(true);
+ view.sortByColumn(0, Qt::AscendingOrder);
+ QApplication::processEvents();
+ QCOMPARE(model.stringList() , sortedDataA);
+
+ view.horizontalHeader()->setSortIndicator(0, Qt::DescendingOrder);
+ QApplication::processEvents();
+ QCOMPARE(model.stringList() , sortedDataD);
+
+ QHeaderView *h = new QHeaderView(Qt::Horizontal);
+ h->setModel(&model);
+ view.setHorizontalHeader(h);
+ h->setSortIndicator(0, Qt::AscendingOrder);
+ QApplication::processEvents();
+ QCOMPARE(model.stringList() , sortedDataA);
+
+ h->setSortIndicator(0, Qt::DescendingOrder);
+ QApplication::processEvents();
+ QCOMPARE(model.stringList() , sortedDataD);
+}
+
+void tst_QTableView::taskQTBUG_5062_spansInconsistency()
+{
+ const int nRows = 5;
+ const int nColumns = 5;
+
+ QtTestTableModel model(nRows, nColumns);
+ QtTestTableView view;
+ view.setModel(&model);
+
+ for (int i = 0; i < nRows; ++i)
+ view.setSpan(i, 0, 1, nColumns);
+ view.setSpan(2, 0, 1, 1);
+ view.setSpan(3, 0, 1, 1);
+
+ VERIFY_SPANS_CONSISTENCY(&view);
+}
+
+void tst_QTableView::taskQTBUG_4516_clickOnRichTextLabel()
+{
+ QTableView view;
+ QStandardItemModel model(5,5);
+ view.setModel(&model);
+ QLabel label("rich text");
+ label.setTextFormat(Qt::RichText);
+ view.setIndexWidget(model.index(1,1), &label);
+ view.setCurrentIndex(model.index(0,0));
+ QCOMPARE(view.currentIndex(), model.index(0,0));
+
+ QTest::mouseClick(&label, Qt::LeftButton);
+ QCOMPARE(view.currentIndex(), model.index(1,1));
+
+
+}
+
+
+void tst_QTableView::changeHeaderData()
+{
+ QTableView view;
+ QStandardItemModel model(5,5);
+ view.setModel(&model);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QString text = "long long long text";
+ const int textWidth = view.fontMetrics().width(text);
+ QVERIFY(view.verticalHeader()->width() < textWidth);
+
+ model.setHeaderData(2, Qt::Vertical, text);
+ QTest::qWait(100); //leave time for layout
+
+ QVERIFY(view.verticalHeader()->width() > textWidth);
+}
+
+
QTEST_MAIN(tst_QTableView)
#include "tst_qtableview.moc"
diff --git a/tests/auto/qtablewidget/tst_qtablewidget.cpp b/tests/auto/qtablewidget/tst_qtablewidget.cpp
index 5aa2d1d491..b85851f2b5 100644
--- a/tests/auto/qtablewidget/tst_qtablewidget.cpp
+++ b/tests/auto/qtablewidget/tst_qtablewidget.cpp
@@ -102,6 +102,7 @@ private slots:
void cellWidget();
void task231094();
void task219380_removeLastRow();
+ void task262056_sortDuplicate();
private:
QTableWidget *testWidget;
@@ -1474,6 +1475,26 @@ void tst_QTableWidget::task219380_removeLastRow()
QCOMPARE(testWidget->cellWidget(18, 0)->geometry(), testWidget->visualItemRect(&item));
}
+void tst_QTableWidget::task262056_sortDuplicate()
+{
+ testWidget->setColumnCount(2);
+ testWidget->setRowCount(8);
+ testWidget->setSortingEnabled(true);
+ QStringList items = (QStringList() << "AAA" << "BBB" << "CCC" << "CCC" << "DDD"\
+ << "EEE" << "FFF" << "GGG");
+ for (int i = 0; i<8; i++ ) {
+ QTableWidgetItem *twi = new QTableWidgetItem(items.at(i));
+ testWidget->setItem(i,0,twi);
+ testWidget->setItem(i,1,new QTableWidgetItem(QString("item %1").arg(i)));
+ }
+ testWidget->sortItems(0, Qt::AscendingOrder);
+ QSignalSpy layoutChangedSpy(testWidget->model(), SIGNAL(layoutChanged()));
+ testWidget->item(3,0)->setBackgroundColor(Qt::red);
+
+ QCOMPARE(layoutChangedSpy.count(),0);
+
+}
+
QTEST_MAIN(tst_QTableWidget)
#include "tst_qtablewidget.moc"
diff --git a/tests/auto/qtabwidget/tst_qtabwidget.cpp b/tests/auto/qtabwidget/tst_qtabwidget.cpp
index 27c19df6d1..1387a9209c 100644
--- a/tests/auto/qtabwidget/tst_qtabwidget.cpp
+++ b/tests/auto/qtabwidget/tst_qtabwidget.cpp
@@ -590,9 +590,11 @@ void tst_QTabWidget::paintEventCount()
QTest::qWait(1000);
- // Mac and Windows get multiple repaints on the first show, so use those as a starting point.
+ // Mac, Windows and Windows CE get multiple repaints on the first show, so use those as a starting point.
static const int MaxInitialPaintCount =
-#if defined(Q_WS_WIN)
+#if defined(Q_OS_WINCE)
+ 4;
+#elif defined(Q_WS_WIN)
2;
#elif defined(Q_WS_MAC)
5;
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index 8ea137e228..4ed9fcaf88 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -192,6 +192,8 @@ private slots:
void connectToMultiIP();
void moveToThread0();
void increaseReadBufferSize();
+ void taskQtBug5799ConnectionErrorWaitForConnected();
+ void taskQtBug5799ConnectionErrorEventLoop();
#ifdef TEST_QNETWORK_PROXY
void invalidProxy_data();
void invalidProxy();
@@ -2096,7 +2098,7 @@ void tst_QTcpSocket::connectToMultiIP()
stopWatch.restart();
socket->connectToHost("multi.dev.troll.no", 81);
- QVERIFY(!socket->waitForConnected(1000));
+ QVERIFY(!socket->waitForConnected(2000));
QVERIFY(stopWatch.elapsed() < 2000);
QCOMPARE(socket->error(), QAbstractSocket::SocketTimeoutError);
@@ -2116,7 +2118,7 @@ void tst_QTcpSocket::moveToThread0()
QTcpSocket *socket = newSocket();;
socket->connectToHost(QtNetworkSettings::serverName(), 143);
socket->moveToThread(0);
- QVERIFY(socket->waitForConnected(1000));
+ QVERIFY(socket->waitForConnected(2000));
socket->write("XXX LOGOUT\r\n");
QVERIFY(socket->waitForBytesWritten(5000));
QVERIFY(socket->waitForDisconnected());
@@ -2127,7 +2129,7 @@ void tst_QTcpSocket::moveToThread0()
QTcpSocket *socket = newSocket();
socket->moveToThread(0);
socket->connectToHost(QtNetworkSettings::serverName(), 143);
- QVERIFY(socket->waitForConnected(1000));
+ QVERIFY(socket->waitForConnected(2000));
socket->write("XXX LOGOUT\r\n");
QVERIFY(socket->waitForBytesWritten(5000));
QVERIFY(socket->waitForDisconnected());
@@ -2137,7 +2139,7 @@ void tst_QTcpSocket::moveToThread0()
// Case 3: Moved after writing, while waiting for bytes to be written.
QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143);
- QVERIFY(socket->waitForConnected(1000));
+ QVERIFY(socket->waitForConnected(2000));
socket->write("XXX LOGOUT\r\n");
socket->moveToThread(0);
QVERIFY(socket->waitForBytesWritten(5000));
@@ -2148,7 +2150,7 @@ void tst_QTcpSocket::moveToThread0()
// Case 4: Moved after writing, while waiting for response.
QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143);
- QVERIFY(socket->waitForConnected(1000));
+ QVERIFY(socket->waitForConnected(2000));
socket->write("XXX LOGOUT\r\n");
QVERIFY(socket->waitForBytesWritten(5000));
socket->moveToThread(0);
@@ -2214,6 +2216,47 @@ void tst_QTcpSocket::increaseReadBufferSize()
delete active;
}
+void tst_QTcpSocket::taskQtBug5799ConnectionErrorWaitForConnected()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ // check that we get a proper error connecting to port 12346
+ // use waitForConnected, e.g. this should use a synchronous select() on the OS level
+
+ QTcpSocket socket;
+ socket.connectToHost(QtNetworkSettings::serverName(), 12346);
+ QTime timer;
+ timer.start();
+ socket.waitForConnected(10000);
+ QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong");
+ QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
+ QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError,
+ QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
+}
+
+void tst_QTcpSocket::taskQtBug5799ConnectionErrorEventLoop()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ // check that we get a proper error connecting to port 12346
+ // This testcase uses an event loop
+ QTcpSocket socket;
+ connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ socket.connectToHost(QtNetworkSettings::serverName(), 12346);
+
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong");
+ QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
+ QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError,
+ QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
+}
+
+
+
#ifdef TEST_QNETWORK_PROXY
void tst_QTcpSocket::invalidProxy_data()
{
@@ -2263,7 +2306,7 @@ void tst_QTcpSocket::invalidProxy()
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
} else {
QCOMPARE(socket->state(), QAbstractSocket::ConnectingState);
- QVERIFY(!socket->waitForConnected(1000));
+ QVERIFY(!socket->waitForConnected(2000));
}
QVERIFY(!socket->errorString().isEmpty());
@@ -2382,7 +2425,7 @@ void tst_QTcpSocket::proxyFactory()
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
} else {
QCOMPARE(socket->state(), QAbstractSocket::ConnectingState);
- QVERIFY(socket->waitForConnected(10000));
+ QVERIFY(socket->waitForConnected(2000));
QCOMPARE(proxyAuthCalled, 1);
}
QVERIFY(!socket->errorString().isEmpty());
diff --git a/tests/auto/qtextdocument/qtextdocument.pro b/tests/auto/qtextdocument/qtextdocument.pro
index d3ec45d8d7..1e44a9c1b4 100644
--- a/tests/auto/qtextdocument/qtextdocument.pro
+++ b/tests/auto/qtextdocument/qtextdocument.pro
@@ -1,4 +1,5 @@
load(qttest_p4)
+QT += xml
HEADERS += common.h
SOURCES += tst_qtextdocument.cpp
diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp
index f393393e62..11e32b061f 100644
--- a/tests/auto/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp
@@ -59,6 +59,7 @@
#include <qfontmetrics.h>
#include <qimage.h>
#include <qtextlayout.h>
+#include <QDomDocument>
#include "common.h"
@@ -175,6 +176,8 @@ private slots:
void testUndoBlocks();
void receiveCursorPositionChangedAfterContentsChange();
+ void escape_data();
+ void escape();
private:
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
@@ -576,7 +579,7 @@ void tst_QTextDocument::task240325()
}
void tst_QTextDocument::stylesheetFont_data()
-{
+{
QTest::addColumn<QString>("stylesheet");
QTest::addColumn<QFont>("font");
@@ -732,7 +735,7 @@ void tst_QTextDocument::toHtml_data()
cursor.insertText("Blah", fmt);
QTest::newRow("font-family-with-quotes1") << QTextDocumentFragment(&doc)
- << QString("<p DEFAULTBLOCKSTYLE><span style=\" font-family:\"Foo's Family\";\">Blah</span></p>");
+ << QString("<p DEFAULTBLOCKSTYLE><span style=\" font-family:&quot;Foo's Family&quot;;\">Blah</span></p>");
}
{
@@ -743,7 +746,7 @@ void tst_QTextDocument::toHtml_data()
cursor.insertText("Blah", fmt);
QTest::newRow("font-family-with-quotes2") << QTextDocumentFragment(&doc)
- << QString("<p DEFAULTBLOCKSTYLE><span style=\" font-family:'Foo\"s Family';\">Blah</span></p>");
+ << QString("<p DEFAULTBLOCKSTYLE><span style=\" font-family:'Foo&quot;s Family';\">Blah</span></p>");
}
{
@@ -974,6 +977,30 @@ void tst_QTextDocument::toHtml_data()
{
CREATE_DOC_AND_CURSOR();
+ QTextCharFormat fmt;
+ fmt.setAnchor(true);
+ fmt.setAnchorHref("http://www.kde.org/?a=1&b=2");
+ cursor.insertText("Blah", fmt);
+
+ QTest::newRow("href anchor with &") << QTextDocumentFragment(&doc)
+ << QString("<p DEFAULTBLOCKSTYLE><a href=\"http://www.kde.org/?a=1&amp;b=2\">Blah</a></p>");
+ }
+
+ {
+ CREATE_DOC_AND_CURSOR();
+
+ QTextCharFormat fmt;
+ fmt.setAnchor(true);
+ fmt.setAnchorHref("http://www.kde.org/?a='&b=\"");
+ cursor.insertText("Blah", fmt);
+
+ QTest::newRow("href anchor with ' and \"") << QTextDocumentFragment(&doc)
+ << QString("<p DEFAULTBLOCKSTYLE><a href=\"http://www.kde.org/?a='&amp;b=&quot;\">Blah</a></p>");
+ }
+
+ {
+ CREATE_DOC_AND_CURSOR();
+
cursor.insertTable(2, 2);
QTest::newRow("simpletable") << QTextDocumentFragment(&doc)
@@ -1541,6 +1568,9 @@ void tst_QTextDocument::toHtml()
QString output = doc->toHtml();
QCOMPARE(output, expectedOutput);
+
+ QDomDocument document;
+ QVERIFY2(document.setContent(output), "Output was not valid XML");
}
void tst_QTextDocument::toHtml2()
@@ -1691,21 +1721,21 @@ void tst_QTextDocument::capitalizationHtmlInExport()
const QString smallcaps = doc->toHtml();
QVERIFY(re.exactMatch(doc->toHtml()));
- QCOMPARE(re.numCaptures(), 1);
+ QCOMPARE(re.captureCount(), 1);
QCOMPARE(re.cap(1).trimmed(), QString("font-variant:small-caps;"));
cf.setFontCapitalization(QFont::AllUppercase);
cursor.mergeCharFormat(cf);
const QString uppercase = doc->toHtml();
QVERIFY(re.exactMatch(doc->toHtml()));
- QCOMPARE(re.numCaptures(), 1);
+ QCOMPARE(re.captureCount(), 1);
QCOMPARE(re.cap(1).trimmed(), QString("text-transform:uppercase;"));
cf.setFontCapitalization(QFont::AllLowercase);
cursor.mergeCharFormat(cf);
const QString lowercase = doc->toHtml();
QVERIFY(re.exactMatch(doc->toHtml()));
- QCOMPARE(re.numCaptures(), 1);
+ QCOMPARE(re.captureCount(), 1);
QCOMPARE(re.cap(1).trimmed(), QString("text-transform:lowercase;"));
doc->setHtml(smallcaps);
@@ -1731,14 +1761,14 @@ void tst_QTextDocument::wordspacingHtmlExport()
cursor.mergeCharFormat(cf);
QVERIFY(re.exactMatch(doc->toHtml()));
- QCOMPARE(re.numCaptures(), 1);
+ QCOMPARE(re.captureCount(), 1);
QCOMPARE(re.cap(1).trimmed(), QString("word-spacing:4px;"));
cf.setFontWordSpacing(-8.5);
cursor.mergeCharFormat(cf);
QVERIFY(re.exactMatch(doc->toHtml()));
- QCOMPARE(re.numCaptures(), 1);
+ QCOMPARE(re.captureCount(), 1);
QCOMPARE(re.cap(1).trimmed(), QString("word-spacing:-8.5px;"));
}
@@ -2585,6 +2615,17 @@ void tst_QTextDocument::testUndoCommandAdded()
cf.setFontItalic(true);
cursor.mergeCharFormat(cf);
QCOMPARE(spy.count(), 1);
+
+ spy.clear();
+ doc->undo();
+ QCOMPARE(spy.count(), 0);
+ doc->undo();
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+ doc->redo();
+ QCOMPARE(spy.count(), 0);
+ doc->redo();
+ QCOMPARE(spy.count(), 0);
}
void tst_QTextDocument::testUndoBlocks()
@@ -2652,5 +2693,25 @@ void tst_QTextDocument::receiveCursorPositionChangedAfterContentsChange()
QCOMPARE(rec.first, QString("contentsChanged"));
}
+void tst_QTextDocument::escape_data()
+{
+ QTest::addColumn<QString>("original");
+ QTest::addColumn<QString>("expected");
+
+ QTest::newRow("1") << "Hello World\n" << "Hello World\n";
+ QTest::newRow("2") << "#include <QtCore>" << "#include &lt;QtCore&gt;";
+ QTest::newRow("3") << "<p class=\"cool\"><a href=\"http://example.com/?foo=bar&amp;bar=foo\">plop --&gt; </a></p>"
+ << "&lt;p class=&quot;cool&quot;&gt;&lt;a href=&quot;http://example.com/?foo=bar&amp;amp;bar=foo&quot;&gt;plop --&amp;gt; &lt;/a&gt;&lt;/p&gt;";
+ QTest::newRow("4") << QString::fromUtf8("<\320\222\321\201>") << QString::fromUtf8("&lt;\320\222\321\201&gt;");
+}
+
+void tst_QTextDocument::escape()
+{
+ QFETCH(QString, original);
+ QFETCH(QString, expected);
+
+ QCOMPARE(Qt::escape(original), expected);
+}
+
QTEST_MAIN(tst_QTextDocument)
#include "tst_qtextdocument.moc"
diff --git a/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
index 8c4d8fdabd..4dc732cd60 100644
--- a/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
+++ b/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
@@ -2197,6 +2197,16 @@ void tst_QTextDocumentFragment::html_quotedFontFamily()
setHtml("<div style='font-family: \"Foo Bar\";'>Test</div>");
QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar"));
+
+ setHtml("<div style='font-family: \"Foo Bar\";'>Test</div>");
+ QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar"));
+
+ setHtml("<div style='font-family: Foo\n Bar;'>Test</div>");
+ QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar"));
+
+ setHtml("<div style='font-family: Foo\n Bar, serif, \"bar foo\";'>Test</div>");
+ QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar,serif,bar foo"));
+
}
void tst_QTextDocumentFragment::defaultFont()
diff --git a/tests/auto/qtextedit/fullWidthSelection/centered-fully-selected.png b/tests/auto/qtextedit/fullWidthSelection/centered-fully-selected.png
index 7467478ef9..ced6eb6e5b 100644
--- a/tests/auto/qtextedit/fullWidthSelection/centered-fully-selected.png
+++ b/tests/auto/qtextedit/fullWidthSelection/centered-fully-selected.png
Binary files differ
diff --git a/tests/auto/qtextedit/fullWidthSelection/centered-partly-selected.png b/tests/auto/qtextedit/fullWidthSelection/centered-partly-selected.png
index 7a10e634ae..481b99c7fc 100644
--- a/tests/auto/qtextedit/fullWidthSelection/centered-partly-selected.png
+++ b/tests/auto/qtextedit/fullWidthSelection/centered-partly-selected.png
Binary files differ
diff --git a/tests/auto/qtextedit/fullWidthSelection/last-char-on-line.png b/tests/auto/qtextedit/fullWidthSelection/last-char-on-line.png
index df5b92e559..292d3f9d4c 100644
--- a/tests/auto/qtextedit/fullWidthSelection/last-char-on-line.png
+++ b/tests/auto/qtextedit/fullWidthSelection/last-char-on-line.png
Binary files differ
diff --git a/tests/auto/qtextedit/fullWidthSelection/last-char-on-parag.png b/tests/auto/qtextedit/fullWidthSelection/last-char-on-parag.png
index d58d4cc06e..69b72ede09 100644
--- a/tests/auto/qtextedit/fullWidthSelection/last-char-on-parag.png
+++ b/tests/auto/qtextedit/fullWidthSelection/last-char-on-parag.png
Binary files differ
diff --git a/tests/auto/qtextedit/fullWidthSelection/multiple-full-width-lines.png b/tests/auto/qtextedit/fullWidthSelection/multiple-full-width-lines.png
index c5c3c22e84..467b91e6e0 100644
--- a/tests/auto/qtextedit/fullWidthSelection/multiple-full-width-lines.png
+++ b/tests/auto/qtextedit/fullWidthSelection/multiple-full-width-lines.png
Binary files differ
diff --git a/tests/auto/qtextedit/fullWidthSelection/nowrap_long.png b/tests/auto/qtextedit/fullWidthSelection/nowrap_long.png
index 7ded2549b5..cce921b0cc 100644
--- a/tests/auto/qtextedit/fullWidthSelection/nowrap_long.png
+++ b/tests/auto/qtextedit/fullWidthSelection/nowrap_long.png
Binary files differ
diff --git a/tests/auto/qtextedit/fullWidthSelection/single-full-width-line.png b/tests/auto/qtextedit/fullWidthSelection/single-full-width-line.png
index d2fd629cda..937494ac3c 100644
--- a/tests/auto/qtextedit/fullWidthSelection/single-full-width-line.png
+++ b/tests/auto/qtextedit/fullWidthSelection/single-full-width-line.png
Binary files differ
diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp
index 59abbd5fe4..fee030c9ef 100644
--- a/tests/auto/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/qtextedit/tst_qtextedit.cpp
@@ -1967,7 +1967,7 @@ void tst_QTextEdit::fullWidthSelection()
qt_setQtEnableTestFont(true);
QFont testFont;
testFont.setFamily("__Qt__Box__Engine__");
- testFont.setPixelSize(12);
+ testFont.setPixelSize(11);
testFont.setWeight(QFont::Normal);
QTextCharFormat cf;
cf.setFont(testFont);
@@ -2015,7 +2015,7 @@ void tst_QTextEdit::fullWidthSelection2()
qt_setQtEnableTestFont(true);
QFont testFont;
testFont.setFamily("__Qt__Box__Engine__");
- testFont.setPixelSize(12);
+ testFont.setPixelSize(11);
testFont.setWeight(QFont::Normal);
QTextCharFormat cf;
cf.setFont(testFont);
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index fe87dfb175..7c3f4f2481 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -118,6 +118,7 @@ private slots:
void smallTextLengthWordWrap();
void smallTextLengthWrapAtWordBoundaryOrAnywhere();
void testLineBreakingAllSpaces();
+ void lineWidthFromBOM();
private:
@@ -1306,6 +1307,18 @@ void tst_QTextLayout::columnWrapWithTabs()
}
+void tst_QTextLayout::lineWidthFromBOM()
+{
+ const QString string(QChar(0xfeff)); // BYTE ORDER MARK
+ QTextLayout layout(string);
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ line.setLineWidth(INT_MAX / 256);
+ layout.endLayout();
+
+ // Don't spin into an infinite loop
+ }
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"
diff --git a/tests/auto/qtextscriptengine/generate/generate.pro b/tests/auto/qtextscriptengine/generate/generate.pro
index 355633d6f2..354e0e5cdf 100644
--- a/tests/auto/qtextscriptengine/generate/generate.pro
+++ b/tests/auto/qtextscriptengine/generate/generate.pro
@@ -5,6 +5,7 @@
TEMPLATE = app
CONFIG -= moc
INCLUDEPATH += . /usr/include/freetype2
+INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src
# Input
SOURCES += main.cpp
diff --git a/tests/auto/qtextscriptengine/generate/main.cpp b/tests/auto/qtextscriptengine/generate/main.cpp
index 853c72679d..15fbc47504 100644
--- a/tests/auto/qtextscriptengine/generate/main.cpp
+++ b/tests/auto/qtextscriptengine/generate/main.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
-#include <QtTest/QtTest>
+#include <QApplication>
#include <QTextEdit>
#include <QLineEdit>
#include <QVBoxLayout>
@@ -85,7 +85,7 @@ void MyEdit::setText(const QString &str)
result += "0x" + QString::number(str.at(i).unicode(), 16) + ", ";
result += "0x0 },\n { ";
for (int i = 0; i < e->layoutData->items[0].num_glyphs; ++i)
- result += "0x" + QString::number(e->layoutData->glyphPtr[i].glyph, 16) + ", ";
+ result += "0x" + QString::number(e->layoutData->glyphLayout.glyphs[i], 16) + ", ";
result += "0x0 } }";
setPlainText(result);
diff --git a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
index 226348a79d..78e0ce6a83 100644
--- a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
+++ b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
@@ -98,7 +98,7 @@ private slots:
void telugu();
void kannada();
void malayalam();
- // sinhala missing
+ void sinhala();
void khmer();
void linearB();
@@ -379,7 +379,11 @@ void tst_QTextScriptEngine::bengali()
{ 0x151, 0x276, 0x172, 0x143, 0x0 } },
{ { 0x9b0, 0x9cd, 0x995, 0x9be, 0x983, 0x0 },
{ 0x151, 0x276, 0x172, 0x144, 0x0 } },
-
+ // test decomposed two parts matras
+ { { 0x995, 0x9c7, 0x9be, 0x0 },
+ { 0x179, 0x151, 0x172, 0x0 } },
+ { { 0x995, 0x9c7, 0x9d7, 0x0 },
+ { 0x179, 0x151, 0x17e, 0x0 } },
{ {0}, {0} }
};
@@ -502,16 +506,16 @@ void tst_QTextScriptEngine::bengali()
if (QFontDatabase().families(QFontDatabase::Bengali).contains("Likhan")) {
QFont f("Likhan");
const ShapeTable shape_table [] = {
- { { 0x09a8, 0x09cd, 0x09af, 0x0 },
- { 0x0192, 0x0 } },
+ { { 0x9a8, 0x9cd, 0x9af, 0x0 },
+ { 0x1ca, 0x0 } },
{ { 0x09b8, 0x09cd, 0x09af, 0x0 },
- { 0x01d6, 0x0 } },
+ { 0x020e, 0x0 } },
{ { 0x09b6, 0x09cd, 0x09af, 0x0 },
- { 0x01bc, 0x0 } },
+ { 0x01f4, 0x0 } },
{ { 0x09b7, 0x09cd, 0x09af, 0x0 },
- { 0x01c6, 0x0 } },
+ { 0x01fe, 0x0 } },
{ { 0x09b0, 0x09cd, 0x09a8, 0x09cd, 0x200d, 0x0 },
- { 0xd3, 0x12f, 0x0 } },
+ { 0x10b, 0x167, 0x0 } },
{ {0}, {0} }
};
@@ -647,6 +651,12 @@ void tst_QTextScriptEngine::tamil()
{ 0x0025, 0x0 } },
{ { 0x0b83, 0x0b95, 0x0 },
{ 0x0025, 0x0031, 0x0 } },
+ { { 0xb95, 0xbc6, 0xbbe, 0x0 },
+ { 0xa, 0x31, 0x7, 0x0 } },
+ { { 0xb95, 0xbc7, 0xbbe, 0x0 },
+ { 0xb, 0x31, 0x7, 0x0 } },
+ { { 0xb95, 0xbc6, 0xbd7, 0x0 },
+ { 0xa, 0x31, 0x40, 0x0 } },
{ {0}, {0} }
};
@@ -694,7 +704,9 @@ void tst_QTextScriptEngine::telugu()
{ 0xe6, 0xb3, 0x83, 0x0 } },
{ { 0xc15, 0xc4d, 0xc30, 0xc48, 0x0 },
{ 0xe6, 0xb3, 0x9f, 0x0 } },
- { {0}, {0} }
+ { { 0xc15, 0xc46, 0xc56, 0x0 },
+ { 0xe6, 0xb3, 0x0 } },
+ { {0}, {0} }
};
@@ -762,7 +774,16 @@ void tst_QTextScriptEngine::kannada()
{ 0x00b0, 0x006c, 0x0 } },
{ { 0x0cb7, 0x0ccd, 0x0 },
{ 0x0163, 0x0 } },
-
+ { { 0xc95, 0xcbf, 0xcd5, 0x0 },
+ { 0x114, 0x73, 0x0 } },
+ { { 0xc95, 0xcc6, 0xcd5, 0x0 },
+ { 0x90, 0x6c, 0x73, 0x0 } },
+ { { 0xc95, 0xcc6, 0xcd6, 0x0 },
+ { 0x90, 0x6c, 0x74, 0x0 } },
+ { { 0xc95, 0xcc6, 0xcc2, 0x0 },
+ { 0x90, 0x6c, 0x69, 0x0 } },
+ { { 0xc95, 0xcca, 0xcd5, 0x0 },
+ { 0x90, 0x6c, 0x69, 0x73, 0x0 } },
{ {0}, {0} }
};
@@ -816,8 +837,14 @@ void tst_QTextScriptEngine::malayalam()
{ 0x009e, 0x0 } },
{ { 0x0d30, 0x0d4d, 0x200d, 0x0 },
{ 0x009e, 0x0 } },
-
-
+ { { 0xd15, 0xd46, 0xd3e, 0x0 },
+ { 0x5e, 0x34, 0x58, 0x0 } },
+ { { 0xd15, 0xd47, 0xd3e, 0x0 },
+ { 0x5f, 0x34, 0x58, 0x0 } },
+ { { 0xd15, 0xd46, 0xd57, 0x0 },
+ { 0x5e, 0x34, 0x65, 0x0 } },
+ { { 0xd15, 0xd57, 0x0 },
+ { 0x34, 0x65, 0x0 } },
{ {0}, {0} }
};
@@ -836,6 +863,42 @@ void tst_QTextScriptEngine::malayalam()
#endif
}
+void tst_QTextScriptEngine::sinhala()
+{
+#if defined(Q_WS_X11)
+ {
+ if (QFontDatabase().families(QFontDatabase::Sinhala).contains("Malithi Web")) {
+ QFont f("Malithi Web");
+ const ShapeTable shape_table [] = {
+ { { 0xd9a, 0xdd9, 0xdcf, 0x0 },
+ { 0x4a, 0x61, 0x42, 0x0 } },
+ { { 0xd9a, 0xdd9, 0xddf, 0x0 },
+ { 0x4a, 0x61, 0x50, 0x0 } },
+ { { 0xd9a, 0xdd9, 0xdca, 0x0 },
+ { 0x4a, 0x62, 0x0 } },
+ { { 0xd9a, 0xddc, 0xdca, 0x0 },
+ { 0x4a, 0x61, 0x42, 0x41, 0x0 } },
+ { { 0xd9a, 0xdda, 0x0 },
+ { 0x4a, 0x62, 0x0 } },
+ { { 0xd9a, 0xddd, 0x0 },
+ { 0x4a, 0x61, 0x42, 0x41, 0x0 } },
+ { {0}, {0} }
+ };
+
+
+ const ShapeTable *s = shape_table;
+ while (s->unicode[0]) {
+ QVERIFY( shaping(f, s) );
+ ++s;
+ }
+ } else {
+ QSKIP("couln't find Malithi Web", SkipAll);
+ }
+ }
+#else
+ QSKIP("X11 specific test", SkipAll);
+#endif
+}
void tst_QTextScriptEngine::khmer()
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index 91b2cc5529..4fc6dd3363 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -172,6 +172,7 @@ private slots:
void expandAndCollapse_data();
void expandAndCollapse();
void expandAndCollapseAll();
+ void expandWithNoChildren();
void keyboardNavigation();
void headerSections();
void moveCursor_data();
@@ -234,6 +235,7 @@ private slots:
void task254234_proxySort();
void task248022_changeSelection();
void task245654_changeModelAndExpandAll();
+ void doubleClickedWithSpans();
};
class QtTestModel: public QAbstractItemModel
@@ -1548,6 +1550,19 @@ void tst_QTreeView::expandAndCollapseAll()
// QCOMPARE(collapsedSpy.count(), count);
}
+void tst_QTreeView::expandWithNoChildren()
+{
+ QTreeView tree;
+ QStandardItemModel model(1,1);
+ tree.setModel(&model);
+ tree.setAnimated(true);
+ tree.doItemsLayout();
+ //this test should not output warnings
+ tree.expand(model.index(0,0));
+}
+
+
+
void tst_QTreeView::keyboardNavigation()
{
const int rows = 10;
@@ -2877,7 +2892,10 @@ void tst_QTreeView::styleOptionViewItem()
QVERIFY(!opt.text.isEmpty());
QCOMPARE(opt.index, index);
- QCOMPARE(!(opt.features & QStyleOptionViewItemV2::Alternate), !(index.row() % 2));
+ //qDebug() << index << opt.text;
+
+ if (allCollapsed)
+ QCOMPARE(!(opt.features & QStyleOptionViewItemV2::Alternate), !(index.row() % 2));
QCOMPARE(!(opt.features & QStyleOptionViewItemV2::HasCheckIndicator), !opt.text.contains("Checkable"));
if (opt.text.contains("Beginning"))
@@ -2897,12 +2915,16 @@ void tst_QTreeView::styleOptionViewItem()
else
QCOMPARE(opt.checkState, Qt::Unchecked);
+ QCOMPARE(!(opt.state & QStyle::State_Children) , !opt.text.contains("HasChildren"));
+ QCOMPARE(!!(opt.state & QStyle::State_Sibling) , !opt.text.contains("Last"));
+
QVERIFY(!opt.text.contains("Assert"));
QStyledItemDelegate::paint(painter, option, index);
count++;
}
mutable int count;
+ bool allCollapsed;
};
QTreeView view;
@@ -2912,8 +2934,9 @@ void tst_QTreeView::styleOptionViewItem()
view.setItemDelegate(&delegate);
model.appendRow(QList<QStandardItem*>()
<< new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") );
+ QStandardItem *par1 = new QStandardItem("Beginning HasChildren");
model.appendRow(QList<QStandardItem*>()
- << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") );
+ << par1 << new QStandardItem("Middle HasChildren") << new QStandardItem("Middle HasChildren") << new QStandardItem("End HasChildren") );
model.appendRow(QList<QStandardItem*>()
<< new QStandardItem("OnlyOne") << new QStandardItem("Assert") << new QStandardItem("Assert") << new QStandardItem("Assert") );
QStandardItem *checkable = new QStandardItem("Checkable");
@@ -2923,13 +2946,143 @@ void tst_QTreeView::styleOptionViewItem()
checked->setCheckState(Qt::Checked);
model.appendRow(QList<QStandardItem*>()
<< new QStandardItem("Beginning") << checkable << checked << new QStandardItem("End") );
+ model.appendRow(QList<QStandardItem*>()
+ << new QStandardItem("Beginning Last") << new QStandardItem("Middle Last") << new QStandardItem("Middle Last") << new QStandardItem("End Last") );
+
+ par1->appendRow(QList<QStandardItem*>()
+ << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") );
+ QStandardItem *par2 = new QStandardItem("Beginning HasChildren");
+ par1->appendRow(QList<QStandardItem*>()
+ << par2 << new QStandardItem("Middle HasChildren") << new QStandardItem("Middle HasChildren") << new QStandardItem("End HasChildren") );
+ par2->appendRow(QList<QStandardItem*>()
+ << new QStandardItem("Beginning Last") << new QStandardItem("Middle Last") << new QStandardItem("Middle Last") << new QStandardItem("End Last") );
+
+ QStandardItem *par3 = new QStandardItem("Beginning Last");
+ par1->appendRow(QList<QStandardItem*>()
+ << par3 << new QStandardItem("Middle Last") << new QStandardItem("Middle Last") << new QStandardItem("End Last") );
+ par3->appendRow(QList<QStandardItem*>()
+ << new QStandardItem("Assert") << new QStandardItem("Assert") << new QStandardItem("Assert") << new QStandardItem("Asser") );
+ view.setRowHidden(0, par3->index(), true);
+ par1->appendRow(QList<QStandardItem*>()
+ << new QStandardItem("Assert") << new QStandardItem("Assert") << new QStandardItem("Assert") << new QStandardItem("Asser") );
+ view.setRowHidden(3, par1->index(), true);
+
view.setFirstColumnSpanned(2, QModelIndex(), true);
view.setAlternatingRowColors(true);
delegate.count = 0;
+ delegate.allCollapsed = true;
view.showMaximized();
+ QApplication::processEvents();
QTRY_VERIFY(delegate.count >= 13);
+ delegate.count = 0;
+ delegate.allCollapsed = false;
+ view.expandAll();
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.count >= 13);
+ delegate.count = 0;
+ view.collapse(par2->index());
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.count >= 4);
+
+
+ //test dynamic models
+ {
+ delegate.count = 0;
+ QStandardItemModel model2;
+ QStandardItem *item0 = new QStandardItem("OnlyOne Last");
+ model2.appendRow(QList<QStandardItem*>() << item0);
+ view.setModel(&model2);
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.count >= 1);
+ QApplication::processEvents();
+
+ QStandardItem *item00 = new QStandardItem("OnlyOne Last");
+ item0->appendRow(QList<QStandardItem*>() << item00);
+ item0->setText("OnlyOne Last HasChildren");
+ QApplication::processEvents();
+ delegate.count = 0;
+ view.expandAll();
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.count >= 2);
+ QApplication::processEvents();
+
+ QStandardItem *item1 = new QStandardItem("OnlyOne Last");
+ delegate.count = 0;
+ item0->setText("OnlyOne HasChildren");
+ model2.appendRow(QList<QStandardItem*>() << item1);
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.count >= 3);
+ QApplication::processEvents();
+
+ QStandardItem *item01 = new QStandardItem("OnlyOne Last");
+ delegate.count = 0;
+ item00->setText("OnlyOne");
+ item0->appendRow(QList<QStandardItem*>() << item01);
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.count >= 4);
+ QApplication::processEvents();
+
+ QStandardItem *item000 = new QStandardItem("OnlyOne Last");
+ delegate.count = 0;
+ item00->setText("OnlyOne HasChildren");
+ item00->appendRow(QList<QStandardItem*>() << item000);
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.count >= 5);
+ QApplication::processEvents();
+
+ delegate.count = 0;
+ item0->removeRow(0);
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.count >= 3);
+ QApplication::processEvents();
+
+ item00 = new QStandardItem("OnlyOne");
+ item0->insertRow(0, QList<QStandardItem*>() << item00);
+ QApplication::processEvents();
+ delegate.count = 0;
+ view.expandAll();
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.count >= 4);
+ QApplication::processEvents();
+
+ delegate.count = 0;
+ item0->removeRow(1);
+ item00->setText("OnlyOne Last");
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.count >= 3);
+ QApplication::processEvents();
+
+ delegate.count = 0;
+ item0->removeRow(0);
+ item0->setText("OnlyOne");
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.count >= 2);
+ QApplication::processEvents();
+
+ //with hidden items
+ item0->setText("OnlyOne HasChildren");
+ item00 = new QStandardItem("OnlyOne");
+ item0->appendRow(QList<QStandardItem*>() << item00);
+ item01 = new QStandardItem("Assert");
+ item0->appendRow(QList<QStandardItem*>() << item01);
+ view.setRowHidden(1, item0->index(), true);
+ view.expandAll();
+ QStandardItem *item02 = new QStandardItem("OnlyOne Last");
+ item0->appendRow(QList<QStandardItem*>() << item02);
+ delegate.count = 0;
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.count >= 4);
+ QApplication::processEvents();
+
+ item0->removeRow(2);
+ item00->setText("OnlyOne Last");
+ delegate.count = 0;
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.count >= 3);
+ QApplication::processEvents();
+ }
}
class task174627_TreeView : public QTreeView
@@ -3493,7 +3646,37 @@ void tst_QTreeView::task245654_changeModelAndExpandAll()
}
-
+void tst_QTreeView::doubleClickedWithSpans()
+{
+ QTreeView view;
+ QStandardItemModel model(1, 2);
+ view.setModel(&model);
+ view.setFirstColumnSpanned(0, QModelIndex(), true);
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_VERIFY(view.isActiveWindow());
+
+ QPoint p(10, 10);
+ QCOMPARE(view.indexAt(p), model.index(0, 0));
+ QSignalSpy spy(&view, SIGNAL(doubleClicked(QModelIndex)));
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, p);
+ QTest::mouseDClick(view.viewport(), Qt::LeftButton, 0, p);
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, p);
+ QCOMPARE(spy.count(), 1);
+
+ //let's click on the 2nd column
+ p.setX(p.x() + view.header()->sectionSize(0));
+ QCOMPARE(view.indexAt(p), model.index(0, 0));
+
+ //end the previous edition
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p);
+ QTest::qWait(150);
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, p);
+ QTest::mouseDClick(view.viewport(), Qt::LeftButton, 0, p);
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, p);
+ QTRY_COMPARE(spy.count(), 2);
+}
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"
diff --git a/tests/auto/qtreewidget/tst_qtreewidget.cpp b/tests/auto/qtreewidget/tst_qtreewidget.cpp
index 11c4543da0..621072ce38 100644
--- a/tests/auto/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/qtreewidget/tst_qtreewidget.cpp
@@ -49,6 +49,9 @@
#include <qheaderview.h>
#include <qlineedit.h>
#include <QScrollBar>
+#include <QStyledItemDelegate>
+
+#include "../../shared/util.h"
//TESTED_CLASS=
@@ -163,6 +166,8 @@ private slots:
void task217309();
void setCurrentItemExpandsParent();
void task239150_editorWidth();
+ void setTextUpdate();
+ void taskQTBUG2844_visualItemRect();
public slots:
void itemSelectionChanged();
@@ -597,9 +602,9 @@ void tst_QTreeWidget::setItemHidden()
testWidget->scrollToItem(child);
QVERIFY(testWidget->visualItemRect(parent).isValid()
- && testWidget->viewport()->rect().contains(testWidget->visualItemRect(parent)));
+ && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(parent)));
QVERIFY(testWidget->visualItemRect(child).isValid()
- && testWidget->viewport()->rect().contains(testWidget->visualItemRect(child)));
+ && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(child)));
QVERIFY(!testWidget->isItemHidden(parent));
QVERIFY(!testWidget->isItemHidden(child));
@@ -607,9 +612,9 @@ void tst_QTreeWidget::setItemHidden()
testWidget->setItemHidden(parent, true);
QVERIFY(!(testWidget->visualItemRect(parent).isValid()
- && testWidget->viewport()->rect().contains(testWidget->visualItemRect(parent))));
+ && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(parent))));
QVERIFY(!(testWidget->visualItemRect(child).isValid()
- && testWidget->viewport()->rect().contains(testWidget->visualItemRect(child))));
+ && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(child))));
QVERIFY(testWidget->isItemHidden(parent));
QVERIFY(!testWidget->isItemHidden(child));
@@ -3233,6 +3238,60 @@ void tst_QTreeWidget::task239150_editorWidth()
+void tst_QTreeWidget::setTextUpdate()
+{
+ QTreeWidget treeWidget;
+ treeWidget.setColumnCount(2);
+
+ class MyItemDelegate : public QStyledItemDelegate
+ {
+ public:
+ MyItemDelegate() : numPaints(0) { }
+ void paint(QPainter *painter,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const
+ {
+ numPaints++;
+ QStyledItemDelegate::paint(painter, option, index);
+ }
+
+ mutable int numPaints;
+ } delegate;
+
+ treeWidget.setItemDelegate(&delegate);
+ treeWidget.show();
+ QStringList strList;
+ strList << "variable1" << "0";
+ QTreeWidgetItem *item = new QTreeWidgetItem(strList);
+ treeWidget.insertTopLevelItem(0, item);
+ QTest::qWait(50);
+ QTRY_VERIFY(delegate.numPaints > 0);
+ delegate.numPaints = 0;
+
+ item->setText(1, "42");
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.numPaints > 0);
+}
+
+void tst_QTreeWidget::taskQTBUG2844_visualItemRect()
+{
+ CustomTreeWidget tree;
+ tree.resize(150, 100);
+ tree.setColumnCount(3);
+ QTreeWidgetItem item(&tree);
+
+ QRect itemRect = tree.visualItemRect(&item);
+
+ QRect rectCol0 = tree.visualRect(tree.indexFromItem(&item, 0));
+ QRect rectCol1 = tree.visualRect(tree.indexFromItem(&item, 1));
+ QRect rectCol2 = tree.visualRect(tree.indexFromItem(&item, 2));
+
+ QCOMPARE(tree.visualItemRect(&item), rectCol0 | rectCol2);
+ tree.setColumnHidden(2, true);
+ QCOMPARE(tree.visualItemRect(&item), rectCol0 | rectCol1);
+}
+
+
+
QTEST_MAIN(tst_QTreeWidget)
#include "tst_qtreewidget.moc"
diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp
index 7ea2163bf3..9418be0450 100644
--- a/tests/auto/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp
@@ -719,6 +719,8 @@ void tst_QUdpSocket::outOfProcessConnectedClientServerTest()
QProcess serverProcess;
serverProcess.start(QLatin1String("clientserver/clientserver server 1 1"),
QIODevice::ReadWrite | QIODevice::Text);
+ QVERIFY2(serverProcess.waitForStarted(3000),
+ qPrintable("Failed to start subprocess: " + serverProcess.errorString()));
// Wait until the server has started and reports success.
while (!serverProcess.canReadLine())
@@ -732,6 +734,9 @@ void tst_QUdpSocket::outOfProcessConnectedClientServerTest()
clientProcess.start(QString::fromLatin1("clientserver/clientserver connectedclient %1 %2")
.arg(QLatin1String("127.0.0.1")).arg(serverPort),
QIODevice::ReadWrite | QIODevice::Text);
+ QVERIFY2(clientProcess.waitForStarted(3000),
+ qPrintable("Failed to start subprocess: " + clientProcess.errorString()));
+
// Wait until the server has started and reports success.
while (!clientProcess.canReadLine())
QVERIFY(clientProcess.waitForReadyRead(3000));
@@ -779,6 +784,8 @@ void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest()
QProcess serverProcess;
serverProcess.start(QLatin1String("clientserver/clientserver server 1 1"),
QIODevice::ReadWrite | QIODevice::Text);
+ QVERIFY2(serverProcess.waitForStarted(3000),
+ qPrintable("Failed to start subprocess: " + serverProcess.errorString()));
// Wait until the server has started and reports success.
while (!serverProcess.canReadLine())
@@ -792,6 +799,9 @@ void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest()
clientProcess.start(QString::fromLatin1("clientserver/clientserver unconnectedclient %1 %2")
.arg(QLatin1String("127.0.0.1")).arg(serverPort),
QIODevice::ReadWrite | QIODevice::Text);
+ QVERIFY2(clientProcess.waitForStarted(3000),
+ qPrintable("Failed to start subprocess: " + clientProcess.errorString()));
+
// Wait until the server has started and reports success.
while (!clientProcess.canReadLine())
QVERIFY(clientProcess.waitForReadyRead(3000));
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 026c30ede5..03e77aa94f 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -137,6 +137,7 @@ private slots:
void ipv6();
void ipv6_2_data();
void ipv6_2();
+ void moreIpv6();
void toPercentEncoding_data();
void toPercentEncoding();
void isRelative_data();
@@ -2276,6 +2277,13 @@ void tst_QUrl::ipv6_2()
QCOMPARE(url.toString(), output);
}
+void tst_QUrl::moreIpv6()
+{
+ QUrl waba1("http://www.kde.org/cgi/test.cgi");
+ waba1.setHost("::ffff:129.144.52.38");
+ QCOMPARE(QString::fromLatin1(waba1.toEncoded()), QString::fromLatin1("http://[::ffff:129.144.52.38]/cgi/test.cgi"));
+}
+
void tst_QUrl::punycode_data()
{
QTest::addColumn<QString>("original");
@@ -3671,15 +3679,21 @@ void tst_QUrl::binaryData()
void tst_QUrl::fromUserInput_data()
{
+ //
+ // most of this test is:
+ // Copyright (C) Research In Motion Limited 2009. All rights reserved.
+ // Distributed under the BSD license.
+ // See qurl.cpp
+ //
+
QTest::addColumn<QString>("string");
- QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QUrl>("guessUrlFromString");
// Null
QTest::newRow("null") << QString() << QUrl();
// File
QDirIterator it(QDir::homePath());
- QString fileString;
int c = 0;
while (it.hasNext()) {
it.next();
@@ -3687,49 +3701,56 @@ void tst_QUrl::fromUserInput_data()
}
// basic latin1
- QTest::newRow("unicode-0") << QString::fromUtf8("\xC3\xA5.com/") << QUrl::fromEncoded(QString::fromUtf8("http://\xC3\xA5.com/").toUtf8(), QUrl::TolerantMode);
+ QTest::newRow("unicode-0") << QString::fromUtf8("\xc3\xa5.com/") << QUrl::fromEncoded(QString::fromUtf8("http://\xc3\xa5.com/").toUtf8(), QUrl::TolerantMode);
+ QTest::newRow("unicode-0b") << QString::fromUtf8("\xc3\xa5.com/") << QUrl::fromEncoded("http://%C3%A5.com/", QUrl::TolerantMode);
+ QTest::newRow("unicode-0c") << QString::fromUtf8("\xc3\xa5.com/") << QUrl::fromEncoded("http://xn--5ca.com/", QUrl::TolerantMode);
// unicode
- QTest::newRow("unicode-1") << QString::fromUtf8("\xCE\xBB.com/") << QUrl::fromEncoded(QString::fromUtf8("http://\xCE\xBB.com/").toUtf8(), QUrl::TolerantMode);
+ QTest::newRow("unicode-1") << QString::fromUtf8("\xce\xbb.com/") << QUrl::fromEncoded(QString::fromUtf8("http://\xce\xbb.com/").toUtf8(), QUrl::TolerantMode);
+ QTest::newRow("unicode-1b") << QString::fromUtf8("\xce\xbb.com/") << QUrl::fromEncoded("http://%CE%BB.com/", QUrl::TolerantMode);
+ QTest::newRow("unicode-1c") << QString::fromUtf8("\xce\xbb.com/") << QUrl::fromEncoded("http://xn--wxa.com/", QUrl::TolerantMode);
// no scheme
- QTest::newRow("add scheme-0") << "webkit.org" << QUrl("http://webkit.org");
- QTest::newRow("add scheme-1") << "www.webkit.org" << QUrl("http://www.webkit.org");
- QTest::newRow("add scheme-2") << "ftp.webkit.org" << QUrl("ftp://ftp.webkit.org");
- QTest::newRow("add scheme-3") << "webkit" << QUrl("webkit");
+ QTest::newRow("add scheme-0") << "example.org" << QUrl("http://example.org");
+ QTest::newRow("add scheme-1") << "www.example.org" << QUrl("http://www.example.org");
+ QTest::newRow("add scheme-2") << "ftp.example.org" << QUrl("ftp://ftp.example.org");
+ QTest::newRow("add scheme-3") << "hostname" << QUrl("http://hostname");
// QUrl's tolerant parser should already handle this
- QTest::newRow("not-encoded-0") << "http://webkit.org/test page.html" << QUrl("http://webkit.org/test%20page.html");
+ QTest::newRow("not-encoded-0") << "http://example.org/test page.html" << QUrl::fromEncoded("http://example.org/test%20page.html");
// Make sure the :80, i.e. port doesn't screw anything up
- QUrl portUrl("http://webkit.org");
+ QUrl portUrl("http://example.org");
portUrl.setPort(80);
- QTest::newRow("port-0") << "webkit.org:80" << portUrl;
- QTest::newRow("port-1") << "http://webkit.org:80" << portUrl;
+ QTest::newRow("port-0") << "example.org:80" << portUrl;
+ QTest::newRow("port-1") << "http://example.org:80" << portUrl;
+ portUrl.setPath("path");
+ QTest::newRow("port-1") << "example.org:80/path" << portUrl;
+ QTest::newRow("port-1") << "http://example.org:80/path" << portUrl;
// mailto doesn't have a ://, but is valid
- QUrl mailto("somebody@somewhere.net");
+ QUrl mailto("ben@example.net");
mailto.setScheme("mailto");
- QTest::newRow("mailto") << "mailto:somebody@somewhere.net" << mailto;
+ QTest::newRow("mailto") << "mailto:ben@example.net" << mailto;
// misc
- QTest::newRow("localhost-0") << "localhost" << QUrl("http://localhost");
QTest::newRow("localhost-1") << "localhost:80" << QUrl("http://localhost:80");
- QTest::newRow("spaces-0") << " http://webkit.org/test page.html " << QUrl("http://webkit.org/test%20page.html");
- QTest::newRow("trash-0") << "webkit.org/test?someData=42%&someOtherData=abcde#anchor" << QUrl::fromEncoded("http://webkit.org/test?someData=42%25&someOtherData=abcde#anchor");
+ QTest::newRow("spaces-0") << " http://example.org/test page.html " << QUrl("http://example.org/test%20page.html");
+ QTest::newRow("trash-0") << "example.org/test?someData=42%&someOtherData=abcde#anchor" << QUrl::fromEncoded("http://example.org/test?someData=42%25&someOtherData=abcde#anchor");
+ QTest::newRow("other-scheme-0") << "spotify:track:0hO542doVbfGDAGQULMORT" << QUrl("spotify:track:0hO542doVbfGDAGQULMORT");
+ QTest::newRow("other-scheme-1") << "weirdscheme:80:otherstuff" << QUrl("weirdscheme:80:otherstuff");
// FYI: The scheme in the resulting url user
QUrl authUrl("user:pass@domain.com");
QTest::newRow("misc-1") << "user:pass@domain.com" << authUrl;
}
-// public static QUrl guessUrlFromString(QString const& string)
void tst_QUrl::fromUserInput()
{
QFETCH(QString, string);
- QFETCH(QUrl, url);
+ QFETCH(QUrl, guessUrlFromString);
- QUrl guessedUrl = QUrl::fromUserInput(string);
- QCOMPARE(guessedUrl, url);
+ QUrl url = QUrl::fromUserInput(string);
+ QCOMPARE(url, guessUrlFromString);
}
void tst_QUrl::task_199967()
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index 9295897c1c..3d68a734db 100644
--- a/tests/auto/qvariant/tst_qvariant.cpp
+++ b/tests/auto/qvariant/tst_qvariant.cpp
@@ -270,6 +270,8 @@ private slots:
void task256984_setValue();
void numericalConvert();
+ void moreCustomTypes();
+ void variantInVariant();
};
Q_DECLARE_METATYPE(QDate)
@@ -318,6 +320,14 @@ void tst_QVariant::constructor()
QVariant var6(qlonglong(0));
QCOMPARE(var6.type(), QVariant::LongLong);
QCOMPARE(var6.typeName(), "qlonglong");
+
+ QVariant var7 = 5;
+ QVERIFY(var7.isValid());
+ QVERIFY(!var7.isNull());
+ QVariant var8;
+ var8.setValue<int>(5);
+ QVERIFY(var8.isValid());
+ QVERIFY(!var8.isNull());
}
void tst_QVariant::copy_constructor()
@@ -1422,8 +1432,10 @@ void tst_QVariant::matrix4x4()
QVariant variant;
QMatrix4x4 matrix = qVariantValue<QMatrix4x4>(variant);
QVERIFY(matrix.isIdentity());
- qVariantSetValue(variant, QMatrix4x4().scale(2.0));
- QCOMPARE(QMatrix4x4().scale(2.0), qVariantValue<QMatrix4x4>(variant));
+ QMatrix4x4 m;
+ m.scale(2.0f);
+ qVariantSetValue(variant, m);
+ QCOMPARE(m, qVariantValue<QMatrix4x4>(variant));
void *mmatrix = QMetaType::construct(QVariant::Matrix4x4, 0);
QVERIFY(mmatrix);
@@ -3127,7 +3139,254 @@ void tst_QVariant::numericalConvert()
}
+template<class T> void playWithVariant(const T &orig, bool isNull, const QString &toString, double toDouble, bool toBool)
+{
+ QVariant v = QVariant::fromValue(orig);
+ QVERIFY(v.isValid());
+ QCOMPARE(v.isNull(), isNull);
+ QCOMPARE(v.toString(), toString);
+ QCOMPARE(v.toDouble(), toDouble);
+ QCOMPARE(v.toBool(), toBool);
+ QCOMPARE(qvariant_cast<T>(v), orig);
+
+ {
+ QVariant v2 = v;
+ QCOMPARE(v2, v);
+ QVERIFY(v2.isValid());
+ QCOMPARE(v2.isNull(), isNull);
+ QCOMPARE(v2.toString(), toString);
+ QCOMPARE(v2.toDouble(), toDouble);
+ QCOMPARE(v2.toBool(), toBool);
+ QCOMPARE(qvariant_cast<T>(v2), orig);
+
+ QVariant v3;
+ v = QVariant();
+ QCOMPARE(v3, v);
+ v = v2;
+ QCOMPARE(v, v2);
+ QCOMPARE(qvariant_cast<T>(v2), qvariant_cast<T>(v));
+ QCOMPARE(v2.toString(), toString);
+ v3 = qVariantFromValue(orig);
+
+ QVERIFY(v3.isValid());
+ QCOMPARE(v3.isNull(), isNull);
+ QCOMPARE(v3.toString(), toString);
+ QCOMPARE(v3.toDouble(), toDouble);
+ QCOMPARE(v3.toBool(), toBool);
+ QCOMPARE(qvariant_cast<T>(v3), qvariant_cast<T>(v));
+ }
+
+ QVERIFY(v.isValid());
+ QCOMPARE(v.isNull(), isNull);
+ QCOMPARE(v.toString(), toString);
+ QCOMPARE(v.toDouble(), toDouble);
+ QCOMPARE(v.toBool(), toBool);
+ QCOMPARE(qvariant_cast<T>(v), orig);
+
+ if (qMetaTypeId<T>() != qMetaTypeId<QVariant>()) {
+ QCOMPARE(v.userType(), qMetaTypeId<T>());
+ QCOMPARE(QVariant::typeToName(QVariant::Type(v.userType())), QMetaType::typeName(qMetaTypeId<T>()));
+ }
+}
+
+
+struct MyPrimitive
+{
+ char x, y;
+ bool operator==(const MyPrimitive &o) const
+ {
+ return x == o.x && y == o.y;
+ }
+};
+Q_DECLARE_TYPEINFO(MyPrimitive, Q_PRIMITIVE_TYPE);
+
+struct MyData
+{
+ void *ptr;
+ MyData() : ptr(this) {}
+ ~MyData() { Q_ASSERT(ptr == this); }
+ MyData(const MyData& o) : ptr(this) { Q_ASSERT(o.ptr == &o); }
+ MyData &operator=(const MyData &o)
+ {
+ Q_ASSERT(ptr == this);
+ Q_ASSERT(o.ptr == &o);
+ return *this;
+ }
+ bool operator==(const MyData &o) const
+ {
+ Q_ASSERT(ptr == this);
+ Q_ASSERT(o.ptr == &o);
+ return true;
+ }
+};
+
+struct MyMovable
+{
+ static int count;
+ int v;
+ MyMovable() { v = count++; }
+ ~MyMovable() { count--; }
+ MyMovable(const MyMovable &o) : v(o.v) { count++; }
+
+ bool operator==(const MyMovable &o) const
+ {
+ return v == o.v;
+ }
+};
+
+int MyMovable::count = 0;
+
+
+Q_DECLARE_TYPEINFO(MyMovable, Q_MOVABLE_TYPE);
+
+Q_DECLARE_METATYPE(QList<QSize>)
+Q_DECLARE_METATYPE(MyPrimitive)
+Q_DECLARE_METATYPE(MyData)
+Q_DECLARE_METATYPE(MyMovable)
+Q_DECLARE_METATYPE(QList<MyPrimitive>)
+Q_DECLARE_METATYPE(QList<MyData>)
+Q_DECLARE_METATYPE(QList<MyMovable>)
+Q_DECLARE_METATYPE(MyPrimitive *)
+Q_DECLARE_METATYPE(MyData *)
+Q_DECLARE_METATYPE(MyMovable *)
+void tst_QVariant::moreCustomTypes()
+{
+ {
+ QList<QSize> listSize;
+ playWithVariant(listSize, false, QString(), 0, false);
+ listSize << QSize(4,5) << QSize(89,23) << QSize(5,6);
+ playWithVariant(listSize, false, QString(), 0, false);
+ }
+
+ {
+ QString str;
+ playWithVariant(str, true, QString(), 0, false);
+ str = QString::fromLatin1("123456789.123");
+ playWithVariant(str, false, str, 123456789.123, true);
+ }
+
+ {
+ QSize size;
+ playWithVariant(size, false, QString(), 0, false);
+ playWithVariant(QSize(45,78), false, QString(), 0, false);
+ }
+
+ {
+ MyData d;
+ playWithVariant(d, false, QString(), 0, false);
+ playWithVariant(&d, false, QString(), 0, false);
+ QList<MyData> l;
+ playWithVariant(l, false, QString(), 0, false);
+ l << MyData() << MyData();
+ playWithVariant(l, false, QString(), 0, false);
+ }
+
+ {
+ MyPrimitive d = { 4, 5 };
+ playWithVariant(d, false, QString(), 0, false);
+ playWithVariant(&d, false, QString(), 0, false);
+ QList<MyPrimitive> l;
+ playWithVariant(l, false, QString(), 0, false);
+ l << d;
+ playWithVariant(l, false, QString(), 0, false);
+ }
+
+ {
+ MyMovable d;
+ playWithVariant(d, false, QString(), 0, false);
+ playWithVariant(&d, false, QString(), 0, false);
+ QList<MyMovable> l;
+ playWithVariant(l, false, QString(), 0, false);
+ l << MyMovable() << d;
+ playWithVariant(l, false, QString(), 0, false);
+ }
+ QCOMPARE(MyMovable::count, 0);
+
+ {
+ playWithVariant(12.12, false, "12.12", 12.12, true);
+ playWithVariant(12.12f, false, "12.12", 12.12f, true);
+ playWithVariant('a', false, "a", 'a', true);
+ playWithVariant((unsigned char)('a'), false, "a", 'a', true);
+ playWithVariant( quint8(12), false, "\xc", 12, true);
+ playWithVariant( qint8(13), false, "\xd", 13, true);
+ playWithVariant(quint16(14), false, "14", 14, true);
+ playWithVariant( qint16(15), false, "15", 15, true);
+ playWithVariant(quint32(16), false, "16", 16, true);
+ playWithVariant( qint32(17), false, "17", 17, true);
+ playWithVariant(quint64(18), false, "18", 18, true);
+ playWithVariant( qint64(19), false, "19", 19, true);
+ playWithVariant( qint8(-12), false, "\xf4", -12, true);
+ playWithVariant( qint16(-13), false, "-13", -13, true);
+ playWithVariant( qint32(-14), false, "-14", -14, true);
+ playWithVariant( qint64(-15), false, "-15", -15, true);
+ playWithVariant(quint64(0), false, "0", 0, false);
+ playWithVariant( true, false, "true", 1, true);
+ playWithVariant( false, false, "false", 0, false);
+
+ playWithVariant(QString("hello\n"), false, "hello\n", 0, true);
+ }
+
+ {
+ int i = 5;
+ playWithVariant((void *)(&i), false, QString(), 0, false);
+ playWithVariant((void *)(0), false, QString(), 0, false);
+ }
+
+ {
+ QVariant v1 = QVariant::fromValue(5);
+ QVariant v2 = QVariant::fromValue(5.0);
+ QVariant v3 = QVariant::fromValue(quint16(5));
+ QVariant v4 = 5;
+ QVariant v5 = QVariant::fromValue(MyPrimitive());
+ QVariant v6 = QVariant::fromValue(MyMovable());
+ QVariant v7 = QVariant::fromValue(MyData());
+ playWithVariant(v1, false, "5", 5, true);
+ playWithVariant(v2, false, "5", 5, true);
+ playWithVariant(v3, false, "5", 5, true);
+ playWithVariant(v4, false, "5", 5, true);
+
+ playWithVariant(v5, false, QString(), 0, false);
+ }
+}
+
+
+void tst_QVariant::variantInVariant()
+{
+ QVariant var1 = 5;
+ QCOMPARE(var1.type(), QVariant::Int);
+ QVariant var2 = var1;
+ QCOMPARE(var2, var1);
+ QCOMPARE(var2.type(), QVariant::Int);
+ QVariant var3 = QVariant::fromValue(var1);
+ QCOMPARE(var3, var1);
+ QCOMPARE(var3.type(), QVariant::Int);
+ QVariant var4 = qvariant_cast<QVariant>(var1);
+ QCOMPARE(var4, var1);
+ QCOMPARE(var4.type(), QVariant::Int);
+ QVariant var5;
+ var5 = var1;
+ QCOMPARE(var5, var1);
+ QCOMPARE(var5.type(), QVariant::Int);
+ QVariant var6;
+ var6.setValue(var1);
+ QCOMPARE(var6, var1);
+ QCOMPARE(var6.type(), QVariant::Int);
+
+ QCOMPARE(QVariant::fromValue(var1), QVariant::fromValue(var2));
+ QCOMPARE(qvariant_cast<QVariant>(var3), QVariant::fromValue(var4));
+ QCOMPARE(qvariant_cast<QVariant>(var5), qvariant_cast<QVariant>(var6));
+
+ QString str("hello");
+ QVariant var8 = qvariant_cast<QVariant>(QVariant::fromValue(QVariant::fromValue(str)));
+ QCOMPARE((int)var8.type(), (int)QVariant::String);
+ QCOMPARE(qvariant_cast<QString>(QVariant(qvariant_cast<QVariant>(var8))), str);
+
+ QVariant var9(qMetaTypeId<QVariant>(), &var1);
+ QCOMPARE(var9.userType(), qMetaTypeId<QVariant>());
+ QCOMPARE(qvariant_cast<QVariant>(var9), var1);
+}
+
QTEST_MAIN(tst_QVariant)
#include "tst_qvariant.moc"
diff --git a/tests/auto/qvideoframe/tst_qvideoframe.cpp b/tests/auto/qvideoframe/tst_qvideoframe.cpp
index b231069f88..432ef5cf1d 100644
--- a/tests/auto/qvideoframe/tst_qvideoframe.cpp
+++ b/tests/auto/qvideoframe/tst_qvideoframe.cpp
@@ -524,7 +524,7 @@ void tst_QVideoFrame::assign()
void tst_QVideoFrame::map_data()
{
QTest::addColumn<QSize>("size");
- QTest::addColumn<int>("numBytes");
+ QTest::addColumn<int>("mappedBytes");
QTest::addColumn<int>("bytesPerLine");
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
QTest::addColumn<QAbstractVideoBuffer::MapMode>("mode");
@@ -554,29 +554,29 @@ void tst_QVideoFrame::map_data()
void tst_QVideoFrame::map()
{
QFETCH(QSize, size);
- QFETCH(int, numBytes);
+ QFETCH(int, mappedBytes);
QFETCH(int, bytesPerLine);
QFETCH(QVideoFrame::PixelFormat, pixelFormat);
QFETCH(QAbstractVideoBuffer::MapMode, mode);
- QVideoFrame frame(numBytes, size, bytesPerLine, pixelFormat);
+ QVideoFrame frame(mappedBytes, size, bytesPerLine, pixelFormat);
QVERIFY(!frame.bits());
- QCOMPARE(frame.numBytes(), 0);
+ QCOMPARE(frame.mappedBytes(), 0);
QCOMPARE(frame.bytesPerLine(), 0);
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
QVERIFY(frame.map(mode));
QVERIFY(frame.bits());
- QCOMPARE(frame.numBytes(), numBytes);
+ QCOMPARE(frame.mappedBytes(), mappedBytes);
QCOMPARE(frame.bytesPerLine(), bytesPerLine);
QCOMPARE(frame.mapMode(), mode);
frame.unmap();
QVERIFY(!frame.bits());
- QCOMPARE(frame.numBytes(), 0);
+ QCOMPARE(frame.mappedBytes(), 0);
QCOMPARE(frame.bytesPerLine(), 0);
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
}
@@ -614,21 +614,21 @@ void tst_QVideoFrame::mapImage()
QVideoFrame frame(image);
QVERIFY(!frame.bits());
- QCOMPARE(frame.numBytes(), 0);
+ QCOMPARE(frame.mappedBytes(), 0);
QCOMPARE(frame.bytesPerLine(), 0);
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
QVERIFY(frame.map(mode));
QVERIFY(frame.bits());
- QCOMPARE(frame.numBytes(), image.numBytes());
+ QCOMPARE(frame.mappedBytes(), image.numBytes());
QCOMPARE(frame.bytesPerLine(), image.bytesPerLine());
QCOMPARE(frame.mapMode(), mode);
frame.unmap();
QVERIFY(!frame.bits());
- QCOMPARE(frame.numBytes(), 0);
+ QCOMPARE(frame.mappedBytes(), 0);
QCOMPARE(frame.bytesPerLine(), 0);
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
}
diff --git a/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp b/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp
index bc6fe68cc6..2b78d200fe 100644
--- a/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp
+++ b/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp
@@ -68,8 +68,8 @@ private slots:
void scanLineDirection();
void frameRate_data();
void frameRate();
- void yuvColorSpace_data();
- void yuvColorSpace();
+ void yCbCrColorSpace_data();
+ void yCbCrColorSpace();
void pixelAspectRatio_data();
void pixelAspectRatio();
void sizeHint_data();
@@ -81,9 +81,6 @@ private slots:
void assign();
};
-Q_DECLARE_METATYPE(QVideoSurfaceFormat::ViewportMode)
-
-
tst_QVideoSurfaceFormat::tst_QVideoSurfaceFormat()
{
}
@@ -120,9 +117,9 @@ void tst_QVideoSurfaceFormat::constructNull()
QCOMPARE(format.frameHeight(), -1);
QCOMPARE(format.viewport(), QRect());
QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
- QCOMPARE(format.frameRate(), QVideoSurfaceFormat::FrameRate());
+ QCOMPARE(format.frameRate(), 0.0);
QCOMPARE(format.pixelAspectRatio(), QSize(1, 1));
- QCOMPARE(format.yuvColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined);
+ QCOMPARE(format.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined);
}
void tst_QVideoSurfaceFormat::construct_data()
@@ -159,9 +156,9 @@ void tst_QVideoSurfaceFormat::construct()
QCOMPARE(format.frameHeight(), frameSize.height());
QCOMPARE(format.viewport(), viewport);
QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
- QCOMPARE(format.frameRate(), QVideoSurfaceFormat::FrameRate());
+ QCOMPARE(format.frameRate(), 0.0);
QCOMPARE(format.pixelAspectRatio(), QSize(1, 1));
- QCOMPARE(format.yuvColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined);
+ QCOMPARE(format.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined);
}
void tst_QVideoSurfaceFormat::frameSize_data()
@@ -202,45 +199,23 @@ void tst_QVideoSurfaceFormat::viewport_data()
QTest::addColumn<QSize>("initialSize");
QTest::addColumn<QRect>("viewport");
QTest::addColumn<QSize>("newSize");
- QTest::addColumn<QVideoSurfaceFormat::ViewportMode>("viewportMode");
QTest::addColumn<QRect>("expectedViewport");
QTest::newRow("grow reset")
<< QSize(64, 64)
<< QRect(8, 8, 48, 48)
<< QSize(1024, 1024)
- << QVideoSurfaceFormat::ResetViewport
<< QRect(0, 0, 1024, 1024);
- QTest::newRow("grow keep")
- << QSize(64, 64)
- << QRect(8, 8, 48, 48)
- << QSize(1024, 1024)
- << QVideoSurfaceFormat::KeepViewport
- << QRect(8, 8, 48, 48);
QTest::newRow("shrink reset")
<< QSize(1024, 1024)
<< QRect(8, 8, 1008, 1008)
<< QSize(64, 64)
- << QVideoSurfaceFormat::ResetViewport
<< QRect(0, 0, 64, 64);
- QTest::newRow("shrink keep")
- << QSize(1024, 1024)
- << QRect(8, 8, 1008, 1008)
- << QSize(64, 64)
- << QVideoSurfaceFormat::KeepViewport
- << QRect(8, 8, 56, 56);
QTest::newRow("unchanged reset")
<< QSize(512, 512)
<< QRect(8, 8, 496, 496)
<< QSize(512, 512)
- << QVideoSurfaceFormat::ResetViewport
<< QRect(0, 0, 512, 512);
- QTest::newRow("unchanged keep")
- << QSize(512, 512)
- << QRect(8, 8, 496, 496)
- << QSize(512, 512)
- << QVideoSurfaceFormat::KeepViewport
- << QRect(8, 8, 496, 496);
}
void tst_QVideoSurfaceFormat::viewport()
@@ -248,7 +223,6 @@ void tst_QVideoSurfaceFormat::viewport()
QFETCH(QSize, initialSize);
QFETCH(QRect, viewport);
QFETCH(QSize, newSize);
- QFETCH(QVideoSurfaceFormat::ViewportMode, viewportMode);
QFETCH(QRect, expectedViewport);
{
@@ -261,7 +235,7 @@ void tst_QVideoSurfaceFormat::viewport()
QCOMPARE(format.viewport(), viewport);
QCOMPARE(format.property("viewport").toRect(), viewport);
- format.setFrameSize(newSize, viewportMode);
+ format.setFrameSize(newSize);
QCOMPARE(format.viewport(), expectedViewport);
QCOMPARE(format.property("viewport").toRect(), expectedViewport);
@@ -315,21 +289,21 @@ void tst_QVideoSurfaceFormat::scanLineDirection()
void tst_QVideoSurfaceFormat::frameRate_data()
{
- QTest::addColumn<QVideoSurfaceFormat::FrameRate>("frameRate");
+ QTest::addColumn<qreal>("frameRate");
QTest::newRow("null")
- << QVideoSurfaceFormat::FrameRate(0, 0);
+ << qreal(0.0);
QTest::newRow("1/1")
- << QVideoSurfaceFormat::FrameRate(1, 1);
+ << qreal(1.0);
QTest::newRow("24/1")
- << QVideoSurfaceFormat::FrameRate(24, 1);
+ << qreal(24.0);
QTest::newRow("15/2")
- << QVideoSurfaceFormat::FrameRate(15, 2);
+ << qreal(7.5);
}
void tst_QVideoSurfaceFormat::frameRate()
{
- QFETCH(QVideoSurfaceFormat::FrameRate, frameRate);
+ QFETCH(qreal, frameRate);
{
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
@@ -337,35 +311,22 @@ void tst_QVideoSurfaceFormat::frameRate()
format.setFrameRate(frameRate);
QCOMPARE(format.frameRate(), frameRate);
- QCOMPARE(qvariant_cast<QVideoSurfaceFormat::FrameRate>(format.property("frameRate")),
- frameRate);
- }
- {
- QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
-
- format.setFrameRate(frameRate.first, frameRate.second);
-
- QCOMPARE(format.frameRate(), frameRate);
- QCOMPARE(
- qvariant_cast<QVideoSurfaceFormat::FrameRate>(format.property("frameRate")),
- frameRate);
+ QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate);
}
{
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
format.setFrameRate(frameRate);
- format.setProperty(
- "frameRate", qVariantFromValue<QVideoSurfaceFormat::FrameRate>(frameRate));
+ format.setProperty("frameRate", frameRate);
QCOMPARE(format.frameRate(), frameRate);
- QCOMPARE(qvariant_cast<QVideoSurfaceFormat::FrameRate>(format.property("frameRate")),
- frameRate);
+ QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate);
}
}
-void tst_QVideoSurfaceFormat::yuvColorSpace_data()
+void tst_QVideoSurfaceFormat::yCbCrColorSpace_data()
{
- QTest::addColumn<QVideoSurfaceFormat::YuvColorSpace>("colorspace");
+ QTest::addColumn<QVideoSurfaceFormat::YCbCrColorSpace>("colorspace");
QTest::newRow("undefined")
<< QVideoSurfaceFormat::YCbCr_Undefined;
@@ -377,24 +338,24 @@ void tst_QVideoSurfaceFormat::yuvColorSpace_data()
<< QVideoSurfaceFormat::YCbCr_JPEG;
}
-void tst_QVideoSurfaceFormat::yuvColorSpace()
+void tst_QVideoSurfaceFormat::yCbCrColorSpace()
{
- QFETCH(QVideoSurfaceFormat::YuvColorSpace, colorspace);
+ QFETCH(QVideoSurfaceFormat::YCbCrColorSpace, colorspace);
{
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
- format.setYuvColorSpace(colorspace);
+ format.setYCbCrColorSpace(colorspace);
- QCOMPARE(format.yuvColorSpace(), colorspace);
- QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YuvColorSpace>(format.property("yuvColorSpace")),
+ QCOMPARE(format.yCbCrColorSpace(), colorspace);
+ QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")),
colorspace);
}
{
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
- format.setProperty("yuvColorSpace", qVariantFromValue(colorspace));
+ format.setProperty("yCbCrColorSpace", qVariantFromValue(colorspace));
- QCOMPARE(format.yuvColorSpace(), colorspace);
- QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YuvColorSpace>(format.property("yuvColorSpace")),
+ QCOMPARE(format.yCbCrColorSpace(), colorspace);
+ QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")),
colorspace);
}
}
@@ -496,7 +457,7 @@ void tst_QVideoSurfaceFormat::staticPropertyNames()
QVERIFY(propertyNames.contains("scanLineDirection"));
QVERIFY(propertyNames.contains("frameRate"));
QVERIFY(propertyNames.contains("pixelAspectRatio"));
- QVERIFY(propertyNames.contains("yuvColorSpace"));
+ QVERIFY(propertyNames.contains("yCbCrColorSpace"));
QVERIFY(propertyNames.contains("sizeHint"));
QCOMPARE(propertyNames.count(), 10);
}
@@ -579,19 +540,26 @@ void tst_QVideoSurfaceFormat::compare()
QCOMPARE(format1 == format4, false);
QCOMPARE(format1 != format4, true);
- format2.setFrameSize(1024, 768, QVideoSurfaceFormat::ResetViewport);
+ format2.setFrameSize(1024, 768);
// Not equal, frame size differs.
QCOMPARE(format1 == format2, false);
QCOMPARE(format1 != format2, true);
- format1.setFrameSize(1024, 768, QVideoSurfaceFormat::KeepViewport);
+ format1.setFrameSize(1024, 768);
+
+ // Equal.
+ QCOMPARE(format1 == format2, true);
+ QCOMPARE(format1 != format2, false);
+
+ format1.setViewport(QRect(0, 0, 800, 600));
+ format2.setViewport(QRect(112, 84, 800, 600));
- // Not equal, viewport differs.
+ // Not equal, viewports differ.
QCOMPARE(format1 == format2, false);
QCOMPARE(format1 != format2, true);
- format1.setViewport(QRect(0, 0, 1024, 768));
+ format1.setViewport(QRect(112, 84, 800, 600));
// Equal.
QCOMPARE(format1 == format2, true);
@@ -609,13 +577,13 @@ void tst_QVideoSurfaceFormat::compare()
QCOMPARE(format1 == format2, true);
QCOMPARE(format1 != format2, false);
- format1.setFrameRate(QVideoSurfaceFormat::FrameRate(15, 2));
+ format1.setFrameRate(7.5);
// Not equal frame rate differs.
QCOMPARE(format1 == format2, false);
QCOMPARE(format1 != format2, true);
- format2.setFrameRate(15, 2);
+ format2.setFrameRate(qreal(7.50001));
// Equal.
QCOMPARE(format1 == format2, true);
@@ -633,13 +601,13 @@ void tst_QVideoSurfaceFormat::compare()
QCOMPARE(format1 == format2, true);
QCOMPARE(format1 != format2, false);
- format2.setYuvColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601);
+ format2.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601);
// Not equal yuv color space differs.
QCOMPARE(format1 == format2, false);
QCOMPARE(format1 != format2, true);
- format1.setYuvColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601);
+ format1.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601);
// Equal.
QCOMPARE(format1 == format2, true);
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index f8341c3243..9692c6e4cf 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -69,6 +69,9 @@
#include <QtGui/qpaintengine.h>
#include <private/qbackingstore_p.h>
+#include <QtGui/QGraphicsView>
+#include <QtGui/QGraphicsProxyWidget>
+
#include "../../shared/util.h"
@@ -239,7 +242,12 @@ private slots:
void setFixedSize();
void ensureCreated();
+ void winIdChangeEvent();
+#ifdef Q_OS_SYMBIAN
+ void reparentCausesChildWinIdChange();
+#else
void persistentWinId();
+#endif
void qobject_castInDestroyedSlot();
void showHideEvent_data();
@@ -285,6 +293,7 @@ private slots:
#ifdef Q_WS_X11
void minAndMaxSizeWithX11BypassWindowManagerHint();
void showHideShow();
+ void clean_qt_x11_enforce_cursor();
#endif
void compatibilityChildInsertedEvents();
@@ -323,6 +332,7 @@ private slots:
void doubleRepaint();
#ifndef Q_WS_MAC
void resizeInPaintEvent();
+ void opaqueChildren();
#endif
void setMaskInResizeEvent();
@@ -378,6 +388,8 @@ private slots:
void cbaVisibility();
#endif
+ void focusProxyAndInputMethods();
+
private:
bool ensureScreenSize(int width, int height);
QWidget *testWidget;
@@ -2973,7 +2985,7 @@ void tst_QWidget::stackUnder()
qApp->processEvents();
#endif
#ifndef Q_WS_MAC
- QEXPECT_FAIL(0, "Task 153869", Continue);
+ QEXPECT_FAIL(0, "See QTBUG-493", Continue);
#endif
QCOMPARE(child->numPaintEvents, 0);
} else {
@@ -3318,9 +3330,10 @@ void tst_QWidget::widgetAt()
w2->lower();
qApp->processEvents();
QTRY_VERIFY((wr = QApplication::widgetAt(100, 100)));
- QCOMPARE(wr->objectName(), QString("w1"));
-
+ const bool match = (wr->objectName() == QString("w1"));
w2->raise();
+ QVERIFY(match);
+
qApp->processEvents();
QTRY_VERIFY((wr = QApplication::widgetAt(100, 100)));
QCOMPARE(wr->objectName(), QString("w2"));
@@ -4348,6 +4361,161 @@ void tst_QWidget::ensureCreated()
}
}
+class WinIdChangeWidget : public QWidget {
+public:
+ WinIdChangeWidget(QWidget *p = 0)
+ : QWidget(p)
+ , m_winIdChangeEventCount(0)
+ {
+
+ }
+protected:
+ bool event(QEvent *e)
+ {
+ if (e->type() == QEvent::WinIdChange) {
+ ++m_winIdChangeEventCount;
+ return true;
+ }
+ return QWidget::event(e);
+ }
+public:
+ int m_winIdChangeEventCount;
+};
+
+void tst_QWidget::winIdChangeEvent()
+{
+ {
+ // Transforming an alien widget into a native widget
+ WinIdChangeWidget widget;
+ const WId winIdBefore = widget.internalWinId();
+ const WId winIdAfter = widget.winId();
+ QVERIFY(winIdBefore != winIdAfter);
+ QCOMPARE(widget.m_winIdChangeEventCount, 1);
+ }
+
+ {
+ // Changing parent of a native widget
+ // Should cause winId of child to change, on all platforms
+ QWidget parent1, parent2;
+ WinIdChangeWidget child(&parent1);
+ const WId winIdBefore = child.winId();
+ QCOMPARE(child.m_winIdChangeEventCount, 1);
+ child.setParent(&parent2);
+ const WId winIdAfter = child.internalWinId();
+ QVERIFY(winIdBefore != winIdAfter);
+ QCOMPARE(child.m_winIdChangeEventCount, 2);
+ }
+
+ {
+ // Changing grandparent of a native widget
+ // Should cause winId of grandchild to change only on Symbian
+ QWidget grandparent1, grandparent2;
+ QWidget parent(&grandparent1);
+ WinIdChangeWidget child(&parent);
+ const WId winIdBefore = child.winId();
+ QCOMPARE(child.m_winIdChangeEventCount, 1);
+ parent.setParent(&grandparent2);
+ const WId winIdAfter = child.internalWinId();
+#ifdef Q_OS_SYMBIAN
+ QVERIFY(winIdBefore != winIdAfter);
+ QCOMPARE(child.m_winIdChangeEventCount, 2);
+#else
+ QCOMPARE(winIdBefore, winIdAfter);
+ QCOMPARE(child.m_winIdChangeEventCount, 1);
+#endif
+ }
+
+ {
+ // Changing parent of an alien widget
+ QWidget parent1, parent2;
+ WinIdChangeWidget child(&parent1);
+ const WId winIdBefore = child.internalWinId();
+ child.setParent(&parent2);
+ const WId winIdAfter = child.internalWinId();
+ QCOMPARE(winIdBefore, winIdAfter);
+ QCOMPARE(child.m_winIdChangeEventCount, 0);
+ }
+
+ {
+ // Making native child widget into a top-level window
+ QWidget parent;
+ WinIdChangeWidget child(&parent);
+ child.winId();
+ const WId winIdBefore = child.internalWinId();
+ QCOMPARE(child.m_winIdChangeEventCount, 1);
+ const Qt::WindowFlags flags = child.windowFlags();
+ child.setWindowFlags(flags | Qt::Window);
+ const WId winIdAfter = child.internalWinId();
+ QVERIFY(winIdBefore != winIdAfter);
+ QCOMPARE(child.m_winIdChangeEventCount, 2);
+ }
+}
+
+#ifdef Q_OS_SYMBIAN
+void tst_QWidget::reparentCausesChildWinIdChange()
+{
+ QWidget *parent = new QWidget;
+ QWidget *w1 = new QWidget;
+ QWidget *w2 = new QWidget;
+ QWidget *w3 = new QWidget;
+ w1->setParent(parent);
+ w2->setParent(w1);
+ w3->setParent(w2);
+
+ WId winId1 = w1->winId();
+ WId winId2 = w2->winId();
+ WId winId3 = w3->winId();
+
+ // reparenting causes winIds of the widget being reparented, and all of its children, to change
+ w1->setParent(0);
+ QVERIFY(w1->winId() != winId1);
+ winId1 = w1->winId();
+ QVERIFY(w2->winId() != winId2);
+ winId2 = w2->winId();
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w1->setParent(parent);
+ QVERIFY(w1->winId() != winId1);
+ winId1 = w1->winId();
+ QVERIFY(w2->winId() != winId2);
+ winId2 = w2->winId();
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w2->setParent(0);
+ QVERIFY(w2->winId() != winId2);
+ winId2 = w2->winId();
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w2->setParent(parent);
+ QVERIFY(w2->winId() != winId2);
+ winId2 = w2->winId();
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w2->setParent(w1);
+ QVERIFY(w2->winId() != winId2);
+ winId2 = w2->winId();
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w3->setParent(0);
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w3->setParent(w1);
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w3->setParent(w2);
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ delete parent;
+}
+#else
void tst_QWidget::persistentWinId()
{
QWidget *parent = new QWidget;
@@ -4404,6 +4572,7 @@ void tst_QWidget::persistentWinId()
delete parent;
}
+#endif // Q_OS_SYMBIAN
class ShowHideEventWidget : public QWidget
{
@@ -4524,9 +4693,6 @@ void tst_QWidget::update()
QCOMPARE(child.paintedRegion, child.visibleRegion());
QCOMPARE(w.numPaintEvents, 1);
QCOMPARE(w.visibleRegion(), QRegion(w.rect()));
-#ifdef QT_MAC_USE_COCOA
- QEXPECT_FAIL(0, "Cocoa compositor paints the content view", Continue);
-#endif
QCOMPARE(w.paintedRegion, child.visibleRegion().translated(childOffset));
w.reset();
@@ -5136,15 +5302,6 @@ void tst_QWidget::windowMoveResize()
// now hide
widget.hide();
QTest::qWait(10);
-#if defined (Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
- QEXPECT_FAIL("130,100 0x200, flags 800",
- "Cocoa's Delegate sends a spurios move event when the window has a width of zero and non-zero height",
- Abort);
-
- QEXPECT_FAIL("130,100 0x200, flags 0",
- "Cocoa's Delegate sends a spurios move event when the window has a width of zero and non-zero height",
- Abort);
-#endif
QTRY_COMPARE(widget.pos(), rect.topLeft());
QTRY_COMPARE(widget.size(), rect.size());
@@ -6060,6 +6217,35 @@ void tst_QWidget::showHideShow()
QVERIFY(w.gotExpectedMapNotify);
}
+
+void tst_QWidget::clean_qt_x11_enforce_cursor()
+{
+ {
+ QWidget window;
+ QWidget *w = new QWidget(&window);
+ QWidget *child = new QWidget(w);
+ child->setAttribute(Qt::WA_SetCursor, true);
+
+ window.show();
+ QApplication::setActiveWindow(&window);
+ QTest::qWaitForWindowShown(&window);
+ QTest::qWait(100);
+ QCursor::setPos(window.geometry().center());
+ QTest::qWait(100);
+
+ child->setFocus();
+ QApplication::processEvents();
+ QTest::qWait(100);
+
+ delete w;
+ }
+
+ QGraphicsScene scene;
+ QLineEdit *edit = new QLineEdit;
+ scene.addWidget(edit);
+
+ // If the test didn't crash, then it passed.
+}
#endif
class EventRecorder : public QObject
@@ -6137,6 +6323,7 @@ void tst_QWidget::compatibilityChildInsertedEvents()
widget.show();
expected =
EventRecorder::EventList()
+ << qMakePair(&widget, QEvent::WinIdChange)
<< qMakePair(&widget, QEvent::Polish)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
@@ -6222,6 +6409,7 @@ void tst_QWidget::compatibilityChildInsertedEvents()
widget.show();
expected =
EventRecorder::EventList()
+ << qMakePair(&widget, QEvent::WinIdChange)
<< qMakePair(&widget, QEvent::Polish)
#ifdef QT_HAS_QT3SUPPORT
<< qMakePair(&widget, QEvent::ChildInserted)
@@ -6319,6 +6507,7 @@ void tst_QWidget::compatibilityChildInsertedEvents()
widget.show();
expected =
EventRecorder::EventList()
+ << qMakePair(&widget, QEvent::WinIdChange)
<< qMakePair(&widget, QEvent::Polish)
#ifdef QT_HAS_QT3SUPPORT
<< qMakePair(&widget, QEvent::ChildInserted)
@@ -7466,16 +7655,16 @@ void tst_QWidget::updateWhileMinimized()
UpdateWidget widget;
// Filter out activation change and focus events to avoid update() calls in QWidget.
widget.updateOnActivationChangeAndFocusIn = false;
- widget.show();
widget.reset();
+ widget.show();
QTest::qWaitForWindowShown(&widget);
QApplication::processEvents();
QTRY_VERIFY(widget.numPaintEvents > 0);
- QTest::qWait(50);
+ QTest::qWait(150);
// Minimize window.
widget.showMinimized();
- QTest::qWait(70);
+ QTest::qWait(110);
widget.reset();
@@ -8090,6 +8279,47 @@ void tst_QWidget::resizeInPaintEvent()
// Make sure the resize triggers another update.
QTRY_COMPARE(widget.numPaintEvents, 1);
}
+
+void tst_QWidget::opaqueChildren()
+{
+ QWidget widget;
+ widget.resize(200, 200);
+
+ QWidget child(&widget);
+ child.setGeometry(-700, -700, 200, 200);
+
+ QWidget grandChild(&child);
+ grandChild.resize(200, 200);
+
+ QWidget greatGrandChild(&grandChild);
+ greatGrandChild.setGeometry(50, 50, 200, 200);
+ greatGrandChild.setPalette(Qt::red);
+ greatGrandChild.setAutoFillBackground(true); // Opaque child widget.
+
+ widget.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&widget);
+#endif
+ QTest::qWait(100);
+
+ // Child, grandChild and greatGrandChild are outside the ancestor clip.
+ QRegion expectedOpaqueRegion(50, 50, 150, 150);
+ QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), expectedOpaqueRegion);
+
+ // Now they are all inside the ancestor clip.
+ child.setGeometry(50, 50, 150, 150);
+ QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), expectedOpaqueRegion);
+
+ // Set mask on greatGrandChild.
+ const QRegion mask(10, 10, 50, 50);
+ greatGrandChild.setMask(mask);
+ expectedOpaqueRegion &= mask.translated(50, 50);
+ QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), expectedOpaqueRegion);
+
+ // Make greatGrandChild "transparent".
+ greatGrandChild.setAutoFillBackground(false);
+ QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), QRegion());
+}
#endif
@@ -8176,7 +8406,7 @@ public:
static bool firstTime = true;
if (firstTime)
- QTimer::singleShot(150, this, SLOT(resizeMe()));
+ QTimer::singleShot(250, this, SLOT(resizeMe()));
firstTime = false;
}
@@ -8193,7 +8423,7 @@ void tst_QWidget::moveInResizeEvent()
testWidget.setGeometry(50, 50, 200, 200);
testWidget.show();
QTest::qWaitForWindowShown(&testWidget);
- QTest::qWait(160);
+ QTest::qWait(300);
QRect expectedGeometry(100,100, 100, 100);
QTRY_COMPARE(testWidget.geometry(), expectedGeometry);
@@ -9267,7 +9497,8 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
QPixmap correct(main.size());
correct.fill(Qt::green);
- QTRY_COMPARE(QPixmap::grabWindow(main.winId()).toImage(), correct.toImage());
+ QTRY_COMPARE(QPixmap::grabWindow(main.winId()).toImage().convertToFormat(QImage::Format_RGB32),
+ correct.toImage().convertToFormat(QImage::Format_RGB32));
QApplication::restoreOverrideCursor();
}
@@ -9390,5 +9621,62 @@ void tst_QWidget::cbaVisibility()
}
#endif
+class InputContextTester : public QInputContext
+{
+ Q_OBJECT
+public:
+ QString identifierName() { return QString(); }
+ bool isComposing() const { return false; }
+ QString language() { return QString(); }
+ void reset() { ++resets; }
+ int resets;
+};
+
+void tst_QWidget::focusProxyAndInputMethods()
+{
+ InputContextTester *inputContext = new InputContextTester;
+ QWidget *toplevel = new QWidget(0, Qt::X11BypassWindowManagerHint);
+ toplevel->setAttribute(Qt::WA_InputMethodEnabled, true);
+ toplevel->setInputContext(inputContext); // ownership is transferred
+
+ QWidget *child = new QWidget(toplevel);
+ child->setFocusProxy(toplevel);
+ child->setAttribute(Qt::WA_InputMethodEnabled, true);
+
+ toplevel->setFocusPolicy(Qt::WheelFocus);
+ child->setFocusPolicy(Qt::WheelFocus);
+
+ QVERIFY(!child->hasFocus());
+ QVERIFY(!toplevel->hasFocus());
+
+ toplevel->show();
+ QTest::qWaitForWindowShown(toplevel);
+ QApplication::setActiveWindow(toplevel);
+ QVERIFY(toplevel->hasFocus());
+ QVERIFY(child->hasFocus());
+
+ // verify that toggling input methods on the child widget
+ // correctly propagate to the focus proxy's input method
+ // and that the input method gets the focus proxy passed
+ // as the focus widget instead of the child widget.
+ // otherwise input method queries go to the wrong widget
+
+ QCOMPARE(inputContext->focusWidget(), toplevel);
+
+ child->setAttribute(Qt::WA_InputMethodEnabled, false);
+ QVERIFY(!inputContext->focusWidget());
+
+ child->setAttribute(Qt::WA_InputMethodEnabled, true);
+ QCOMPARE(inputContext->focusWidget(), toplevel);
+
+ child->setEnabled(false);
+ QVERIFY(!inputContext->focusWidget());
+
+ child->setEnabled(true);
+ QCOMPARE(inputContext->focusWidget(), toplevel);
+
+ delete toplevel;
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"
diff --git a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp
index 50b3337592..d25738fc38 100644
--- a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp
+++ b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp
@@ -395,7 +395,9 @@ void tst_QWidgetAction::releaseWidgetCrash()
QMainWindow *w = new QMainWindow;
QAction *a = new CrashedAction(w);
QMenu *menu = w->menuBar()->addMenu("Test");
+ menu->addAction("foo");
menu->addAction(a);
+ menu->addAction("bar");
delete w;
}
diff --git a/tests/auto/qworkspace/tst_qworkspace.cpp b/tests/auto/qworkspace/tst_qworkspace.cpp
index c1fe3e0ea6..35f8a4d559 100644
--- a/tests/auto/qworkspace/tst_qworkspace.cpp
+++ b/tests/auto/qworkspace/tst_qworkspace.cpp
@@ -426,6 +426,9 @@ void tst_QWorkspace::showWindows()
void tst_QWorkspace::changeWindowTitle()
{
+#ifdef Q_OS_WINCE
+ QSKIP( "Test fails on Windows CE due to QWorkspace state handling", SkipAll);
+#endif
const QString mwc( "MainWindow's Caption" );
const QString mwc2( "MainWindow's New Caption" );
const QString wc( "Widget's Caption" );
diff --git a/tests/auto/qxmlnodemodelindex/tst_qxmlnodemodelindex.cpp b/tests/auto/qxmlnodemodelindex/tst_qxmlnodemodelindex.cpp
index cb6bd4daa6..c19deb6249 100644
--- a/tests/auto/qxmlnodemodelindex/tst_qxmlnodemodelindex.cpp
+++ b/tests/auto/qxmlnodemodelindex/tst_qxmlnodemodelindex.cpp
@@ -178,7 +178,7 @@ void tst_QXmlNodeModelIndex::model() const
/* Check default value. */
{
const QXmlNodeModelIndex index;
- QCOMPARE(index.model(), static_cast<void *>(0));
+ QCOMPARE(index.model(), static_cast<const QAbstractXmlNodeModel *>(0));
}
}
diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp
index 8a9d4ef142..49f2b08173 100644
--- a/tests/auto/qxmlquery/tst_qxmlquery.cpp
+++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp
@@ -345,8 +345,8 @@ void tst_QXmlQuery::copyConstructor() const
query1.setInitialTemplateName(name);
const QXmlQuery query2(query1);
- QCOMPARE(query2.messageHandler(), &silencer);
- QCOMPARE(query2.uriResolver(), &resolver);
+ QCOMPARE(query2.messageHandler(), static_cast<QAbstractMessageHandler *>(&silencer));
+ QCOMPARE(query2.uriResolver(), static_cast<const QAbstractUriResolver *>(&resolver));
QCOMPARE(query2.queryLanguage(), QXmlQuery::XSLT20);
QCOMPARE(query2.initialTemplateName(), name);
QCOMPARE(query2.networkAccessManager(), &networkManager);
@@ -522,7 +522,7 @@ void tst_QXmlQuery::assignmentOperator() const
QVERIFY(copy.isValid());
QCOMPARE(copy.uriResolver(), static_cast<const QAbstractUriResolver *>(&returnURI));
- QCOMPARE(copy.messageHandler(), &silencer);
+ QCOMPARE(copy.messageHandler(), static_cast<QAbstractMessageHandler *>(&silencer));
QCOMPARE(testName.localName(copy.namePool()), QString::fromLatin1("somethingToCheck"));
QXmlResultItems result;
@@ -559,7 +559,7 @@ void tst_QXmlQuery::assignmentOperator() const
/* Check that the copy picked up the new things. */
QVERIFY(copy.isValid());
QCOMPARE(copy.uriResolver(), static_cast<const QAbstractUriResolver *>(&secondUriResolver));
- QCOMPARE(copy.messageHandler(), &secondSilencer);
+ QCOMPARE(copy.messageHandler(), static_cast<QAbstractMessageHandler *>(&secondSilencer));
QXmlResultItems resultCopy;
copy.evaluateTo(&resultCopy);
@@ -577,7 +577,7 @@ void tst_QXmlQuery::assignmentOperator() const
/* Check that the original is unchanged. */
QVERIFY(original.isValid());
QCOMPARE(original.uriResolver(), static_cast<const QAbstractUriResolver *>(&returnURI));
- QCOMPARE(original.messageHandler(), &silencer);
+ QCOMPARE(original.messageHandler(), static_cast<QAbstractMessageHandler *>(&silencer));
QXmlResultItems resultOriginal;
original.evaluateTo(&resultOriginal);
@@ -931,7 +931,7 @@ void tst_QXmlQuery::setMessageHandler() const
QXmlQuery query;
MessageSilencer silencer;
query.setMessageHandler(&silencer);
- QCOMPARE(&silencer, query.messageHandler());
+ QCOMPARE(static_cast<QAbstractMessageHandler *>(&silencer), query.messageHandler());
}
void tst_QXmlQuery::evaluateToReceiver()
@@ -1691,7 +1691,7 @@ void tst_QXmlQuery::setUriResolver() const
TestURIResolver resolver;
QXmlQuery query;
query.setUriResolver(&resolver);
- QCOMPARE(query.uriResolver(), &resolver);
+ QCOMPARE(query.uriResolver(), static_cast<const QAbstractUriResolver *>(&resolver));
}
}
diff --git a/tests/auto/qxmlschema/tst_qxmlschema.cpp b/tests/auto/qxmlschema/tst_qxmlschema.cpp
index 79f5587489..ec91f888a3 100644
--- a/tests/auto/qxmlschema/tst_qxmlschema.cpp
+++ b/tests/auto/qxmlschema/tst_qxmlschema.cpp
@@ -357,7 +357,7 @@ void tst_QXmlSchema::messageHandler() const
QXmlSchema schema;
schema.setMessageHandler(&handler);
- QCOMPARE(schema.messageHandler(), &handler);
+ QCOMPARE(schema.messageHandler(), static_cast<QAbstractMessageHandler *>(&handler));
}
}
@@ -394,7 +394,7 @@ void tst_QXmlSchema::uriResolver() const
QXmlSchema schema;
schema.setUriResolver(&resolver);
- QCOMPARE(schema.uriResolver(), &resolver);
+ QCOMPARE(schema.uriResolver(), static_cast<const QAbstractUriResolver *>(&resolver));
}
}
diff --git a/tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp b/tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp
index 519f8643c9..9fc784b363 100644
--- a/tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp
+++ b/tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp
@@ -149,8 +149,8 @@ void tst_QXmlSchemaValidator::propertyInitialization() const
schema.setNetworkAccessManager(&manager);
QXmlSchemaValidator validator(schema);
- QCOMPARE(validator.messageHandler(), &handler);
- QCOMPARE(validator.uriResolver(), &resolver);
+ QCOMPARE(validator.messageHandler(), static_cast<QAbstractMessageHandler *>(&handler));
+ QCOMPARE(validator.uriResolver(), static_cast<const QAbstractUriResolver *>(&resolver));
QCOMPARE(validator.networkAccessManager(), &manager);
}
}
@@ -384,7 +384,7 @@ void tst_QXmlSchemaValidator::messageHandler() const
QXmlSchemaValidator validator(schema);
validator.setMessageHandler(&handler);
- QCOMPARE(validator.messageHandler(), &handler);
+ QCOMPARE(validator.messageHandler(), static_cast<QAbstractMessageHandler *>(&handler));
}
/* Test that we return the message handler that was set, even if the schema changed in between. */
@@ -399,7 +399,7 @@ void tst_QXmlSchemaValidator::messageHandler() const
const QXmlSchema schema2;
validator.setSchema(schema2);
- QCOMPARE(validator.messageHandler(), &handler);
+ QCOMPARE(validator.messageHandler(), static_cast<QAbstractMessageHandler *>(&handler));
}
}
@@ -452,7 +452,7 @@ void tst_QXmlSchemaValidator::uriResolver() const
QXmlSchemaValidator validator(schema);
validator.setUriResolver(&resolver);
- QCOMPARE(validator.uriResolver(), &resolver);
+ QCOMPARE(validator.uriResolver(), static_cast<const QAbstractUriResolver *>(&resolver));
}
/* Test that we return the uri resolver that was set, even if the schema changed in between. */
@@ -467,7 +467,7 @@ void tst_QXmlSchemaValidator::uriResolver() const
const QXmlSchema schema2;
validator.setSchema(schema2);
- QCOMPARE(validator.uriResolver(), &resolver);
+ QCOMPARE(validator.uriResolver(), static_cast<const QAbstractUriResolver *>(&resolver));
}
}
diff --git a/tests/auto/qxmlserializer/tst_qxmlserializer.cpp b/tests/auto/qxmlserializer/tst_qxmlserializer.cpp
index aeca140d0e..51044ff308 100644
--- a/tests/auto/qxmlserializer/tst_qxmlserializer.cpp
+++ b/tests/auto/qxmlserializer/tst_qxmlserializer.cpp
@@ -148,7 +148,7 @@ void tst_QXmlSerializer::outputDevice() const
{
const QXmlQuery query;
const QXmlSerializer serializer(query, &file);
- QCOMPARE(serializer.outputDevice(), &file);
+ QCOMPARE(serializer.outputDevice(), static_cast< QIODevice *>(&file));
}
}
@@ -158,7 +158,7 @@ void tst_QXmlSerializer::serializationError() const
QXmlQuery query;
MessageSilencer silencer;
query.setMessageHandler(&silencer);
-
+
query.setQuery(queryString);
QByteArray output;
diff --git a/tests/auto/uic/baseline/mainwindowbase.ui.h b/tests/auto/uic/baseline/mainwindowbase.ui.h
index 46270a7ef7..8472dbb6bb 100644
--- a/tests/auto/uic/baseline/mainwindowbase.ui.h
+++ b/tests/auto/uic/baseline/mainwindowbase.ui.h
@@ -221,7 +221,6 @@ public:
hboxLayout->setSpacing(4);
hboxLayout->setContentsMargins(8, 8, 8, 8);
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
- hboxLayout->setContentsMargins(0, 0, 0, 0);
helpview = new QTextEdit(widget);
helpview->setObjectName(QString::fromUtf8("helpview"));
helpview->setMinimumSize(QSize(200, 0));
diff --git a/tests/auto/uiloader/baseline/css_itemview_task258382.ui b/tests/auto/uiloader/baseline/css_itemview_task258382.ui
new file mode 100644
index 0000000000..11c56b4ba2
--- /dev/null
+++ b/tests/auto/uiloader/baseline/css_itemview_task258382.ui
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>437</width>
+ <height>352</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">::item { border: 1px solid black; background-color: purple; }
+::item {margin-left: 20px; }
+
+QAbstractItemView { selection-background-color: red;
+show-decoration- selected: 0;
+ }
+
+::item:selected { background-color: yellow; }</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QTreeWidget" name="treeWidget">
+ <column>
+ <property name="text">
+ <string>1</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Column</string>
+ </property>
+ </column>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ <item>
+ <property name="text">
+ <string>New Subitem</string>
+ </property>
+ <item>
+ <property name="text">
+ <string>New Subitem</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ </item>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QTableWidget" name="tableWidget">
+ <row>
+ <property name="text">
+ <string>New Row</string>
+ </property>
+ </row>
+ <row>
+ <property name="text">
+ <string>New Row</string>
+ </property>
+ </row>
+ <row>
+ <property name="text">
+ <string>New Row</string>
+ </property>
+ </row>
+ <row>
+ <property name="text">
+ <string>New Row</string>
+ </property>
+ </row>
+ <row>
+ <property name="text">
+ <string>New Row</string>
+ </property>
+ </row>
+ <column>
+ <property name="text">
+ <string>New Column</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Column</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Column</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Column</string>
+ </property>
+ </column>
+ <item row="0" column="0">
+ <property name="text">
+ <string>mljkh mh mjl</string>
+ </property>
+ </item>
+ <item row="0" column="1">
+ <property name="text">
+ <string>h jlh mjklh </string>
+ </property>
+ </item>
+ <item row="0" column="2">
+ <property name="text">
+ <string>mjklh mlhj mjlh m</string>
+ </property>
+ </item>
+ <item row="1" column="3">
+ <property name="text">
+ <string>mlhj lmhj </string>
+ </property>
+ </item>
+ <item row="2" column="0">
+ <property name="text">
+ <string>mlkj l</string>
+ </property>
+ </item>
+ <item row="2" column="1">
+ <property name="text">
+ <string>mlkj </string>
+ </property>
+ </item>
+ <item row="2" column="2">
+ <property name="text">
+ <string>mlkj lmkj </string>
+ </property>
+ </item>
+ <item row="2" column="3">
+ <property name="text">
+ <string>mlkhj mlh</string>
+ </property>
+ </item>
+ <item row="3" column="1">
+ <property name="text">
+ <string>mlkj lmkj </string>
+ </property>
+ </item>
+ <item row="4" column="0">
+ <property name="text">
+ <string>mlkj lmkj </string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/auto/xmlpatterns.pri b/tests/auto/xmlpatterns.pri
index 7cdd67fbe6..8c8ccadb20 100644
--- a/tests/auto/xmlpatterns.pri
+++ b/tests/auto/xmlpatterns.pri
@@ -15,8 +15,9 @@ QT -= gui
XMLPATTERNS_SDK = QtXmlPatternsSDK
if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
- win32:XMLPATTERNS_SDK = $${XMLPATTERNS_SDK}d
- else: XMLPATTERNS_SDK = $${XMLPATTERNS_SDK}_debug
+ symbian: XMLPATTERNS_SDK = $${XMLPATTERNS_SDK}
+ else:win32: XMLPATTERNS_SDK = $${XMLPATTERNS_SDK}d
+ else: XMLPATTERNS_SDK = $${XMLPATTERNS_SDK}_debug
}
INCLUDEPATH += \
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt b/tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt
index a7945f05f8..b620e0504f 100644
--- a/tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt
+++ b/tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt
@@ -1 +1 @@
-Error XPST0008 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/externalVariable.xq, at line 1, column 69: No variable by name externalVariable exists
+Error XPST0008 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/externalVariable.xq, at line 1, column 69: No variable with name externalVariable exists
diff --git a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
index 0dcb070468..ff7c8c0b04 100644
--- a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
+++ b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
@@ -48,6 +48,10 @@
#include "../qxmlquery/TestFundament.h"
#include "../network-settings.h"
+#if defined(Q_OS_SYMBIAN)
+#define SRCDIR ""
+#endif
+
/*!
\class tst_XmlPatterns
\internal
@@ -130,6 +134,8 @@ void tst_XmlPatterns::xquerySupport()
#ifdef Q_OS_WINCE
QSKIP("WinCE: This test uses unsupported WinCE functionality", SkipAll);
+#elif defined(Q_OS_SYMBIAN)
+ QSKIP("Symbian: This test uses unsupported Symbian functionality (QProcess with std streams)", SkipAll);
#endif
QFETCH(int, expectedExitCode);
@@ -154,7 +160,9 @@ void tst_XmlPatterns::xquerySupport()
QCOMPARE(process.exitCode(), expectedExitCode);
const QByteArray rawProducedStderr((process.readAllStandardError()));
- const QString fixedStderr(QString::fromLocal8Bit(rawProducedStderr).remove(m_filenameInStderr));
+ QString fixedStderr(QString::fromLocal8Bit(rawProducedStderr).remove(m_filenameInStderr));
+ // convert Windows line endings to Unix ones
+ fixedStderr.replace("\r\n", "\n");
const QString errorFileName(inputFile(QLatin1String(SRCDIR "stderrBaselines/") +
QString::fromUtf8(QTest::currentDataTag()).remove(m_normalizeTestName) +
@@ -218,7 +226,7 @@ void tst_XmlPatterns::xquerySupport()
void tst_XmlPatterns::xquerySupport_data() const
{
-#ifdef Q_OS_WINCE
+#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
return;
#endif
@@ -849,6 +857,8 @@ void tst_XmlPatterns::xsltSupport_data() const
#ifdef Q_OS_WINCE
QSKIP("WinCE: This test uses unsupported WinCE functionality", SkipAll);
+#elif defined(Q_OS_SYMBIAN)
+ QSKIP("Symbian: This test uses unsupported Symbian functionality (QProcess with std streams)", SkipAll);
#endif
QTest::addColumn<int>("expectedExitCode");
diff --git a/tests/auto/xmlpatterns/xmlpatterns.pro b/tests/auto/xmlpatterns/xmlpatterns.pro
index 01e3b2bd18..54dd9aa61b 100644
--- a/tests/auto/xmlpatterns/xmlpatterns.pro
+++ b/tests/auto/xmlpatterns/xmlpatterns.pro
@@ -2,10 +2,10 @@ load(qttest_p4)
SOURCES += tst_xmlpatterns.cpp \
../qxmlquery/TestFundament.cpp
-!wince* {
-DEFINES += SRCDIR=\\\"$$PWD/\\\"
-} else {
+wince* {
DEFINES += SRCDIR=\\\"./\\\"
+} else:!symbian {
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
}
include (../xmlpatterns.pri)
diff --git a/tests/auto/xmlpatternsdiagnosticsts/test/test.pro b/tests/auto/xmlpatternsdiagnosticsts/test/test.pro
index aeff89649a..acd71e4382 100644
--- a/tests/auto/xmlpatternsdiagnosticsts/test/test.pro
+++ b/tests/auto/xmlpatternsdiagnosticsts/test/test.pro
@@ -25,8 +25,8 @@ INCLUDEPATH += $$(QTSRCDIR)/tests/auto/xmlpatternsxqts/lib/ \
../../xmlpatternsxqts/test \
../../xmlpatternsxqts/lib
-wince*: {
- catalog.sources = TestSuite Baseline.xml
+wince*|symbian {
+ catalog.sources = ../TestSuite ../Baseline.xml
catalog.path = .
DEPLOYMENT += catalog
}
diff --git a/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro b/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro
index bcc988a3f1..0f55078f0a 100644
--- a/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro
+++ b/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro
@@ -11,8 +11,9 @@ SOURCES += ../xmlpatternsxqts/test/tst_suitetest.cpp
PATTERNIST_SDK = QtXmlPatternsSDK
if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
- win32:PATTERNIST_SDK = $${PATTERNIST_SDK}d
- else: PATTERNIST_SDK = $${PATTERNIST_SDK}_debug
+ symbian: PATTERNIST_SDK = $${PATTERNIST_SDK}
+ else:win32: PATTERNIST_SDK = $${PATTERNIST_SDK}d
+ else: PATTERNIST_SDK = $${PATTERNIST_SDK}_debug
}
LIBS += -l$$PATTERNIST_SDK
diff --git a/tests/auto/xmlpatternsxqts/lib/Global.h b/tests/auto/xmlpatternsxqts/lib/Global.h
index eadb9405f8..a620417ec5 100644
--- a/tests/auto/xmlpatternsxqts/lib/Global.h
+++ b/tests/auto/xmlpatternsxqts/lib/Global.h
@@ -47,7 +47,7 @@
#include "private/qitem_p.h"
#include "private/qnamepool_p.h"
-#ifdef Q_WS_WIN
+#if defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
# ifdef Q_PATTERNISTSDK_BUILDING
#define Q_PATTERNISTSDK_EXPORT __declspec(dllexport)
#else
diff --git a/tests/auto/xmlpatternsxqts/lib/lib.pro b/tests/auto/xmlpatternsxqts/lib/lib.pro
index cb9453a063..f5b0a06db4 100644
--- a/tests/auto/xmlpatternsxqts/lib/lib.pro
+++ b/tests/auto/xmlpatternsxqts/lib/lib.pro
@@ -13,6 +13,12 @@ mac {
INSTALLS += target
}
+symbian {
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY = All -Tcb
+ MMP_RULES += EXPORTUNFROZEN
+}
+
# We add gui, because xmlpatterns.pri pull it out.
QT += xmlpatterns xml network testlib gui
diff --git a/tests/auto/xmlpatternsxqts/test/test.pro b/tests/auto/xmlpatternsxqts/test/test.pro
index 603ae65b26..a69838af5e 100644
--- a/tests/auto/xmlpatternsxqts/test/test.pro
+++ b/tests/auto/xmlpatternsxqts/test/test.pro
@@ -24,5 +24,3 @@ win32 {
else: DESTDIR = ../release
}
TARGET = tst_xmlpatternsxqts
-
-include (../../xmlpatterns.pri)
diff --git a/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro b/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro
index a3b13da9c4..39267c8de6 100644
--- a/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro
+++ b/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro
@@ -1,10 +1,10 @@
TEMPLATE = subdirs
-SUBDIRS = test
contains(QT_CONFIG,xmlpatterns) {
SUBDIRS += lib
!wince*:lib.file = lib/lib.pro
test.depends = lib
}
+SUBDIRS += test
# Needed on the win32-g++ setup and on the test machine arsia.
INCLUDEPATH += $$QT_BUILD_TREE/include/QtXmlPatterns/private \
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro
index ad1920bdba..a63fb41738 100644
--- a/tests/benchmarks/benchmarks.pro
+++ b/tests/benchmarks/benchmarks.pro
@@ -9,8 +9,8 @@ SUBDIRS = containers-associative \
qiodevice \
qpixmap \
blendbench \
- qstring \
- qstringlist \
+ qstring \
+ qstringlist \
qmatrix4x4 \
qnetworkreply \
qobject \
diff --git a/tests/benchmarks/qanimation/rectanimation.cpp b/tests/benchmarks/qanimation/rectanimation.cpp
index ab381f4d84..88eec4d8dc 100644
--- a/tests/benchmarks/qanimation/rectanimation.cpp
+++ b/tests/benchmarks/qanimation/rectanimation.cpp
@@ -92,8 +92,3 @@ void RectAnimation::updateCurrentTime(int currentTime)
if (m_object)
m_object->setRect(m_current);
}
-
-void RectAnimation::updateState(QAbstractAnimation::State state)
-{
- Q_UNUSED(state);
-}
diff --git a/tests/benchmarks/qanimation/rectanimation.h b/tests/benchmarks/qanimation/rectanimation.h
index ea1f804e2d..38a6f48c8b 100644
--- a/tests/benchmarks/qanimation/rectanimation.h
+++ b/tests/benchmarks/qanimation/rectanimation.h
@@ -59,7 +59,6 @@ public:
int duration() const;
virtual void updateCurrentTime(int currentTime);
- virtual void updateState(QAbstractAnimation::State state);
private:
DummyObject *m_object;
diff --git a/tests/benchmarks/qapplication/main.cpp b/tests/benchmarks/qapplication/main.cpp
index a299db2b95..0ec65a8cf9 100644
--- a/tests/benchmarks/qapplication/main.cpp
+++ b/tests/benchmarks/qapplication/main.cpp
@@ -39,7 +39,6 @@
**
****************************************************************************/
#include <QApplication>
-#include <QProcess>
#include <qtest.h>
@@ -54,34 +53,19 @@ private slots:
/*
Test the performance of the QApplication constructor.
- This test creates a new process and thus includes process creation overhead.
- Callgrind results are meaningless since the child process is not traced.
+ Note: results from the second start on can be misleading,
+ since all global statics are already initialized.
*/
void tst_qapplication::ctor()
{
- QProcess proc;
- const QString program = QCoreApplication::applicationFilePath();
- const QStringList arguments = QStringList() << QLatin1String("--exit-now");
-
+ // simulate reasonable argc, argv
+ int argc = 1;
+ char *argv[] = { "tst_qapplication" };
QBENCHMARK {
- proc.start(program, arguments);
- QVERIFY(proc.waitForStarted());
- QVERIFY(proc.waitForFinished());
- QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
- QCOMPARE(proc.exitCode(), 0);
+ QApplication app(argc, argv);
}
}
-int main(int argc, char** argv)
-{
- QApplication app(argc, argv);
-
- if (argc == 2 && QLatin1String("--exit-now") == QLatin1String(argv[1])) {
- return 0;
- }
-
- tst_qapplication test;
- return QTest::qExec(&test, argc, argv);
-}
+QTEST_APPLESS_MAIN(tst_qapplication)
#include "main.moc"
diff --git a/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 000ab6ea26..81064d7df6 100644
--- a/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -41,6 +41,7 @@
#include <QtTest/QtTest>
#include <QtGui/qgraphicsanchorlayout.h>
+#include <QtGui/qgraphicslinearlayout.h>
#include <QtGui/qgraphicswidget.h>
#include <QtGui/qgraphicsview.h>
@@ -54,6 +55,12 @@ public:
private slots:
void s60_hard_complex_data();
void s60_hard_complex();
+ void linearVsAnchorSizeHints_data();
+ void linearVsAnchorSizeHints();
+ void linearVsAnchorSetGeometry_data();
+ void linearVsAnchorSetGeometry();
+ void linearVsAnchorNested_data();
+ void linearVsAnchorNested();
};
@@ -192,6 +199,235 @@ void tst_QGraphicsAnchorLayout::s60_hard_complex()
}
}
+static QGraphicsLayout* createLayouts(int whichLayout)
+{
+ QSizeF min(0, 10);
+ QSizeF pref(50, 10);
+ QSizeF max(100, 10);
+
+ QGraphicsWidget *a = createItem(min, pref, max, "a");
+ QGraphicsWidget *b = createItem(min, pref, max, "b");
+ QGraphicsWidget *c = createItem(min, pref, max, "c");
+ QGraphicsWidget *d = createItem(min, pref, max, "d");
+
+ QGraphicsLayout *l;
+ if (whichLayout == 0) {
+ l = new QGraphicsLinearLayout;
+ QGraphicsLinearLayout *linear = static_cast<QGraphicsLinearLayout *>(l);
+ linear->setContentsMargins(0, 0, 0, 0);
+
+ linear->addItem(a);
+ linear->addItem(b);
+ linear->addItem(c);
+ linear->addItem(d);
+ } else {
+ l = new QGraphicsAnchorLayout;
+ QGraphicsAnchorLayout *anchor = static_cast<QGraphicsAnchorLayout *>(l);
+ anchor->setContentsMargins(0, 0, 0, 0);
+
+ // Horizontal
+ setAnchor(anchor, anchor, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
+ setAnchor(anchor, a, Qt::AnchorRight, b, Qt::AnchorLeft, 0);
+ setAnchor(anchor, b, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
+ setAnchor(anchor, c, Qt::AnchorRight, d, Qt::AnchorLeft, 0);
+ setAnchor(anchor, d, Qt::AnchorRight, anchor, Qt::AnchorRight, 0);
+
+ // Vertical
+ anchor->addAnchors(anchor, a, Qt::Vertical);
+ anchor->addAnchors(anchor, b, Qt::Vertical);
+ anchor->addAnchors(anchor, c, Qt::Vertical);
+ anchor->addAnchors(anchor, d, Qt::Vertical);
+ }
+
+ return l;
+}
+
+void tst_QGraphicsAnchorLayout::linearVsAnchorSizeHints_data()
+{
+ QTest::addColumn<int>("whichLayout");
+ QTest::addColumn<int>("whichSizeHint");
+
+ QTest::newRow("QGraphicsLinearLayout::minimum")
+ << 0 << int(Qt::MinimumSize);
+ QTest::newRow("QGraphicsLinearLayout::preferred")
+ << 0 << int(Qt::PreferredSize);
+ QTest::newRow("QGraphicsLinearLayout::maximum")
+ << 0 << int(Qt::MaximumSize);
+ QTest::newRow("QGraphicsLinearLayout::noSizeHint")
+ << 0 << -1;
+
+ QTest::newRow("QGraphicsAnchorLayout::minimum")
+ << 1 << int(Qt::MinimumSize);
+ QTest::newRow("QGraphicsAnchorLayout::preferred")
+ << 1 << int(Qt::PreferredSize);
+ QTest::newRow("QGraphicsAnchorLayout::maximum")
+ << 1 << int(Qt::MaximumSize);
+ QTest::newRow("QGraphicsAnchorLayout::noSizeHint")
+ << 1 << -1;
+}
+
+void tst_QGraphicsAnchorLayout::linearVsAnchorSizeHints()
+{
+ QFETCH(int, whichSizeHint);
+ QFETCH(int, whichLayout);
+
+ QGraphicsLayout *l = createLayouts(whichLayout);
+
+ QSizeF sizeHint;
+ // warm up instruction cache
+ l->invalidate();
+ sizeHint = l->effectiveSizeHint((Qt::SizeHint)whichSizeHint);
+ // ...then measure...
+
+ QBENCHMARK {
+ l->invalidate();
+ sizeHint = l->effectiveSizeHint((Qt::SizeHint)whichSizeHint);
+ }
+}
+
+void tst_QGraphicsAnchorLayout::linearVsAnchorSetGeometry_data()
+{
+ QTest::addColumn<int>("whichLayout");
+
+ QTest::newRow("QGraphicsLinearLayout")
+ << 0;
+ QTest::newRow("QGraphicsAnchorLayout")
+ << 1;
+}
+
+void tst_QGraphicsAnchorLayout::linearVsAnchorSetGeometry()
+{
+ QFETCH(int, whichLayout);
+
+ QGraphicsLayout *l = createLayouts(whichLayout);
+
+ QRectF sizeHint;
+ qreal maxWidth;
+ qreal increment;
+ // warm up instruction cache
+ l->invalidate();
+ sizeHint.setSize(l->effectiveSizeHint(Qt::MinimumSize));
+ maxWidth = l->effectiveSizeHint(Qt::MaximumSize).width();
+ increment = (maxWidth - sizeHint.width()) / 100;
+ l->setGeometry(sizeHint);
+ // ...then measure...
+
+ QBENCHMARK {
+ l->invalidate();
+ for (qreal width = sizeHint.width(); width <= maxWidth; width += increment) {
+ sizeHint.setWidth(width);
+ l->setGeometry(sizeHint);
+ }
+ }
+}
+
+void tst_QGraphicsAnchorLayout::linearVsAnchorNested_data()
+{
+ QTest::addColumn<int>("whichLayout");
+ QTest::newRow("LinearLayout")
+ << 0;
+ QTest::newRow("AnchorLayout setup with null-anchors knot")
+ << 1;
+ QTest::newRow("AnchorLayout setup easy to simplificate")
+ << 2;
+}
+
+void tst_QGraphicsAnchorLayout::linearVsAnchorNested()
+{
+ QFETCH(int, whichLayout);
+
+ QSizeF min(10, 10);
+ QSizeF pref(80, 80);
+ QSizeF max(150, 150);
+
+ QGraphicsWidget *a = createItem(min, pref, max, "a");
+ QGraphicsWidget *b = createItem(min, pref, max, "b");
+ QGraphicsWidget *c = createItem(min, pref, max, "c");
+ QGraphicsWidget *d = createItem(min, pref, max, "d");
+
+ QGraphicsLayout *layout;
+
+ if (whichLayout == 0) {
+ QGraphicsLinearLayout *linear1 = new QGraphicsLinearLayout;
+ QGraphicsLinearLayout *linear2 = new QGraphicsLinearLayout(Qt::Vertical);
+ QGraphicsLinearLayout *linear3 = new QGraphicsLinearLayout;
+
+ linear1->addItem(a);
+ linear1->addItem(linear2);
+ linear2->addItem(b);
+ linear2->addItem(linear3);
+ linear3->addItem(c);
+ linear3->addItem(d);
+
+ layout = linear1;
+ } else if (whichLayout == 1) {
+ QGraphicsAnchorLayout *anchor = new QGraphicsAnchorLayout;
+
+ // A
+ anchor->addCornerAnchors(a, Qt::TopLeftCorner, anchor, Qt::TopLeftCorner);
+ anchor->addCornerAnchors(a, Qt::TopRightCorner, b, Qt::TopLeftCorner);
+ anchor->addCornerAnchors(a, Qt::BottomLeftCorner, anchor, Qt::BottomLeftCorner);
+ anchor->addCornerAnchors(a, Qt::BottomRightCorner, c, Qt::BottomLeftCorner);
+
+ // B
+ anchor->addCornerAnchors(b, Qt::TopRightCorner, anchor, Qt::TopRightCorner);
+ anchor->addCornerAnchors(b, Qt::BottomLeftCorner, c, Qt::TopLeftCorner);
+ anchor->addCornerAnchors(b, Qt::BottomRightCorner, d, Qt::TopRightCorner);
+
+ // C
+ anchor->addCornerAnchors(c, Qt::TopRightCorner, d, Qt::TopLeftCorner);
+ anchor->addCornerAnchors(c, Qt::BottomRightCorner, d, Qt::BottomLeftCorner);
+
+ // D
+ anchor->addCornerAnchors(d, Qt::BottomRightCorner, anchor, Qt::BottomRightCorner);
+
+ layout = anchor;
+ } else {
+ QGraphicsAnchorLayout *anchor = new QGraphicsAnchorLayout;
+
+ // A
+ anchor->addAnchor(a, Qt::AnchorLeft, anchor, Qt::AnchorLeft);
+ anchor->addAnchors(a, anchor, Qt::Vertical);
+ anchor->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
+ anchor->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft);
+
+ // B
+ anchor->addAnchor(b, Qt::AnchorTop, anchor, Qt::AnchorTop);
+ anchor->addAnchor(b, Qt::AnchorRight, anchor, Qt::AnchorRight);
+ anchor->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop);
+ anchor->addAnchor(b, Qt::AnchorBottom, d, Qt::AnchorTop);
+
+ // C
+ anchor->addAnchor(c, Qt::AnchorRight, d, Qt::AnchorLeft);
+ anchor->addAnchor(c, Qt::AnchorBottom, anchor, Qt::AnchorBottom);
+
+ // D
+ anchor->addAnchor(d, Qt::AnchorRight, anchor, Qt::AnchorRight);
+ anchor->addAnchor(d, Qt::AnchorBottom, anchor, Qt::AnchorBottom);
+
+ layout = anchor;
+ }
+
+ QSizeF sizeHint;
+ // warm up instruction cache
+ layout->invalidate();
+ sizeHint = layout->effectiveSizeHint(Qt::PreferredSize);
+
+ // ...then measure...
+ QBENCHMARK {
+ // To ensure that all sizeHints caches are invalidated in
+ // the LinearLayout setup, we must call updateGeometry on the
+ // children. If we didn't, only the top level layout would be
+ // re-calculated.
+ static_cast<QGraphicsLayoutItem *>(a)->updateGeometry();
+ static_cast<QGraphicsLayoutItem *>(b)->updateGeometry();
+ static_cast<QGraphicsLayoutItem *>(c)->updateGeometry();
+ static_cast<QGraphicsLayoutItem *>(d)->updateGeometry();
+ layout->invalidate();
+ sizeHint = layout->effectiveSizeHint(Qt::PreferredSize);
+ }
+}
+
QTEST_MAIN(tst_QGraphicsAnchorLayout)
#include "tst_qgraphicsanchorlayout.moc"
diff --git a/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp b/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp
index 71f45ff0cf..f80b579780 100644
--- a/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp
+++ b/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp
@@ -220,7 +220,7 @@ void tst_QMatrix4x4::mapVector3D()
QVector3D v(10.5f, -2.0f, 3.0f);
QVector3D result;
- m1.inferSpecialType();
+ m1.optimize();
QBENCHMARK {
result = m1 * v;
@@ -244,7 +244,7 @@ void tst_QMatrix4x4::mapVector2D()
QPointF v(10.5f, -2.0f);
QPointF result;
- m1.inferSpecialType();
+ m1.optimize();
QBENCHMARK {
result = m1 * v;
diff --git a/tests/benchmarks/qnetworkreply/qnetworkreply.pro b/tests/benchmarks/qnetworkreply/qnetworkreply.pro
index 060acf53dc..1e67d81774 100644
--- a/tests/benchmarks/qnetworkreply/qnetworkreply.pro
+++ b/tests/benchmarks/qnetworkreply/qnetworkreply.pro
@@ -10,4 +10,4 @@ QT += network
CONFIG += release
# Input
-SOURCES += main.cpp
+SOURCES += tst_qnetworkreply.cpp
diff --git a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp
new file mode 100644
index 0000000000..1d50013f22
--- /dev/null
+++ b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp
@@ -0,0 +1,642 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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$
+**
+****************************************************************************/
+// This file contains benchmarks for QNetworkReply functions.
+
+#include <QDebug>
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtNetwork/qnetworkreply.h>
+#include <QtNetwork/qnetworkrequest.h>
+#include <QtNetwork/qnetworkaccessmanager.h>
+#include <QtNetwork/qtcpsocket.h>
+#include <QtNetwork/qtcpserver.h>
+#include "../../auto/network-settings.h"
+
+
+class TimedSender: public QThread
+{
+ Q_OBJECT
+ qint64 totalBytes;
+ QSemaphore ready;
+ QByteArray dataToSend;
+ QTcpSocket *client;
+ int timeout;
+ int port;
+public:
+ int transferRate;
+ TimedSender(int ms)
+ : totalBytes(0), timeout(ms), port(-1), transferRate(-1)
+ {
+ dataToSend = QByteArray(16*1024, '@');
+ start();
+ ready.acquire();
+ }
+
+ inline int serverPort() const { return port; }
+
+private slots:
+ void writeMore()
+ {
+ while (client->bytesToWrite() < 128 * 1024) {
+ writePacket(dataToSend);
+ }
+ }
+
+protected:
+ void run()
+ {
+ QTcpServer server;
+ server.listen();
+ port = server.serverPort();
+ ready.release();
+
+ server.waitForNewConnection(-1);
+ client = server.nextPendingConnection();
+
+ writeMore();
+ connect(client, SIGNAL(bytesWritten(qint64)), SLOT(writeMore()), Qt::DirectConnection);
+
+ QEventLoop eventLoop;
+ QTimer::singleShot(timeout, &eventLoop, SLOT(quit()));
+
+ QTime timer;
+ timer.start();
+ eventLoop.exec();
+ disconnect(client, SIGNAL(bytesWritten(qint64)), this, 0);
+
+ // wait for the connection to shut down
+ client->disconnectFromHost();
+ if (!client->waitForDisconnected(10000))
+ return;
+
+ transferRate = totalBytes * 1000 / timer.elapsed();
+ qDebug() << "TimedSender::run" << "receive rate:" << (transferRate / 1024) << "kB/s in"
+ << timer.elapsed() << "ms";
+ }
+
+ void writePacket(const QByteArray &array)
+ {
+ client->write(array);
+ totalBytes += array.size();
+ }
+};
+
+
+class QNetworkReplyPtr: public QSharedPointer<QNetworkReply>
+{
+public:
+ inline QNetworkReplyPtr(QNetworkReply *ptr = 0)
+ : QSharedPointer<QNetworkReply>(ptr)
+ { }
+
+ inline operator QNetworkReply *() const { return data(); }
+};
+
+
+class DataReader: public QObject
+{
+ Q_OBJECT
+public:
+ qint64 totalBytes;
+ QByteArray data;
+ QIODevice *device;
+ bool accumulate;
+ DataReader(QIODevice *dev, bool acc = true) : totalBytes(0), device(dev), accumulate(acc)
+ {
+ connect(device, SIGNAL(readyRead()), SLOT(doRead()));
+ }
+
+public slots:
+ void doRead()
+ {
+ QByteArray buffer;
+ buffer.resize(device->bytesAvailable());
+ qint64 bytesRead = device->read(buffer.data(), device->bytesAvailable());
+ if (bytesRead == -1) {
+ QTestEventLoop::instance().exitLoop();
+ return;
+ }
+ buffer.truncate(bytesRead);
+ totalBytes += bytesRead;
+
+ if (accumulate)
+ data += buffer;
+ }
+};
+
+class ThreadedDataReader: public QThread
+{
+ Q_OBJECT
+ // used to make the constructor only return after the tcp server started listening
+ QSemaphore ready;
+ QTcpSocket *client;
+ int timeout;
+ int port;
+public:
+ qint64 transferRate;
+ ThreadedDataReader()
+ : port(-1), transferRate(-1)
+ {
+ start();
+ ready.acquire();
+ }
+
+ inline int serverPort() const { return port; }
+
+protected:
+ void run()
+ {
+ QTcpServer server;
+ server.listen();
+ port = server.serverPort();
+ ready.release();
+
+ server.waitForNewConnection(-1);
+ client = server.nextPendingConnection();
+
+ QEventLoop eventLoop;
+ DataReader reader(client, false);
+ QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit()));
+
+ QTime timer;
+ timer.start();
+ eventLoop.exec();
+ qint64 elapsed = timer.elapsed();
+
+ transferRate = reader.totalBytes * 1000 / elapsed;
+ qDebug() << "ThreadedDataReader::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec";
+ }
+};
+
+class DataGenerator: public QIODevice
+{
+ Q_OBJECT
+ enum { Idle, Started, Stopped } state;
+public:
+ DataGenerator() : state(Idle)
+ { open(ReadOnly); }
+
+ virtual bool isSequential() const { return true; }
+ virtual qint64 bytesAvailable() const { return state == Started ? 1024*1024 : 0; }
+
+public slots:
+ void start() { state = Started; emit readyRead(); }
+ void stop() { state = Stopped; emit readyRead(); }
+
+protected:
+ virtual qint64 readData(char *data, qint64 maxlen)
+ {
+ if (state == Stopped)
+ return -1; // EOF
+
+ // return as many bytes as are wanted
+ memset(data, '@', maxlen);
+ return maxlen;
+ }
+ virtual qint64 writeData(const char *, qint64)
+ { return -1; }
+};
+
+class ThreadedDataReaderHttpServer: public QThread
+{
+ Q_OBJECT
+ // used to make the constructor only return after the tcp server started listening
+ QSemaphore ready;
+ QTcpSocket *client;
+ int timeout;
+ int port;
+public:
+ qint64 transferRate;
+ ThreadedDataReaderHttpServer()
+ : port(-1), transferRate(-1)
+ {
+ start();
+ ready.acquire();
+ }
+
+ inline int serverPort() const { return port; }
+
+protected:
+ void run()
+ {
+ QTcpServer server;
+ server.listen();
+ port = server.serverPort();
+ ready.release();
+
+ server.waitForNewConnection(-1);
+ client = server.nextPendingConnection();
+ client->write("HTTP/1.0 200 OK\r\n");
+ client->write("Content-length: 0\r\n");
+ client->write("\r\n");
+ client->flush();
+
+ QCoreApplication::processEvents();
+
+ QEventLoop eventLoop;
+ DataReader reader(client, false);
+ QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit()));
+
+ QTime timer;
+ timer.start();
+ eventLoop.exec();
+ qint64 elapsed = timer.elapsed();
+
+ transferRate = reader.totalBytes * 1000 / elapsed;
+ qDebug() << "ThreadedDataReaderHttpServer::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec";
+ }
+};
+
+
+class FixedSizeDataGenerator : public QIODevice
+{
+ Q_OBJECT
+ enum { Idle, Started, Stopped } state;
+public:
+ FixedSizeDataGenerator(qint64 size) : state(Idle)
+ { open(ReadOnly | Unbuffered);
+ toBeGeneratedTotalCount = toBeGeneratedCount = size;
+ }
+
+ virtual qint64 bytesAvailable() const
+ {
+ return state == Started ? toBeGeneratedCount + QIODevice::bytesAvailable() : 0;
+ }
+
+ virtual bool isSequential() const{
+ return false;
+ }
+
+ virtual bool reset() const{
+ return false;
+ }
+
+ qint64 size() const {
+ return toBeGeneratedTotalCount;
+ }
+
+public slots:
+ void start() { state = Started; emit readyRead(); }
+
+protected:
+ virtual qint64 readData(char *data, qint64 maxlen)
+ {
+ memset(data, '@', maxlen);
+
+ if (toBeGeneratedCount <= 0) {
+ return -1;
+ }
+
+ qint64 n = qMin(maxlen, toBeGeneratedCount);
+ toBeGeneratedCount -= n;
+
+ if (toBeGeneratedCount <= 0) {
+ // make sure this is a queued connection!
+ emit readChannelFinished();
+ }
+
+ return n;
+ }
+ virtual qint64 writeData(const char *, qint64)
+ { return -1; }
+
+ qint64 toBeGeneratedCount;
+ qint64 toBeGeneratedTotalCount;
+};
+
+class HttpDownloadPerformanceServer : QObject {
+ Q_OBJECT;
+ qint64 dataSize;
+ qint64 dataSent;
+ QTcpServer server;
+ QTcpSocket *client;
+ bool serverSendsContentLength;
+ bool chunkedEncoding;
+
+public:
+ HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0),
+ client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) {
+ server.listen();
+ connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot()));
+ }
+
+ int serverPort() {
+ return server.serverPort();
+ }
+
+public slots:
+
+ void newConnectionSlot() {
+ client = server.nextPendingConnection();
+ client->setParent(this);
+ connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
+ connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64)));
+ }
+
+ void readyReadSlot() {
+ client->readAll();
+ client->write("HTTP/1.0 200 OK\n");
+ if (serverSendsContentLength)
+ client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii());
+ if (chunkedEncoding)
+ client->write(QString("Transfer-Encoding: chunked\n").toAscii());
+ client->write("Connection: close\n\n");
+ }
+
+ void bytesWrittenSlot(qint64 amount) {
+ Q_UNUSED(amount);
+ if (dataSent == dataSize && client) {
+ // close eventually
+
+ // chunked encoding: we have to send a last "empty" chunk
+ if (chunkedEncoding)
+ client->write(QString("0\r\n\r\n").toAscii());
+
+ client->disconnectFromHost();
+ server.close();
+ client = 0;
+ return;
+ }
+
+ // send data
+ if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) {
+ qint64 amount = qMin(qint64(16*1024), dataSize - dataSent);
+ QByteArray data(amount, '@');
+
+ if (chunkedEncoding) {
+ client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii());
+ client->write(data.constData(), amount);
+ client->write(QString("\r\n").toAscii());
+ } else {
+ client->write(data.constData(), amount);
+ }
+
+ dataSent += amount;
+ }
+ }
+};
+
+class HttpDownloadPerformanceClient : QObject {
+ Q_OBJECT;
+ QIODevice *device;
+ public:
+ HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){
+ connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
+ }
+
+ public slots:
+ void readyReadSlot() {
+ device->readAll();
+ }
+
+};
+
+
+
+
+class tst_qnetworkreply : public QObject
+{
+ Q_OBJECT
+
+ QNetworkAccessManager manager;
+private slots:
+ void httpLatency();
+
+#ifndef QT_NO_OPENSSL
+ void echoPerformance_data();
+ void echoPerformance();
+#endif
+
+ void downloadPerformance();
+ void uploadPerformance();
+ void performanceControlRate();
+ void httpUploadPerformance();
+ void httpDownloadPerformance_data();
+ void httpDownloadPerformance();
+
+};
+
+void tst_qnetworkreply::httpLatency()
+{
+ QNetworkAccessManager manager;
+ QBENCHMARK{
+ QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/"));
+ QNetworkReply* reply = manager.get(request);
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
+ QTestEventLoop::instance().enterLoop(5);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ delete reply;
+ }
+}
+
+#ifndef QT_NO_OPENSSL
+void tst_qnetworkreply::echoPerformance_data()
+{
+ QTest::addColumn<bool>("ssl");
+ QTest::newRow("no_ssl") << false;
+ QTest::newRow("ssl") << true;
+}
+
+void tst_qnetworkreply::echoPerformance()
+{
+ QFETCH(bool, ssl);
+ QNetworkAccessManager manager;
+ QNetworkRequest request(QUrl((ssl ? "https://" : "http://") + QtNetworkSettings::serverName() + "/qtest/cgi-bin/echo.cgi"));
+
+ 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++) {
+ int r = qrand();
+ data.data()[i*sizeof(int)] = r;
+ }
+
+ QBENCHMARK{
+ QNetworkReply* reply = manager.post(request, data);
+ connect(reply, SIGNAL(sslErrors( const QList<QSslError> &)), reply, SLOT(ignoreSslErrors()));
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
+ QTestEventLoop::instance().enterLoop(5);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(reply->error() == QNetworkReply::NoError);
+ delete reply;
+ }
+}
+#endif
+
+void tst_qnetworkreply::downloadPerformance()
+{
+ // unlike the above function, this one tries to send as fast as possible
+ // and measures how fast it was.
+ TimedSender sender(5000);
+ QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(sender.serverPort()) + "/?bare=1");
+ QNetworkReplyPtr reply = manager.get(request);
+ DataReader reader(reply, false);
+
+ QTime loopTime;
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ loopTime.start();
+ QTestEventLoop::instance().enterLoop(40);
+ int elapsedTime = loopTime.elapsed();
+ sender.wait();
+
+ qint64 receivedBytes = reader.totalBytes;
+ qDebug() << "tst_QNetworkReply::downloadPerformance" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and"
+ << elapsedTime << "ms";
+}
+
+void tst_qnetworkreply::uploadPerformance()
+{
+ ThreadedDataReader reader;
+ DataGenerator generator;
+
+
+ QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1");
+ QNetworkReplyPtr reply = manager.put(request, &generator);
+ generator.start();
+ connect(&reader, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTimer::singleShot(5000, &generator, SLOT(stop()));
+
+ QTestEventLoop::instance().enterLoop(30);
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+}
+
+void tst_qnetworkreply::httpUploadPerformance()
+{
+#ifdef Q_OS_SYMBIAN
+ // SHow some mercy for non-desktop platform/s
+ enum {UploadSize = 4*1024*1024}; // 4 MB
+#else
+ enum {UploadSize = 128*1024*1024}; // 128 MB
+#endif
+ ThreadedDataReaderHttpServer reader;
+ FixedSizeDataGenerator generator(UploadSize);
+
+ QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1"));
+ request.setHeader(QNetworkRequest::ContentLengthHeader,UploadSize);
+
+ QNetworkReplyPtr reply = manager.put(request, &generator);
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ QTime time;
+ generator.start();
+ time.start();
+ QTestEventLoop::instance().enterLoop(40);
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ qint64 elapsed = time.elapsed();
+ qDebug() << "tst_QNetworkReply::httpUploadPerformance" << elapsed << "msec, "
+ << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec";
+
+ reader.exit();
+ reader.wait();
+}
+
+
+void tst_qnetworkreply::performanceControlRate()
+{
+ // this is a control comparison for the other two above
+ // it does the same thing, but instead bypasses the QNetworkAccess system
+ qDebug() << "The following are the maximum transfer rates that we can get in this system"
+ " (bypassing QNetworkAccess)";
+
+ TimedSender sender(5000);
+ QTcpSocket sink;
+ sink.connectToHost("127.0.0.1", sender.serverPort());
+ DataReader reader(&sink, false);
+
+ QTime loopTime;
+ connect(&sink, SIGNAL(disconnected()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ loopTime.start();
+ QTestEventLoop::instance().enterLoop(40);
+ int elapsedTime = loopTime.elapsed();
+ sender.wait();
+
+ qint64 receivedBytes = reader.totalBytes;
+ qDebug() << "tst_QNetworkReply::performanceControlRate" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and"
+ << elapsedTime << "ms";
+}
+
+void tst_qnetworkreply::httpDownloadPerformance_data()
+{
+ QTest::addColumn<bool>("serverSendsContentLength");
+ QTest::addColumn<bool>("chunkedEncoding");
+
+ QTest::newRow("Server sends no Content-Length") << false << false;
+ QTest::newRow("Server sends Content-Length") << true << false;
+ QTest::newRow("Server uses chunked encoding") << false << true;
+
+}
+
+void tst_qnetworkreply::httpDownloadPerformance()
+{
+ QFETCH(bool, serverSendsContentLength);
+ QFETCH(bool, chunkedEncoding);
+#ifdef Q_OS_SYMBIAN
+ // Show some mercy to non-desktop platform/s
+ enum {UploadSize = 4*1024*1024}; // 4 MB
+#else
+ enum {UploadSize = 128*1024*1024}; // 128 MB
+#endif
+ HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding);
+
+ QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1"));
+ QNetworkReplyPtr reply = manager.get(request);
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
+ HttpDownloadPerformanceClient client(reply);
+
+ QTime time;
+ time.start();
+ QTestEventLoop::instance().enterLoop(40);
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ qint64 elapsed = time.elapsed();
+ qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, "
+ << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec";
+}
+
+QTEST_MAIN(tst_qnetworkreply)
+
+#include "tst_qnetworkreply.moc"
diff --git a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp
index 4f011c4261..8d5f6e6ef6 100644
--- a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp
@@ -60,6 +60,8 @@ private slots:
void constructor();
void evaluate_data();
void evaluate();
+ void evaluateProgram_data();
+ void evaluateProgram();
void connectAndDisconnect();
void newObject();
void newQObject();
@@ -153,6 +155,22 @@ void tst_QScriptEngine::connectAndDisconnect()
}
}
+void tst_QScriptEngine::evaluateProgram_data()
+{
+ evaluate_data();
+}
+
+void tst_QScriptEngine::evaluateProgram()
+{
+ QFETCH(QString, code);
+ QScriptEngine engine;
+ QScriptProgram program(code);
+
+ QBENCHMARK {
+ (void)engine.evaluate(program);
+ }
+}
+
void tst_QScriptEngine::newObject()
{
QScriptEngine engine;
@@ -241,6 +259,5 @@ void tst_QScriptEngine::nativeCall()
}
}
-
QTEST_MAIN(tst_QScriptEngine)
#include "tst_qscriptengine.moc"
diff --git a/tests/manual/gestures/graphicsview/gestures.cpp b/tests/manual/gestures/graphicsview/gestures.cpp
index 5416457d19..4c21712a28 100644
--- a/tests/manual/gestures/graphicsview/gestures.cpp
+++ b/tests/manual/gestures/graphicsview/gestures.cpp
@@ -45,41 +45,41 @@
Qt::GestureType ThreeFingerSlideGesture::Type = Qt::CustomGesture;
-QGesture *ThreeFingerSlideGestureRecognizer::createGesture(QObject *)
+QGesture *ThreeFingerSlideGestureRecognizer::create(QObject *)
{
return new ThreeFingerSlideGesture;
}
-QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event)
+QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event)
{
ThreeFingerSlideGesture *d = static_cast<ThreeFingerSlideGesture *>(state);
QGestureRecognizer::Result result;
switch (event->type()) {
case QEvent::TouchBegin:
- result = QGestureRecognizer::MaybeGesture;
+ result = QGestureRecognizer::MayBeGesture;
case QEvent::TouchEnd:
if (d->gestureFired)
- result = QGestureRecognizer::GestureFinished;
+ result = QGestureRecognizer::FinishGesture;
else
- result = QGestureRecognizer::NotGesture;
+ result = QGestureRecognizer::CancelGesture;
case QEvent::TouchUpdate:
if (d->state() != Qt::NoGesture) {
QTouchEvent *ev = static_cast<QTouchEvent*>(event);
if (ev->touchPoints().size() == 3) {
d->gestureFired = true;
- result = QGestureRecognizer::GestureTriggered;
+ result = QGestureRecognizer::TriggerGesture;
} else {
- result = QGestureRecognizer::MaybeGesture;
+ result = QGestureRecognizer::MayBeGesture;
for (int i = 0; i < ev->touchPoints().size(); ++i) {
const QTouchEvent::TouchPoint &pt = ev->touchPoints().at(i);
const int distance = (pt.pos().toPoint() - pt.startPos().toPoint()).manhattanLength();
if (distance > 20) {
- result = QGestureRecognizer::NotGesture;
+ result = QGestureRecognizer::CancelGesture;
}
}
}
} else {
- result = QGestureRecognizer::NotGesture;
+ result = QGestureRecognizer::CancelGesture;
}
break;
@@ -89,7 +89,7 @@ QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::filterEvent(QGestu
if (d->state() != Qt::NoGesture)
result = QGestureRecognizer::Ignore;
else
- result = QGestureRecognizer::NotGesture;
+ result = QGestureRecognizer::CancelGesture;
break;
default:
result = QGestureRecognizer::Ignore;
@@ -105,12 +105,12 @@ void ThreeFingerSlideGestureRecognizer::reset(QGesture *state)
}
-QGesture *RotateGestureRecognizer::createGesture(QObject *)
+QGesture *RotateGestureRecognizer::create(QObject *)
{
return new QGesture;
}
-QGestureRecognizer::Result RotateGestureRecognizer::filterEvent(QGesture *, QObject *, QEvent *event)
+QGestureRecognizer::Result RotateGestureRecognizer::recognize(QGesture *, QObject *, QEvent *event)
{
switch (event->type()) {
case QEvent::TouchBegin:
diff --git a/tests/manual/gestures/graphicsview/gestures.h b/tests/manual/gestures/graphicsview/gestures.h
index 6140b12d62..8a31b7117b 100644
--- a/tests/manual/gestures/graphicsview/gestures.h
+++ b/tests/manual/gestures/graphicsview/gestures.h
@@ -59,8 +59,8 @@ public:
class ThreeFingerSlideGestureRecognizer : public QGestureRecognizer
{
private:
- QGesture* createGesture(QObject *target);
- QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event);
+ QGesture *create(QObject *target);
+ QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event);
void reset(QGesture *state);
};
@@ -70,8 +70,8 @@ public:
RotateGestureRecognizer();
private:
- QGesture* createGesture(QObject *target);
- QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event);
+ QGesture *create(QObject *target);
+ QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event);
void reset(QGesture *state);
};
diff --git a/tests/manual/gestures/graphicsview/main.cpp b/tests/manual/gestures/graphicsview/main.cpp
index 263a963678..f8433b59f3 100644
--- a/tests/manual/gestures/graphicsview/main.cpp
+++ b/tests/manual/gestures/graphicsview/main.cpp
@@ -66,11 +66,11 @@ protected:
default: qDebug("view: Pan: <unknown state>"); break;
}
- const QSizeF offset = pan->offset();
+ const QPointF delta = pan->delta();
QScrollBar *vbar = verticalScrollBar();
QScrollBar *hbar = horizontalScrollBar();
- vbar->setValue(vbar->value() - offset.height());
- hbar->setValue(hbar->value() - offset.width());
+ vbar->setValue(vbar->value() - delta.y());
+ hbar->setValue(hbar->value() - delta.x());
ge->accept(pan);
return true;
}
@@ -126,6 +126,8 @@ public:
scene = new QGraphicsScene(this);
scene->setSceneRect(-2000, -2000, 4000, 4000);
view = new QGraphicsView(scene, 0);
+ view->viewport()->grabGesture(Qt::PanGesture);
+ view->viewport()->grabGesture(ThreeFingerSlideGesture::Type);
QVBoxLayout *l = new QVBoxLayout(this);
l->addWidget(view);
}
@@ -150,8 +152,8 @@ private:
MainWindow::MainWindow()
{
- (void)qApp->registerGestureRecognizer(new MousePanGestureRecognizer);
- ThreeFingerSlideGesture::Type = qApp->registerGestureRecognizer(new ThreeFingerSlideGestureRecognizer);
+ (void)QGestureRecognizer::registerRecognizer(new MousePanGestureRecognizer);
+ ThreeFingerSlideGesture::Type = QGestureRecognizer::registerRecognizer(new ThreeFingerSlideGestureRecognizer);
tabWidget = new QTabWidget;
diff --git a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp
index 0e7f538198..82adfbd97f 100644
--- a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp
+++ b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp
@@ -42,6 +42,8 @@
#include "mousepangesturerecognizer.h"
#include <QEvent>
+#include <QVariant>
+#include <QGraphicsSceneMouseEvent>
#include <QMouseEvent>
#include <QGesture>
@@ -49,35 +51,46 @@ MousePanGestureRecognizer::MousePanGestureRecognizer()
{
}
-QGesture* MousePanGestureRecognizer::createGesture(QObject *)
+QGesture* MousePanGestureRecognizer::create(QObject *)
{
return new QPanGesture;
}
-QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event)
+QGestureRecognizer::Result MousePanGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event)
{
QPanGesture *g = static_cast<QPanGesture *>(state);
- QMouseEvent *me = static_cast<QMouseEvent *>(event);
+ QPoint globalPos;
+ switch (event->type()) {
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ case QEvent::GraphicsSceneMouseMove:
+ case QEvent::GraphicsSceneMouseRelease:
+ globalPos = static_cast<QGraphicsSceneMouseEvent *>(event)->screenPos();
+ break;
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonRelease:
+ globalPos = static_cast<QMouseEvent *>(event)->globalPos();
+ break;
+ default:
+ break;
+ }
if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick
|| event->type() == QEvent::GraphicsSceneMousePress || event->type() == QEvent::GraphicsSceneMouseDoubleClick) {
- g->setHotSpot(me->globalPos());
- g->setProperty("lastPos", me->globalPos());
+ g->setHotSpot(globalPos);
+ g->setProperty("startPos", globalPos);
g->setProperty("pressed", QVariant::fromValue<bool>(true));
- return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint;
+ return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
} else if (event->type() == QEvent::MouseMove || event->type() == QEvent::GraphicsSceneMouseMove) {
if (g->property("pressed").toBool()) {
- QPoint pos = me->globalPos();
- QPoint lastPos = g->property("lastPos").toPoint();
+ QPoint offset = globalPos - g->property("startPos").toPoint();
g->setLastOffset(g->offset());
- lastPos = pos - lastPos;
- g->setOffset(QSizeF(lastPos.x(), lastPos.y()));
- g->setTotalOffset(g->totalOffset() + QSizeF(lastPos.x(), lastPos.y()));
- g->setProperty("lastPos", pos);
- return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint;
+ g->setOffset(QPointF(offset.x(), offset.y()));
+ return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
}
- return QGestureRecognizer::NotGesture;
+ return QGestureRecognizer::CancelGesture;
} else if (event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::GraphicsSceneMouseRelease) {
- return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint;
+ return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint;
}
return QGestureRecognizer::Ignore;
}
@@ -85,11 +98,10 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat
void MousePanGestureRecognizer::reset(QGesture *state)
{
QPanGesture *g = static_cast<QPanGesture *>(state);
- g->setTotalOffset(QSizeF());
- g->setLastOffset(QSizeF());
- g->setOffset(QSizeF());
+ g->setLastOffset(QPointF());
+ g->setOffset(QPointF());
g->setAcceleration(0);
- g->setProperty("lastPos", QVariant());
+ g->setProperty("startPos", QVariant());
g->setProperty("pressed", QVariant::fromValue<bool>(false));
QGestureRecognizer::reset(state);
}
diff --git a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h
index b062fd0620..6e04621f29 100644
--- a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h
+++ b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h
@@ -49,8 +49,8 @@ class MousePanGestureRecognizer : public QGestureRecognizer
public:
MousePanGestureRecognizer();
- QGesture* createGesture(QObject *target);
- QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event);
+ QGesture* create(QObject *target);
+ QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event);
void reset(QGesture *state);
};
diff --git a/tests/manual/gestures/scrollarea/main.cpp b/tests/manual/gestures/scrollarea/main.cpp
index 27966370da..4f33b289e2 100644
--- a/tests/manual/gestures/scrollarea/main.cpp
+++ b/tests/manual/gestures/scrollarea/main.cpp
@@ -50,7 +50,7 @@ public:
ScrollArea(QWidget *parent = 0)
: QScrollArea(parent), outside(false)
{
- viewport()->grabGesture(Qt::PanGesture);
+ viewport()->grabGesture(Qt::PanGesture, Qt::ReceivePartialGestures);
}
protected:
@@ -73,11 +73,11 @@ protected:
QPanGesture *pan = static_cast<QPanGesture *>(event->gesture(Qt::PanGesture));
if (pan) {
switch(pan->state()) {
- case Qt::GestureStarted: qDebug("area: Pan: started"); break;
- case Qt::GestureFinished: qDebug("area: Pan: finished"); break;
- case Qt::GestureCanceled: qDebug("area: Pan: canceled"); break;
+ case Qt::GestureStarted: qDebug() << this << "Pan: started"; break;
+ case Qt::GestureFinished: qDebug() << this << "Pan: finished"; break;
+ case Qt::GestureCanceled: qDebug() << this << "Pan: canceled"; break;
case Qt::GestureUpdated: break;
- default: qDebug("area: Pan: <unknown state>"); break;
+ default: qDebug() << this << "Pan: <unknown state>"; break;
}
if (pan->state() == Qt::GestureStarted)
@@ -87,23 +87,23 @@ protected:
if (outside)
return;
- const QSizeF offset = pan->offset();
- const QSizeF totalOffset = pan->totalOffset();
+ const QPointF delta = pan->delta();
+ const QPointF totalOffset = pan->offset();
QScrollBar *vbar = verticalScrollBar();
QScrollBar *hbar = horizontalScrollBar();
- if ((vbar->value() == vbar->minimum() && totalOffset.height() > 10) ||
- (vbar->value() == vbar->maximum() && totalOffset.height() < -10)) {
+ if ((vbar->value() == vbar->minimum() && totalOffset.y() > 10) ||
+ (vbar->value() == vbar->maximum() && totalOffset.y() < -10)) {
outside = true;
return;
}
- if ((hbar->value() == hbar->minimum() && totalOffset.width() > 10) ||
- (hbar->value() == hbar->maximum() && totalOffset.width() < -10)) {
+ if ((hbar->value() == hbar->minimum() && totalOffset.x() > 10) ||
+ (hbar->value() == hbar->maximum() && totalOffset.x() < -10)) {
outside = true;
return;
}
- vbar->setValue(vbar->value() - offset.height());
- hbar->setValue(hbar->value() - offset.width());
+ vbar->setValue(vbar->value() - delta.y());
+ hbar->setValue(hbar->value() - delta.x());
event->accept(pan);
}
}
@@ -134,11 +134,11 @@ protected:
QPanGesture *pan = static_cast<QPanGesture *>(event->gesture(Qt::PanGesture));
if (pan) {
switch (pan->state()) {
- case Qt::GestureStarted: qDebug("slider: Pan: started"); break;
- case Qt::GestureFinished: qDebug("slider: Pan: finished"); break;
- case Qt::GestureCanceled: qDebug("slider: Pan: canceled"); break;
+ case Qt::GestureStarted: qDebug() << this << "Pan: started"; break;
+ case Qt::GestureFinished: qDebug() << this << "Pan: finished"; break;
+ case Qt::GestureCanceled: qDebug() << this << "Pan: canceled"; break;
case Qt::GestureUpdated: break;
- default: qDebug("slider: Pan: <unknown state>"); break;
+ default: qDebug() << this << "Pan: <unknown state>"; break;
}
if (pan->state() == Qt::GestureStarted)
@@ -147,28 +147,28 @@ protected:
event->ignore(pan);
if (outside)
return;
- const QSizeF offset = pan->offset();
- const QSizeF totalOffset = pan->totalOffset();
+ const QPointF delta = pan->delta();
+ const QPointF totalOffset = pan->offset();
if (orientation() == Qt::Horizontal) {
- if ((value() == minimum() && totalOffset.width() < -10) ||
- (value() == maximum() && totalOffset.width() > 10)) {
+ if ((value() == minimum() && totalOffset.x() < -10) ||
+ (value() == maximum() && totalOffset.x() > 10)) {
outside = true;
return;
}
- if (totalOffset.height() < 40 && totalOffset.height() > -40) {
- setValue(value() + offset.width());
+ if (totalOffset.y() < 40 && totalOffset.y() > -40) {
+ setValue(value() + delta.x());
event->accept(pan);
} else {
outside = true;
}
} else if (orientation() == Qt::Vertical) {
- if ((value() == maximum() && totalOffset.height() < -10) ||
- (value() == minimum() && totalOffset.height() > 10)) {
+ if ((value() == maximum() && totalOffset.y() < -10) ||
+ (value() == minimum() && totalOffset.y() > 10)) {
outside = true;
return;
}
- if (totalOffset.width() < 40 && totalOffset.width() > -40) {
- setValue(value() - offset.height());
+ if (totalOffset.x() < 40 && totalOffset.x() > -40) {
+ setValue(value() - delta.y());
event->accept(pan);
} else {
outside = true;
@@ -186,6 +186,7 @@ public:
MainWindow()
{
rootScrollArea = new ScrollArea;
+ rootScrollArea->setObjectName(QLatin1String("rootScrollArea"));
setCentralWidget(rootScrollArea);
QWidget *root = new QWidget;
@@ -193,14 +194,17 @@ public:
rootScrollArea->setWidget(root);
Slider *verticalSlider = new Slider(Qt::Vertical, root);
+ verticalSlider->setObjectName(QLatin1String("verticalSlider"));
verticalSlider ->move(650, 1100);
Slider *horizontalSlider = new Slider(Qt::Horizontal, root);
+ horizontalSlider->setObjectName(QLatin1String("horizontalSlider"));
horizontalSlider ->move(600, 1000);
childScrollArea = new ScrollArea(root);
+ childScrollArea->setObjectName(QLatin1String("childScrollArea"));
childScrollArea->move(500, 500);
QWidget *w = new QWidget;
- w->setMinimumWidth(400);
+ w->setMinimumWidth(700);
QVBoxLayout *l = new QVBoxLayout(w);
l->setMargin(20);
for (int i = 0; i < 100; ++i) {
@@ -211,6 +215,14 @@ public:
l->addWidget(w);
}
childScrollArea->setWidget(w);
+#if defined(Q_OS_WIN)
+ // Windows can force Qt to create a native window handle for an
+ // intermediate widget and that will block gesture to get touch events.
+ // So this hack to make sure gestures get all touch events they need.
+ foreach (QObject *w, children())
+ if (w->isWidgetType())
+ static_cast<QWidget *>(w)->setAttribute(Qt::WA_AcceptTouchEvents);
+#endif
}
private:
ScrollArea *rootScrollArea;
@@ -220,7 +232,7 @@ private:
int main(int argc, char **argv)
{
QApplication app(argc, argv);
- app.registerGestureRecognizer(new MousePanGestureRecognizer);
+ QGestureRecognizer::registerRecognizer(new MousePanGestureRecognizer);
MainWindow w;
w.show();
return app.exec();
diff --git a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp
index 79b633e0d3..66fcf18023 100644
--- a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp
+++ b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp
@@ -49,34 +49,39 @@ MousePanGestureRecognizer::MousePanGestureRecognizer()
{
}
-QGesture* MousePanGestureRecognizer::createGesture(QObject *) const
+QGesture *MousePanGestureRecognizer::create(QObject *)
{
return new QPanGesture;
}
-QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event)
+QGestureRecognizer::Result MousePanGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event)
{
QPanGesture *g = static_cast<QPanGesture *>(state);
+ if (event->type() == QEvent::TouchBegin) {
+ // ignore the following mousepress event
+ g->setProperty("ignoreMousePress", QVariant::fromValue<bool>(true));
+ } else if (event->type() == QEvent::TouchEnd) {
+ g->setProperty("ignoreMousePress", QVariant::fromValue<bool>(false));
+ }
QMouseEvent *me = static_cast<QMouseEvent *>(event);
- if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick) {
+ if (event->type() == QEvent::MouseButtonPress) {
+ if (g->property("ignoreMousePress").toBool())
+ return QGestureRecognizer::Ignore;
g->setHotSpot(me->globalPos());
- g->setProperty("lastPos", me->globalPos());
+ g->setProperty("startPos", me->globalPos());
g->setProperty("pressed", QVariant::fromValue<bool>(true));
- return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint;
+ return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
} else if (event->type() == QEvent::MouseMove) {
if (g->property("pressed").toBool()) {
- QPoint pos = me->globalPos();
- QPoint lastPos = g->property("lastPos").toPoint();
+ QPoint offset = me->globalPos() - g->property("startPos").toPoint();
g->setLastOffset(g->offset());
- lastPos = pos - lastPos;
- g->setOffset(QSizeF(lastPos.x(), lastPos.y()));
- g->setTotalOffset(g->totalOffset() + QSizeF(lastPos.x(), lastPos.y()));
- g->setProperty("lastPos", pos);
- return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint;
+ g->setOffset(QPointF(offset.x(), offset.y()));
+ return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
}
- return QGestureRecognizer::NotGesture;
+ return QGestureRecognizer::CancelGesture;
} else if (event->type() == QEvent::MouseButtonRelease) {
- return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint;
+ if (g->property("pressed").toBool())
+ return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint;
}
return QGestureRecognizer::Ignore;
}
@@ -84,11 +89,11 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat
void MousePanGestureRecognizer::reset(QGesture *state)
{
QPanGesture *g = static_cast<QPanGesture *>(state);
- g->setTotalOffset(QSizeF());
- g->setLastOffset(QSizeF());
- g->setOffset(QSizeF());
+ g->setLastOffset(QPointF());
+ g->setOffset(QPointF());
g->setAcceleration(0);
- g->setProperty("lastPos", QVariant());
+ g->setProperty("startPos", QVariant());
g->setProperty("pressed", QVariant::fromValue<bool>(false));
+ g->setProperty("ignoreMousePress", QVariant::fromValue<bool>(false));
QGestureRecognizer::reset(state);
}
diff --git a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h
index c92d477e64..6e04621f29 100644
--- a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h
+++ b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h
@@ -49,8 +49,8 @@ class MousePanGestureRecognizer : public QGestureRecognizer
public:
MousePanGestureRecognizer();
- QGesture* createGesture(QObject *target) const;
- QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event);
+ QGesture* create(QObject *target);
+ QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event);
void reset(QGesture *state);
};
diff --git a/tests/manual/textrendering/glyphshaping/glyphshaping.pro b/tests/manual/textrendering/glyphshaping/glyphshaping.pro
new file mode 100644
index 0000000000..caa9028bc9
--- /dev/null
+++ b/tests/manual/textrendering/glyphshaping/glyphshaping.pro
@@ -0,0 +1,5 @@
+SOURCES = main.cpp
+OTHER_FILES = glyphshaping_data.xml
+glyphshaping_data.path = .
+glyphshaping_data.sources = $$PWD/glyphshaping_data.xml
+DEPLOYMENT += glyphshaping_data
diff --git a/tests/manual/textrendering/glyphshaping/glyphshaping_data.xml b/tests/manual/textrendering/glyphshaping/glyphshaping_data.xml
new file mode 100644
index 0000000000..040804e838
--- /dev/null
+++ b/tests/manual/textrendering/glyphshaping/glyphshaping_data.xml
@@ -0,0 +1,251 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<shapingtests>
+
+ <language name="Vietnamese">
+ <test
+ name="capital U, combining horn"
+ inpututf16="0x0055, 0x031B"
+ outpututf16="0x01AF"
+ />
+ <test
+ name="capital U, apostrophe"
+ inpututf16="0x0055, 0x0027"
+ outpututf16="0x0055"
+ />
+ <test
+ name="capital U, modifier prime"
+ inpututf16="0x0055, 0x02B9"
+ outpututf16="0x0055"
+ />
+ <test
+ name="capital U, modifier apostrophe"
+ inpututf16="0x0055, 0x02BC"
+ outpututf16="0x0055"
+ />
+ <test
+ name="capital U, combining comma above right"
+ inpututf16="0x0055, 0x0315"
+ outpututf16="0x0055, 0x0315"
+ />
+ <test
+ name="capital U, right single quote mark"
+ inpututf16="0x0055, 0x2019"
+ outpututf16="0x0055"
+ />
+ <test
+ name="capital U with horn, space"
+ inpututf16="0x01AF, 0x0020"
+ outpututf16="0x01AF"
+ />
+ <test
+ name="capital E, combining horn"
+ inpututf16="0x0045, 0x031B"
+ outpututf16="0x0045, 0x031B"
+ />
+ <test
+ name="capital A, combining breve, combining acute"
+ inpututf16="0x0041, 0x0306, 0x0301"
+ outpututf16="0x1EAE"
+ />
+ <test
+ name="capital A with breve, combining acute"
+ inpututf16="0x0102, 0x0301"
+ outpututf16="0x1EAE"
+ />
+ <test
+ name="capital A, combining acute, combining breve"
+ inpututf16="0x0041, 0x0301, 0x0306"
+ outpututf16="0x0041, 0x0301, 0x0306"
+ />
+ <test
+ name="capital A, combining dot below, combining breve"
+ inpututf16="0x0041, 0x0323"
+ outpututf16="0x0306"
+ />
+ <test
+ name="capital A with dot below, combining breve"
+ inpututf16="0x1EA0, 0x0306"
+ outpututf16="0x1EB6"
+ />
+ <test
+ name="capital A with breve, combining dot below"
+ inpututf16="0x0102, 0x0323"
+ outpututf16="0x0102, 0x0323"
+ />
+ <test
+ name="capital E, combining circumflex, combining acute"
+ inpututf16="0x0045, 0x0302, 0x0301"
+ outpututf16="0x1EBE"
+ />
+ <test
+ name="capital E with circumflex, combining acute"
+ inpututf16="0x00CA, 0x0301"
+ outpututf16="0x1EBE"
+ />
+ <test
+ name="capital O, combining horn, combining hook above"
+ inpututf16="0x004F, 0x031B, 0x0309"
+ outpututf16="0x1EDE"
+ />
+ <test
+ name="capital O with horn, combining hook above"
+ inpututf16="0x01A0, 0x0309"
+ outpututf16="0x1EDE"
+ />
+ </language>
+
+ <language name="Tamil">
+ <test
+ name="Tamil Ka"
+ inpututf16="0x0B95"
+ outputglyphids="0x0bf6"
+ />
+ <test
+ name="Tamil e"
+ inpututf16="0x0B8E"
+ outputglyphids="0x0bf0"
+ />
+ <test
+ name="Latin A"
+ inpututf16="0x0061"
+ outpututf16="0x0061"
+ />
+ <test
+ name="Hindi Ka"
+ inpututf16="0x0905"
+ outputglyphids="0x0528"
+ />
+ <test
+ name="03 - 1: Latin 06"
+ inpututf16="0x0036"
+ outputglyphids="0x077A"
+ />
+ <test
+ name="03 - 2: Tamil 06"
+ inpututf16="0x0BEC"
+ outputglyphids="0x0c20"
+ />
+ <test
+ name="10 1.3.6 - 1: Pa, Virama, Ka, Virama, Tta, -e"
+ inpututf16="0x0BAA, 0x0BCD, 0x0B95, 0x0BCD, 0x0B9F, 0x0BC7"
+ outputglyphids="0x0c3a, 0x0c30, 0x0c13, 0x0bfb"
+ />
+ <test
+ name="10 1.3.6 - 2: Pa, Virama, Ka, AU"
+ inpututf16="0x0BAA, 0x0BCD, 0x0B95, 0x0BCC"
+ outputglyphids="0x0c3a, 0x0c12, 0x0bf6, 0x0c19"
+ />
+ <test
+ name="10 1.3.6 - 3: Ka, Virama, Ssa, OO"
+ inpututf16="0x0B95, 0x0BCD, 0x0BB7, 0x0BCB"
+ outputglyphids="0x0c13, 0x0c2f, 0x0c0d"
+ />
+ <test
+ name="11: Ka, -e"
+ inpututf16="0x0B95, 0x0BC7"
+ outputglyphids="0x0c13, 0x0bf6"
+ />
+ <test
+ name="12 1.3.5.2: Ka, O"
+ inpututf16="0x0B95, 0x0BCA"
+ outputglyphids="0x0c12, 0x0bf6, 0x0c0d"
+ />
+ <test
+ name="13 - 1: Ka"
+ inpututf16="0x0B95"
+ outputglyphids="0x0bf6"
+ />
+ <test
+ name="13 - 2: Aythem, A"
+ inpututf16="0x0B83, 0x0B85"
+ />
+ <test
+ name="14 - 1: Ka, Anusvara"
+ inpututf16="0x0B95, 0x0B82"
+ outputglyphids="0x0bf6, 0x0be8"
+ />
+ <test
+ name="14 - 2: Ka"
+ inpututf16="0x0B95"
+ outputglyphids="0x0bf6"
+ />
+ <test
+ name="15 - 1: Ra, Virama"
+ inpututf16="0x0BB0, 0x0BCD"
+ outputglyphids="0x0c03"
+ />
+ <test
+ name="15 - 2: ZWJ"
+ inpututf16="0x8205"
+ />
+ <test
+ name="16: Ka, Anusvara"
+ inpututf16="0x0B95, 0x0B82"
+ outputglyphids="0x0bf6"
+ />
+ <test
+ name="17 1.3.11 - 1: Tta, I"
+ inpututf16="0x0B9F, 0x0BBF"
+ outputglyphids="0x0c51"
+ />
+ <test
+ name="17 1.3.11 - 2: Tta, Ii"
+ inpututf16="0x0B9F, 0x0BC0"
+ outputglyphids="0x0c52"
+ />
+ <test
+ name="18 - 1: Ra, I"
+ inpututf16="0x0BB0, 0x0BBF"
+ outputglyphids="0x0c0d, 0x0c0e"
+ />
+ <test
+ name="18 - 2: Ra, Ii"
+ inpututf16="0x0BB0, 0x0BC0"
+ outputglyphids="0x0c0d, 0x0c0f"
+ />
+ <test
+ name="19 - 1: Nga, I"
+ inpututf16="0x0B99, 0x0BBF"
+ outputglyphids="0x0bf7, 0x0c0e"
+ />
+ <test
+ name="19 - 2: Nga, Ii"
+ inpututf16="0x0B99, 0x0BC0"
+ outputglyphids="0x0c4a"
+ />
+ <test
+ name="20 - 1: Ja, U"
+ inpututf16="0x0B9C, 0x0BC1"
+ outputglyphids="0x0bf9, 0x0c10"
+ />
+ <test
+ name="20 - 2: Ja, Uu"
+ inpututf16="0x0B9C, 0x0BC2"
+ outputglyphids="0x0bf9, 0x0c11"
+ />
+ <test
+ name="21 1.3.15: Ka, Ai"
+ inpututf16="0x0B95, 0x0BC8"
+ outputglyphids="0x0c14, 0x0bf6"
+ />
+ <test
+ name="22: Ka, Virama, Ssa"
+ inpututf16="0x0B95, 0x0BCD, 0x0BB7"
+ outputglyphids="0x0c2f"
+ />
+ <test
+ name="23 1.3.17: Sa, Virama, Ra, Matra I"
+ inpututf16="0x0BB8, 0x0BCD, 0x0BB0, 0x0BC0"
+ outputglyphids="0x0c79"
+ />
+ <test
+ name="24 1.3.18 - 1: Ka"
+ inpututf16="0x0B95"
+ outputglyphids="0x0bf6"
+ />
+ <test
+ name="24 1.3.18 - 2: Virama, ZWJ"
+ inpututf16="0x0BCD, 0x8205"
+ />
+ </language>
+</shapingtests>
diff --git a/tests/manual/textrendering/glyphshaping/main.cpp b/tests/manual/textrendering/glyphshaping/main.cpp
new file mode 100644
index 0000000000..d2b53a0098
--- /dev/null
+++ b/tests/manual/textrendering/glyphshaping/main.cpp
@@ -0,0 +1,269 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 <QtGui>
+
+static const int fontPixelSize = 25;
+static const QLatin1String fontFamily("Series 60 Sans");
+
+struct testDataSet
+{
+ QString language;
+ QString name;
+ QString input;
+ QString inputOriginal;
+ QString output;
+ QString outputOriginal;
+ QVector<uint> outputGlyphIDs;
+ QString outputGlyphIDsOriginal;
+};
+
+QString charHexCsv2String(const QString &csv)
+{
+ QString result;
+ foreach (const QString &charString, csv.split(QLatin1Char(','), QString::SkipEmptyParts)) {
+ bool isOk;
+ const uint charUInt = charString.toUInt(&isOk, 16);
+ Q_ASSERT(isOk);
+ const int size = charUInt >= SHRT_MAX ? 2:1;
+ result.append(QString::fromUtf16((const ushort*)&charUInt, size));
+ }
+ return result;
+}
+
+QList<testDataSet> testDataSetList()
+{
+ QList<testDataSet> result;
+ QFile file("glyphshaping_data.xml");
+ const bool success = file.open(QIODevice::ReadOnly);
+ Q_ASSERT(success);
+
+ const QLatin1String language("language");
+ const QLatin1String test("test");
+ const QLatin1String inputUtf16("inpututf16");
+ const QLatin1String outputUtf16("outpututf16");
+ const QLatin1String outputGlyphIDs("outputglyphids");
+ const QLatin1String name("name");
+
+ QString languageName;
+
+ QXmlStreamReader reader(&file);
+ while (!reader.atEnd()) {
+ const QXmlStreamReader::TokenType token = reader.readNext();
+ switch (token) {
+ case QXmlStreamReader::StartElement:
+ if (reader.name() == language) {
+ Q_ASSERT(reader.attributes().hasAttribute(name));
+ languageName = reader.attributes().value(name).toString();
+ } else if (reader.name() == test) {
+ if (!reader.attributes().hasAttribute(outputUtf16)
+ && !reader.attributes().hasAttribute(outputGlyphIDs))
+ continue;
+ Q_ASSERT(!languageName.isEmpty());
+ Q_ASSERT(reader.attributes().hasAttribute(name));
+ Q_ASSERT(reader.attributes().hasAttribute(inputUtf16));
+ testDataSet set;
+ set.language = languageName;
+ set.name = reader.attributes().value(name).toString();
+ set.inputOriginal = reader.attributes().value(inputUtf16).toString();
+ set.input = charHexCsv2String(set.inputOriginal);
+ set.outputOriginal = reader.attributes().value(outputUtf16).toString();
+ set.output = charHexCsv2String(set.outputOriginal);
+ set.outputGlyphIDsOriginal = reader.attributes().value(outputGlyphIDs).toString();
+ result.append(set);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ return result;
+}
+
+QImage renderedText(const QString &text, const QFont &font)
+{
+ const QFontMetrics metrics(font);
+ const QRect boundingRect = metrics.boundingRect(text);
+ QImage result(boundingRect.size(), QImage::Format_ARGB32);
+ result.fill(0);
+
+ QPainter p(&result);
+ p.setFont(font);
+ p.drawText(boundingRect.translated(-boundingRect.topLeft()), text);
+
+ return result;
+}
+
+QString dumpImageHtml(const QString &text, const QString &pathName)
+{
+ if (text.isEmpty())
+ return QLatin1String("<td/>");
+ QFont font(fontFamily);
+ font.setPixelSize(fontPixelSize);
+ const QImage textImage = renderedText(text, font);
+ const QString imageFileName =
+ (pathName + QDir::separator() + QLatin1String("%1.png"))
+ .arg(textImage.cacheKey());
+ const bool success = textImage.save(imageFileName);
+ Q_ASSERT(success);
+ return
+ QString::fromLatin1("<td title=\"%2\"><img src=\"%1\" alt=\"%2\" width=\"%3\" height=\"%4\"/></td>")
+ .arg(QDir::cleanPath(imageFileName)).arg(text).arg(textImage.width()).arg(textImage.height());
+}
+
+QString dlItem(const QString &dt, const QString &dd)
+{
+ if (!dd.trimmed().isEmpty())
+ return QString::fromLatin1("\t\t\t\t\t\t<dt>%1</dt><dd>%2</dd>\n").arg(dt).arg(dd);
+ return QString();
+}
+
+bool dumpHtml(const QString &pathName)
+{
+ QFile htmlPage(pathName + QDir::separator() + QLatin1String("index.html"));
+ if (!htmlPage.open(QFile::WriteOnly))
+ return false;
+
+ QString platformName = QString::fromLatin1(
+#if defined(Q_OS_WIN)
+ "Win32"
+#elif defined(Q_WS_X11)
+ "X11"
+#elif defined(Q_OS_SYMBIAN)
+ "Symbian"
+#else
+ ""
+#endif
+ );
+
+ QString result = QString::fromLatin1(
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
+ " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\n"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"
+ "\t<head>\n"
+ "\t\t<title>Qt on %1 glyph shaping (%2)</title>\n"
+ "\t\t<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />\n"
+ "\t\t<style type=\"text/css\" media=\"screen\">\n"
+ "\t\t\ttable { font-family: Arial; background-color: #ccccff; font-size: 12pt; }\n"
+ "\t\t\ttd { font-family:\"%2\"; background-color: #eeeeee; font-size: %3px; }\n"
+ "\t\t\tth { font-weight:normal; }\n"
+ "\t\t\tdl { font-family: Arial; font-size: 8pt; margin: 3px; }\n"
+ "\t\t\tdt { font-weight: bold; float: left; }\n"
+ "\t\t\ttr:hover { background-color: #ddddff; }\n"
+ "\t\t\ttd:hover { background-color: #ddddff; }\n"
+ "\t\t</style>\n"
+ "\t</head>\n"
+ "\t<body>\n"
+ "\t\t<h1>Qt on %1 glyph shaping (%2)</h1>\n"
+ "\t\t<dl>\n"
+ "\t\t\t<dt>I</dt><dd>Input Utf-16 to shaper</dd>\n"
+ "\t\t\t<dt>O-Utf</dt><dd>expected output Utf-16</dd>\n"
+ "\t\t\t<dt>O-ID</dt><dd>expected output Glyph IDs for \"Series 60 Sans\"</dd>\n"
+ "\t\t</dl>\n"
+ "\t\t<table>\n"
+ ).arg(platformName).arg(fontFamily).arg(fontPixelSize);
+
+ QString languageName;
+ foreach (const testDataSet &dataSet, testDataSetList()) {
+ if (languageName != dataSet.language) {
+ result.append(QString::fromLatin1(
+ "\t\t\t<tr>\n"
+ "\t\t\t\t<th rowspan=\"2\"><h2>%1</h2></th>\n"
+ "\t\t\t\t<th colspan=\"2\">Qt/%2</th>\n"
+ "\t\t\t\t<th rowspan=\"2\">Glyphs</th>\n"
+ "\t\t\t\t<th colspan=\"2\">Browser</th>\n"
+ "\t\t\t</tr>\n"
+ "\t\t\t<tr>\n"
+ "\t\t\t\t<th>In</th>\n"
+ "\t\t\t\t<th>Out</th>\n"
+ "\t\t\t\t<th>In</th>\n"
+ "\t\t\t\t<th>Out</th>\n"
+ "\t\t\t</tr>\n"
+ ).arg(dataSet.language).arg(platformName));
+ languageName = dataSet.language;
+ }
+ QString glyphsData;
+ if (!dataSet.inputOriginal.isEmpty())
+ glyphsData.append(dlItem(QLatin1String("I"), dataSet.inputOriginal));
+ if (!dataSet.outputOriginal.isEmpty())
+ glyphsData.append(dlItem(QLatin1String("O-Utf"), dataSet.outputOriginal));
+ if (!dataSet.outputGlyphIDsOriginal.isEmpty())
+ glyphsData.append(dlItem(QLatin1String("O-ID"), dataSet.outputGlyphIDsOriginal));
+ if (!glyphsData.isEmpty()) {
+ glyphsData.prepend(QLatin1String("\t\t\t\t\t<dl>\n"));
+ glyphsData.append(QLatin1String("\t\t\t\t\t</dl>\n"));
+ }
+ result.append(QString::fromLatin1(
+ "\t\t\t<tr>\n"
+ "\t\t\t\t<th>%1</th>\n"
+ "\t\t\t\t%2\n"
+ "\t\t\t\t%3\n"
+ "\t\t\t\t<td>\n"
+ "%4"
+ "\t\t\t\t</td>\n"
+ "\t\t\t\t<td>%5</td>\n"
+ "\t\t\t\t<td>%6</td>\n"
+ "\t\t\t</tr>\n"
+ ).arg(dataSet.name)
+ .arg(dumpImageHtml(dataSet.input, pathName))
+ .arg(dumpImageHtml(dataSet.output, pathName))
+ .arg(glyphsData)
+ .arg(dataSet.input)
+ .arg(dataSet.output)
+ );
+ }
+
+ result.append(QString::fromLatin1(
+ "\t\t</table>\n"
+ "\t</body>\n"
+ "</html>")
+ );
+
+ htmlPage.write(result.toUtf8());
+
+ return true;
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ return dumpHtml(QLatin1String(".")) ? 0 : 1;
+}
diff --git a/tests/manual/textrendering/textperformance/main.cpp b/tests/manual/textrendering/textperformance/main.cpp
new file mode 100644
index 0000000000..47e0a88482
--- /dev/null
+++ b/tests/manual/textrendering/textperformance/main.cpp
@@ -0,0 +1,231 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 <QtGui>
+
+static const int lastMeasurementsCount = 50;
+
+class FontBlaster: public QWidget
+{
+ Q_OBJECT
+
+public:
+ FontBlaster(QWidget *parent = 0)
+ : QWidget(parent)
+ , m_currentMode(0)
+ {
+ setFocusPolicy(Qt::StrongFocus);
+ }
+
+ void paintEvent(QPaintEvent *event)
+ {
+ Q_UNUSED(event);
+ QPainter p(this);
+
+ if (!m_timer.isNull())
+ m_lastMeasurements.append(m_timer.elapsed());
+ m_timer.start();
+
+ p.save();
+ m_modes[m_currentMode].function(p, size());
+ p.restore();
+
+ const QFontMetrics fm = p.fontMetrics();
+ p.setOpacity(0.7);
+ p.fillRect(0, 0, width(), fm.height(), Qt::gray);
+ p.fillRect(0, height() - fm.height(), width(), height(), Qt::gray);
+ p.setOpacity(1);
+ p.setPen(palette().color(QPalette::Text));
+ p.drawText(2, fm.ascent(), m_modes[m_currentMode].name);
+
+ if (m_lastMeasurements.count() == lastMeasurementsCount) {
+ m_lastMeasurements.removeFirst();
+ int lastMsecsSum = 0;
+ foreach(const int measurement, m_lastMeasurements)
+ lastMsecsSum += measurement;
+
+ p.drawText(2, height() - fm.descent(),
+ QLatin1String("Fps: ") +
+ QString::number(1000 / ((qreal)lastMsecsSum / lastMeasurementsCount), 'f', 1)
+ );
+ }
+
+ QTimer::singleShot(0, this, SLOT(repaint()));
+ }
+
+ /*
+ Creating all kinds of size/weight/italic combinations, stress testing
+ the glyph cache.
+ Also: painting with different opacities, stress testing blitting.
+ */
+ static void paintDifferentFontStyles(QPainter &p, const QSize &size)
+ {
+ static const QString text = QLatin1String("Qt rocks!!!");
+ static const int textsPerPaint = 30;
+ for (int i = 0; i < textsPerPaint; i++) {
+ const int fontSize = 4 + (qrand() % 5);
+ const int fontWeight = (qrand() % 2) == 1 ? QFont::Normal : QFont::Bold;
+ const bool fontItalic = (qrand() % 2) == 1;
+ const QFont font("Default", fontSize, fontWeight, fontItalic);
+ p.setFont(font);
+ p.setPen(QColor::fromHsv(qrand() % 359, 155 + qrand() % 100,
+ 155 + qrand() % 100, 100 + qrand() % 155));
+ const QSize textSize(p.fontMetrics().boundingRect(text).size());
+ const QPoint position(
+ -textSize.width() / 2 + (qrand() % size.width()),
+ textSize.height() / 2 + (qrand() % size.height()));
+ p.drawText(position, text);
+ }
+ }
+
+ /*
+ Drawing a multiline latin text, stress testing the text layout system.
+ */
+ static void paintLongLatinText(QPainter &p, const QSize &size)
+ {
+ static const char* const pieces[] = {
+ "lorem ipsum",
+ "dolor sit amet",
+ "consectetuer",
+ "sed diam nonumy",
+ "eos et accusam",
+ "sea takimata sanctus"
+ };
+ static const int piecesCount = (int)(sizeof pieces / sizeof pieces[0]);
+ static const int piecesPerPaint = 30;
+
+ QString text;
+ for (int i = 0; i < piecesPerPaint; ++i) {
+ QString piece = QLatin1String(pieces[qrand() % piecesCount]);
+ if (i == 0 || qrand() % 2) {
+ // Make this piece the beginning of a new sentence.
+ piece[0] = piece[0].toUpper();
+ if (i > 0)
+ piece.prepend(QLatin1String(". "));
+ } else {
+ piece.prepend(QLatin1String(", "));
+ }
+ text.append(piece);
+ }
+ text.append(QLatin1Char('.'));
+
+ p.drawText(QRectF(QPointF(0, 0), QSizeF(size)),
+ Qt::AlignTop | Qt::AlignAbsolute | Qt::TextWordWrap, text);
+ }
+
+ /*
+ Drawing one text with several snippets of different writingSystems, stress
+ testing the font merging in the font database.
+ */
+ static void paintInternationalText(QPainter &p, const QSize &size)
+ {
+ static QStringList samples;
+ if (samples.isEmpty()) {
+ foreach (const QFontDatabase::WritingSystem system, QFontDatabase().writingSystems())
+ if (system != QFontDatabase::Ogham && system != QFontDatabase::Runic)
+ samples.append(QFontDatabase::writingSystemSample(system));
+ }
+ static const int systemsPerPaint = 65;
+ QString text;
+ for (int i = 0; i < systemsPerPaint; i++) {
+ if (i > 0)
+ text.append(QLatin1Char(' '));
+ text.append(samples.at(qrand() % samples.count()));
+ }
+ p.drawText(QRectF(QPointF(0, 0), QSizeF(size)),
+ Qt::AlignTop | Qt::AlignAbsolute | Qt::TextWordWrap, text);
+ }
+
+protected:
+ void nextMode()
+ {
+ m_currentMode = (m_currentMode + 1) % m_modesCount;
+ m_lastMeasurements.clear();
+ }
+
+ void keyPressEvent(QKeyEvent *event)
+ {
+ Q_UNUSED(event);
+ nextMode();
+ }
+
+ void mousePressEvent(QMouseEvent *event)
+ {
+ Q_UNUSED(event);
+ nextMode();
+ }
+
+private:
+ static const struct mode {
+ QString name;
+ void (*function)(QPainter &, const QSize&);
+ } m_modes[];
+ static const int m_modesCount;
+
+ int m_currentMode;
+ QList<int> m_lastMeasurements;
+ QTime m_timer;
+};
+
+const struct FontBlaster::mode FontBlaster::m_modes[] = {
+ { QLatin1String("Qt rocks!!!"), FontBlaster::paintDifferentFontStyles },
+ { QLatin1String("Latin"), FontBlaster::paintLongLatinText },
+ { QLatin1String("International"), FontBlaster::paintInternationalText }
+};
+
+const int FontBlaster::m_modesCount =
+ (int)(sizeof m_modes / sizeof m_modes[0]);
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ FontBlaster dlg;
+#ifdef Q_OS_SYMBIAN
+ dlg.showFullScreen();
+#else
+ dlg.show();
+#endif
+
+ return a.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/textrendering/textperformance/textperformance.pro b/tests/manual/textrendering/textperformance/textperformance.pro
new file mode 100644
index 0000000000..bba41b9c12
--- /dev/null
+++ b/tests/manual/textrendering/textperformance/textperformance.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/tests/manual/windowflags/previewwindow.cpp b/tests/manual/windowflags/previewwindow.cpp
index 78f9fcbed7..31e8b3ecfd 100644
--- a/tests/manual/windowflags/previewwindow.cpp
+++ b/tests/manual/windowflags/previewwindow.cpp
@@ -103,8 +103,18 @@ PreviewWindow::PreviewWindow(QWidget *parent)
closeButton = new QPushButton(tr("&Close"));
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
+ showNormalButton = new QPushButton(tr("Show normal"));
+ connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal()));
+ showMaximizedButton = new QPushButton(tr("Show maximized"));
+ connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized()));
+ showFullScreenButton = new QPushButton(tr("Show fullscreen"));
+ connect(showFullScreenButton, SIGNAL(clicked()), this, SLOT(showFullScreen()));
+
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(textEdit);
+ layout->addWidget(showNormalButton);
+ layout->addWidget(showMaximizedButton);
+ layout->addWidget(showFullScreenButton);
layout->addWidget(closeButton);
setLayout(layout);
@@ -129,8 +139,18 @@ PreviewDialog::PreviewDialog(QWidget *parent)
closeButton = new QPushButton(tr("&Close"));
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
+ showNormalButton = new QPushButton(tr("Show normal"));
+ connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal()));
+ showMaximizedButton = new QPushButton(tr("Show maximized"));
+ connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized()));
+ showFullScreenButton = new QPushButton(tr("Show fullscreen"));
+ connect(showFullScreenButton, SIGNAL(clicked()), this, SLOT(showFullScreen()));
+
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(textEdit);
+ layout->addWidget(showNormalButton);
+ layout->addWidget(showMaximizedButton);
+ layout->addWidget(showFullScreenButton);
layout->addWidget(closeButton);
setLayout(layout);
diff --git a/tests/manual/windowflags/previewwindow.h b/tests/manual/windowflags/previewwindow.h
index fdd21d7b04..fbf822b5d7 100644
--- a/tests/manual/windowflags/previewwindow.h
+++ b/tests/manual/windowflags/previewwindow.h
@@ -62,6 +62,9 @@ public:
private:
QTextEdit *textEdit;
QPushButton *closeButton;
+ QPushButton *showNormalButton;
+ QPushButton *showMaximizedButton;
+ QPushButton *showFullScreenButton;
};
class PreviewDialog : public QDialog
@@ -76,6 +79,9 @@ public:
private:
QTextEdit *textEdit;
QPushButton *closeButton;
+ QPushButton *showNormalButton;
+ QPushButton *showMaximizedButton;
+ QPushButton *showFullScreenButton;
};
#endif