diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-11-25 18:20:45 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-11-25 18:20:45 (GMT) |
commit | e58b7f0cc139c5fda3d472c38161be8fb718db7d (patch) | |
tree | 3c20cccfe050d125a5f4736ba11b6383e8734be4 /tests/auto | |
parent | c2a4a1b1e06f8b0d02e7b56c9eb0c19fd2fae80a (diff) | |
parent | 4c3539dfbc65d5decdd842d4181f9aa3d38d213c (diff) | |
download | Qt-e58b7f0cc139c5fda3d472c38161be8fb718db7d.zip Qt-e58b7f0cc139c5fda3d472c38161be8fb718db7d.tar.gz Qt-e58b7f0cc139c5fda3d472c38161be8fb718db7d.tar.bz2 |
Merge branch '4.6'
Conflicts:
doc/src/modules.qdoc
examples/assistant/simpletextviewer/findfiledialog.cpp
examples/webkit/fancybrowser/mainwindow.cpp
src/gui/widgets/qtabbar.cpp
src/gui/widgets/qtabbar_p.h
tests/auto/qpixmap/tst_qpixmap.cpp
tools/assistant/compat/helpdialog.cpp
tools/assistant/compat/tabbedbrowser.cpp
translations/translations.pri
Diffstat (limited to 'tests/auto')
96 files changed, 4076 insertions, 312 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 46f26f8..d5d72a7 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 \ @@ -58,9 +59,15 @@ Q3SUBDIRS += \ q3toolbar \ q3urloperator \ q3valuelist \ - q3valuevector + q3valuevector \ + q3combobox \ + q3frame \ + q3uridrag \ + q3widgetstack SUBDIRS += \ +# exceptionsafety_objects \ shouldn't enable it + languagechange \ collections \ exceptionsafety \ mediaobject \ @@ -402,8 +409,55 @@ SUBDIRS += \ symbols \ qrand \ utf8 \ - gestures - + gestures \ + qabstractnetworkcache \ + qabstractproxymodel \ + qbytearraymatcher \ + qcalendarwidget \ + qcolumnview \ + qcommandlinkbutton \ + qdbuscontext \ + qdbusserver \ + qdbusservicewatcher \ + qdiriterator \ + qeasingcurve \ + qfileiconprovider \ + qformlayout \ + q_func_info \ + qfuture \ + qfuturewatcher \ + qguard \ + qhttpsocketengine \ + qinputcontext \ + qlocalsocket \ + qmacstyle \ + qmargins \ + qnetworkaddressentry \ + qnetworkcachemetadata \ + qnetworkdiskcache \ + qobjectperformance \ + qpainterpathstroker \ + qplugin \ + qpluginloader \ + qscrollbar \ + qsharedmemory \ + qsidebar \ + qsizegrip \ + qsoftkeymanager \ + qsqldriver \ + qsystemsemaphore \ + qtconcurrentfilter \ + qtconcurrentiteratekernel \ + qtconcurrentmap \ + qtconcurrentrun \ + qtconcurrentthreadengine \ + qthreadpool \ + qtokenautomaton \ + qtouchevent \ + qwidget_window \ + rcc \ + windowsmobile + !wince*:SUBDIRS += $$Q3SUBDIRS contains(QT_CONFIG, OdfWriter):SUBDIRS += qzip qtextodfwriter diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp index 8c6056e..b7c79cf 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/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp index f97805e..84f466b 100644 --- a/tests/auto/collections/tst_collections.cpp +++ b/tests/auto/collections/tst_collections.cpp @@ -3586,7 +3586,7 @@ void tst_Collections::alignment() #else void tst_Collections::alignment() { - QSKIP("Compiler doesn't support necessary extension keywords", SkipAll) + QSKIP("Compiler doesn't support necessary extension keywords", SkipAll); } #endif diff --git a/tests/auto/guiapplauncher/README.txt b/tests/auto/guiapplauncher/README.txt new file mode 100644 index 0000000..317f9d0 --- /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 0000000..2f81061 --- /dev/null +++ b/tests/auto/guiapplauncher/guiapplauncher.pro @@ -0,0 +1,18 @@ +# ------------------------------------------------- +# 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 + +# process enumeration,etc. +win32:LIBS+=-luser32 diff --git a/tests/auto/guiapplauncher/test.ts b/tests/auto/guiapplauncher/test.ts new file mode 100644 index 0000000..79c9c76 --- /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>&Writing system</source> + <translation>S&kript</translation> + </message> + <message> + <location line="+3"/> + <source>&Family</source> + <translation>&Schriftart</translation> + </message> + <message> + <location line="+4"/> + <source>&Style</source> + <translation>S&chriftschnitt</translation> + </message> + <message> + <location line="+4"/> + <source>&Point size</source> + <translation>Schriftg&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&tents</source> + <translation>Inhal&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><b>Help</b><p>Choose the topic you want help on from the contents list, or search the index for keywords.</p></source> + <translation><b>Hilfe</b><p>Wählen Sie ein Hilfethema aus dem Inhalt oder suchen Sie im Index nach Schlüsselwörtern.</p></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><b>Help topics organized by category.</b><p>Double-click an item to see the topics in that category. To view a topic, just double-click it.</p></source> + <translation><b>Hilfethemen geordnet nach Kategorie.</b><p>Doppelklicken Sie einen Eintrag, um die Themen dieser Kategorie zu sehen. Doppelklicken Sie ein Thema, um es angezeigt zu bekommen.</p></translation> + </message> + <message> + <location/> + <source>column 1</source> + <translation>Spalte 1</translation> + </message> + <message> + <location/> + <source>&Index</source> + <translation>&Index</translation> + </message> + <message> + <location/> + <source>&Look For:</source> + <translation>Suchen &nach:</translation> + </message> + <message> + <location/> + <source>Enter keyword</source> + <translation>Geben Sie ein Schlüsselwort ein</translation> + </message> + <message> + <location/> + <source><b>Enter a keyword.</b><p>The list will select an item that matches the entered string best.</p></source> + <translation><b>Geben Sie ein Schlüsselwort ein.</b><p>Es wird dann der Eintrag aus der Liste ausgewählt, der am besten mit dem eingegebenen Begriff übereinstimmt.</p></translation> + </message> + <message> + <location/> + <source><b>List of available help topics.</b><p>Double-click on an item to open its help page. If more than one is found, you must specify which page you want.</p></source> + <translation><b>Liste aller verfügbaren Hilfethemen.</b><p>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.</p></translation> + </message> + <message> + <location/> + <source>&Bookmarks</source> + <translation>L&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>&New</source> + <translation>&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>&Delete</source> + <translation>&Löschen</translation> + </message> + <message> + <location/> + <source>&Search</source> + <translation>&Suche</translation> + </message> + <message> + <location/> + <source>Searching f&or:</source> + <translation>Suche &nach:</translation> + </message> + <message> + <location/> + <source><b>Enter search word(s).</b><p>Enter here the word(s) you are looking for. The words may contain wildcards (*). For a sequence of words quote them.</p></source> + <translation><b>Geben Sie Suchbegriffe ein.</b><p>Geben Sie hier die gesuchten Begriffe ein. Die Begriffe können Wildcards (*) enthalten. Eine Phrase muß in Anführungszeichen stehen.</p></translation> + </message> + <message> + <location/> + <source><b>Found documents</b><p>This list contains all found documents from the last search. The documents are ordered, i.e. the first document has the most matches.</p></source> + <translation><b>Gefundene Dokumente</b><p>Diese Liste beinhaltet alle gefundenen Dokumente der letzten Suche. Die Dokumente sind nach der Häufigkeit der Treffer geordnet.</p></translation> + </message> + <message> + <location/> + <source>Found &Documents:</source> + <translation>Gefundene &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&lp</source> + <translation>Hi&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: '%1'</source> + <translation>Der Link '%1' konnte nicht geöffnet werden</translation> + </message> + <message> + <location line="+1"/> + <source><div align="center"><h1>The page could not be found</h1><br><h3>'%1'</h3></div></source> + <translation><div align="center"><h1>Die Seite wurde nicht gefunden</h1><br><h3>'%1'</h3></div></translation> + </message> + <message> + <location line="+2"/> + <source>Error...</source> + <translation>Fehler ...</translation> + </message> + <message> + <location line="+56"/> + <source>Copy &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>&Print...</source> + <translation>&Drucken...</translation> + </message> + <message> + <location/> + <source>E&xit</source> + <translation>&Beenden</translation> + </message> + <message> + <location/> + <source>&Copy</source> + <translation>&Kopieren</translation> + </message> + <message> + <location/> + <source>&Find in Text...</source> + <translation>Text&suche...</translation> + </message> + <message> + <location/> + <source>&Home</source> + <translation>St&artseite</translation> + </message> + <message> + <location/> + <source>&Previous</source> + <translation>&Vorherige</translation> + </message> + <message> + <location/> + <source>&Next</source> + <translation>&Nächste</translation> + </message> + <message> + <location/> + <source>About Qt</source> + <translation>Ãœber Qt</translation> + </message> + <message> + <location/> + <source>Zoom &in</source> + <translation>Vergrößern</translation> + </message> + <message> + <location/> + <source>Zoom &out</source> + <translation>Ver&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>&Add Bookmark</source> + <translation>&Füge Lesezeichen hinzu</translation> + </message> + <message> + <location/> + <source>&File</source> + <translation>&Datei</translation> + </message> + <message> + <location/> + <source>&Edit</source> + <translation>&Bearbeiten</translation> + </message> + <message> + <location/> + <source>&View</source> + <translation>&Ansicht</translation> + </message> + <message> + <location/> + <source>&Go</source> + <translation>&Gehe zu</translation> + </message> + <message> + <location/> + <source>Boo&kmarks</source> + <translation>&Lesezeichen</translation> + </message> + <message> + <location/> + <source>Qt Assistant by Nokia</source> + <translation>Qt Assistant von Nokia</translation> + </message> + <message> + <location/> + <source>&Help</source> + <translation>&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'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>&Close</source> + <translation>&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's This?</source> + <translation>Direkthilfe</translation> + </message> + <message> + <location/> + <source>"What's This?" 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 &Next</source> + <translation>Weitersuchen</translation> + </message> + <message> + <location/> + <source>F3</source> + <translation>F3</translation> + </message> + <message> + <location/> + <source>Find &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: '%1'</source> + <translation>Fehler beim Öffnen des Inhalts in Datei: '%1'</translation> + </message> + <message> + <location line="-246"/> + <source>Sidebar</source> + <translation>Sidebar</translation> + </message> + <message> + <location line="+18"/> + <source>&Window</source> + <translation>&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><img src=":/trolltech/assistant/images/wrap.png">&nbsp;Search wrapped</source> + <translation><img src=":/trolltech/assistant/images/wrap.png">&nbsp;Seitenende</translation> + </message> +</context> +<context> + <name>TopicChooser</name> + <message> + <location filename="../tools/assistant/compat/topicchooser.cpp" line="+56"/> + <source>Choose a topic for <b>%1</b></source> + <translation>Wählen Sie ein Thema für <b>%1</b></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 <b>Display</b>-button to open the online help.</source> + <translation>Wählen Sie ein Thema aus der Liste aus und klicken Sie <b>Anzeigen</b> um die Hilfe zu öffnen.</translation> + </message> + <message> + <location/> + <source>&Topics</source> + <translation>&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>&Display</source> + <translation>&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>&Close</source> + <translation>&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 0000000..02efcd4 --- /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 0000000..a61bd5e --- /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 0000000..758a14e --- /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/auto/qsysinfo/tst_qsysinfo.cpp b/tests/auto/guiapplauncher/windowmanager.h index 8784863..56e2eb9 100644 --- a/tests/auto/qsysinfo/tst_qsysinfo.cpp +++ b/tests/auto/guiapplauncher/windowmanager.h @@ -39,14 +39,40 @@ ** ****************************************************************************/ +#ifndef WINDOWMANAGER_H +#define WINDOWMANAGER_H -#include <QtTest/QtTest> +#include <QtCore/QSharedPointer> +#include <QtCore/QString> +#include <QtCore/QProcess> -class tst_QSysInfo: public QObject +/* WindowManager: Provides functions to retrieve the top level window of + * an application and send it a close event. */ + +class WindowManager { - Q_OBJECT -private slots: + Q_DISABLE_COPY(WindowManager) +public: + static QSharedPointer<WindowManager> create(); + + virtual ~WindowManager(); + + bool openDisplay(QString *errorMessage); + bool isDisplayOpen() const; + + // 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); }; -QTEST_MAIN(tst_QSysInfo) -#include "tst_qsysinfo.moc" +#endif // WINDOWMANAGER_H diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp index d4f2ff4..36d25fe 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/lupdate/testdata/good/codecforsrc/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp index 158451a..d99723e 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp @@ -47,12 +47,21 @@ int main(int argc, char **argv) { QApplication a(argc, argv); + QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); + QWidget w; QLabel label1(QObject::tr("abc", "ascii"), &w); QLabel label2(QObject::tr("æøå", "utf-8"), &w); + QLabel label2a(QObject::tr("\303\246\303\270\303\245", "utf-8 oct"), &w); + QLabel label3(QObject::trUtf8("Für Élise", "trUtf8"), &w); + QLabel label3a(QObject::trUtf8("F\303\274r \303\211lise", "trUtf8 oct"), &w); -// I would expect the following to work !? -// QLabel label3(QObject::trUtf8("F\374r \310lise", "trUtf8"), &w); + QBoxLayout *ly = new QVBoxLayout(&w); + ly->addWidget(&label1); + ly->addWidget(&label2); + ly->addWidget(&label2a); + ly->addWidget(&label3); + ly->addWidget(&label3a); w.show(); return a.exec(); diff --git a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result index bc0d9bb..711bf02 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result @@ -5,16 +5,34 @@ <context> <name>QObject</name> <message> - <location filename="main.cpp" line="51"/> + <location filename="main.cpp" line="53"/> <source>abc</source> <comment>ascii</comment> <translation type="unfinished"></translation> </message> <message> - <location filename="main.cpp" line="52"/> + <location filename="main.cpp" line="54"/> <source>æøå</source> <comment>utf-8</comment> <translation type="unfinished"></translation> </message> + <message> + <location filename="main.cpp" line="55"/> + <source>æøå</source> + <comment>utf-8 oct</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="56"/> + <source>Für Élise</source> + <comment>trUtf8</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="57"/> + <source>Für Élise</source> + <comment>trUtf8 oct</comment> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result index 91da744..6ee369a 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result @@ -6,7 +6,7 @@ <name>QObject</name> <message> <location filename="main.cpp" line="61"/> - <source>Ã</source> + <source>Б</source> <translation type="unfinished"></translation> </message> </context> diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp index abb8b89..98b491c 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp @@ -49,9 +49,11 @@ public: void doFoo() { tr("random ascii only"); - tr("this contains an umlaut ü ü"); + tr("this contains an umlaut ü ü literally"); + tr("this contains an umlaut \xfc ü escaped"); trUtf8("random ascii only in utf8"); - trUtf8("umlaut \xfc ü in utf8"); + trUtf8("umlaut ü ü in literal utf8"); + trUtf8("umlaut \303\274 ü in escaped utf8"); } }; diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result index 26eb245..d548e24 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result @@ -11,17 +11,27 @@ </message> <message> <location filename="main.cpp" line="52"/> - <source>this contains an umlaut ü &uuml;</source> + <source>this contains an umlaut ü &uuml; literally</source> <translation type="unfinished"></translation> </message> <message> <location filename="main.cpp" line="53"/> + <source>this contains an umlaut ü &uuml; escaped</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="54"/> <source>random ascii only in utf8</source> <translation type="unfinished"></translation> </message> <message utf8="true"> - <location filename="main.cpp" line="54"/> - <source>umlaut ü &uuml; in utf8</source> + <location filename="main.cpp" line="55"/> + <source>umlaut ü &uuml; in literal utf8</source> + <translation type="unfinished"></translation> + </message> + <message utf8="true"> + <location filename="main.cpp" line="56"/> + <source>umlaut ü &uuml; in escaped utf8</source> <translation type="unfinished"></translation> </message> </context> diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp index abb8b89..cd93539 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp @@ -49,9 +49,10 @@ public: void doFoo() { tr("random ascii only"); - tr("this contains an umlaut ü ü"); + tr("this contains an umlaut ü ü literally"); + tr("this contains an umlaut \303\274 ü escaped, really in utf-8"); trUtf8("random ascii only in utf8"); - trUtf8("umlaut \xfc ü in utf8"); + trUtf8("umlaut \303\274 ü in escaped utf8"); } }; diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result index e27c157..6728a25 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result @@ -11,17 +11,22 @@ </message> <message> <location filename="main.cpp" line="52"/> - <source>this contains an umlaut ü &uuml;</source> + <source>this contains an umlaut ü &uuml; literally</source> <translation type="unfinished"></translation> </message> <message> <location filename="main.cpp" line="53"/> - <source>random ascii only in utf8</source> + <source>this contains an umlaut ü &uuml; escaped, really in utf-8</source> <translation type="unfinished"></translation> </message> <message> <location filename="main.cpp" line="54"/> - <source>umlaut ü &uuml; in utf8</source> + <source>random ascii only in utf8</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="55"/> + <source>umlaut ü &uuml; in escaped utf8</source> <translation type="unfinished"></translation> </message> </context> diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index a09d998..b9be5cb 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 @@ -153,7 +156,7 @@ static QString prettyByteArray(const QByteArray &array) return result; } -static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout = 2000) +static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout = 4000) { QTime timer; timer.start(); @@ -168,7 +171,7 @@ static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout } } -static bool doSocketFlush(QTcpSocket *socket, int timeout = 2000) +static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000) { #ifndef QT_NO_OPENSSL QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket); @@ -717,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/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp index bdc31af..413419d 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/qabstractslider/tst_qabstractslider.cpp b/tests/auto/qabstractslider/tst_qabstractslider.cpp index d9574df..ee1ba19 100644 --- a/tests/auto/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/qabstractslider/tst_qabstractslider.cpp @@ -742,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 diff --git a/tests/auto/qalgorithms/tst_qalgorithms.cpp b/tests/auto/qalgorithms/tst_qalgorithms.cpp index 176a451..1e24efe 100644 --- a/tests/auto/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/qalgorithms/tst_qalgorithms.cpp @@ -620,8 +620,8 @@ void tst_QAlgorithms::test_qBinaryFind() //-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.constBegin(), data.constEnd(), resultValue) == data.constEnd()); + QVERIFY(qBinaryFind(data, resultValue) == data.constEnd()); QVERIFY(qBinaryFind(data.begin(), data.end(), resultValue) == data.end()); QVERIFY(qBinaryFind(data.begin(), data.end(), resultValue, qLess<int>()) == data.end()); return; diff --git a/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp index 381f46f..a57c1d6 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/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index cc59b62..af71961 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -2290,11 +2290,8 @@ void tst_QComboBox::setItemDelegate() QComboBox comboBox; QStyledItemDelegate *itemDelegate = new QStyledItemDelegate; comboBox.setItemDelegate(itemDelegate); -#ifdef Q_CC_MWERKS + // the cast is a workaround for the XLC and Metrowerks compilers QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate); -#else - QCOMPARE(comboBox.itemDelegate(), itemDelegate); -#endif } void tst_QComboBox::task253944_itemDelegateIsReset() @@ -2303,19 +2300,13 @@ void tst_QComboBox::task253944_itemDelegateIsReset() QStyledItemDelegate *itemDelegate = new QStyledItemDelegate; comboBox.setItemDelegate(itemDelegate); + // the casts are workarounds for the XLC and Metrowerks compilers + comboBox.setEditable(true); -#ifdef Q_CC_MWERKS QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate); -#else - QCOMPARE(comboBox.itemDelegate(), itemDelegate); -#endif comboBox.setStyleSheet("QComboBox { border: 1px solid gray; }"); -#ifdef Q_CC_MWERKS QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate); -#else - QCOMPARE(comboBox.itemDelegate(), itemDelegate); -#endif } @@ -2479,6 +2470,10 @@ void tst_QComboBox::keyBoardNavigationWithMouse() 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); diff --git a/tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp index 33226bf..f833196 100644 --- a/tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp +++ b/tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp @@ -51,6 +51,7 @@ #include <qtimer.h> #include <QDialog> #include <QGridLayout> +#include <QPainter> Q_DECLARE_METATYPE(QCommandLinkButton*) @@ -83,7 +84,8 @@ private slots: void clicked(); void toggled(); void defaultAndAutoDefault(); - void setAutoRepeat(); + void setAutoRepeat(); + void heightForWithWithIcon(); protected slots: void resetCounters(); @@ -106,17 +108,17 @@ private: void tst_QCommandLinkButton::getSetCheck() { QCommandLinkButton obj1; - + QString text("mytext"); QVERIFY(obj1.description().isEmpty()); obj1.setDescription(text); QVERIFY(obj1.description() == text); - + QVERIFY(obj1.text().isEmpty()); obj1.setText(text); QVERIFY(obj1.text() == text); - - + + QMenu *var1 = new QMenu; obj1.setMenu(var1); QCOMPARE(var1, obj1.menu()); @@ -393,8 +395,8 @@ void tst_QCommandLinkButton::setAccel() QTest::qWait(100); } - QVERIFY(testWidget->isActiveWindow()); - + QVERIFY(testWidget->isActiveWindow()); + QTest::keyClick( testWidget, 'A', Qt::AltModifier ); QTest::qWait( 500 ); QVERIFY( click_count == 1 ); @@ -556,5 +558,33 @@ void tst_QCommandLinkButton::defaultAndAutoDefault() } } +void tst_QCommandLinkButton::heightForWithWithIcon() +{ + QWidget mainWin; + + QPixmap pixmap(64, 64); + { + pixmap.fill(Qt::white); + QPainter painter(&pixmap); + painter.setBrush(Qt::black); + painter.drawEllipse(0, 0, 63, 63); + } + + QCommandLinkButton *largeIconButton = new QCommandLinkButton(QString("Large Icon"), + QString("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris nibh lectus, adipiscing eu."), + &mainWin); + largeIconButton->setIconSize(QSize(64, 64)); + largeIconButton->setIcon(pixmap); + + QVBoxLayout *layout = new QVBoxLayout(); + layout->addWidget(largeIconButton); + layout->addStretch(); + mainWin.setLayout(layout); + mainWin.showMaximized(); + QTest::qWaitForWindowShown(&mainWin); + QVERIFY(largeIconButton->height() > 68); //enough room for the icon + +} + QTEST_MAIN(tst_QCommandLinkButton) #include "tst_qcommandlinkbutton.moc" diff --git a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp index 91050f5..a2c4758 100644 --- a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp +++ b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp @@ -133,7 +133,7 @@ tst_QDBusAbstractInterface::tst_QDBusAbstractInterface() void tst_QDBusAbstractInterface::initTestCase() { // enable debugging temporarily: - putenv("QDBUS_DEBUG=1"); + //putenv("QDBUS_DEBUG=1"); // register the object QDBusConnection con = QDBusConnection::sessionBus(); @@ -465,6 +465,7 @@ void tst_QDBusAbstractInterface::followSignal() QDBusConnectionInterface::DontAllowReplacement); QVERIFY(r.isValid() && r.value() == QDBusConnectionInterface::ServiceRegistered); QVERIFY(con.interface()->isServiceRegistered(serviceToFollow)); + QCoreApplication::instance()->processEvents(); // emit the signal again: emit targetObj.voidSignal(); diff --git a/tests/auto/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/qdbusconnection/tst_qdbusconnection.cpp index bb034a3..c1976c0 100644 --- a/tests/auto/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/qdbusconnection/tst_qdbusconnection.cpp @@ -96,6 +96,8 @@ private slots: void registerQObjectChildren(); void callSelf(); + void callSelfByAnotherName_data(); + void callSelfByAnotherName(); void multipleInterfacesInQObject(); void slotsWithLessParameters(); @@ -493,6 +495,70 @@ void tst_QDBusConnection::callSelf() QCOMPARE(reply.arguments().value(0).toInt(), 45); } +void tst_QDBusConnection::callSelfByAnotherName_data() +{ + QTest::addColumn<int>("registerMethod"); + QTest::newRow("connection") << 0; + QTest::newRow("connection-interface") << 1; + QTest::newRow("direct") << 2; +} + +void tst_QDBusConnection::callSelfByAnotherName() +{ + static int counter = 0; + QString sname = serviceName() + QString::number(counter++); + + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); + + TestObject testObject; + QVERIFY(con.registerObject("/test", &testObject, + QDBusConnection::ExportAllContents)); + con.connect("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "NameOwnerChanged", + QStringList() << sname << "", + QString(), &QTestEventLoop::instance(), SLOT(exitLoop())); + + // register the name + QFETCH(int, registerMethod); + switch (registerMethod) { + case 0: + QVERIFY(con.registerService(sname)); + break; + + case 1: + QVERIFY(con.interface()->registerService(sname).value() == QDBusConnectionInterface::ServiceRegistered); + break; + + case 2: { + // flag is DBUS_NAME_FLAG_DO_NOT_QUEUE = 0x04 + // reply is DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER = 1 + QDBusReply<uint> reply = con.interface()->call("RequestName", sname, 4u); + QVERIFY(reply.value() == 1); + } + } + + struct Deregisterer { + QDBusConnection con; + QString sname; + Deregisterer(const QDBusConnection &con, const QString &sname) : con(con), sname(sname) {} + ~Deregisterer() { con.interface()->unregisterService(sname); } + } deregisterer(con, sname); + + // give the connection a chance to find out that we're good to go + QTestEventLoop::instance().enterLoop(2); + con.disconnect("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "NameOwnerChanged", + QStringList() << sname << "", + QString(), &QTestEventLoop::instance(), SLOT(exitLoop())); + QVERIFY(!QTestEventLoop::instance().timeout()); + + // make the call + QDBusMessage msg = QDBusMessage::createMethodCall(sname, "/test", + QString(), "test0"); + QDBusMessage reply = con.call(msg, QDBus::Block, 1000); + + QVERIFY(reply.type() == QDBusMessage::ReplyMessage); +} + void tst_QDBusConnection::multipleInterfacesInQObject() { QDBusConnection con = QDBusConnection::sessionBus(); diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp index 62d6342..bcd5bd9 100644 --- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp @@ -234,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(); @@ -249,7 +250,7 @@ void tst_QDBusInterface::invalidAfterServiceOwnerChanged() QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); - QVERIFY(!invalidInterface.isValid()); + QVERIFY(invalidInterface.isValid()); } void tst_QDBusInterface::introspect() diff --git a/tests/auto/qdbusperformance/tst_qdbusperformance.cpp b/tests/auto/qdbusperformance/tst_qdbusperformance.cpp index 7227d5d..066b5b2 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/tst_qdbusservicewatcher.cpp b/tests/auto/qdbusservicewatcher/tst_qdbusservicewatcher.cpp index 10b43b1..ac0f806 100644 --- a/tests/auto/qdbusservicewatcher/tst_qdbusservicewatcher.cpp +++ b/tests/auto/qdbusservicewatcher/tst_qdbusservicewatcher.cpp @@ -47,12 +47,13 @@ class tst_QDBusServiceWatcher: public QObject { Q_OBJECT QString serviceName; + int testCounter; public: tst_QDBusServiceWatcher(); private slots: void initTestCase(); - void cleanup(); + void init(); void watchForCreation(); void watchForDisappearance(); @@ -61,7 +62,7 @@ private slots: }; tst_QDBusServiceWatcher::tst_QDBusServiceWatcher() - : serviceName("com.example.TestName") + : testCounter(0) { } @@ -71,10 +72,10 @@ void tst_QDBusServiceWatcher::initTestCase() QVERIFY(con.isConnected()); } -void tst_QDBusServiceWatcher::cleanup() +void tst_QDBusServiceWatcher::init() { - // ensure that the name isn't registered - QDBusConnection::sessionBus().unregisterService(serviceName); + // change the service name from test to test + serviceName = "com.example.TestService" + QString::number(testCounter++); } void tst_QDBusServiceWatcher::watchForCreation() @@ -135,6 +136,7 @@ void tst_QDBusServiceWatcher::watchForDisappearance() QVERIFY(con.isConnected()); QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForUnregistration); + watcher.setObjectName("watcher for disappearance"); QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString))); QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString))); diff --git a/tests/auto/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/qdialogbuttonbox/tst_qdialogbuttonbox.cpp index 936ebf7..2c49fc8 100644 --- a/tests/auto/qdialogbuttonbox/tst_qdialogbuttonbox.cpp +++ b/tests/auto/qdialogbuttonbox/tst_qdialogbuttonbox.cpp @@ -111,6 +111,9 @@ private slots: void testDefaultButton_data(); void testDefaultButton(); void testS60SoftKeys(); +#ifdef QT_SOFTKEYS_ENABLED + void testSoftKeyReparenting(); +#endif void task191642_default(); private: @@ -715,6 +718,17 @@ void tst_QDialogButtonBox::testDefaultButton_data() QTest::newRow("third accept explicit after add") << 0 << 2 << 2; } +static int softKeyCount(QWidget *widget) +{ + int softkeyCount = 0; + QList<QAction *> actions = widget->actions(); + foreach (QAction *action, actions) { + if (action->softKeyRole() != QAction::NoSoftKey) + softkeyCount++; + } + return softkeyCount; +} + void tst_QDialogButtonBox::testS60SoftKeys() { #ifdef Q_WS_S60 @@ -722,33 +736,47 @@ void tst_QDialogButtonBox::testS60SoftKeys() QDialogButtonBox buttonBox(&dialog); buttonBox.setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); dialog.show(); - - int softkeyCount = 0; - QList<QAction *> actions = dialog.actions(); - foreach (QAction *action, actions) { - if (action->softKeyRole() != QAction::NoSoftKey) - softkeyCount++; - } - QCOMPARE( softkeyCount, 2); + + QCOMPARE( softKeyCount(&dialog), 2); QDialog dialog2(0); QDialogButtonBox buttonBox2(&dialog2); buttonBox2.setStandardButtons(QDialogButtonBox::Cancel); dialog2.show(); - int softkeyCount2 = 0; - QList<QAction *> actions2 = dialog2.actions(); - foreach (QAction *action, actions2) { - if (action->softKeyRole() != QAction::NoSoftKey) - softkeyCount2++; - } - QCOMPARE( softkeyCount2, 1); - + QCOMPARE( softKeyCount(&dialog2), 1); + #else QSKIP("S60-specific test", SkipAll ); #endif } +#ifdef QT_SOFTKEYS_ENABLED +void tst_QDialogButtonBox::testSoftKeyReparenting() +{ + QDialog dialog; + QDialogButtonBox *buttonBox = new QDialogButtonBox; + buttonBox->addButton(QDialogButtonBox::Ok); + buttonBox->addButton(QDialogButtonBox::Cancel); + + QCOMPARE(softKeyCount(&dialog), 0); + QCOMPARE(softKeyCount(buttonBox), 2); + + // Were the softkeys re-parented correctly? + dialog.setLayout(new QVBoxLayout); + dialog.layout()->addWidget(buttonBox); + QCOMPARE(softKeyCount(&dialog), 2); + QCOMPARE(softKeyCount(buttonBox), 0); + + // Softkeys are only added to QDialog, not QWidget + QWidget *nested = new QWidget; + nested->setLayout(new QVBoxLayout); + nested->layout()->addWidget(buttonBox); + QCOMPARE(softKeyCount(nested), 0); + QCOMPARE(softKeyCount(buttonBox), 2); +} +#endif + void tst_QDialogButtonBox::testDefaultButton() { QFETCH(int, whenToSetDefault); diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp index c9a7f1c..8f72e39 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; } @@ -865,7 +866,9 @@ void tst_QDockWidget::taskQTBUG_1665_closableChanged() dock.show(); QTest::qWaitForWindowShown(&dock); - if (dock.windowFlags() & Qt::FramelessWindowHint) + 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); diff --git a/tests/auto/qfile/qfile.pro b/tests/auto/qfile/qfile.pro index f70f750..33fd2fd 100644 --- a/tests/auto/qfile/qfile.pro +++ b/tests/auto/qfile/qfile.pro @@ -5,5 +5,5 @@ wince*:{ SUBDIRS = test stdinprocess } -SUBDIRS += largefile +!symbian*:SUBDIRS += largefile diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index b3d6fd9..cf46ce1 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -210,6 +210,7 @@ private slots: void task167217(); void openDirectory(); + void writeNothing(); public: // disabled this test for the moment... it hangs @@ -750,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); @@ -2489,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()); } @@ -2840,5 +2842,16 @@ void tst_QFile::openStandardStreams() } } +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/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp index e80f8e0..efb1b56 100644 --- a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp @@ -72,6 +72,7 @@ private slots: void veryNarrowElidedText(); void averageCharWidth(); void elidedMultiLength(); + void elidedMultiLengthF(); void bearingIncludedInBoundingRect(); }; @@ -218,13 +219,13 @@ void tst_QFontMetrics::averageCharWidth() QVERIFY(fmf.averageCharWidth() != 0); } -void tst_QFontMetrics::elidedMultiLength() +template<class FontMetrics> void elidedMultiLength_helper() { QString text1 = "Long Text 1\x9cShorter\x9csmall"; QString text1_long = "Long Text 1"; QString text1_short = "Shorter"; QString text1_small = "small"; - QFontMetrics fm = QFontMetrics(QFont()); + FontMetrics fm = FontMetrics(QFont()); int width_long = fm.size(0, text1_long).width(); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, 8000), text1_long); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_long + 1), text1_long); @@ -238,7 +239,16 @@ void tst_QFontMetrics::elidedMultiLength() QString text1_el = QString::fromLatin1("s") + ellipsisChar; int width_small = fm.width(text1_el); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_small + 1), text1_el); +} +void tst_QFontMetrics::elidedMultiLength() +{ + elidedMultiLength_helper<QFontMetrics>(); +} + +void tst_QFontMetrics::elidedMultiLengthF() +{ + elidedMultiLength_helper<QFontMetricsF>(); } void tst_QFontMetrics::bearingIncludedInBoundingRect() diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp index 1e7f424..27c2e13 100644 --- a/tests/auto/qftp/tst_qftp.cpp +++ b/tests/auto/qftp/tst_qftp.cpp @@ -618,7 +618,7 @@ void tst_QFtp::get() } addCommand( QFtp::Close, ftp->close() ); - QTestEventLoop::instance().enterLoop( 30 ); + QTestEventLoop::instance().enterLoop( 50 ); delete ftp; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -1020,7 +1020,7 @@ void tst_QFtp::renameInit( const QString &host, const QString &user, const QStri addCommand( QFtp::Put, ftp->put( QByteArray(), createFile ) ); addCommand( QFtp::Close, ftp->close() ); - QTestEventLoop::instance().enterLoop( 30 ); + QTestEventLoop::instance().enterLoop( 50 ); delete ftp; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -1295,14 +1295,18 @@ void tst_QFtp::abort_data() // Qt/CE and Symbian test environment has to less memory for this test #if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QByteArray bigData( 10*1024*1024, 0 ); +#else + QByteArray bigData( 1*1024*1024, 0 ); +#endif bigData.fill( 'B' ); - QTest::newRow( "put_fluke01" ) << QtNetworkSettings::serverName() << (uint)21 << QString("qtest/upload/abort_put") << bigData; -#endif } void tst_QFtp::abort() { + // In case you wonder where the abort() actually happens, look into + // tst_QFtp::dataTransferProgress + // QFETCH( QString, host ); QFETCH( uint, port ); QFETCH( QString, file ); @@ -1324,7 +1328,7 @@ void tst_QFtp::abort() addCommand( QFtp::Close, ftp->close() ); for(int time = 0; time <= uploadData.length() / 30000; time += 30) { - QTestEventLoop::instance().enterLoop( 30 ); + QTestEventLoop::instance().enterLoop( 50 ); if(ftp->currentCommand() == QFtp::None) break; } @@ -1404,7 +1408,7 @@ void tst_QFtp::bytesAvailable() if ( type != 0 ) addCommand( QFtp::Close, ftp->close() ); - QTestEventLoop::instance().enterLoop( 30 ); + QTestEventLoop::instance().enterLoop( 40 ); if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -1493,7 +1497,7 @@ void tst_QFtp::proxy() addCommand( QFtp::Cd, ftp->cd( dir ) ); addCommand( QFtp::List, ftp->list() ); - QTestEventLoop::instance().enterLoop( 30 ); + QTestEventLoop::instance().enterLoop( 50 ); delete ftp; if ( QTestEventLoop::instance().timeout() ) { @@ -1921,7 +1925,7 @@ bool tst_QFtp::fileExists( const QString &host, quint16 port, const QString &use delete ftp; if ( QTestEventLoop::instance().timeout() ) { // ### make this test work - qWarning("Network operation timed out"); + qWarning("tst_QFtp::fileExists: Network operation timed out"); return FALSE; } inFileDirExistsFunction = FALSE; @@ -1972,6 +1976,7 @@ bool tst_QFtp::dirExists( const QString &host, quint16 port, const QString &user if ( QTestEventLoop::instance().timeout() ) { // ### make this test work // QFAIL( "Network operation timed out" ); + qWarning("tst_QFtp::dirExists: Network operation timed out"); return FALSE; } inFileDirExistsFunction = FALSE; diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index c680dec..5dc072d 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -76,6 +76,7 @@ private slots: void partialGLWidgetUpdates_data(); void partialGLWidgetUpdates(); void glWidgetRendering(); + void glFBOSimpleRendering(); void glFBORendering(); void multipleFBOInterleavedRendering(); void glFBOUseInGLWidget(); @@ -711,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,8 +797,6 @@ public: void tst_QGL::graphicsViewClipping() { - if (appDefaultDepth() < 24) - QSKIP("This test won't work for bit depths < 24", SkipAll); const int size = 64; UnclippedWidget *widget = new UnclippedWidget; widget->setFixedSize(size, size); @@ -734,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; @@ -758,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() @@ -849,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 @@ -868,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 } @@ -877,9 +952,11 @@ public: void tst_QGL::glWidgetRendering() { - if (appDefaultDepth() < 24) - QSKIP("This test won't work for bit depths < 24", SkipAll); GLWidget w; +#ifdef Q_WS_QWS + w.setWindowFlags(Qt::FramelessWindowHint); +#endif + w.setGeometry(100, 100, 200, 200); w.show(); #ifdef Q_WS_X11 @@ -894,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 @@ -949,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()); } @@ -1047,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 @@ -1089,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; } @@ -1102,12 +1209,13 @@ protected: void tst_QGL::glFBOUseInGLWidget() { - if (appDefaultDepth() < 24) - QSKIP("This test won't work for bit depths < 24", SkipAll); if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) 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(); @@ -1122,17 +1230,15 @@ 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() { - if (appDefaultDepth() < 24) - QSKIP("This test won't work for bit depths < 24", SkipAll); // Try it as a top-level first: GLWidget *widget = new GLWidget; widget->setGeometry(0, 0, 200, 30); @@ -1222,7 +1328,7 @@ void tst_QGL::glWidgetRenderPixmap() QImage reference(fb.size(), QImage::Format_RGB32); reference.fill(0xffff0000); - QCOMPARE(fb, reference); + QFUZZY_COMPARE_IMAGES(fb, reference); } class ColormapExtended : public QGLColormap @@ -1495,9 +1601,10 @@ protected: void tst_QGL::replaceClipping() { - if (appDefaultDepth() < 24) - QSKIP("This test won't work for bit depths < 24", SkipAll); ReplaceClippingGLWidget glw; +#ifdef Q_WS_QWS + glw.setWindowFlags(Qt::FramelessWindowHint); +#endif glw.resize(300, 300); glw.show(); @@ -1513,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 @@ -1521,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); @@ -1622,9 +1735,10 @@ protected: void tst_QGL::clipTest() { - if (appDefaultDepth() < 24) - QSKIP("This test won't work for bit depths < 24", SkipAll); ClipTestGLWidget glw; +#ifdef Q_WS_QWS + glw.setWindowFlags(Qt::FramelessWindowHint); +#endif glw.resize(220, 220); glw.show(); @@ -1640,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() @@ -1722,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. @@ -1759,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()); @@ -1807,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 c7ed309..e2f87b8 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -85,6 +85,9 @@ private slots: void simplificationVsOrder(); void parallelSimplificationOfCenter(); void simplificationVsRedundance(); + void spacingPersistency(); + void snakeParallelWithLayout(); + void parallelToHalfLayout(); }; class RectWidget : public QGraphicsWidget @@ -1866,5 +1869,112 @@ void tst_QGraphicsAnchorLayout::simplificationVsRedundance() QCOMPARE(usedSimplex(l, Qt::Vertical), false); } +/* + 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); + + l->addAnchors(l, a, Qt::Horizontal); + QGraphicsAnchor *anchor = l->anchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + + anchor->setSpacing(-30); + QCOMPARE(anchor->spacing(), -30.0); + + anchor->setSpacing(30); + QCOMPARE(anchor->spacing(), 30.0); + + anchor->setSizePolicy(QSizePolicy::Ignored); + w.effectiveSizeHint(Qt::PreferredSize); + + QCOMPARE(anchor->spacing(), 30.0); +} + +/* + Test whether a correct preferred size is set when a "snake" sequence is in parallel with the + layout or half of the layout. The tricky thing here is that all items on the snake should + keep their preferred sizes. +*/ +void tst_QGraphicsAnchorLayout::snakeParallelWithLayout() +{ + QSizeF min(10, 20); + QSizeF pref(50, 20); + QSizeF max(100, 20); + + QGraphicsWidget *a = createItem(max, max, max, "A"); + QGraphicsWidget *b = createItem(min, pref, max, "B"); + QGraphicsWidget *c = createItem(max, max, max, "C"); + + QGraphicsWidget parent; + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&parent); + l->setContentsMargins(0, 0, 0, 0); + l->setSpacing(0); + + // First we'll do the case in parallel with the entire layout... + l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorRight); + l->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft); + l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight); + + l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop); + l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop); + l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop); + l->addAnchor(c, Qt::AnchorBottom, l, Qt::AnchorBottom); + + parent.resize(l->effectiveSizeHint(Qt::PreferredSize)); + + // Note that A and C are fixed in the maximum size + QCOMPARE(l->geometry(), QRectF(QPointF(0, 0), QSizeF(150, 60))); + QCOMPARE(a->geometry(), QRectF(QPointF(0, 0), max)); + QCOMPARE(b->geometry(), QRectF(QPointF(50, 20), pref)); + QCOMPARE(c->geometry(), QRectF(QPointF(50, 40), max)); + + // Then, we change the "snake" to be in parallel with half of the layout + delete l->anchor(c, Qt::AnchorRight, l, Qt::AnchorRight); + l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorHorizontalCenter); + + parent.resize(l->effectiveSizeHint(Qt::PreferredSize)); + + QCOMPARE(l->geometry(), QRectF(QPointF(0, 0), QSizeF(300, 60))); + QCOMPARE(a->geometry(), QRectF(QPointF(0, 0), max)); + QCOMPARE(b->geometry(), QRectF(QPointF(50, 20), pref)); + QCOMPARE(c->geometry(), QRectF(QPointF(50, 40), max)); +} + +/* + Avoid regression where the sizeHint constraints would not be + created for a parallel anchor that included the first layout half +*/ +void tst_QGraphicsAnchorLayout::parallelToHalfLayout() +{ + QGraphicsWidget *a = createItem(); + + QGraphicsWidget w; + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&w); + l->setContentsMargins(10, 10, 10, 10); + + l->addAnchors(l, a, Qt::Vertical); + + QGraphicsAnchor *anchor; + anchor = l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + anchor->setSpacing(5); + anchor = l->addAnchor(l, Qt::AnchorHorizontalCenter, a, Qt::AnchorRight); + anchor->setSpacing(-5); + + const QSizeF minimumSizeHint = w.effectiveSizeHint(Qt::MinimumSize); + const QSizeF preferredSizeHint = w.effectiveSizeHint(Qt::PreferredSize); + const QSizeF maximumSizeHint = w.effectiveSizeHint(Qt::MaximumSize); + + const QSizeF overhead = QSizeF(10 + 5 + 5, 10) * 2; + + QCOMPARE(minimumSizeHint, QSizeF(200, 100) + overhead); + QCOMPARE(preferredSizeHint, QSizeF(300, 100) + overhead); + QCOMPARE(maximumSizeHint, QSizeF(400, 100) + overhead); +} + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index 0fbd069..baa1ba1 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -167,7 +167,7 @@ public: { setContentsMargins( 0,0,0,0 ); if (name.isEmpty()) - setData(0, QString::fromAscii("w%1").arg(int(this))); + setData(0, QString::fromAscii("w%1").arg(quintptr(this))); else setData(0, name); } @@ -1722,7 +1722,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() QRectF expected = truncate(item.rect); QRectF actual = truncate(widgets[item.index]->geometry()); - QCOMPARE(expected, actual); + QCOMPARE(actual, expected); } // Test mirrored mode @@ -1739,7 +1739,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() QRectF expected = truncate(mirroredRect); QRectF actual = truncate(widgets[item.index]->geometry()); - QCOMPARE(expected, actual); + QCOMPARE(actual, expected); delete widgets[item.index]; } diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 27c6809..db80db6 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -4078,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); diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 9269164..42d5268 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -181,6 +181,7 @@ private slots: void updateAndDelete(); void inputMethod(); void clickFocus(); + void windowFrameMargins(); }; // Subclass that exposes the protected functions. @@ -1286,8 +1287,9 @@ void tst_QGraphicsProxyWidget::paintEvent() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); + QApplication::setActiveWindow(&view); QTest::qWaitForWindowShown(&view); - QTest::qWait(70); + QTRY_VERIFY(view.isActiveWindow()); SubQGraphicsProxyWidget proxy; @@ -1298,14 +1300,14 @@ void tst_QGraphicsProxyWidget::paintEvent() w->show(); QTest::qWaitForWindowShown(w); QApplication::processEvents(); - QTest::qWait(100); + 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(110); + QTest::qWait(30); proxy.paintCount = 0; w->update(); @@ -2573,20 +2575,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 } @@ -2746,10 +2750,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(150); + QTRY_VERIFY(view.isActiveWindow()); qRegisterMetaType<QList<QRectF> >("QList<QRectF>"); QSignalSpy signalSpy(&scene, SIGNAL(changed(const QList<QRectF> &))); @@ -3501,6 +3507,29 @@ void tst_QGraphicsProxyWidget::clickFocus() QVERIFY(!proxy->widget()->hasFocus()); } +void tst_QGraphicsProxyWidget::windowFrameMargins() +{ + // Make sure the top margin is non-zero when passing Qt::Window. + QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, Qt::Window); + + qreal left, top, right, bottom; + proxy->getWindowFrameMargins(&left, &top, &right, &bottom); + QVERIFY(top > 0); + + proxy->setWidget(new QPushButton("testtest")); + proxy->getWindowFrameMargins(&left, &top, &right, &bottom); + QVERIFY(top > 0); + + QGraphicsScene scene; + scene.addItem(proxy); + proxy->getWindowFrameMargins(&left, &top, &right, &bottom); + QVERIFY(top > 0); + + proxy->unsetWindowFrameMargins(); + proxy->getWindowFrameMargins(&left, &top, &right, &bottom); + QVERIFY(top > 0); +} + QTEST_MAIN(tst_QGraphicsProxyWidget) #include "tst_qgraphicsproxywidget.moc" diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 9a561eb..20d9eb8 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -276,6 +276,7 @@ private slots: void task176178_itemIndexMethodBreaksSceneRect(); void task160653_selectionChanged(); void task250680_childClip(); + void taskQTBUG_5904_crashWithDeviceCoordinateCache(); }; void tst_QGraphicsScene::initTestCase() @@ -3983,20 +3984,28 @@ void tst_QGraphicsScene::isActive() 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(12); + QTest::qWait(50); QTRY_VERIFY(!scene1.isActive()); QTRY_VERIFY(!scene2.isActive()); + QVERIFY(!scene1.hasFocus()); + QVERIFY(!scene2.hasFocus()); toplevel1.show(); QApplication::setActiveWindow(&toplevel1); @@ -4005,14 +4014,21 @@ void tst_QGraphicsScene::isActive() 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; @@ -4025,6 +4041,8 @@ void tst_QGraphicsScene::isActive() QVERIFY(!scene1.isActive()); QVERIFY(!scene2.isActive()); + QVERIFY(!scene1.hasFocus()); + QVERIFY(!scene2.hasFocus()); toplevel2.show(); QApplication::setActiveWindow(&toplevel2); @@ -4033,66 +4051,89 @@ void tst_QGraphicsScene::isActive() 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()); - - view1->show(); + 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; @@ -4104,6 +4145,9 @@ void tst_QGraphicsScene::isActive() QVERIFY(!scene1.isActive()); QVERIFY(!scene2.isActive()); + QVERIFY(!scene1.hasFocus()); + QVERIFY(!scene2.hasFocus()); + toplevel3.show(); QApplication::setActiveWindow(&toplevel3); @@ -4112,23 +4156,45 @@ void tst_QGraphicsScene::isActive() 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()); } +void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() +{ + QGraphicsScene scene; + QGraphicsRectItem *rectItem = scene.addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green)); + + rectItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + + QPixmap pixmap(100,200); + QPainter painter(&pixmap); + painter.setRenderHint(QPainter::Antialiasing); + scene.render(&painter); + painter.end(); + // No crash, then it passed! +} QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index f07453c..797e1fb 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -235,6 +235,7 @@ private slots: void task259503_scrollingArtifacts(); void QTBUG_4151_clipAndIgnore_data(); void QTBUG_4151_clipAndIgnore(); + void QTBUG_5859_exposedRect(); }; void tst_QGraphicsView::initTestCase() @@ -3600,6 +3601,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); @@ -3614,27 +3616,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 @@ -3858,5 +3868,43 @@ void tst_QGraphicsView::QTBUG_4151_clipAndIgnore() QCOMPARE(view.items(view.rect()).size(), numItems); } +void tst_QGraphicsView::QTBUG_5859_exposedRect() +{ + class CustomScene : public QGraphicsScene + { + public: + CustomScene(const QRectF &rect) : QGraphicsScene(rect) { } + void drawBackground(QPainter *painter, const QRectF &rect) + { lastBackgroundExposedRect = rect; } + QRectF lastBackgroundExposedRect; + }; + + class CustomRectItem : public QGraphicsRectItem + { + public: + CustomRectItem(const QRectF &rect) : QGraphicsRectItem(rect) + { setFlag(QGraphicsItem::ItemUsesExtendedStyleOption); } + void paint(QPainter * painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) + { lastExposedRect = option->exposedRect; } + QRectF lastExposedRect; + }; + + CustomScene scene(QRectF(0,0,50,50)); + + CustomRectItem item(scene.sceneRect()); + + scene.addItem(&item); + + QGraphicsView view(&scene); + view.scale(4.15, 4.15); + view.show(); + QTest::qWaitForWindowShown(&view); + + view.viewport()->repaint(10,10,20,20); + QApplication::processEvents(); + + QCOMPARE(item.lastExposedRect, scene.lastBackgroundExposedRect); +} + QTEST_MAIN(tst_QGraphicsView) #include "tst_qgraphicsview.moc" diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 6b5ad09..3b98c2f 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -160,6 +160,8 @@ private slots: void widgetSendsGeometryChanges(); void respectHFW(); void addChildInpolishEvent(); + void polishEvent(); + void polishEvent2(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2768,6 +2770,55 @@ 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); +} + +void tst_QGraphicsWidget::polishEvent2() +{ + class MyGraphicsWidget : public QGraphicsWidget + { public: + void polishEvent() + { events << QEvent::Polish; } + QList<QEvent::Type> events; + }; + + QGraphicsScene scene; + + MyGraphicsWidget *widget = new MyGraphicsWidget; + widget->hide(); + scene.addItem(widget); + + widget->events.clear(); + + QApplication::processEvents(); + + // Make sure the item got polish event. + QVERIFY(widget->events.contains(QEvent::Polish)); +} QTEST_MAIN(tst_QGraphicsWidget) #include "tst_qgraphicswidget.moc" diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp index c13e829..a8e7461 100644 --- a/tests/auto/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/qheaderview/tst_qheaderview.cpp @@ -43,6 +43,7 @@ #include <QtTest/QtTest> #include <QStandardItemModel> #include <QStringListModel> +#include <QSortFilterProxyModel> #include <qabstractitemmodel.h> #include <qapplication.h> @@ -188,6 +189,7 @@ private slots: void task236450_hidden_data(); void task236450_hidden(); void task248050_hideRow(); + void QTBUG6058_reset(); protected: QHeaderView *view; @@ -1947,5 +1949,49 @@ void tst_QHeaderView::task248050_hideRow() } +//returns 0 if everything is fine. +static int checkHeaderViewOrder(QHeaderView *view, const QVector<int> &expected) +{ + if (view->count() != expected.count()) + return 1; + + for (int i = 0; i < expected.count(); i++) { + if (view->logicalIndex(i) != expected.at(i)) + return i + 10; + if (view->visualIndex(expected.at(i)) != i) + return i + 100; + } + return 0; +} + + +void tst_QHeaderView::QTBUG6058_reset() +{ + QStringListModel model1( QStringList() << "0" << "1" << "2" << "3" << "4" << "5" ); + QStringListModel model2( QStringList() << "a" << "b" << "c" ); + QSortFilterProxyModel proxy; + + QHeaderView view(Qt::Vertical); + view.setModel(&proxy); + view.show(); + QTest::qWait(20); + + proxy.setSourceModel(&model1); + QApplication::processEvents(); + view.swapSections(0,2); + view.swapSections(1,4); + QApplication::processEvents(); + QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 4 << 0 << 3 << 1 << 5) , 0); + + proxy.setSourceModel(&model2); + QApplication::processEvents(); + QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 0 << 1 ) , 0); + + proxy.setSourceModel(&model1); + QApplication::processEvents(); + QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 0 << 1 << 3 << 4 << 5 ) , 0); +} + + QTEST_MAIN(tst_QHeaderView) #include "tst_qheaderview.moc" diff --git a/tests/auto/qhttp/tst_qhttp.cpp b/tests/auto/qhttp/tst_qhttp.cpp index 0ea0d15..b4b6ceb 100644 --- a/tests/auto/qhttp/tst_qhttp.cpp +++ b/tests/auto/qhttp/tst_qhttp.cpp @@ -363,7 +363,7 @@ void tst_QHttp::get() } addRequest( QHttpRequestHeader(), getId ); - QTestEventLoop::instance().enterLoop( 30 ); + QTestEventLoop::instance().enterLoop( 50 ); if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); diff --git a/tests/auto/qimagereader/images/grayscale-ref.tif b/tests/auto/qimagereader/images/grayscale-ref.tif Binary files differnew file mode 100644 index 0000000..960531e --- /dev/null +++ b/tests/auto/qimagereader/images/grayscale-ref.tif diff --git a/tests/auto/qimagereader/images/grayscale.tif b/tests/auto/qimagereader/images/grayscale.tif Binary files differnew file mode 100644 index 0000000..5f4e114 --- /dev/null +++ b/tests/auto/qimagereader/images/grayscale.tif diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 05b506c..15b1c1c 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 ab5572d..5997f39 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"); diff --git a/tests/auto/qiodevice/tst_qiodevice.cpp b/tests/auto/qiodevice/tst_qiodevice.cpp index 056ad6a..84fd8ad 100644 --- a/tests/auto/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/qiodevice/tst_qiodevice.cpp @@ -77,6 +77,9 @@ private slots: void readLine_data(); void readLine(); + + void readLine2_data(); + void readLine2(); }; // Testing get/set functions @@ -453,5 +456,114 @@ void tst_QIODevice::readLine() QCOMPARE(line.size(), linelen); } +void tst_QIODevice::readLine2_data() +{ + QTest::addColumn<QByteArray>("line"); + + QTest::newRow("1024 - 4") << QByteArray(1024 - 4, 'x'); + QTest::newRow("1024 - 3") << QByteArray(1024 - 3, 'x'); + QTest::newRow("1024 - 2") << QByteArray(1024 - 2, 'x'); + QTest::newRow("1024 - 1") << QByteArray(1024 - 1, 'x'); + QTest::newRow("1024" ) << QByteArray(1024 , 'x'); + QTest::newRow("1024 + 1") << QByteArray(1024 + 1, 'x'); + QTest::newRow("1024 + 2") << QByteArray(1024 + 2, 'x'); + + QTest::newRow("4096 - 4") << QByteArray(4096 - 4, 'x'); + QTest::newRow("4096 - 3") << QByteArray(4096 - 3, 'x'); + QTest::newRow("4096 - 2") << QByteArray(4096 - 2, 'x'); + QTest::newRow("4096 - 1") << QByteArray(4096 - 1, 'x'); + QTest::newRow("4096" ) << QByteArray(4096 , 'x'); + QTest::newRow("4096 + 1") << QByteArray(4096 + 1, 'x'); + QTest::newRow("4096 + 2") << QByteArray(4096 + 2, 'x'); + + QTest::newRow("8192 - 4") << QByteArray(8192 - 4, 'x'); + QTest::newRow("8192 - 3") << QByteArray(8192 - 3, 'x'); + QTest::newRow("8192 - 2") << QByteArray(8192 - 2, 'x'); + QTest::newRow("8192 - 1") << QByteArray(8192 - 1, 'x'); + QTest::newRow("8192" ) << QByteArray(8192 , 'x'); + QTest::newRow("8192 + 1") << QByteArray(8192 + 1, 'x'); + QTest::newRow("8192 + 2") << QByteArray(8192 + 2, 'x'); + + QTest::newRow("16384 - 4") << QByteArray(16384 - 4, 'x'); + QTest::newRow("16384 - 3") << QByteArray(16384 - 3, 'x'); + QTest::newRow("16384 - 2") << QByteArray(16384 - 2, 'x'); + QTest::newRow("16384 - 1") << QByteArray(16384 - 1, 'x'); + QTest::newRow("16384" ) << QByteArray(16384 , 'x'); + QTest::newRow("16384 + 1") << QByteArray(16384 + 1, 'x'); + QTest::newRow("16384 + 2") << QByteArray(16384 + 2, 'x'); + + QTest::newRow("20000") << QByteArray(20000, 'x'); + + QTest::newRow("32768 - 4") << QByteArray(32768 - 4, 'x'); + QTest::newRow("32768 - 3") << QByteArray(32768 - 3, 'x'); + QTest::newRow("32768 - 2") << QByteArray(32768 - 2, 'x'); + QTest::newRow("32768 - 1") << QByteArray(32768 - 1, 'x'); + QTest::newRow("32768" ) << QByteArray(32768 , 'x'); + QTest::newRow("32768 + 1") << QByteArray(32768 + 1, 'x'); + QTest::newRow("32768 + 2") << QByteArray(32768 + 2, 'x'); + + QTest::newRow("40000") << QByteArray(40000, 'x'); +} + +void tst_QIODevice::readLine2() +{ + QFETCH(QByteArray, line); + + int length = line.size(); + + QByteArray data("First line.\r\n"); + data.append(line); + data.append("\r\n"); + data.append(line); + data.append("\r\n"); + data.append("\r\n0123456789"); + + { + QBuffer buffer(&data); + buffer.open(QIODevice::ReadOnly); + + buffer.seek(0); + QByteArray temp; + temp.resize(64536); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(13)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(length + 2)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(length + 2)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(2)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(10)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(-1)); + + buffer.seek(0); + QCOMPARE(buffer.readLine().size(), 13); + QCOMPARE(buffer.readLine().size(), length + 2); + QCOMPARE(buffer.readLine().size(), length + 2); + QCOMPARE(buffer.readLine().size(), 2); + QCOMPARE(buffer.readLine().size(), 10); + QVERIFY(buffer.readLine().isNull()); + } + + { + QBuffer buffer(&data); + buffer.open(QIODevice::ReadOnly | QIODevice::Text); + + buffer.seek(0); + QByteArray temp; + temp.resize(64536); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(12)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(length + 1)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(length + 1)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(1)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(10)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(-1)); + + buffer.seek(0); + QCOMPARE(buffer.readLine().size(), 12); + QCOMPARE(buffer.readLine().size(), length + 1); + QCOMPARE(buffer.readLine().size(), length + 1); + QCOMPARE(buffer.readLine().size(), 1); + QCOMPARE(buffer.readLine().size(), 10); + QVERIFY(buffer.readLine().isNull()); + } +} + QTEST_MAIN(tst_QIODevice) #include "tst_qiodevice.moc" diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index 77c259c..269afbd 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/qlabel/tst_qlabel.cpp b/tests/auto/qlabel/tst_qlabel.cpp index 9d957a5..6b7e106 100644 --- a/tests/auto/qlabel/tst_qlabel.cpp +++ b/tests/auto/qlabel/tst_qlabel.cpp @@ -51,6 +51,7 @@ #include <qmovie.h> #include <qpicture.h> #include <qmessagebox.h> +#include <private/qlabel_p.h> //TESTED_CLASS= //TESTED_FILES= @@ -116,6 +117,9 @@ private slots: void unicodeText_data(); void unicodeText(); + void mnemonic_data(); + void mnemonic(); + private: QLabel *testWidget; QPointer<Widget> test_box; @@ -224,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() @@ -245,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() @@ -509,5 +515,50 @@ void tst_QLabel::unicodeText() 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 &&") << QString("&With Double &") << 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/qlibrary/lib2/lib2.pro b/tests/auto/qlibrary/lib2/lib2.pro index 436d7ba..fc00af8 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 b4dfbba..dd5bb29 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -51,6 +51,10 @@ #include "qcompleter.h" #include "qstandarditemmodel.h" +#ifndef QT_NO_CLIPBOARD +#include "qclipboard.h" +#endif + #ifdef Q_WS_MAC #include <Carbon/Carbon.h> // For the random function. #include <cstdlib> // For the random function. @@ -157,6 +161,10 @@ private slots: void undo_keypressevents_data(); void undo_keypressevents(); +#ifndef QT_NO_CLIPBOARD + void QTBUG5786_undoPaste(); +#endif + void clear(); void text_data(); @@ -1406,6 +1414,36 @@ void tst_QLineEdit::undo_keypressevents() QVERIFY(testWidget->text().isEmpty()); } +#ifndef QT_NO_CLIPBOARD +void tst_QLineEdit::QTBUG5786_undoPaste() +{ + QString initial("initial"); + QString string("test"); + QString additional("add"); + QApplication::clipboard()->setText(string); + QLineEdit edit(initial); + QCOMPARE(edit.text(), initial); + edit.paste(); + QCOMPARE(edit.text(), initial + string); + edit.paste(); + QCOMPARE(edit.text(), initial + string + string); + edit.insert(additional); + QCOMPARE(edit.text(), initial + string + string + additional); + edit.undo(); + QCOMPARE(edit.text(), initial + string + string); + edit.undo(); + QCOMPARE(edit.text(), initial + string); + edit.undo(); + QCOMPARE(edit.text(), initial); + edit.selectAll(); + QApplication::clipboard()->setText(QString()); + edit.paste(); + QVERIFY(edit.text().isEmpty()); + +} +#endif + + void tst_QLineEdit::clear() { // checking that clear of empty/nullstring doesn't add to undo history diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 1c8fecf..602da61 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -122,6 +122,7 @@ private slots: void taskQTBUG_633_changeModelData(); void taskQTBUG_435_deselectOnViewportClick(); void taskQTBUG_2678_spacingAndWrappedText(); + void taskQTBUG_5877_skippingItemInPageDownUp(); }; // Testing get/set functions @@ -509,9 +510,7 @@ void tst_QListView::moveCursor2() QModelIndex idx = vu.moveCursor(QMoveCursorListView::MoveHome, Qt::NoModifier); QCOMPARE(idx, model.index(0,0)); idx = vu.moveCursor(QMoveCursorListView::MoveDown, Qt::NoModifier); - QModelIndex p = model.index(8,0); QCOMPARE(idx, model.index(8,0)); - } void tst_QListView::moveCursor3() @@ -605,7 +604,6 @@ void tst_QListView::indexAt() QVERIFY(view2.m_index.isValid()); QVERIFY(view2.m_index.row() != 0); - } void tst_QListView::clicked() @@ -703,7 +701,6 @@ void tst_QListView::modelColumn() view.setModel(&model); - // // Set and get with a valid model // @@ -743,7 +740,6 @@ void tst_QListView::modelColumn() } } - void tst_QListView::hideFirstRow() { QStringList items; @@ -814,7 +810,6 @@ void tst_QListView::batchedMode() ba.setBit(idx.row(), true); } QCOMPARE(ba.size(), 3); - } void tst_QListView::setCurrentIndex() @@ -1146,7 +1141,6 @@ void tst_QListView::selection() for (int i = 0; i < selected.count(); ++i) { QVERIFY(expectedItems.contains(selected.at(i).row())); } - } void tst_QListView::scrollTo() @@ -1251,7 +1245,6 @@ void tst_QListView::scrollTo() QTest::keyClick(lv.viewport(), Qt::Key_Up, Qt::NoModifier); QCOMPARE(lv.visualRect(index).y(), 0); - } @@ -1772,7 +1765,6 @@ void tst_QListView::clickOnViewportClearsSelection() QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, point); //now the selection should be cleared QVERIFY(!view.selectionModel()->hasSelection()); - } void tst_QListView::task262152_setModelColumnNavigate() @@ -1795,7 +1787,6 @@ void tst_QListView::task262152_setModelColumnNavigate() QTest::keyClick(&view, Qt::Key_Down); QTest::qWait(30); QTRY_COMPARE(view.currentIndex(), model.index(2,1)); - } void tst_QListView::taskQTBUG_2233_scrollHiddenItems_data() @@ -1891,5 +1882,38 @@ void tst_QListView::taskQTBUG_2678_spacingAndWrappedText() QCOMPARE(w.horizontalScrollBar()->minimum(), w.horizontalScrollBar()->maximum()); } +void tst_QListView::taskQTBUG_5877_skippingItemInPageDownUp() +{ + QList<int> currentItemIndexes; + QtTestModel model(0); + model.colCount = 1; + model.rCount = 100; + + currentItemIndexes << 0 << 6 << 16 << 25 << 34 << 42 << 57 << 68 << 77 + << 83 << 91 << 94; + QMoveCursorListView vu; + vu.setModel(&model); + vu.show(); + + QTest::qWaitForWindowShown(&vu); + + int itemHeight = vu.visualRect(model.index(0, 0)).height(); + int visibleRowCount = vu.viewport()->height() / itemHeight; + int scrolledRowCount = visibleRowCount - 1; + + for (int i = 0; i < currentItemIndexes.size(); ++i) { + vu.selectionModel()->setCurrentIndex(model.index(currentItemIndexes[i], 0), + QItemSelectionModel::SelectCurrent); + + QModelIndex idx = vu.moveCursor(QMoveCursorListView::MovePageDown, Qt::NoModifier); + int newCurrent = qMin(currentItemIndexes[i] + scrolledRowCount, 99); + QCOMPARE(idx, model.index(newCurrent, 0)); + + idx = vu.moveCursor(QMoveCursorListView::MovePageUp, Qt::NoModifier); + newCurrent = qMax(currentItemIndexes[i] - scrolledRowCount, 0); + QCOMPARE(idx, model.index(newCurrent, 0)); + } +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index 5ead049..8cabadb 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -695,7 +695,7 @@ public: || socket.error() == QLocalSocket::ConnectionRefusedError) && tries < 1000); if (tries == 0 && socket.state() != QLocalSocket::ConnectedState) { - QVERIFY(socket.waitForConnected(3000)); + QVERIFY(socket.waitForConnected(7000)); QVERIFY(socket.state() == QLocalSocket::ConnectedState); } @@ -725,7 +725,7 @@ public: int done = clients; while (done > 0) { bool timedOut = true; - QVERIFY(server.waitForNewConnection(3000, &timedOut)); + QVERIFY(server.waitForNewConnection(7000, &timedOut)); QVERIFY(!timedOut); QLocalSocket *serverSocket = server.nextPendingConnection(); QVERIFY(serverSocket); diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index f12fa92..7cdfe46 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -87,6 +87,7 @@ private slots: void widgetActionFocus(); void mouseActivation(); void tearOff(); + void layoutDirection(); #if defined(QT3_SUPPORT) void indexBasedInsertion_data(); @@ -101,11 +102,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; @@ -594,6 +597,31 @@ void tst_QMenu::tearOff() QVERIFY(!torn->isVisible()); } +void tst_QMenu::layoutDirection() +{ + QMainWindow win; + win.setLayoutDirection(Qt::RightToLeft); + + QMenu menu(&win); + menu.show(); + QTest::qWaitForWindowShown(&menu); + QCOMPARE(menu.layoutDirection(), Qt::RightToLeft); + menu.close(); + + menu.setParent(0); + menu.show(); + QTest::qWaitForWindowShown(&menu); + QCOMPARE(menu.layoutDirection(), QApplication::layoutDirection()); + menu.close(); + + //now the menubar + QAction *action = win.menuBar()->addMenu(&menu); + win.menuBar()->setActiveAction(action); + QTest::qWaitForWindowShown(&menu); + QCOMPARE(menu.layoutDirection(), Qt::RightToLeft); +} + + #if defined(QT3_SUPPORT) void tst_QMenu::indexBasedInsertion_data() @@ -858,6 +886,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 4291c3e..320cd8d 100644 --- a/tests/auto/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/qmenubar/tst_qmenubar.cpp @@ -167,6 +167,7 @@ private slots: void task223138_triggered(); void task256322_highlight(); void menubarSizeHint(); + void taskQTBUG4965_escapeEaten(); #if defined(QT3_SUPPORT) void indexBasedInsertion_data(); @@ -1664,6 +1665,27 @@ void tst_QMenuBar::menubarSizeHint() QCOMPARE(resSize, mb.sizeHint()); } +void tst_QMenuBar::taskQTBUG4965_escapeEaten() +{ + QMenuBar menubar; + QMenu menu("menu1"); + QAction *first = menubar.addMenu(&menu); + menu.addAction("quit", &menubar, SLOT(close()), QKeySequence("ESC")); + menubar.show(); + menubar.setActiveWindow(); + QTest::qWaitForWindowShown(&menubar); + menubar.setActiveAction(first); + QTRY_VERIFY(menu.isVisible()); + QCOMPARE(menubar.activeAction(), first); + QTest::keyClick(0, Qt::Key_Escape); + QVERIFY(!menu.isVisible()); + QTRY_VERIFY(menubar.hasFocus()); + QCOMPARE(menubar.activeAction(), first); + QTest::keyClick(0, Qt::Key_Escape); + QVERIFY(!menubar.activeAction()); + QTest::keyClick(0, Qt::Key_Escape); //now the action should be triggered + QTRY_VERIFY(!menubar.isVisible()); +} #if defined(QT3_SUPPORT) void tst_QMenuBar::indexBasedInsertion_data() diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index ff7e78e..b52c515 100644 --- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -168,13 +168,16 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() cookie.setDomain("something.completely.different"); QTest::newRow("security-domain-1") << preset << cookie << "http://www.foo.tld" << result << false; - cookie.setDomain("www.foo.tld"); + // we want the cookie to be accepted although the path does not match, see QTBUG-5815 + cookie.setDomain(".foo.tld"); cookie.setPath("/something"); - QTest::newRow("security-path-1") << preset << cookie << "http://www.foo.tld" << result << false; + result += cookie; + QTest::newRow("security-path-1") << preset << cookie << "http://www.foo.tld" << result << true; // setting the defaults: finalCookie = cookie; finalCookie.setPath("/something/"); + finalCookie.setDomain("www.foo.tld"); cookie.setPath(""); cookie.setDomain(""); result.clear(); @@ -285,6 +288,22 @@ void tst_QNetworkCookieJar::cookiesForUrl_data() QTest::newRow("exp-match-4") << allCookies << "http://qt.nokia.com/web" << result; QTest::newRow("exp-match-4") << allCookies << "http://qt.nokia.com/web/" << result; QTest::newRow("exp-match-6") << allCookies << "http://qt.nokia.com/web/content" << result; + + // path matching + allCookies.clear(); + QNetworkCookie anotherCookie; + anotherCookie.setName("a"); + anotherCookie.setPath("/web"); + anotherCookie.setDomain(".nokia.com"); + allCookies += anotherCookie; + result.clear(); + QTest::newRow("path-unmatch-1") << allCookies << "http://nokia.com/" << result; + QTest::newRow("path-unmatch-2") << allCookies << "http://nokia.com/something/else" << result; + result += anotherCookie; + QTest::newRow("path-match-1") << allCookies << "http://nokia.com/web" << result; + QTest::newRow("path-match-2") << allCookies << "http://nokia.com/web/" << result; + QTest::newRow("path-match-3") << allCookies << "http://nokia.com/web/content" << result; + } void tst_QNetworkCookieJar::cookiesForUrl() diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 0b61dcd..5fe716a 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -225,6 +225,9 @@ private Q_SLOTS: void ioPostToHttpUploadProgress(); void ioPostToHttpEmtpyUploadProgress(); + void lastModifiedHeaderForFile(); + void lastModifiedHeaderForHttp(); + void rateControl_data(); void rateControl(); @@ -2209,7 +2212,7 @@ void tst_QNetworkReply::ioGetWithManyProxies() connect(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); #endif - QTestEventLoop::instance().enterLoop(10); + QTestEventLoop::instance().enterLoop(15); QVERIFY(!QTestEventLoop::instance().timeout()); manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), @@ -2619,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 - + QTestEventLoop::instance().enterLoop(12); disconnect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); disconnect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), @@ -2969,6 +2967,41 @@ 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() { QTest::addColumn<int>("rate"); diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index fcb59f9..0512499 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -48,6 +48,7 @@ #include <qdesktopwidget.h> #include <qpaintengine.h> #include <qtreewidget.h> +#include <qsplashscreen.h> #include <private/qpixmapdata_p.h> @@ -170,6 +171,7 @@ private slots: void loadFromDataNullValues(); void preserveDepth(); + void splash_crash(); }; static bool lenientCompare(const QPixmap &actual, const QPixmap &expected) @@ -1440,6 +1442,17 @@ void tst_QPixmap::fromImage_crash() delete img; } +//This is testing QPixmapData::createCompatiblePixmapData - see QTBUG-5977 +void tst_QPixmap::splash_crash() +{ + QPixmap pix; + pix = QPixmap(":/images/designer.png"); + QSplashScreen splash(pix); + splash.show(); + QCoreApplication::processEvents(); + splash.close(); +} + void tst_QPixmap::fromData() { unsigned char bits[] = { 0xaa, 0x55 }; diff --git a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp index a80c787..751c7dc 100644 --- a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp +++ b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp @@ -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/qscriptable/tst_qscriptable.cpp b/tests/auto/qscriptable/tst_qscriptable.cpp index 90f1db8..c0945d8 100644 --- a/tests/auto/qscriptable/tst_qscriptable.cpp +++ b/tests/auto/qscriptable/tst_qscriptable.cpp @@ -332,7 +332,7 @@ void tst_QScriptable::thisObject() { QVERIFY(!m_scriptable.oofThisObject().isValid()); m_engine.evaluate("o.oof = 123"); - QEXPECT_FAIL("", "Setter doesn't get called when it's in the prototype", Continue); + QEXPECT_FAIL("", "QTBUG-5749: Setter doesn't get called when it's in the prototype", Continue); QVERIFY(m_scriptable.oofThisObject().strictlyEquals(m_engine.evaluate("o"))); } { diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index a0af214..4ecd887 100644 --- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp +++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp @@ -1114,7 +1114,7 @@ void tst_QScriptContext::calledAsConstructor() QVERIFY(!fun3.property("calledAsConstructor").toBool()); eng.evaluate("new test();"); if (qt_script_isJITEnabled()) - QEXPECT_FAIL("", "calledAsConstructor is not correctly set for JS functions when JIT is enabled", Continue); + QEXPECT_FAIL("", "QTBUG-6132: calledAsConstructor is not correctly set for JS functions when JIT is enabled", Continue); QVERIFY(fun3.property("calledAsConstructor").toBool()); } diff --git a/tests/auto/qscriptcontextinfo/tst_qscriptcontextinfo.cpp b/tests/auto/qscriptcontextinfo/tst_qscriptcontextinfo.cpp index fe69c07..09ef820 100644 --- a/tests/auto/qscriptcontextinfo/tst_qscriptcontextinfo.cpp +++ b/tests/auto/qscriptcontextinfo/tst_qscriptcontextinfo.cpp @@ -249,13 +249,13 @@ void tst_QScriptContextInfo::qtFunction() QCOMPARE(info.functionEndLineNumber(), -1); QCOMPARE(info.functionStartLineNumber(), -1); if (x == 0) - QEXPECT_FAIL("", "QScriptContextInfo doesn't pick the correct meta-index for overloaded slots", Continue); + QEXPECT_FAIL("", "QTBUG-6133: QScriptContextInfo doesn't pick the correct meta-index for overloaded slots", Continue); QCOMPARE(info.functionParameterNames().size(), pnames.size()); if (x == 0) - QEXPECT_FAIL("", "QScriptContextInfo doesn't pick the correct meta-index for overloaded slots", Continue); + QEXPECT_FAIL("", "QTBUG-6133: QScriptContextInfo doesn't pick the correct meta-index for overloaded slots", Continue); QCOMPARE(info.functionParameterNames(), pnames); if (x == 0) - QEXPECT_FAIL("", "QScriptContextInfo doesn't pick the correct meta-index for overloaded slots", Continue); + QEXPECT_FAIL("", "QTBUG-6133: QScriptContextInfo doesn't pick the correct meta-index for overloaded slots", Continue); QCOMPARE(info.functionMetaIndex(), metaObject()->indexOfMethod(sig)); } diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 8eaad78..3bc2443 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -1148,7 +1148,7 @@ void tst_QScriptEngine::globalObjectProperties() QScriptValue::PropertyFlags flags = QScriptValue::ReadOnly | QScriptValue::SkipInEnumeration; global.setProperty(name, val, flags); QVERIFY(global.property(name).equals(val)); - QEXPECT_FAIL("", "custom Global Object properties don't retain attributes", Continue); + QEXPECT_FAIL("", "QTBUG-6134: custom Global Object properties don't retain attributes", Continue); QCOMPARE(global.propertyFlags(name), flags); global.setProperty(name, QScriptValue()); QVERIFY(!global.property(name).isValid()); @@ -2033,7 +2033,7 @@ void tst_QScriptEngine::valueConversion() QScriptValue val = qScriptValueFromValue(&eng, in); QVERIFY(val.isRegExp()); QRegExp out = val.toRegExp(); - QEXPECT_FAIL("", "JSC-based back-end doesn't preserve QRegExp::patternSyntax (always uses RegExp2)", Continue); + QEXPECT_FAIL("", "QTBUG-6136: JSC-based back-end doesn't preserve QRegExp::patternSyntax (always uses RegExp2)", Continue); QCOMPARE(out.patternSyntax(), in.patternSyntax()); QCOMPARE(out.pattern(), in.pattern()); QCOMPARE(out.caseSensitivity(), in.caseSensitivity()); @@ -2050,7 +2050,7 @@ void tst_QScriptEngine::valueConversion() in.setMinimal(true); QScriptValue val = qScriptValueFromValue(&eng, in); QVERIFY(val.isRegExp()); - QEXPECT_FAIL("", "JSC-based back-end doesn't preserve QRegExp::minimal (always false)", Continue); + QEXPECT_FAIL("", "QTBUG-6136: JSC-based back-end doesn't preserve QRegExp::minimal (always false)", Continue); QCOMPARE(val.toRegExp().isMinimal(), in.isMinimal()); } } @@ -2505,7 +2505,7 @@ void tst_QScriptEngine::stacktrace() QVERIFY(eng.hasUncaughtException()); QVERIFY(result.isError()); - QEXPECT_FAIL("", "", Abort); + QEXPECT_FAIL("", "QTBUG-6139: uncaughtExceptionBacktrace() doesn't give the full backtrace", Abort); QCOMPARE(eng.uncaughtExceptionBacktrace(), backtrace); QVERIFY(eng.hasUncaughtException()); QVERIFY(result.strictlyEquals(eng.uncaughtException())); @@ -3045,7 +3045,7 @@ void tst_QScriptEngine::errorConstructors() eng.clearExceptions(); QVERIFY(ret.toString().startsWith(name)); if (x != 0) - QEXPECT_FAIL("", "JSC doesn't assign lineNumber when errors are not thrown", Continue); + QEXPECT_FAIL("", "QTBUG-6138: JSC doesn't assign lineNumber when errors are not thrown", Continue); QCOMPARE(ret.property("lineNumber").toInt32(), i+2); } } @@ -3063,14 +3063,19 @@ void tst_QScriptEngine::argumentsProperty() { { QScriptEngine eng; - QEXPECT_FAIL("", "", Continue); - QVERIFY(eng.evaluate("arguments").isUndefined()); + { + QScriptValue ret = eng.evaluate("arguments"); + QVERIFY(ret.isError()); + QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: Can't find variable: arguments")); + } eng.evaluate("arguments = 10"); - QScriptValue ret = eng.evaluate("arguments"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt32(), 10); - QEXPECT_FAIL("", "", Continue); - QVERIFY(!eng.evaluate("delete arguments").toBoolean()); + { + QScriptValue ret = eng.evaluate("arguments"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt32(), 10); + } + QVERIFY(eng.evaluate("delete arguments").toBoolean()); + QVERIFY(!eng.globalObject().property("arguments").isValid()); } { QScriptEngine eng; @@ -3081,11 +3086,11 @@ void tst_QScriptEngine::argumentsProperty() } { QScriptEngine eng; + QVERIFY(!eng.globalObject().property("arguments").isValid()); QScriptValue ret = eng.evaluate("(function() { arguments = 456; return arguments; })()"); QVERIFY(ret.isNumber()); QCOMPARE(ret.toInt32(), 456); - QEXPECT_FAIL("", "", Continue); - QVERIFY(eng.evaluate("arguments").isUndefined()); + QVERIFY(!eng.globalObject().property("arguments").isValid()); } { diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp index 032c34b..1a02785 100644 --- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp +++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp @@ -85,6 +85,7 @@ private slots: void functionEntryAndExit_native(); void functionEntryAndExit_native2(); void functionEntryAndExit_nativeThrowing(); + void functionEntryAndExit_builtin_data(); void functionEntryAndExit_builtin(); void functionEntryAndExit_objects(); void functionEntryAndExit_slots(); @@ -114,6 +115,7 @@ private slots: void evaluateProgram(); void evaluateProgram_SyntaxError(); void evaluateNullProgram(); + void QTBUG6108(); private: double m_testProperty; @@ -475,7 +477,7 @@ void tst_QScriptEngineAgent::scriptLoadAndUnload_eval() spy->clear(); eng.evaluate("eval('function foo() { print(123); }')"); - QEXPECT_FAIL("","Eval is threaded in different way that in old backend", Abort); + QEXPECT_FAIL("","QTBUG-6140 Eval is threaded in different way that in old backend", Abort); QCOMPARE(spy->count(), 3); QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad); @@ -810,18 +812,42 @@ void tst_QScriptEngineAgent::functionEntryAndExit_nativeThrowing() delete spy; } +void tst_QScriptEngineAgent::functionEntryAndExit_builtin_data() +{ + QTest::addColumn<QString>("script"); + QTest::addColumn<QString>("result"); + + QTest::newRow("string native") << "'ciao'.toString()" << "ciao"; + QTest::newRow("string object") << "String('ciao').toString()" << "ciao"; + QTest::newRow("number native") << "(123).toString()" << "123"; + QTest::newRow("number object") << "Number(123).toString()" << "123"; + QTest::newRow("array native") << "['s','a'].toString()" << "s, a"; + QTest::newRow("array object") << "Array('s', 'a').toString()" << "s,a"; + QTest::newRow("boolean native") << "false.toString()" << "false"; + QTest::newRow("boolean object") << "Boolean(true).toString()" << "true"; + QTest::newRow("regexp native") << "/a/.toString()" << "/a/"; + QTest::newRow("regexp object") << "RegExp('a').toString()" << "/a/"; +} + /** check behaiviour of built-in function */ void tst_QScriptEngineAgent::functionEntryAndExit_builtin() { + QFETCH(QString, script); + QFETCH(QString, result); QScriptEngine eng; ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry | ScriptEngineSpy::IgnoreFunctionExit)); { spy->clear(); - eng.evaluate("'ciao'.toString()"); - - if (qt_script_isJITEnabled()) - QEXPECT_FAIL("", "Some events are missing when JIT is enabled", Abort); + eng.evaluate(script); + + if (qt_script_isJITEnabled()) { + QEXPECT_FAIL("string native", "QTBUG-6187 Some events are missing when JIT is enabled", Abort); + QEXPECT_FAIL("number native", "QTBUG-6187 Some events are missing when JIT is enabled", Abort); + QEXPECT_FAIL("array native", "QTBUG-6187 Some events are missing when JIT is enabled", Abort); + QEXPECT_FAIL("boolean native", "QTBUG-6187 Some events are missing when JIT is enabled", Abort); + QEXPECT_FAIL("regexp native", "QTBUG-6187 Some events are missing when JIT is enabled", Abort); + } QCOMPARE(spy->count(), 4); // evaluate() entry @@ -834,14 +860,13 @@ void tst_QScriptEngineAgent::functionEntryAndExit_builtin() // built-in native function exit QCOMPARE(spy->at(2).type, ScriptEngineEvent::FunctionExit); QCOMPARE(spy->at(2).scriptId, qint64(-1)); - QVERIFY(spy->at(2).value.isString()); - QCOMPARE(spy->at(2).value.toString(), QString("ciao")); + QCOMPARE(spy->at(2).value.toString(), QString(result)); // evaluate() exit QCOMPARE(spy->at(3).type, ScriptEngineEvent::FunctionExit); QCOMPARE(spy->at(3).scriptId, spy->at(0).scriptId); QVERIFY(spy->at(3).value.isString()); - QCOMPARE(spy->at(3).value.toString(), QString("ciao")); + QCOMPARE(spy->at(3).value.toString(), QString(result)); } delete spy; } @@ -1160,16 +1185,16 @@ void tst_QScriptEngineAgent::positionChange_1() { spy->clear(); eng.evaluate(";"); - QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue); + QEXPECT_FAIL("","QTBUG-6142 JSC do not evaluate ';' to statemant",Continue); QCOMPARE(spy->count(), 1); if (spy->count()) { - QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue); + QEXPECT_FAIL("","QTBUG-6142 JSC do not evaluate ';' to statemant",Continue); QCOMPARE(spy->at(0).type, ScriptEngineEvent::PositionChange); - QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue); + QEXPECT_FAIL("","QTBUG-6142 JSC do not evaluate ';' to statemant",Continue); QVERIFY(spy->at(0).scriptId != -1); - QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue); + QEXPECT_FAIL("","QTBUG-6142 JSC do not evaluate ';' to statemant",Continue); QCOMPARE(spy->at(0).lineNumber, 1); - QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue); + QEXPECT_FAIL("","QTBUG-6142 JSC do not evaluate ';' to statemant",Continue); QCOMPARE(spy->at(0).columnNumber, 1); } } @@ -1551,7 +1576,7 @@ void tst_QScriptEngineAgent::positionChange_2() } { - QEXPECT_FAIL("","I believe the test is wrong. Expressions shouldn't call positionChange " + QEXPECT_FAIL("","QTBUG-6142 I believe the test is wrong. Expressions shouldn't call positionChange " "because statement '1+2' will call it at least twice, why debugger have to " "stop here so many times?", Abort); spy->clear(); @@ -2088,8 +2113,6 @@ void tst_QScriptEngineAgent::syntaxError() i = 2; QCOMPARE(spy->at(i).type, ScriptEngineEvent::ContextPush); - QEXPECT_FAIL("","The test is broken, contextPush event do not provide scriptId", Continue); - QVERIFY(spy->at(i).scriptId == -1); i = 3; QCOMPARE(spy->at(i).type, ScriptEngineEvent::FunctionEntry); QVERIFY(spy->at(i).scriptId == -1); @@ -2098,14 +2121,12 @@ void tst_QScriptEngineAgent::syntaxError() QVERIFY(spy->at(i).scriptId == -1); i = 5; QCOMPARE(spy->at(i).type, ScriptEngineEvent::ContextPop); - QEXPECT_FAIL("","The test is broken, contextPop event do not provide scriptId", Continue); - QVERIFY(spy->at(i).scriptId == -1); i = 6; QCOMPARE(spy->at(i).type, ScriptEngineEvent::ExceptionThrow); QCOMPARE(spy->at(i).scriptId, spy->at(0).scriptId); QVERIFY(!spy->at(i).hasExceptionHandler); QVERIFY(spy->at(i).value.isError()); - QEXPECT_FAIL("","There are other messages in JSC",Continue); + QEXPECT_FAIL("","QTBUG-6137 There are other messages in JSC",Continue); QCOMPARE(spy->at(i).value.toString(), QString("SyntaxError: Expected `}'")); QCOMPARE(spy->at(i).scriptId, spy->at(0).scriptId); i = 7; @@ -2138,7 +2159,7 @@ void tst_QScriptEngineAgent::extension_invoctaion() QCOMPARE(spy->at(1).lineNumber, lineNumber); QCOMPARE(spy->at(1).columnNumber, 1); - QEXPECT_FAIL("","In JSC Eval('debugger') returns undefined",Abort); + QEXPECT_FAIL("","QTBUG-6135 In JSC Eval('debugger') returns undefined",Abort); QVERIFY(ret.isString()); QCOMPARE(ret.toString(), QString::fromLatin1("extension(DebuggerInvocationRequest)")); } @@ -2306,5 +2327,32 @@ void tst_QScriptEngineAgent::evaluateNullProgram() QCOMPARE(spy->count(), 0); } +void tst_QScriptEngineAgent::QTBUG6108() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); + eng.evaluate("eval('a = 1')"); + QCOMPARE(spy->count(), 5); + + QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad); + QVERIFY(spy->at(0).scriptId != -1); + + QCOMPARE(spy->at(1).type, ScriptEngineEvent::FunctionEntry); + QVERIFY(spy->at(1).scriptId != -1); + QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); + + QCOMPARE(spy->at(2).type, ScriptEngineEvent::PositionChange); + QVERIFY(spy->at(2).scriptId != -1); + QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); + QCOMPARE(spy->at(2).lineNumber, 1); + + QCOMPARE(spy->at(3).type, ScriptEngineEvent::FunctionExit); + QVERIFY(spy->at(3).scriptId != -1); + QCOMPARE(spy->at(3).scriptId, spy->at(0).scriptId); + + QCOMPARE(spy->at(4).type, ScriptEngineEvent::ScriptUnload); + QCOMPARE(spy->at(4).scriptId, spy->at(0).scriptId); +} + QTEST_MAIN(tst_QScriptEngineAgent) #include "tst_qscriptengineagent.moc" diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index db46b66..169a688 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -347,7 +347,6 @@ void tst_QSslSocket::constructing() QCOMPARE(socket.sslConfiguration(), QSslConfiguration::defaultConfiguration()); QCOMPARE(socket.errorString(), QString("Unknown error")); char c = '\0'; - QTest::ignoreMessage(QtWarningMsg, "QIODevice::getChar: Closed device"); QVERIFY(!socket.getChar(&c)); QCOMPARE(c, '\0'); QVERIFY(!socket.isOpen()); diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index fd39515..a13bb0d 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -209,6 +209,7 @@ private slots: void task260403_clonedSignals(); void postEventFromOtherThread(); void eventFilterForApplication(); + void eventClassesExported(); }; tst_QStateMachine::tst_QStateMachine() @@ -4307,5 +4308,12 @@ void tst_QStateMachine::eventFilterForApplication() QVERIFY(machine.configuration().contains(s2)); } +void tst_QStateMachine::eventClassesExported() +{ + // make sure this links + QStateMachine::WrappedEvent *wrappedEvent = new QStateMachine::WrappedEvent(0, 0); + QStateMachine::SignalEvent *signalEvent = new QStateMachine::SignalEvent(0, 0, QList<QVariant>()); +} + QTEST_MAIN(tst_QStateMachine) #include "tst_qstatemachine.moc" diff --git a/tests/auto/qstatusbar/tst_qstatusbar.cpp b/tests/auto/qstatusbar/tst_qstatusbar.cpp index 9774559..92d9185 100644 --- a/tests/auto/qstatusbar/tst_qstatusbar.cpp +++ b/tests/auto/qstatusbar/tst_qstatusbar.cpp @@ -77,6 +77,7 @@ private slots: void insertPermanentWidget(); void setSizeGripEnabled(); void task194017_hiddenWidget(); + void QTBUG4334_hiddenOnMaximizedWindow(); private: QStatusBar *testWidget; @@ -257,6 +258,19 @@ void tst_QStatusBar::task194017_hiddenWidget() QVERIFY(!label->isVisible()); } +void tst_QStatusBar::QTBUG4334_hiddenOnMaximizedWindow() +{ + QMainWindow main; + QStatusBar statusbar; + statusbar.setSizeGripEnabled(true); + main.setStatusBar(&statusbar); + main.showMaximized(); + QTest::qWaitForWindowShown(&main); + QVERIFY(!statusbar.findChild<QSizeGrip*>()->isVisible()); + main.showNormal(); + QTest::qWaitForWindowShown(&main); + QVERIFY(statusbar.findChild<QSizeGrip*>()->isVisible()); +} QTEST_MAIN(tst_QStatusBar) #include "tst_qstatusbar.moc" diff --git a/tests/auto/qsysinfo/.gitignore b/tests/auto/qsysinfo/.gitignore deleted file mode 100644 index e50cae2..0000000 --- a/tests/auto/qsysinfo/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qsysinfo diff --git a/tests/auto/qsysinfo/qsysinfo.pro b/tests/auto/qsysinfo/qsysinfo.pro deleted file mode 100644 index e822fec..0000000 --- a/tests/auto/qsysinfo/qsysinfo.pro +++ /dev/null @@ -1,5 +0,0 @@ -load(qttest_p4) -SOURCES += tst_qsysinfo.cpp -QT = core - - diff --git a/tests/auto/qtabbar/tst_qtabbar.cpp b/tests/auto/qtabbar/tst_qtabbar.cpp index 78c65ae..5d7a704 100644 --- a/tests/auto/qtabbar/tst_qtabbar.cpp +++ b/tests/auto/qtabbar/tst_qtabbar.cpp @@ -298,6 +298,10 @@ void tst_QTabBar::setUsesScrollButtons() if (usesArrows != -128) tabBar.setUsesScrollButtons(usesArrows); QTEST(tabBar.usesScrollButtons(), "expectedArrows"); + + // Make sure style sheet does not override user set mode + tabBar.setStyleSheet("QWidget { background-color: #ABA8A6;}"); + QTEST(tabBar.usesScrollButtons(), "expectedArrows"); } void tst_QTabBar::removeLastTab() @@ -535,7 +539,7 @@ void tst_QTabBar::task251184_removeTab() QCOMPARE(bar.count(), 1); QCOMPARE(bar.currentIndex(), 0); - QCOMPARE(bar.tabText(bar.currentIndex()), QString("bar2")); + QCOMPARE(bar.tabText(bar.currentIndex()), QString("bar2")); } diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index f571e8a..50d6c67 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -198,6 +198,7 @@ private slots: void task191545_dragSelectRows(); void taskQTBUG_5062_spansInconsistency(); void taskQTBUG_4516_clickOnRichTextLabel(); + void taskQTBUG_5237_wheelEventOnHeader(); void mouseWheel_data(); void mouseWheel(); @@ -3015,6 +3016,14 @@ void tst_QTableView::spans_data() << QPoint(2, 0) << 1 << 2; + + QTest::newRow("QTBUG-6004: No failing Q_ASSERT, then it passes.") + << 5 << 5 + << (SpanList() << QRect(0, 0, 2, 2) << QRect(0, 0, 1, 1)) + << false + << QPoint(0, 0) + << 1 + << 1; } void tst_QTableView::spans() @@ -3613,17 +3622,9 @@ void tst_QTableView::mouseWheel_data() QTest::newRow("scroll down per item") << int(QAbstractItemView::ScrollPerItem) << -120 << 10 + qApp->wheelScrollLines() << 10 + qApp->wheelScrollLines(); -#ifdef Q_WS_MAC - // On Mac, we always scroll one pixel per 120 delta (rather than multiplying with - // singleStep) since wheel events are accelerated by the OS. - QTest::newRow("scroll down per pixel") - << int(QAbstractItemView::ScrollPerPixel) << -120 - << 10 + qApp->wheelScrollLines() << 10 + qApp->wheelScrollLines(); -#else QTest::newRow("scroll down per pixel") << int(QAbstractItemView::ScrollPerPixel) << -120 << 10 + qApp->wheelScrollLines() * 89 << 10 + qApp->wheelScrollLines() * 28; -#endif } void tst_QTableView::mouseWheel() @@ -3913,7 +3914,7 @@ void tst_QTableView::changeHeaderData() QTest::qWaitForWindowShown(&view); QString text = "long long long text"; - const int textWidth = view.fontMetrics().width(text); + const int textWidth = view.verticalHeader()->fontMetrics().width(text); QVERIFY(view.verticalHeader()->width() < textWidth); model.setHeaderData(2, Qt::Vertical, text); @@ -3922,6 +3923,22 @@ void tst_QTableView::changeHeaderData() QVERIFY(view.verticalHeader()->width() > textWidth); } +void tst_QTableView::taskQTBUG_5237_wheelEventOnHeader() +{ + QTableView view; + QStandardItemModel model(500,5); + view.setModel(&model); + view.show(); + QTest::qWaitForWindowShown(&view); + + int sbValueBefore = view.verticalScrollBar()->value(); + QHeaderView *header = view.verticalHeader(); + QTest::mouseMove(header); + QWheelEvent wheelEvent(header->geometry().center(), -720, 0, 0); + QApplication::sendEvent(header->viewport(), &wheelEvent); + int sbValueAfter = view.verticalScrollBar()->value(); + QVERIFY(sbValueBefore != sbValueAfter); +} QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp index 2540096..8b86111 100644 --- a/tests/auto/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp @@ -523,7 +523,7 @@ void tst_QTcpServer::waitForConnectionTest() QTcpSocket findLocalIpSocket; findLocalIpSocket.connectToHost(QtNetworkSettings::serverName(), 143); - QVERIFY(findLocalIpSocket.waitForConnected(2000)); + QVERIFY(findLocalIpSocket.waitForConnected(5000)); QTcpServer server; bool timeout = false; diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index 5577903..863b8f5 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(); @@ -369,7 +371,6 @@ void tst_QTcpSocket::constructing() QCOMPARE(socket->socketType(), QTcpSocket::TcpSocket); char c; - QTest::ignoreMessage(QtWarningMsg, "QIODevice::getChar: Closed device"); QCOMPARE(socket->getChar(&c), false); QCOMPARE((int) socket->bytesAvailable(), 0); QCOMPARE(socket->canReadLine(), false); @@ -775,7 +776,7 @@ void tst_QTcpSocket::unget() for (int i = 0; i < 10; i += 2) { while (socket->bytesAvailable() < 2) - QVERIFY(socket->waitForReadyRead(5000)); + QVERIFY(socket->waitForReadyRead(10000)); int bA = socket->bytesAvailable(); QVERIFY(socket->read(buf, 2) == 2); buf[2] = '\0'; @@ -828,7 +829,6 @@ void tst_QTcpSocket::openCloseOpenClose() QVERIFY(socket->socketType() == QTcpSocket::TcpSocket); char c; - QTest::ignoreMessage(QtWarningMsg, "QIODevice::getChar: Closed device"); QCOMPARE(socket->getChar(&c), false); QCOMPARE((int) socket->bytesAvailable(), 0); QCOMPARE(socket->canReadLine(), false); @@ -1957,7 +1957,6 @@ void tst_QTcpSocket::zeroAndMinusOneReturns() QCOMPARE(socket->write("BLUBBER"), qint64(-1)); QCOMPARE(socket->read(c, 16), qint64(-1)); QCOMPARE(socket->readLine(c, 16), qint64(-1)); - QTest::ignoreMessage(QtWarningMsg, "QIODevice::getChar: Closed device"); QVERIFY(!socket->getChar(c)); QVERIFY(!socket->putChar('a')); @@ -2116,7 +2115,7 @@ void tst_QTcpSocket::moveToThread0() QTcpSocket *socket = newSocket();; socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->moveToThread(0); - QVERIFY(socket->waitForConnected(2000)); + QVERIFY(socket->waitForConnected(5000)); socket->write("XXX LOGOUT\r\n"); QVERIFY(socket->waitForBytesWritten(5000)); QVERIFY(socket->waitForDisconnected()); @@ -2127,7 +2126,7 @@ void tst_QTcpSocket::moveToThread0() QTcpSocket *socket = newSocket(); socket->moveToThread(0); socket->connectToHost(QtNetworkSettings::serverName(), 143); - QVERIFY(socket->waitForConnected(2000)); + QVERIFY(socket->waitForConnected(5000)); socket->write("XXX LOGOUT\r\n"); QVERIFY(socket->waitForBytesWritten(5000)); QVERIFY(socket->waitForDisconnected()); @@ -2137,7 +2136,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(2000)); + QVERIFY(socket->waitForConnected(5000)); socket->write("XXX LOGOUT\r\n"); socket->moveToThread(0); QVERIFY(socket->waitForBytesWritten(5000)); @@ -2148,7 +2147,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(2000)); + QVERIFY(socket->waitForConnected(5000)); socket->write("XXX LOGOUT\r\n"); QVERIFY(socket->waitForBytesWritten(5000)); socket->moveToThread(0); @@ -2214,6 +2213,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 +2303,7 @@ void tst_QTcpSocket::invalidProxy() QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); } else { QCOMPARE(socket->state(), QAbstractSocket::ConnectingState); - QVERIFY(!socket->waitForConnected(2000)); + QVERIFY(!socket->waitForConnected(5000)); } QVERIFY(!socket->errorString().isEmpty()); @@ -2382,7 +2422,7 @@ void tst_QTcpSocket::proxyFactory() QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); } else { QCOMPARE(socket->state(), QAbstractSocket::ConnectingState); - QVERIFY(socket->waitForConnected(2000)); + QVERIFY(socket->waitForConnected(5000)); QCOMPARE(proxyAuthCalled, 1); } QVERIFY(!socket->errorString().isEmpty()); diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 1d54409..11e32b0 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -2615,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() diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp index fee030c..bebc4bd 100644 --- a/tests/auto/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/qtextedit/tst_qtextedit.cpp @@ -200,6 +200,7 @@ private slots: void pasteFromQt3RichText(); void noWrapBackgrounds(); void preserveCharFormatAfterUnchangingSetPosition(); + void twoSameInputMethodEvents(); private: void createSelection(); @@ -2183,5 +2184,23 @@ void tst_QTextEdit::preserveCharFormatAfterUnchangingSetPosition() QCOMPARE(edit.textColor(), color); } +// Regression test for QTBUG-4696 +void tst_QTextEdit::twoSameInputMethodEvents() +{ + ed->setText("testLine"); + ed->show(); + QList<QInputMethodEvent::Attribute> attributes; + attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, + ed->textCursor().position(), + 0, + QVariant())); + + QInputMethodEvent event("PreEditText", attributes); + QApplication::sendEvent(ed, &event); + QCOMPARE(ed->document()->firstBlock().layout()->lineCount(), 1); + QApplication::sendEvent(ed, &event); + QCOMPARE(ed->document()->firstBlock().layout()->lineCount(), 1); +} + QTEST_MAIN(tst_QTextEdit) #include "tst_qtextedit.moc" diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index 7c3f4f2..1df26b8 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -1115,14 +1115,14 @@ void tst_QTextLayout::testTabDPIScale() QTextOption option = layout.textOption(); QList<QTextOption::Tab> tabs; QTextOption::Tab tab; - tab.position = 200; + tab.position = 300; tabs.append(tab); - tab.position = 400; + tab.position = 600; tab.type = QTextOption::RightTab; tabs.append(tab); - tab.position = 600; + tab.position = 800; tab.type = QTextOption::CenterTab; tabs.append(tab); option.setTabs(tabs); diff --git a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp index 78e0ce6..2f9cc04 100644 --- a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp @@ -858,6 +858,33 @@ void tst_QTextScriptEngine::malayalam() QSKIP("couln't find AkrutiMal2", SkipAll); } } + { + if (QFontDatabase().families(QFontDatabase::Malayalam).contains("Rachana")) { + QFont f("Rachana"); + const ShapeTable shape_table [] = { + { { 0xd37, 0xd4d, 0xd1f, 0xd4d, 0xd30, 0xd40, 0x0 }, + { 0x385, 0xa3, 0x0 } }, + { { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0x0 }, + { 0x2ff, 0x0 } }, + { { 0xd33, 0xd4d, 0xd33, 0x0 }, + { 0x3f8, 0x0 } }, + { { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0x0 }, + { 0x2ff, 0x0 } }, + + { {0}, {0} } + }; + + + const ShapeTable *s = shape_table; + while (s->unicode[0]) { + QVERIFY( shaping(f, s) ); + ++s; + } + } else { + QSKIP("couln't find Rachana", SkipAll); + } + } + #else QSKIP("X11 specific test", SkipAll); #endif diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 58f059b..4fc6dd3 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -3653,7 +3653,9 @@ void tst_QTreeView::doubleClickedWithSpans() 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)); diff --git a/tests/auto/qtreewidget/tst_qtreewidget.cpp b/tests/auto/qtreewidget/tst_qtreewidget.cpp index 6defd7b..0c6df4f 100644 --- a/tests/auto/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/qtreewidget/tst_qtreewidget.cpp @@ -167,6 +167,9 @@ private slots: void setCurrentItemExpandsParent(); void task239150_editorWidth(); void setTextUpdate(); + void taskQTBUG2844_visualItemRect(); + void setChildIndicatorPolicy(); + public slots: void itemSelectionChanged(); @@ -601,9 +604,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)); @@ -611,9 +614,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)); @@ -3271,6 +3274,76 @@ void tst_QTreeWidget::setTextUpdate() 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); +} + +void tst_QTreeWidget::setChildIndicatorPolicy() +{ + QTreeWidget treeWidget; + treeWidget.setColumnCount(1); + + class MyItemDelegate : public QStyledItemDelegate + { + public: + MyItemDelegate() : numPaints(0), expectChildren(false) { } + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const + { + numPaints++; + QCOMPARE(!(option.state & QStyle::State_Children), !expectChildren); + QStyledItemDelegate::paint(painter, option, index); + } + mutable int numPaints; + bool expectChildren; + } delegate; + + treeWidget.setItemDelegate(&delegate); + treeWidget.show(); + + QTreeWidgetItem *item = new QTreeWidgetItem(QStringList("Hello")); + treeWidget.insertTopLevelItem(0, item); + QTest::qWait(50); + QTRY_VERIFY(delegate.numPaints > 0); + + delegate.numPaints = 0; + delegate.expectChildren = true; + item->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator); + QApplication::processEvents(); + QTRY_COMPARE(delegate.numPaints, 1); + + delegate.numPaints = 0; + delegate.expectChildren = false; + item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); + QApplication::processEvents(); + QTRY_COMPARE(delegate.numPaints, 1); + + delegate.numPaints = 0; + delegate.expectChildren = true; + new QTreeWidgetItem(item); + QApplication::processEvents(); + QTRY_COMPARE(delegate.numPaints, 1); + + delegate.numPaints = 0; + delegate.expectChildren = false; + item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator); + QApplication::processEvents(); + QTRY_COMPARE(delegate.numPaints, 1); +} + QTEST_MAIN(tst_QTreeWidget) diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp index 9418be0..160d74c 100644 --- a/tests/auto/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp @@ -295,8 +295,8 @@ void tst_QUdpSocket::loop() QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.length(), peterAddress, peter.localPort()), qint64(paulMessage.length())); - QVERIFY(peter.waitForReadyRead(5000)); - QVERIFY(paul.waitForReadyRead(5000)); + QVERIFY(peter.waitForReadyRead(9000)); + QVERIFY(paul.waitForReadyRead(9000)); char peterBuffer[16*1024]; char paulBuffer[16*1024]; if (success) { diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index c8fe4e5..03e77aa 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -3713,7 +3713,7 @@ void tst_QUrl::fromUserInput_data() 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") << "webkit" << QUrl("webkit"); + QTest::newRow("add scheme-3") << "hostname" << QUrl("http://hostname"); // QUrl's tolerant parser should already handle this QTest::newRow("not-encoded-0") << "http://example.org/test page.html" << QUrl::fromEncoded("http://example.org/test%20page.html"); @@ -3723,6 +3723,9 @@ void tst_QUrl::fromUserInput_data() portUrl.setPort(80); 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("ben@example.net"); @@ -3730,10 +3733,11 @@ void tst_QUrl::fromUserInput_data() 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://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"); diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index e027dd1..1e3f5f8 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -384,10 +384,14 @@ private slots: void activateWindow(); + void openModal_taskQTBUG_5804(); + #ifdef Q_OS_SYMBIAN void cbaVisibility(); #endif + void focusProxyAndInputMethods(); + private: bool ensureScreenSize(int width, int height); QWidget *testWidget; @@ -9581,6 +9585,29 @@ void tst_QWidget::activateWindow() QTRY_VERIFY(!mainwindow2->isActiveWindow()); } +void tst_QWidget::openModal_taskQTBUG_5804() +{ + class Widget : public QWidget + { + public: + Widget(QWidget *parent) : QWidget(parent) + { + } + ~Widget() + { + QMessageBox msgbox; + QTimer::singleShot(10, &msgbox, SLOT(accept())); + msgbox.exec(); //open a modal dialog + } + }; + + QWidget *win = new QWidget; + new Widget(win); + win->show(); + QTest::qWaitForWindowShown(win); + delete win; +} + #ifdef Q_OS_SYMBIAN void tst_QWidget::cbaVisibility() { @@ -9619,5 +9646,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/qworkspace/tst_qworkspace.cpp b/tests/auto/qworkspace/tst_qworkspace.cpp index c1fe3e0..35f8a4d 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/qxmlstream/data/doctypeEmptyMarkupDecl.ref b/tests/auto/qxmlstream/data/doctypeEmptyMarkupDecl.ref new file mode 100644 index 0000000..ea85e32 --- /dev/null +++ b/tests/auto/qxmlstream/data/doctypeEmptyMarkupDecl.ref @@ -0,0 +1,7 @@ +StartDocument( ) +Comment( text=" Empty markup declaration in a doctype. " ) +DTD( text=" +<!DOCTYPE doc []>" dtdName="doc" ) +StartElement( name="doc" qualifiedName="doc" ) +EndElement( name="doc" qualifiedName="doc" ) +EndDocument( ) diff --git a/tests/auto/qxmlstream/data/doctypeEmptyMarkupDecl.xml b/tests/auto/qxmlstream/data/doctypeEmptyMarkupDecl.xml new file mode 100644 index 0000000..1c66c0c --- /dev/null +++ b/tests/auto/qxmlstream/data/doctypeEmptyMarkupDecl.xml @@ -0,0 +1,3 @@ +<!-- Empty markup declaration in a doctype. --> +<!DOCTYPE doc []> +<doc></doc> diff --git a/tests/auto/rcc/rcc.pro b/tests/auto/rcc/rcc.pro index d6a2083..1759b48 100644 --- a/tests/auto/rcc/rcc.pro +++ b/tests/auto/rcc/rcc.pro @@ -4,3 +4,9 @@ TARGET = tst_rcc SOURCES += tst_rcc.cpp +wince* { + DEFINES += SRCDIR=\\\"\\\" +} else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} + diff --git a/tests/auto/rcc/tst_rcc.cpp b/tests/auto/rcc/tst_rcc.cpp index c9e3d76..2fe0dc4 100644 --- a/tests/auto/rcc/tst_rcc.cpp +++ b/tests/auto/rcc/tst_rcc.cpp @@ -102,7 +102,7 @@ void tst_rcc::rcc_data() QTest::addColumn<QString>("qrcfile"); QTest::addColumn<QString>("expected"); - QTest::newRow("images") << "data" << "images.qrc" << "images.expected"; + QTest::newRow("images") << SRCDIR "data" << "images.qrc" << "images.expected"; } void tst_rcc::rcc() diff --git a/tests/auto/uic/baseline/mainwindowbase.ui.h b/tests/auto/uic/baseline/mainwindowbase.ui.h index 46270a7..8472dbb 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/windowsmobile/test/test.pro b/tests/auto/windowsmobile/test/test.pro index b7f65a9..61e275d 100644 --- a/tests/auto/windowsmobile/test/test.pro +++ b/tests/auto/windowsmobile/test/test.pro @@ -5,7 +5,7 @@ HEADERS += ddhelper.h SOURCES += tst_windowsmobile.cpp ddhelper.cpp RESOURCES += windowsmobile.qrc -TARGET = tst_windowsmobile +TARGET = ../tst_windowsmobile wincewm*: { addFiles.sources = $$OUT_PWD/../testQMenuBar/*.exe diff --git a/tests/auto/windowsmobile/testQMenuBar/testQMenuBar.pro b/tests/auto/windowsmobile/testQMenuBar/testQMenuBar.pro index 6dd288b..87986e4 100644 --- a/tests/auto/windowsmobile/testQMenuBar/testQMenuBar.pro +++ b/tests/auto/windowsmobile/testQMenuBar/testQMenuBar.pro @@ -1,2 +1,3 @@ SOURCES += main.cpp -DESTDIR = ./ +TARGET = ../testQMenuBar + diff --git a/tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt b/tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt index a7945f0..b620e05 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 22f6693..ff7c8c0 100644 --- a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp +++ b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp @@ -160,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) + |