aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@digia.com>2013-08-06 16:07:23 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-06 18:26:47 +0200
commitf1b9ba8c6ee6b991ef4e513bc4f39045fd55d1e6 (patch)
treecd587156a07344e98aca0cd1511075fe272bfec5
parent27deff6d2b5a9eb1d98cd7b377ab934a35086664 (diff)
parent1d3b9db5b54d8ae99c6b149c8d3d91eda19b5838 (diff)
Merge "Merge branch 'stable' into dev" into refs/staging/dev
-rw-r--r--examples/quick/demos/tweetsearch/content/TweetDelegate.qml6
-rw-r--r--examples/quick/demos/tweetsearch/content/TweetsModel.qml96
-rw-r--r--examples/quick/demos/tweetsearch/content/tweetsearch.js61
-rw-r--r--examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc45
-rw-r--r--examples/quick/demos/tweetsearch/tweetsearch.pro5
-rw-r--r--examples/quick/demos/tweetsearch/tweetsearch.qml20
-rw-r--r--examples/quick/text/doc/src/text.qdoc2
-rw-r--r--src/imports/dialogs/DefaultColorDialog.qml27
-rw-r--r--src/imports/dialogs/qquickabstractcolordialog_p.h8
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.cpp16
-rw-r--r--src/qml/doc/src/external-resources.qdoc4
-rw-r--r--src/qml/doc/src/javascript/date.qdoc3
-rw-r--r--src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc2
-rw-r--r--src/qml/doc/src/qmltypereference.qdoc10
-rw-r--r--src/qml/doc/src/qtqml.qdoc5
-rw-r--r--src/qml/qml/qqmlengine.cpp5
-rw-r--r--src/qml/qml/qqmltypeloader.cpp18
-rw-r--r--src/quick/items/qquickflickable.cpp10
-rw-r--r--src/quick/items/qquickimplicitsizeitem.cpp16
-rw-r--r--src/quick/items/qquicklistview.cpp12
-rw-r--r--src/quick/items/qquickpainteditem.cpp3
-rw-r--r--src/quick/items/qquickpathview.cpp35
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp6
-rw-r--r--src/quick/scenegraph/qsgdefaultrectanglenode.cpp2
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode.cpp2
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp4
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp28
-rw-r--r--tests/auto/quick/qquickdrag/tst_qquickdrag.cpp46
-rw-r--r--tests/auto/quick/qquickflickable/data/ratios.qml71
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp23
-rw-r--r--tests/auto/quick/qquickgridview/qquickgridview.pro2
-rw-r--r--tests/auto/quick/qquickimage/data/qtbug_32513.qml63
-rw-r--r--tests/auto/quick/qquickimage/tst_qquickimage.cpp10
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp167
-rw-r--r--tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml67
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp38
-rw-r--r--tests/auto/quick/qquickpath/tst_qquickpath.cpp4
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp10
-rw-r--r--tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml2
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp52
-rw-r--r--tests/auto/quick/qquicktextedit/data/hAlignVisual.qml3
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp82
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp13
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp2
-rw-r--r--tests/auto/quick/rendernode/tst_rendernode.cpp2
-rw-r--r--tests/auto/quick/touchmouse/touchmouse.pro2
46 files changed, 806 insertions, 304 deletions
diff --git a/examples/quick/demos/tweetsearch/content/TweetDelegate.qml b/examples/quick/demos/tweetsearch/content/TweetDelegate.qml
index 8cd22110d4..e8bfff437b 100644
--- a/examples/quick/demos/tweetsearch/content/TweetDelegate.qml
+++ b/examples/quick/demos/tweetsearch/content/TweetDelegate.qml
@@ -103,7 +103,7 @@ Item {
Text {
id: name
- text: Helper.realName(model.name)
+ text: model.name
anchors { left: avatar.right; leftMargin: 10; top: avatar.top; topMargin: -3 }
font.pixelSize: 12
font.bold: true
@@ -121,7 +121,7 @@ Item {
color: "#adebff"
linkColor: "white"
onLinkActivated: {
- var tag = link.split("http://search.twitter.com/search?q=%23")
+ var tag = link.split("https://twitter.com/search?q=%23")
var user = link.split("https://twitter.com/")
if (tag[1] != undefined) {
mainListView.positionViewAtBeginning()
@@ -166,7 +166,7 @@ Item {
Text {
id: username
- text: Helper.twitterName(model.name)
+ text: model.twitterName
x: 10; anchors { top: avatar2.top; topMargin: -3 }
font.pixelSize: 12
font.bold: true
diff --git a/examples/quick/demos/tweetsearch/content/TweetsModel.qml b/examples/quick/demos/tweetsearch/content/TweetsModel.qml
index cd91a787b7..7d813d18c8 100644
--- a/examples/quick/demos/tweetsearch/content/TweetsModel.qml
+++ b/examples/quick/demos/tweetsearch/content/TweetsModel.qml
@@ -39,53 +39,87 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.XmlListModel 2.0
+import "tweetsearch.js" as Helper
Item {
id: wrapper
- property variant model: xmlModel
+ // Insert valid consumer key and secret tokens below
+ // See https://dev.twitter.com/apps
+//! [auth tokens]
+ property string consumerKey : ""
+ property string consumerSecret : ""
+//! [auth tokens]
+ property string bearerToken : ""
+
+ property variant model: tweets
property string from : ""
property string phrase : ""
- property string mode : "everyone"
- property int status: xmlModel.status
-
- function reload() { xmlModel.reload(); }
-
- property bool isLoading: status == XmlListModel.Loading
+ property int status: XMLHttpRequest.UNSENT
+ property bool isLoading: status === XMLHttpRequest.LOADING
property bool wasLoading: false
signal isLoaded
- XmlListModel {
- id: xmlModel
+ ListModel { id: tweets }
- onStatusChanged: {
- if (status == XmlListModel.Ready && wasLoading == true)
- wrapper.isLoaded()
- if (status == XmlListModel.Loading)
- wasLoading = true;
- else
- wasLoading = false;
- }
+ function encodePhrase(x) { return encodeURIComponent(x); }
- function encodePhrase(x) { return encodeURIComponent(x); }
+ function reload() {
+ tweets.clear()
- source: (from == "" && phrase == "") ? "" :
- 'http://search.twitter.com/search.atom?from='+from+"&rpp=10&phrase="+encodePhrase(phrase)
+ if (from == "" && phrase == "")
+ return;
- namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " +
- "declare namespace twitter=\"http://api.twitter.com/\";";
+//! [requesting]
+ var req = new XMLHttpRequest;
+ req.open("GET", "https://api.twitter.com/1.1/search/tweets.json?from=" + from +
+ "&count=10&q=" + encodePhrase(phrase));
+ req.setRequestHeader("Authorization", "Bearer " + bearerToken);
+ req.onreadystatechange = function() {
+ status = req.readyState;
+ if (status === XMLHttpRequest.DONE) {
+ var objectArray = JSON.parse(req.responseText);
+ if (objectArray.errors !== undefined)
+ console.log("Error fetching tweets: " + objectArray.errors[0].message)
+ else {
+ for (var key in objectArray.statuses) {
+ var jsonObject = objectArray.statuses[key];
+ tweets.append(jsonObject);
+ }
+ }
+ if (wasLoading == true)
+ wrapper.isLoaded()
+ }
+ wasLoading = (status === XMLHttpRequest.LOADING);
+ }
+ req.send();
+//! [requesting]
+ }
- query: "/feed/entry"
+ onPhraseChanged: reload();
+ onFromChanged: reload();
- XmlRole { name: "id"; query: "id/string()" }
- XmlRole { name: "content"; query: "content/string()" }
- XmlRole { name: "published"; query: "published/string()" }
- XmlRole { name: "source"; query: "twitter:source/string()" }
- XmlRole { name: "name"; query: "author/name/string()" }
- XmlRole { name: "uri"; query: "author/uri/string()" }
- XmlRole { name: "image"; query: "link[@rel = 'image']/@href/string()" }
+ Component.onCompleted: {
+ if (consumerKey === "" || consumerSecret == "") {
+ bearerToken = encodeURIComponent(Helper.demoToken())
+ return;
+ }
+ var authReq = new XMLHttpRequest;
+ authReq.open("POST", "https://api.twitter.com/oauth2/token");
+ authReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
+ authReq.setRequestHeader("Authorization", "Basic " + Qt.btoa(consumerKey + ":" + consumerSecret));
+ authReq.onreadystatechange = function() {
+ if (authReq.readyState === XMLHttpRequest.DONE) {
+ var jsonResponse = JSON.parse(authReq.responseText);
+ if (jsonResponse.errors !== undefined)
+ console.log("Authentication error: " + jsonResponse.errors[0].message)
+ else
+ bearerToken = jsonResponse.access_token;
+ }
+ }
+ authReq.send("grant_type=client_credentials");
}
+
}
diff --git a/examples/quick/demos/tweetsearch/content/tweetsearch.js b/examples/quick/demos/tweetsearch/content/tweetsearch.js
index 9b8638f69e..42a76c99fc 100644
--- a/examples/quick/demos/tweetsearch/content/tweetsearch.js
+++ b/examples/quick/demos/tweetsearch/content/tweetsearch.js
@@ -1,19 +1,62 @@
.pragma library
-function twitterName(str)
+function formatDate(date)
{
- var s = str.split("(")
- return s[0]
+ var da = new Date(date)
+ return da.toDateString()
}
-function realName(str)
+function demoToken()
{
- var s = str.split("(")
- return s[1].substring(0, s[1].length-1)
+ var a = new Array(22).join('A')
+ return a + String.fromCharCode(0x44, 0x69, 0x4a, 0x52, 0x51, 0x41, 0x41, 0x41, 0x41,
+ 0x41, 0x41, 0x74, 0x2b, 0x72, 0x6a, 0x6c, 0x2b, 0x71,
+ 0x6d, 0x7a, 0x30, 0x72, 0x63, 0x79, 0x2b, 0x42, 0x62,
+ 0x75, 0x58, 0x42, 0x42, 0x73, 0x72, 0x55, 0x48, 0x47,
+ 0x45, 0x67, 0x3d, 0x71, 0x30, 0x45, 0x4b, 0x32, 0x61,
+ 0x57, 0x71, 0x51, 0x4d, 0x62, 0x31, 0x35, 0x67, 0x43,
+ 0x5a, 0x4e, 0x77, 0x5a, 0x6f, 0x39, 0x79, 0x71, 0x61,
+ 0x65, 0x30, 0x68, 0x70, 0x65, 0x32, 0x46, 0x44, 0x73,
+ 0x53, 0x39, 0x32, 0x57, 0x41, 0x75, 0x30, 0x67)
}
-function formatDate(date)
+function linkForEntity(entity)
{
- var da = new Date(date)
- return da.toDateString()
+ return (entity.url ? entity.url :
+ (entity.screen_name ? 'https://twitter.com/' + entity.screen_name :
+ 'https://twitter.com/search?q=%23' + entity.text))
+}
+
+function textForEntity(entity)
+{
+ return (entity.display_url ? entity.display_url :
+ (entity.screen_name ? entity.screen_name : entity.text))
+}
+
+function insertLinks(text, entities)
+{
+ if (typeof text !== 'string')
+ return "";
+
+ if (!entities)
+ return text;
+
+ // Add all links (urls, usernames and hashtags) to an array and sort them in
+ // descending order of appearance in text
+ var links = []
+ if (entities.urls)
+ links = entities.urls.concat(entities.hashtags, entities.user_mentions)
+ else if (entities.url)
+ links = entities.url.urls
+
+ links.sort(function(a, b) { return b.indices[0] - a.indices[0] })
+
+ for (var i = 0; i < links.length; i++) {
+ var offset = links[i].url ? 0 : 1
+ text = text.substring(0, links[i].indices[0] + offset) +
+ '<a href=\"' + linkForEntity(links[i]) + '\">' +
+ textForEntity(links[i]) + '</a>' +
+ text.substring(links[i].indices[1])
+ }
+ return text.replace(/\n/g, '<br>');
}
diff --git a/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc b/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc
index 9ba252fcb5..a56ed0d7e9 100644
--- a/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc
+++ b/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc
@@ -32,5 +32,48 @@
\brief A Twitter search client with 3D effects.
\image qtquick-demo-tweetsearch-med-1.png
\image qtquick-demo-tweetsearch-med-2.png
-*/
+ \section1 Demo Introduction
+
+ The Tweet Search demo searches items posted to Twitter service
+ using a number of query parameters. Search can be done for tweets
+ from a specified user, a hashtag or a search phrase.
+
+ The search result is a list of items showing the contents of the
+ tweet as well as the name and image of the user who posted it.
+ Hashtags, names and links in the content are clickable. Clicking
+ on the image will flip the item to reveal more information.
+
+ \section1 Running the Demo
+
+ Tweet Search uses Twitter API v1.1 for running seaches.
+
+ \section2 Authentication
+
+ Each request must be authenticated on behalf of the application.
+ For demonstration purposes, the application uses a hard-coded
+ token for identifying itself to the Twitter service. However, this
+ token is subject to rate limits for the number of requests as well
+ as possible expiration.
+
+ If you are having authentication or rate limit problems running the
+ demo, obtain a set of application-specific tokens (consumer
+ key and consumer secret) by registering a new application on
+ \l{https://dev.twitter.com/apps}.
+
+ Type in the two token values in \e {TweetsModel.qml}:
+
+ \snippet demos/tweetsearch/content/TweetsModel.qml auth tokens
+
+ Rebuild and run the demo.
+
+ \section2 JSON Parsing
+
+ Search results are returned in JSON (JavaScript Object Notation)
+ format. \c TweetsModel uses an \l XMLHTTPRequest object to send
+ an HTTP GET request, and calls JSON.parse() on the returned text
+ string to convert it to a JavaScript object. Each object
+ representing a tweet is then added to a \l ListModel:
+
+ \snippet demos/tweetsearch/content/TweetsModel.qml requesting
+*/
diff --git a/examples/quick/demos/tweetsearch/tweetsearch.pro b/examples/quick/demos/tweetsearch/tweetsearch.pro
index b063cc4106..27c34bac5d 100644
--- a/examples/quick/demos/tweetsearch/tweetsearch.pro
+++ b/examples/quick/demos/tweetsearch/tweetsearch.pro
@@ -4,5 +4,10 @@ QT += quick qml
SOURCES += main.cpp
RESOURCES += tweetsearch.qrc
+OTHER_FILES = tweetsearch.qml \
+ content/*.qml \
+ content/*.js \
+ content/resources/*
+
target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/tweetsearch
INSTALLS += target
diff --git a/examples/quick/demos/tweetsearch/tweetsearch.qml b/examples/quick/demos/tweetsearch/tweetsearch.qml
index d7e77ceb4b..19d3b5e708 100644
--- a/examples/quick/demos/tweetsearch/tweetsearch.qml
+++ b/examples/quick/demos/tweetsearch/tweetsearch.qml
@@ -40,6 +40,7 @@
import QtQuick 2.0
import "content"
+import "content/tweetsearch.js" as Helper
Rectangle {
id: main
@@ -47,7 +48,6 @@ Rectangle {
height: 480
color: "#d6d6d6"
- property string searchTerms: ""
property int inAnimDur: 250
property int counter: 0
property alias isLoading: tweetsModel.isLoading
@@ -85,13 +85,15 @@ Rectangle {
onTriggered: {
main.counter--;
var id = tweetsModel.model.get(idx[main.counter]).id
- mainListView.add( { "statusText": tweetsModel.model.get(main.counter).content,
- "name": tweetsModel.model.get(main.counter).name,
- "userImage": tweetsModel.model.get(main.counter).image,
- "source": tweetsModel.model.get(main.counter).source,
- "id": id,
- "uri": tweetsModel.model.get(main.counter).uri,
- "published": tweetsModel.model.get(main.counter).published } );
+ var item = tweetsModel.model.get(main.counter)
+ mainListView.add( { "statusText": Helper.insertLinks(item.text, item.entities),
+ "twitterName": item.user.screen_name,
+ "name" : item.user.name,
+ "userImage": item.user.profile_image_url,
+ "source": item.source,
+ "id": id,
+ "uri": Helper.insertLinks(item.user.url, item.user.entities),
+ "published": item.created_at } );
ids.push(id)
}
}
@@ -107,7 +109,7 @@ Rectangle {
PropertyAction { property: "appear"; value: 250 }
}
- onDragEnded: if (header.refresh) { tweetsModel.model.reload() }
+ onDragEnded: if (header.refresh) { tweetsModel.reload() }
ListHeader {
id: header
diff --git a/examples/quick/text/doc/src/text.qdoc b/examples/quick/text/doc/src/text.qdoc
index c93d2db8aa..3a300fbcf3 100644
--- a/examples/quick/text/doc/src/text.qdoc
+++ b/examples/quick/text/doc/src/text.qdoc
@@ -50,7 +50,7 @@
or finally using a FontLoader and specifying a remote font file:
\snippet text/fonts/fonts.qml fontloaderremote
- 'Available Fonts' shows how to use the QML global Qt object and a list view
+ 'Available Fonts' shows how to use the QML \l{QtQml::Qt}{Qt} global object and a list view
to display all the fonts available on the system.
The ListView type uses the list of fonts available as its model:
\snippet text/fonts/availableFonts.qml model
diff --git a/src/imports/dialogs/DefaultColorDialog.qml b/src/imports/dialogs/DefaultColorDialog.qml
index 8636259957..44af99bf18 100644
--- a/src/imports/dialogs/DefaultColorDialog.qml
+++ b/src/imports/dialogs/DefaultColorDialog.qml
@@ -45,11 +45,23 @@ import "qml"
AbstractColorDialog {
id: root
+ property bool _valueSet: true // guard to prevent binding loops
+ function _setControlsFromColor() {
+ _valueSet = false
+ hueSlider.value = root.hue
+ saturationSlider.value = root.saturation
+ lightnessSlider.value = root.lightness
+ alphaSlider.value = root.alpha
+ crosshairs.x = root.lightness * paletteMap.width
+ crosshairs.y = (1.0 - root.saturation) * paletteMap.height
+ _valueSet = true
+ }
+ onColorChanged: _setControlsFromColor()
Rectangle {
id: content
property int maxSize: 0.9 * Math.min(Screen.desktopAvailableWidth, Screen.desktopAvailableHeight)
- implicitHeight: Math.max(maxSize, Screen.logicalPixelDensity * (usePaletteMap ? 10 : 5))
+ implicitHeight: Math.min(maxSize, Screen.logicalPixelDensity * (usePaletteMap ? 100 : 50))
implicitWidth: usePaletteMap ? implicitHeight - bottomMinHeight : implicitHeight * 1.5
color: palette.window
property real bottomMinHeight: sliders.height + buttonRow.height + outerSpacing * 3
@@ -62,12 +74,6 @@ AbstractColorDialog {
SystemPalette { id: palette }
- Binding {
- target: root
- property: "color"
- value: Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value)
- }
-
Item {
id: paletteFrame
visible: content.usePaletteMap
@@ -83,6 +89,7 @@ AbstractColorDialog {
id: paletteMap
x: (parent.width - width) / 2
width: height
+ onWidthChanged: root._setControlsFromColor()
height: parent.height
source: "images/checkers.png"
fillMode: Image.Tile
@@ -197,6 +204,7 @@ AbstractColorDialog {
ColorSlider {
id: hueSlider
value: 0.5
+ onValueChanged: if (_valueSet) root.color = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value)
text: qsTr("Hue")
trackDelegate: Rectangle {
rotation: -90
@@ -217,6 +225,7 @@ AbstractColorDialog {
id: saturationSlider
visible: !content.usePaletteMap
value: 0.5
+ onValueChanged: if (_valueSet) root.color = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value)
text: qsTr("Saturation")
trackDelegate: Rectangle {
rotation: -90
@@ -232,6 +241,7 @@ AbstractColorDialog {
id: lightnessSlider
visible: !content.usePaletteMap
value: 0.5
+ onValueChanged: if (_valueSet) root.color = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value)
text: qsTr("Luminosity")
trackDelegate: Rectangle {
rotation: -90
@@ -249,6 +259,7 @@ AbstractColorDialog {
minimum: 0.0
maximum: 1.0
value: 1.0
+ onValueChanged: if (_valueSet) root.color = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value)
text: qsTr("Alpha")
visible: root.showAlphaChannel
trackDelegate: Item {
@@ -273,7 +284,7 @@ AbstractColorDialog {
Item {
id: buttonRow
- height: buttonsOnly.height
+ height: Math.max(buttonsOnly.height, copyIcon.height)
width: parent.width
anchors {
left: parent.left
diff --git a/src/imports/dialogs/qquickabstractcolordialog_p.h b/src/imports/dialogs/qquickabstractcolordialog_p.h
index 46f0f84acb..bd23e0d1a4 100644
--- a/src/imports/dialogs/qquickabstractcolordialog_p.h
+++ b/src/imports/dialogs/qquickabstractcolordialog_p.h
@@ -66,6 +66,10 @@ class QQuickAbstractColorDialog : public QQuickAbstractDialog
Q_OBJECT
Q_PROPERTY(bool showAlphaChannel READ showAlphaChannel WRITE setShowAlphaChannel NOTIFY showAlphaChannelChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(qreal hue READ hue NOTIFY colorChanged)
+ Q_PROPERTY(qreal saturation READ saturation NOTIFY colorChanged)
+ Q_PROPERTY(qreal lightness READ lightness NOTIFY colorChanged)
+ Q_PROPERTY(qreal alpha READ alpha NOTIFY colorChanged)
public:
QQuickAbstractColorDialog(QObject *parent = 0);
@@ -74,6 +78,10 @@ public:
virtual QString title() const;
bool showAlphaChannel() const;
QColor color() const { return m_color; }
+ qreal hue() const { return m_color.hslHueF(); }
+ qreal saturation() const { return m_color.hslSaturationF(); }
+ qreal lightness() const { return m_color.lightnessF(); }
+ qreal alpha() const { return m_color.alphaF(); }
public Q_SLOTS:
void setVisible(bool v);
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
index 2f9c07cf20..bb65ddbccc 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
@@ -488,16 +488,12 @@ QUrl QQuickFolderListModel::parentFolder() const
QString localFile = d->currentDir.toLocalFile();
if (!localFile.isEmpty()) {
QDir dir(localFile);
-#if defined(Q_OS_WIN)
- if (dir.isRoot())
- dir.setPath("");
- else
-#endif
- dir.cdUp();
+ if (dir.isRoot() || !dir.cdUp())
+ return QUrl();
localFile = dir.path();
} else {
- int pos = d->currentDir.path().lastIndexOf(QLatin1Char('/'));
- if (pos == -1)
+ const int pos = d->currentDir.path().lastIndexOf(QLatin1Char('/'));
+ if (pos <= 0)
return QUrl();
localFile = d->currentDir.path().left(pos);
}
@@ -541,8 +537,8 @@ void QQuickFolderListModel::componentComplete()
{
Q_D(QQuickFolderListModel);
- if (!d->currentDir.isValid() || d->currentDir.toLocalFile().isEmpty() || !QDir().exists(d->currentDir.toLocalFile()))
- setFolder(QUrl(QLatin1String("file://")+QDir::currentPath()));
+ if (!d->currentDir.isValid() || !d->currentDir.isLocalFile() || !QDir().exists(d->currentDir.toLocalFile()))
+ setFolder(QUrl::fromLocalFile(QDir::currentPath()));
}
/*!
diff --git a/src/qml/doc/src/external-resources.qdoc b/src/qml/doc/src/external-resources.qdoc
index 0832564660..671246d7ab 100644
--- a/src/qml/doc/src/external-resources.qdoc
+++ b/src/qml/doc/src/external-resources.qdoc
@@ -35,3 +35,7 @@
\title W3Schools JavaScript Reference
*/
+/*!
+ \externalpage https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
+ \title Mozilla Developer Network Date Reference
+*/ \ No newline at end of file
diff --git a/src/qml/doc/src/javascript/date.qdoc b/src/qml/doc/src/javascript/date.qdoc
index 7da24d4092..085d988377 100644
--- a/src/qml/doc/src/javascript/date.qdoc
+++ b/src/qml/doc/src/javascript/date.qdoc
@@ -30,7 +30,8 @@
\inqmlmodule QtQml 2
\brief Provides date functions
- The QML Date object extends the JS Date object with
+ The QML Date object extends the
+ \l{Mozilla Developer Network Date Reference}{JS Date object} with
locale aware functions.
Functions that accept a locale format may be either an enumeration
diff --git a/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc b/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc
index 7d2d662e4e..1d24acc31a 100644
--- a/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc
+++ b/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc
@@ -70,6 +70,8 @@ QML modules may extend the QML language with more basic types.
For example, the basic types provided by the \c QtQuick module are listed below:
\annotatedlist qtquickbasictypes
+The \l{QtQml::Qt}{Qt} global object provides useful functions for manipulating values of basic types.
+
Currently only QML modules which are provided by Qt may provide their
own basic types, however this may change in future releases of Qt QML.
In order to use types provided by a particular QML module, clients
diff --git a/src/qml/doc/src/qmltypereference.qdoc b/src/qml/doc/src/qmltypereference.qdoc
index 3def3209cc..0b363d424e 100644
--- a/src/qml/doc/src/qmltypereference.qdoc
+++ b/src/qml/doc/src/qmltypereference.qdoc
@@ -104,14 +104,10 @@ When integrating with C++, note that any QDate value
\l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically
converted into a \c date value, and vice-versa.
-Note that the date type has comparison semantics which match
-those of the JavaScript Date object. To compare the value
-of two date properties, you should compare their "toString()"
-values.
+This basic type is provided by the QML language. It can be implicitly converted
+to a \l{QtQml2::Date}{Date} object.
-This basic type is provided by the QML language.
-
-\sa {QML Basic Types}
+\sa {QtQml2::Date}{QML Date object}, {QML Basic Types}
*/
/*!
diff --git a/src/qml/doc/src/qtqml.qdoc b/src/qml/doc/src/qtqml.qdoc
index 26e4867bbc..a260a3d785 100644
--- a/src/qml/doc/src/qtqml.qdoc
+++ b/src/qml/doc/src/qtqml.qdoc
@@ -75,7 +75,7 @@ The Qt QML module contains the QML framework and important QML types used in
applications. The constructs of QML are described in the \l{The QML Reference}.
In addition to the \l{QML Basic Types}, the module comes with
-various QML object types:
+the following QML object types:
\list
\li \l Component
\li \l QtObject
@@ -84,6 +84,9 @@ various QML object types:
\li \l Timer
\endlist
+The \l{QtQml::Qt}{Qt} global object provides useful enums and functions
+for various QML types.
+
\section2 Lists and Models
New in Qt 5.1, the model types are moved to a submodule, \c QtQml.Models. The
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index dbf098e701..a2a40c592d 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -278,11 +278,8 @@ QQmlImageProviderBase::~QQmlImageProviderBase()
\inqmlmodule QtQml 2
\instantiates QQmlEnginePrivate
\ingroup qml-utility-elements
-\brief The QML global Qt object provides useful enums and functions from Qt.
-
\keyword QmlGlobalQtObject
-
-\brief The \c Qt object provides useful enums and functions from Qt, for use in all QML files.
+\brief Provides a global object with useful enums and functions from Qt.
The \c Qt object is a global object with utility functions, properties and enums.
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 022083c596..ffba342491 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -1683,14 +1683,7 @@ QString QQmlTypeLoader::absoluteFilePath(const QString &path)
StringSet **fileSet = m_importDirCache.value(QHashedStringRef(dirPath.constData(), dirPath.length()));
if (!fileSet) {
QHashedString dirPathString(dirPath.toString());
- bool exists = false;
-#ifdef Q_OS_UNIX
- struct stat statBuf;
- if (::stat(QFile::encodeName(dirPathString).constData(), &statBuf) == 0)
- exists = S_ISDIR(statBuf.st_mode);
-#else
- exists = QDir(dirPathString).exists();
-#endif
+ bool exists = QDir(dirPathString).exists();
QStringHash<bool> *files = exists ? new QStringHash<bool> : 0;
m_importDirCache.insert(dirPathString, files);
fileSet = m_importDirCache.value(dirPathString);
@@ -1755,14 +1748,7 @@ bool QQmlTypeLoader::directoryExists(const QString &path)
StringSet **fileSet = m_importDirCache.value(QHashedStringRef(dirPath.constData(), dirPath.length()));
if (!fileSet) {
QHashedString dirPathString(dirPath.toString());
- bool exists = false;
-#ifdef Q_OS_UNIX
- struct stat statBuf;
- if (::stat(QFile::encodeName(dirPathString).constData(), &statBuf) == 0)
- exists = S_ISDIR(statBuf.st_mode);
-#else
- exists = QDir(dirPathString).exists();
-#endif
+ bool exists = QDir(dirPathString).exists();
QStringHash<bool> *files = exists ? new QStringHash<bool> : 0;
m_importDirCache.insert(dirPathString, files);
fileSet = m_importDirCache.value(dirPathString);
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index 75d509129b..f77c427ccf 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -882,8 +882,10 @@ QQuickItem *QQuickFlickable::contentItem()
QQuickFlickableVisibleArea *QQuickFlickable::visibleArea()
{
Q_D(QQuickFlickable);
- if (!d->visibleArea)
+ if (!d->visibleArea) {
d->visibleArea = new QQuickFlickableVisibleArea(this);
+ d->visibleArea->updateVisible(); // calculate initial ratios
+ }
return d->visibleArea;
}
@@ -1519,8 +1521,7 @@ void QQuickFlickable::geometryChanged(const QRectF &newGeometry,
bool changed = false;
if (newGeometry.width() != oldGeometry.width()) {
- if (xflick())
- changed = true;
+ changed = true; // we must update visualArea.widthRatio
if (d->hData.viewSize < 0) {
d->contentItem->setWidth(width());
emit contentWidthChanged();
@@ -1532,8 +1533,7 @@ void QQuickFlickable::geometryChanged(const QRectF &newGeometry,
}
}
if (newGeometry.height() != oldGeometry.height()) {
- if (yflick())
- changed = true;
+ changed = true; // we must update visualArea.heightRatio
if (d->vData.viewSize < 0) {
d->contentItem->setHeight(height());
emit contentHeightChanged();
diff --git a/src/quick/items/qquickimplicitsizeitem.cpp b/src/quick/items/qquickimplicitsizeitem.cpp
index b330b3929f..62dddb4a3b 100644
--- a/src/quick/items/qquickimplicitsizeitem.cpp
+++ b/src/quick/items/qquickimplicitsizeitem.cpp
@@ -47,32 +47,20 @@ QT_BEGIN_NAMESPACE
void QQuickImplicitSizeItemPrivate::implicitWidthChanged()
{
Q_Q(QQuickImplicitSizeItem);
- for (int ii = 0; ii < changeListeners.count(); ++ii) {
- const QQuickItemPrivate::ChangeListener &change = changeListeners.at(ii);
- if (change.types & QQuickItemPrivate::ImplicitWidth) {
- change.listener->itemImplicitWidthChanged(q);
- }
- }
+ QQuickItemPrivate::implicitWidthChanged();
emit q->implicitWidthChanged2();
}
void QQuickImplicitSizeItemPrivate::implicitHeightChanged()
{
Q_Q(QQuickImplicitSizeItem);
- for (int ii = 0; ii < changeListeners.count(); ++ii) {
- const QQuickItemPrivate::ChangeListener &change = changeListeners.at(ii);
- if (change.types & QQuickItemPrivate::ImplicitHeight) {
- change.listener->itemImplicitHeightChanged(q);
- }
- }
+ QQuickItemPrivate::implicitHeightChanged();
emit q->implicitHeightChanged2();
}
QQuickImplicitSizeItem::QQuickImplicitSizeItem(QQuickImplicitSizeItemPrivate &dd, QQuickItem *parent)
: QQuickItem(dd, parent)
{
- connect(this, SIGNAL(implicitHeightChanged2()), this, SIGNAL(implicitHeightChanged()));
- connect(this, SIGNAL(implicitWidthChanged2()), this, SIGNAL(implicitWidthChanged()));
}
QT_END_NAMESPACE
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index f0e39c5e5a..d79f535fd4 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -1023,7 +1023,7 @@ void QQuickListViewPrivate::updateInlineSection(FxListItemSG *listItem)
void QQuickListViewPrivate::updateStickySections()
{
- if (!sectionCriteria
+ if (!sectionCriteria || !sectionCriteria->delegate()
|| (!sectionCriteria->labelPositioning() && !currentSectionItem && !nextSectionItem))
return;
@@ -1360,16 +1360,18 @@ void QQuickListViewPrivate::itemGeometryChanged(QQuickItem *item, const QRectF &
if (visibleItems.count() && item == visibleItems.first()->item) {
FxListItemSG *listItem = static_cast<FxListItemSG*>(visibleItems.first());
if (orient == QQuickListView::Vertical) {
+ const qreal oldItemEndPosition = verticalLayoutDirection == QQuickItemView::BottomToTop ? -oldGeometry.y() : oldGeometry.y() + oldGeometry.height();
qreal diff = newGeometry.height() - oldGeometry.height();
- if (verticalLayoutDirection == QQuickListView::TopToBottom && listItem->endPosition() < q->contentY())
+ if (verticalLayoutDirection == QQuickListView::TopToBottom && oldItemEndPosition < q->contentY())
listItem->setPosition(listItem->position() - diff, true);
- else if (verticalLayoutDirection == QQuickListView::BottomToTop && listItem->endPosition() > q->contentY())
+ else if (verticalLayoutDirection == QQuickListView::BottomToTop && oldItemEndPosition > q->contentY())
listItem->setPosition(listItem->position() + diff, true);
} else {
+ const qreal oldItemEndPosition = q->effectiveLayoutDirection() == Qt::RightToLeft ? -oldGeometry.x() : oldGeometry.x() + oldGeometry.width();
qreal diff = newGeometry.width() - oldGeometry.width();
- if (q->effectiveLayoutDirection() == Qt::LeftToRight && listItem->endPosition() < q->contentX())
+ if (q->effectiveLayoutDirection() == Qt::LeftToRight && oldItemEndPosition < q->contentX())
listItem->setPosition(listItem->position() - diff, true);
- else if (q->effectiveLayoutDirection() == Qt::RightToLeft && listItem->endPosition() > q->contentX())
+ else if (q->effectiveLayoutDirection() == Qt::RightToLeft && oldItemEndPosition > q->contentX())
listItem->setPosition(listItem->position() + diff, true);
}
}
diff --git a/src/quick/items/qquickpainteditem.cpp b/src/quick/items/qquickpainteditem.cpp
index 15abb75352..25a2b93229 100644
--- a/src/quick/items/qquickpainteditem.cpp
+++ b/src/quick/items/qquickpainteditem.cpp
@@ -67,9 +67,6 @@ QT_BEGIN_NAMESPACE
To enable QPainter to do anti-aliased rendering, use setAntialiasing().
- QQuickPaintedItem is meant to make it easier to port old code that is using the
- QPainter API to the QML Scene Graph API and it should be used only for that purpose.
-
To write your own painted item, you first create a subclass of QQuickPaintedItem, and then
start by implementing its only pure virtual public function: paint(), which implements
the actual painting. To get the size of the area painted by the item, use
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index 7798641fcd..091fb3eb4d 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -922,34 +922,37 @@ QQuickItem *QQuickPathView::highlightItem()
\qmlproperty enumeration QtQuick2::PathView::highlightRangeMode
These properties set the preferred range of the highlight (current item)
- within the view. The preferred values must be in the range 0.0-1.0.
+ within the view. The preferred values must be in the range 0.0-1.0.
- If highlightRangeMode is set to \e PathView.NoHighlightRange
+ Valid values for \c highlightRangeMode are:
- If highlightRangeMode is set to \e PathView.ApplyRange the view will
- attempt to maintain the highlight within the range, however
- the highlight can move outside of the range at the ends of the path
- or due to a mouse interaction.
+ \list
+ \li \e PathView.NoHighlightRange - no range is applied and the
+ highlight will move freely within the view.
+ \li \e PathView.ApplyRange - the view will attempt to maintain
+ the highlight within the range, however the highlight can
+ move outside of the range at the ends of the path or due to
+ a mouse interaction.
+ \li \e PathView.StrictlyEnforceRange - the highlight will never
+ move outside of the range. This means that the current item
+ will change if a keyboard or mouse action would cause the
+ highlight to move outside of the range.
+ \endlist
- If highlightRangeMode is set to \e PathView.StrictlyEnforceRange the highlight will never
- move outside of the range. This means that the current item will change
- if a keyboard or mouse action would cause the highlight to move
- outside of the range.
+ The default value is \e PathView.StrictlyEnforceRange.
- Note that this is the correct way to influence where the
+ Defining a highlight range is the correct way to influence where the
current item ends up when the view moves. For example, if you want the
currently selected item to be in the middle of the path, then set the
- highlight range to be 0.5,0.5 and highlightRangeMode to PathView.StrictlyEnforceRange.
+ highlight range to be 0.5,0.5 and highlightRangeMode to \e PathView.StrictlyEnforceRange.
Then, when the path scrolls,
the currently selected item will be the item at that position. This also applies to
when the currently selected item changes - it will scroll to within the preferred
highlight range. Furthermore, the behaviour of the current item index will occur
whether or not a highlight exists.
- The default value is \e PathView.StrictlyEnforceRange.
-
- Note that a valid range requires preferredHighlightEnd to be greater
- than or equal to preferredHighlightBegin.
+ \note A valid range requires \c preferredHighlightEnd to be greater
+ than or equal to \c preferredHighlightBegin.
*/
qreal QQuickPathView::preferredHighlightBegin() const
{
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
index afea96b35c..4652a2241e 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
@@ -172,7 +172,8 @@ void QSGDefaultDistanceFieldGlyphCache::storeGlyphs(const QHash<glyph_t, QImage>
}
}
- glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, glyph.width(), glyph.height(), GL_ALPHA, GL_UNSIGNED_BYTE, glyph.constBits());
+ for (int i = 0; i < glyph.height(); ++i)
+ glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, glyph.width(), 1, GL_ALPHA, GL_UNSIGNED_BYTE, glyph.scanLine(i));
}
QHash<TextureInfo *, QVector<glyph_t> >::const_iterator i;
@@ -242,7 +243,8 @@ void QSGDefaultDistanceFieldGlyphCache::resizeTexture(TextureInfo *texInfo, int
updateTexture(oldTexture, texInfo->texture, texInfo->size);
if (useWorkaround()) {
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, texInfo->image.constBits());
+ for (int i = 0; i < oldHeight; ++i)
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, oldWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, texInfo->image.scanLine(i));
texInfo->image = texInfo->image.copy(0, 0, width, height);
glDeleteTextures(1, &oldTexture);
return;
diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
index 76fbbb4209..276041d144 100644
--- a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
@@ -339,7 +339,7 @@ void QSGDefaultRectangleNode::update()
m_dirty_geometry = false;
}
m_material.setFlag(QSGMaterial::Blending, (m_gradient_stops.size() > 0 && !m_gradient_is_opaque)
- || m_color.alpha() < 255
+ || (m_color.alpha() < 255 && m_color.alpha() != 0)
|| (m_pen_width > 0 && m_border_color.alpha() < 255));
}
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp
index cc4aa4bada..1b10b8b894 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp
@@ -213,7 +213,7 @@ void QSGDistanceFieldGlyphNode::updateGeometry()
QVector<ushort> ip;
ip.reserve(indexes.size() * 6);
- qreal maxTexMargin = m_glyph_cache->distanceFieldRadius() / 2;
+ qreal maxTexMargin = m_glyph_cache->distanceFieldRadius();
qreal fontScale = m_glyph_cache->fontScale(fontPixelSize);
qreal margin = 2;
qreal texMargin = margin / fontScale;
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index 3ab7d2fb30..c8a1888a52 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -536,12 +536,12 @@ void QSGRenderThread::sync()
}
}
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+
RLDEBUG(" Render: - unlocking after sync");
waitCondition.wakeOne();
mutex.unlock();
-
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
}
diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
index cc55fd721c..e35a9f7c7a 100644
--- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
+++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
@@ -89,6 +89,7 @@ private slots:
void showFiles();
void resetFiltering();
void refresh();
+ void cdUp();
#if defined (Q_OS_WIN) && !defined (Q_OS_WINCE)
// WinCE does not have drive concept, so lets execute this test only on desktop Windows.
void changeDrive();
@@ -219,6 +220,33 @@ void tst_qquickfolderlistmodel::refresh()
QTRY_COMPARE(removeEnd, count-1); // wait for refresh
}
+void tst_qquickfolderlistmodel::cdUp()
+{
+ enum { maxIterations = 50 };
+ QQmlComponent component(&engine, testFileUrl("basic.qml"));
+ checkNoErrors(component);
+
+ QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
+ QVERIFY(flm != 0);
+ const QUrl startFolder = flm->property("folder").toUrl();
+ QVERIFY(startFolder.isValid());
+
+ // QTBUG-32139: Ensure navigating upwards terminates cleanly and does not
+ // return invalid Urls like "file:".
+ for (int i = 0; ; ++i) {
+ const QVariant folderV = flm->property("parentFolder");
+ const QUrl folder = folderV.toUrl();
+ if (!folder.isValid())
+ break;
+ QVERIFY(folder.toString() != QLatin1String("file:"));
+ QVERIFY2(i < maxIterations,
+ qPrintable(QString::fromLatin1("Unable to reach root after %1 iterations starting from %2, stuck at %3")
+ .arg(maxIterations).arg(QDir::toNativeSeparators(startFolder.toLocalFile()),
+ QDir::toNativeSeparators(folder.toLocalFile()))));
+ flm->setProperty("folder", folderV);
+ }
+}
+
#if defined (Q_OS_WIN) && !defined (Q_OS_WINCE)
void tst_qquickfolderlistmodel::changeDrive()
{
diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
index dbb4736c05..15282d4b02 100644
--- a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
+++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
@@ -1070,106 +1070,131 @@ void tst_QQuickDrag::recursion_data()
{
QTest::addColumn<QString>("script");
QTest::addColumn<int>("type");
+ QTest::addColumn<int>("moveEvents");
QTest::addColumn<QByteArray>("warning");
QTest::newRow("Drag.start() in Enter")
<< QString("Drag.start()")
<< int(QEvent::DragEnter)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
QTest::newRow("Drag.cancel() in Enter")
<< QString("Drag.cancel()")
<< int(QEvent::DragEnter)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
QTest::newRow("Drag.drop() in Enter")
<< QString("Drag.drop()")
<< int(QEvent::DragEnter)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
QTest::newRow("Drag.active = true in Enter")
<< QString("Drag.active = true")
<< int(QEvent::DragEnter)
+ << 1
<< QByteArray();
QTest::newRow("Drag.active = false in Enter")
<< QString("Drag.active = false")
<< int(QEvent::DragEnter)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
QTest::newRow("move in Enter")
<< QString("x = 23")
<< int(QEvent::DragEnter)
+ << 1
<< QByteArray();
QTest::newRow("Drag.start() in Move")
<< QString("Drag.start()")
<< int(QEvent::DragMove)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
QTest::newRow("Drag.cancel() in Move")
<< QString("Drag.cancel()")
<< int(QEvent::DragMove)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
QTest::newRow("Drag.drop() in Move")
<< QString("Drag.drop()")
<< int(QEvent::DragMove)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
QTest::newRow("Drag.active = true in Move")
<< QString("Drag.active = true")
<< int(QEvent::DragMove)
+ << 1
<< QByteArray();
QTest::newRow("Drag.active = false in Move")
<< QString("Drag.active = false")
<< int(QEvent::DragMove)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
QTest::newRow("move in Move")
<< QString("x = 23")
<< int(QEvent::DragMove)
+ << 2
<< QByteArray();
QTest::newRow("Drag.start() in Leave")
<< QString("Drag.start()")
<< int(QEvent::DragLeave)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
QTest::newRow("Drag.cancel() in Leave")
<< QString("Drag.cancel()")
<< int(QEvent::DragLeave)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
QTest::newRow("Drag.drop() in Leave")
<< QString("Drag.drop()")
<< int(QEvent::DragLeave)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
QTest::newRow("Drag.active = true in Leave")
<< QString("Drag.active = true")
<< int(QEvent::DragLeave)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
QTest::newRow("Drag.active = false in Leave")
<< QString("Drag.active = false")
<< int(QEvent::DragLeave)
+ << 1
<< QByteArray();
QTest::newRow("move in Leave")
<< QString("x = 23")
<< int(QEvent::DragLeave)
+ << 1
<< QByteArray();
QTest::newRow("Drag.start() in Drop")
<< QString("Drag.start()")
<< int(QEvent::Drop)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
QTest::newRow("Drag.cancel() in Drop")
<< QString("Drag.cancel()")
<< int(QEvent::Drop)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
QTest::newRow("Drag.drop() in Drop")
<< QString("Drag.drop()")
<< int(QEvent::Drop)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
QTest::newRow("Drag.active = true in Drop")
<< QString("Drag.active = true")
<< int(QEvent::Drop)
+ << 1
<< QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
QTest::newRow("Drag.active = false in Drop")
<< QString("Drag.active = false")
<< int(QEvent::Drop)
+ << 1
<< QByteArray();
QTest::newRow("move in Drop")
<< QString("x = 23")
<< int(QEvent::Drop)
+ << 1
<< QByteArray();
}
@@ -1177,6 +1202,7 @@ void tst_QQuickDrag::recursion()
{
QFETCH(QString, script);
QFETCH(int, type);
+ QFETCH(int, moveEvents);
QFETCH(QByteArray, warning);
if (!warning.isEmpty())
@@ -1206,22 +1232,36 @@ void tst_QQuickDrag::recursion()
QCOMPARE(dropTarget.leaveEvents, 0);
evaluate<void>(item, "y = 15");
+
+ // the evaluate statement above, y = 15, will cause
+ // QQuickItem::setY(15) to be called, leading to an
+ // event being posted that will be delivered
+ // to RecursingDropTarget::dragMoveEvent(), hence
+ // the following call to QCoreApplication::processEvents()
QCoreApplication::processEvents();
+
+
+ // Regarding 'move in Move' when
+ // RecursingDropTarget::dragMoveEvent() runs,
+ // its call 'evaluate' triggers a second
+ // move event (x = 23) that needs to be delivered.
+ QCoreApplication::processEvents();
+
QCOMPARE(dropTarget.enterEvents, 1);
- QCOMPARE(dropTarget.moveEvents, 1);
+ QCOMPARE(dropTarget.moveEvents, moveEvents);
QCOMPARE(dropTarget.dropEvents, 0);
QCOMPARE(dropTarget.leaveEvents, 0);
if (type == QEvent::Drop) {
QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.MoveAction"), true);
QCOMPARE(dropTarget.enterEvents, 1);
- QCOMPARE(dropTarget.moveEvents, 1);
+ QCOMPARE(dropTarget.moveEvents, moveEvents);
QCOMPARE(dropTarget.dropEvents, 1);
QCOMPARE(dropTarget.leaveEvents, 0);
} else {
evaluate<void>(item, "Drag.cancel()");
QCOMPARE(dropTarget.enterEvents, 1);
- QCOMPARE(dropTarget.moveEvents, 1);
+ QCOMPARE(dropTarget.moveEvents, moveEvents);
QCOMPARE(dropTarget.dropEvents, 0);
QCOMPARE(dropTarget.leaveEvents, 1);
}
diff --git a/tests/auto/quick/qquickflickable/data/ratios.qml b/tests/auto/quick/qquickflickable/data/ratios.qml
new file mode 100644
index 0000000000..1291cada72
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/data/ratios.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 400
+ height: 400
+
+ property bool forceNoFlicking: true
+ property double heightRatioIs: flickable.visibleArea.heightRatio
+ property double heightRatioShould: flickable.height / flickable.contentHeight
+ property double widthRatioIs: flickable.visibleArea.widthRatio
+ property double widthRatioShould: flickable.height / flickable.contentWidth
+
+ Flickable {
+ id: flickable
+ flickableDirection: Flickable.AutoFlickDirection
+ width: forceNoFlicking ? contentItem.width /* so xflick() returns false */ : 20
+ height: forceNoFlicking ? contentItem.height /* likewise */ : 20
+ contentHeight: contentItem.height
+ contentWidth: contentItem.width
+ clip: true
+
+ Rectangle {
+ id: contentItem
+ color: "red"
+ width: 300
+ height: 300
+ }
+ }
+}
+
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 3575dfa012..a8055b3467 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -67,6 +67,7 @@ private slots:
void create();
void horizontalViewportSize();
void verticalViewportSize();
+ void visibleAreaRatiosUpdate();
void properties();
void boundsBehavior();
void rebound();
@@ -158,6 +159,28 @@ void tst_qquickflickable::verticalViewportSize()
delete obj;
}
+void tst_qquickflickable::visibleAreaRatiosUpdate()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("ratios.qml"));
+ QQuickItem *obj = qobject_cast<QQuickItem*>(c.create());
+
+ QVERIFY(obj != 0);
+ // check initial ratio values
+ QCOMPARE(obj->property("heightRatioIs").toDouble(), obj->property("heightRatioShould").toDouble());
+ QCOMPARE(obj->property("widthRatioIs").toDouble(), obj->property("widthRatioShould").toDouble());
+ // change flickable geometry so that flicking is enabled (content size > flickable size)
+ obj->setProperty("forceNoFlicking", false);
+ QCOMPARE(obj->property("heightRatioIs").toDouble(), obj->property("heightRatioShould").toDouble());
+ QCOMPARE(obj->property("widthRatioIs").toDouble(), obj->property("widthRatioShould").toDouble());
+ // change flickable geometry so that flicking is disabled (content size == flickable size)
+ obj->setProperty("forceNoFlicking", true);
+ QCOMPARE(obj->property("heightRatioIs").toDouble(), obj->property("heightRatioShould").toDouble());
+ QCOMPARE(obj->property("widthRatioIs").toDouble(), obj->property("widthRatioShould").toDouble());
+
+ delete obj;
+}
+
void tst_qquickflickable::properties()
{
QQmlEngine engine;
diff --git a/tests/auto/quick/qquickgridview/qquickgridview.pro b/tests/auto/quick/qquickgridview/qquickgridview.pro
index 1efa6c4ae3..3a4155256f 100644
--- a/tests/auto/quick/qquickgridview/qquickgridview.pro
+++ b/tests/auto/quick/qquickgridview/qquickgridview.pro
@@ -12,5 +12,3 @@ TESTDATA = data/*
QT += core-private gui-private qml-private quick-private testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-
-mac:CONFIG+=insignificant_test # QTBUG-27890
diff --git a/tests/auto/quick/qquickimage/data/qtbug_32513.qml b/tests/auto/quick/qquickimage/data/qtbug_32513.qml
new file mode 100644
index 0000000000..b6cbe33eec
--- /dev/null
+++ b/tests/auto/quick/qquickimage/data/qtbug_32513.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ width: 200; height: 200
+
+ Image {
+ cache: false
+
+ NumberAnimation on opacity {
+ loops: Animation.Infinite
+ from: 1; to: 0
+ }
+
+ SequentialAnimation on source {
+ loops: Animation.Infinite
+ PropertyAction { value: "green.png" }
+ PauseAnimation { duration: 100 }
+ PropertyAction { value: "pattern.png" }
+ PauseAnimation { duration: 100 }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
index 0804c7b900..8bdb9c9de5 100644
--- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp
+++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
@@ -99,6 +99,7 @@ private slots:
void sourceSize_QTBUG_16389();
void nullPixmapPaint();
void imageCrash_QTBUG_22125();
+ void imageCrash_QTBUG_32513();
void sourceSize_data();
void sourceSize();
void progressAndStatusChanges();
@@ -704,6 +705,15 @@ void tst_qquickimage::imageCrash_QTBUG_22125()
QCoreApplication::processEvents();
}
+void tst_qquickimage::imageCrash_QTBUG_32513()
+{
+ QQuickView view(testFileUrl("qtbug_32513.qml"));
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QTest::qWait(1000);
+ // shouldn't crash when the image changes sources
+}
+
void tst_qquickimage::sourceSize_data()
{
QTest::addColumn<int>("sourceWidth");
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index a7343f686f..79f08d5147 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -718,24 +718,24 @@ void tst_qquickitem::changeParent()
void tst_qquickitem::multipleFocusClears()
{
//Multiple clears of focus inside a focus scope shouldn't crash. QTBUG-24714
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("multipleFocusClears.qml"));
- view->show();
- ensureFocus(view);
- QTRY_VERIFY(QGuiApplication::focusWindow() == view);
+ QQuickView view;
+ view.setSource(testFileUrl("multipleFocusClears.qml"));
+ view.show();
+ ensureFocus(&view);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &view);
}
void tst_qquickitem::focusSubItemInNonFocusScope()
{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("focusSubItemInNonFocusScope.qml"));
- view->show();
- QTest::qWaitForWindowActive(view);
+ QQuickView view;
+ view.setSource(testFileUrl("focusSubItemInNonFocusScope.qml"));
+ view.show();
+ QTest::qWaitForWindowActive(&view);
- QQuickItem *dummyItem = view->rootObject()->findChild<QQuickItem *>("dummyItem");
+ QQuickItem *dummyItem = view.rootObject()->findChild<QQuickItem *>("dummyItem");
QVERIFY(dummyItem);
- QQuickItem *textInput = view->rootObject()->findChild<QQuickItem *>("textInput");
+ QQuickItem *textInput = view.rootObject()->findChild<QQuickItem *>("textInput");
QVERIFY(textInput);
QVERIFY(dummyItem->hasFocus());
@@ -747,8 +747,6 @@ void tst_qquickitem::focusSubItemInNonFocusScope()
QVERIFY(!dummyItem->hasFocus());
QVERIFY(textInput->hasFocus());
QVERIFY(textInput->hasActiveFocus());
-
- delete view;
}
void tst_qquickitem::parentItemWithFocus()
@@ -880,24 +878,22 @@ void tst_qquickitem::reparentFocusedItem()
void tst_qquickitem::constructor()
{
- QQuickItem *root = new QQuickItem;
+ QScopedPointer<QQuickItem> root(new QQuickItem);
QVERIFY(root->parent() == 0);
QVERIFY(root->parentItem() == 0);
- QQuickItem *child1 = new QQuickItem(root);
- QVERIFY(child1->parent() == root);
- QVERIFY(child1->parentItem() == root);
+ QQuickItem *child1 = new QQuickItem(root.data());
+ QVERIFY(child1->parent() == root.data());
+ QVERIFY(child1->parentItem() == root.data());
QCOMPARE(root->childItems().count(), 1);
QCOMPARE(root->childItems().at(0), child1);
- QQuickItem *child2 = new QQuickItem(root);
- QVERIFY(child2->parent() == root);
- QVERIFY(child2->parentItem() == root);
+ QQuickItem *child2 = new QQuickItem(root.data());
+ QVERIFY(child2->parent() == root.data());
+ QVERIFY(child2->parentItem() == root.data());
QCOMPARE(root->childItems().count(), 2);
QCOMPARE(root->childItems().at(0), child1);
QCOMPARE(root->childItems().at(1), child2);
-
- delete root;
}
void tst_qquickitem::setParentItem()
@@ -1157,80 +1153,87 @@ void tst_qquickitem::enabledFocus()
QCOMPARE(window.activeFocusItem(), static_cast<QQuickItem *>(&child1));
}
+static inline QByteArray msgItem(const QQuickItem *item)
+{
+ QString result;
+ QDebug(&result) << item;
+ return result.toLocal8Bit();
+}
+
void tst_qquickitem::mouseGrab()
{
- QQuickWindow *window = new QQuickWindow;
- window->resize(200, 200);
- window->show();
+ QQuickWindow window;
+ window.setFramePosition(QPoint(100, 100));
+ window.resize(200, 200);
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
- TestItem *child1 = new TestItem;
+ QScopedPointer<TestItem> child1(new TestItem);
+ child1->setObjectName(QStringLiteral("child1"));
child1->setAcceptedMouseButtons(Qt::LeftButton);
child1->setSize(QSizeF(200, 100));
- child1->setParentItem(window->contentItem());
+ child1->setParentItem(window.contentItem());
- TestItem *child2 = new TestItem;
+ QScopedPointer<TestItem> child2(new TestItem);
+ child2->setObjectName(QStringLiteral("child2"));
child2->setAcceptedMouseButtons(Qt::LeftButton);
child2->setY(51);
child2->setSize(QSizeF(200, 100));
- child2->setParentItem(window->contentItem());
+ child2->setParentItem(window.contentItem());
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(50,50));
QTest::qWait(100);
- QVERIFY(window->mouseGrabberItem() == child1);
+ QVERIFY2(window.mouseGrabberItem() == child1.data(), msgItem(window.mouseGrabberItem()).constData());
QTest::qWait(100);
QCOMPARE(child1->pressCount, 1);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(50,50));
QTest::qWait(50);
- QVERIFY(window->mouseGrabberItem() == 0);
+ QVERIFY2(window.mouseGrabberItem() == 0, msgItem(window.mouseGrabberItem()).constData());
QCOMPARE(child1->releaseCount, 1);
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(50,50));
QTest::qWait(50);
- QVERIFY(window->mouseGrabberItem() == child1);
+ QVERIFY2(window.mouseGrabberItem() == child1.data(), msgItem(window.mouseGrabberItem()).constData());
QCOMPARE(child1->pressCount, 2);
child1->setEnabled(false);
- QVERIFY(window->mouseGrabberItem() == 0);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50,50));
+ QVERIFY2(window.mouseGrabberItem() == 0, msgItem(window.mouseGrabberItem()).constData());
+ QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(50,50));
QTest::qWait(50);
QCOMPARE(child1->releaseCount, 1);
child1->setEnabled(true);
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(50,50));
QTest::qWait(50);
- QVERIFY(window->mouseGrabberItem() == child1);
+ QVERIFY2(window.mouseGrabberItem() == child1.data(), msgItem(window.mouseGrabberItem()).constData());
QCOMPARE(child1->pressCount, 3);
child1->setVisible(false);
- QVERIFY(window->mouseGrabberItem() == 0);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50,50));
+ QVERIFY2(window.mouseGrabberItem() == 0, msgItem(window.mouseGrabberItem()));
+ QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(50,50));
QCOMPARE(child1->releaseCount, 1);
child1->setVisible(true);
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(50,50));
QTest::qWait(50);
- QVERIFY(window->mouseGrabberItem() == child1);
+ QVERIFY2(window.mouseGrabberItem() == child1.data(), msgItem(window.mouseGrabberItem()).constData());
QCOMPARE(child1->pressCount, 4);
child2->grabMouse();
- QVERIFY(window->mouseGrabberItem() == child2);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50,50));
+ QVERIFY2(window.mouseGrabberItem() == child2.data(), msgItem(window.mouseGrabberItem()).constData());
+ QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(50,50));
QTest::qWait(50);
QCOMPARE(child1->releaseCount, 1);
QCOMPARE(child2->releaseCount, 1);
child2->grabMouse();
- QVERIFY(window->mouseGrabberItem() == child2);
- QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50,50));
+ QVERIFY2(window.mouseGrabberItem() == child2.data(), msgItem(window.mouseGrabberItem()).constData());
+ QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(50,50));
QTest::qWait(50);
QCOMPARE(child1->pressCount, 4);
QCOMPARE(child2->pressCount, 1);
- QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(50,50));
QTest::qWait(50);
QCOMPARE(child1->releaseCount, 1);
QCOMPARE(child2->releaseCount, 2);
-
- delete child1;
- delete child2;
- delete window;
}
void tst_qquickitem::touchEventAcceptIgnore_data()
@@ -1245,13 +1248,14 @@ void tst_qquickitem::touchEventAcceptIgnore()
{
QFETCH(bool, itemSupportsTouch);
- TestWindow *window = new TestWindow;
- window->resize(100, 100);
- window->show();
+ TestWindow window;
+ window.resize(100, 100);
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
- TestItem *item = new TestItem;
+ QScopedPointer<TestItem> item(new TestItem);
item->setSize(QSizeF(100, 100));
- item->setParentItem(window->contentItem());
+ item->setParentItem(window.contentItem());
item->acceptIncomingTouchEvents = itemSupportsTouch;
static QTouchDevice* device = 0;
@@ -1277,7 +1281,7 @@ void tst_qquickitem::touchEventAcceptIgnore()
item->touchEventReached = false;
- bool accepted = window->event(&event);
+ bool accepted = window.event(&event);
QVERIFY(item->touchEventReached);
QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
@@ -1297,7 +1301,7 @@ void tst_qquickitem::touchEventAcceptIgnore()
item->touchEventReached = false;
- bool accepted = window->event(&event);
+ bool accepted = window.event(&event);
QCOMPARE(item->touchEventReached, itemSupportsTouch);
QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
@@ -1317,14 +1321,11 @@ void tst_qquickitem::touchEventAcceptIgnore()
item->touchEventReached = false;
- bool accepted = window->event(&event);
+ bool accepted = window.event(&event);
QCOMPARE(item->touchEventReached, itemSupportsTouch);
QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
}
-
- delete item;
- delete window;
}
void tst_qquickitem::polishOutsideAnimation()
@@ -1346,16 +1347,15 @@ void tst_qquickitem::polishOutsideAnimation()
void tst_qquickitem::polishOnCompleted()
{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("polishOnCompleted.qml"));
- view->show();
+ QQuickView view;
+ view.setSource(testFileUrl("polishOnCompleted.qml"));
+ view.show();
+ QTest::qWaitForWindowExposed(&view);
- TestPolishItem *item = qobject_cast<TestPolishItem*>(view->rootObject());
+ TestPolishItem *item = qobject_cast<TestPolishItem*>(view.rootObject());
QVERIFY(item);
QTRY_VERIFY(item->wasPolished);
-
- delete view;
}
void tst_qquickitem::wheelEvent_data()
@@ -1376,20 +1376,21 @@ void tst_qquickitem::wheelEvent()
const bool shouldReceiveWheelEvents = visible && enabled;
- QQuickWindow *window = new QQuickWindow;
- window->resize(200, 200);
- window->show();
+ QQuickWindow window;
+ window.resize(200, 200);
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
TestItem *item = new TestItem;
item->setSize(QSizeF(200, 100));
- item->setParentItem(window->contentItem());
+ item->setParentItem(window.contentItem());
item->setEnabled(enabled);
item->setVisible(visible);
QWheelEvent event(QPoint(100, 50), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical);
event.setAccepted(false);
- QGuiApplication::sendEvent(window, &event);
+ QGuiApplication::sendEvent(&window, &event);
if (shouldReceiveWheelEvents) {
QVERIFY(event.isAccepted());
@@ -1398,8 +1399,6 @@ void tst_qquickitem::wheelEvent()
QVERIFY(!event.isAccepted());
QCOMPARE(item->wheelCount, 0);
}
-
- delete window;
}
class HoverItem : public QQuickItem
@@ -1503,11 +1502,11 @@ void tst_qquickitem::hoverEvent()
void tst_qquickitem::hoverEventInParent()
{
- QQuickWindow *window = new QQuickWindow();
- window->resize(200, 200);
- window->show();
+ QQuickWindow window;
+ window.resize(200, 200);
+ window.show();
- HoverItem *parentItem = new HoverItem(window->contentItem());
+ HoverItem *parentItem = new HoverItem(window.contentItem());
parentItem->setSize(QSizeF(200, 200));
parentItem->setAcceptHoverEvents(true);
@@ -1523,12 +1522,12 @@ void tst_qquickitem::hoverEventInParent()
const QPoint insideLeft(50, 100);
const QPoint insideRight(150, 100);
- sendMouseMove(window, insideLeft);
+ sendMouseMove(&window, insideLeft);
parentItem->resetCounters();
leftItem->resetCounters();
rightItem->resetCounters();
- sendMouseMove(window, insideRight);
+ sendMouseMove(&window, insideRight);
QCOMPARE(parentItem->hoverEnterCount, 0);
QCOMPARE(parentItem->hoverLeaveCount, 0);
QCOMPARE(leftItem->hoverEnterCount, 0);
@@ -1536,15 +1535,13 @@ void tst_qquickitem::hoverEventInParent()
QCOMPARE(rightItem->hoverEnterCount, 1);
QCOMPARE(rightItem->hoverLeaveCount, 0);
- sendMouseMove(window, insideLeft);
+ sendMouseMove(&window, insideLeft);
QCOMPARE(parentItem->hoverEnterCount, 0);
QCOMPARE(parentItem->hoverLeaveCount, 0);
QCOMPARE(leftItem->hoverEnterCount, 1);
QCOMPARE(leftItem->hoverLeaveCount, 1);
QCOMPARE(rightItem->hoverEnterCount, 1);
QCOMPARE(rightItem->hoverLeaveCount, 1);
-
- delete window;
}
void tst_qquickitem::paintOrder_data()
diff --git a/tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml b/tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml
new file mode 100644
index 0000000000..7903c392d1
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtTest 1.0
+
+Item {
+ function resizeThirdItem(size) {
+ resizingListModel.setProperty(3, "size", size)
+ }
+
+ ListView {
+ width: 300
+ height: 542
+ model: ListModel {
+ id: resizingListModel
+ ListElement { size: 300; }
+ ListElement { size: 300; }
+ ListElement { size: 300; }
+ ListElement { size: 300; }
+ ListElement { size: 300; }
+ ListElement { size: 300; }
+ }
+ delegate: Rectangle {
+ width: parent.width
+ color: index % 2 == 0 ? "red" : "blue"
+ height: size
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index bec61eaccb..2268f0754c 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -209,6 +209,7 @@ private slots:
void defaultHighlightMoveDuration();
void accessEmptyCurrentItem_QTBUG_30227();
void delayedChanges_QTBUG_30555();
+ void outsideViewportChangeNotAffectingView();
private:
template <class T> void items(const QUrl &source);
@@ -6880,6 +6881,43 @@ void tst_QQuickListView::delayedChanges_QTBUG_30555()
delete window;
}
+void tst_QQuickListView::outsideViewportChangeNotAffectingView()
+{
+ QQuickView *window = createView();
+ window->setSource(testFileUrl("outsideViewportChangeNotAffectingView.qml"));
+
+ QQuickListView *listview = window->rootObject()->findChild<QQuickListView*>();
+ QTRY_VERIFY(listview != 0);
+
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ flick(window, QPoint(20, 200), QPoint(20, 20), 10);
+
+ QTRY_COMPARE(listview->isFlicking(), false);
+
+ QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4);
+ QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.);
+
+ QMetaObject::invokeMethod(window->rootObject(), "resizeThirdItem", Q_ARG(QVariant, 290));
+ QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4);
+ QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.);
+
+ QMetaObject::invokeMethod(window->rootObject(), "resizeThirdItem", Q_ARG(QVariant, 300));
+ QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4);
+ QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.);
+
+ QMetaObject::invokeMethod(window->rootObject(), "resizeThirdItem", Q_ARG(QVariant, 310));
+ QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4);
+ QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.);
+
+ QMetaObject::invokeMethod(window->rootObject(), "resizeThirdItem", Q_ARG(QVariant, 400));
+ QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4);
+ QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.);
+
+ delete window;
+}
+
QTEST_MAIN(tst_QQuickListView)
#include "tst_qquicklistview.moc"
diff --git a/tests/auto/quick/qquickpath/tst_qquickpath.cpp b/tests/auto/quick/qquickpath/tst_qquickpath.cpp
index fa68442329..6ecc5cee50 100644
--- a/tests/auto/quick/qquickpath/tst_qquickpath.cpp
+++ b/tests/auto/quick/qquickpath/tst_qquickpath.cpp
@@ -128,7 +128,7 @@ void tst_QuickPath::catmullromCurve()
pos = obj->pointAt(.75);
QCOMPARE(pos.toPoint(), QPoint(51,105)); //fuzzy compare
pos = obj->pointAt(1);
- QCOMPARE(pos, QPointF(100,150));
+ QCOMPARE(pos.toPoint(), QPoint(100,150));
}
void tst_QuickPath::closedCatmullromCurve()
@@ -227,7 +227,7 @@ void tst_QuickPath::line()
QCOMPARE(p1.x(), p1.y());
QPointF p2 = path2->pointAt(t);
- QCOMPARE(p1, p2);
+ QCOMPARE(p1.toPoint(), p2.toPoint());
}
}
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 274b93e81a..e4ad7b9c40 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -1725,6 +1725,14 @@ void tst_QQuickPathView::missingPercent()
delete obj;
}
+static inline bool hasFraction(qreal o)
+{
+ const bool result = o != qFloor(o);
+ if (!result)
+ qDebug() << "o != qFloor(o)" << o;
+ return result;
+}
+
void tst_QQuickPathView::cancelDrag()
{
QScopedPointer<QQuickView> window(createView());
@@ -1747,7 +1755,7 @@ void tst_QQuickPathView::cancelDrag()
QTest::mouseMove(window.data(), QPoint(30, 100));
QTest::mouseMove(window.data(), QPoint(85, 100));
- QTRY_VERIFY(pathview->offset() != qFloor(pathview->offset()));
+ QTRY_VERIFY(hasFraction(pathview->offset()));
QTRY_VERIFY(pathview->isMoving());
QVERIFY(pathview->isDragging());
QCOMPARE(draggingSpy.count(), 1);
diff --git a/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml b/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml
index 136e5d21a2..9c9318d3cc 100644
--- a/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml
+++ b/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml
@@ -6,7 +6,7 @@ Rectangle {
Text {
objectName: "textItem"
- text: "AA\nBBBBB\nCCCCCCCCCCCCCCCC"
+ text: "AA\nBBBBBBB\nCCCCCCCCCCCCCCCC"
anchors.centerIn: parent
horizontalAlignment: Text.AlignLeft
}
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index 32099ae187..6b93791545 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -854,9 +854,20 @@ int tst_qquicktext::numberOfNonWhitePixels(int fromX, int toX, const QImage &ima
return pixels;
}
+static inline QByteArray msgNotGreaterThan(int n1, int n2)
+{
+ return QByteArray::number(n1) + QByteArrayLiteral(" is not greater than ") + QByteArray::number(n2);
+}
+
+static inline QByteArray msgNotLessThan(int n1, int n2)
+{
+ return QByteArray::number(n1) + QByteArrayLiteral(" is not less than ") + QByteArray::number(n2);
+}
+
void tst_qquicktext::hAlignImplicitWidth()
{
QQuickView view(testFileUrl("hAlignImplicitWidth.qml"));
+ view.setFlags(view.flags() | Qt::WindowStaysOnTopHint); // Prevent being obscured by other windows.
view.show();
view.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -864,34 +875,45 @@ void tst_qquicktext::hAlignImplicitWidth()
QQuickText *text = view.rootObject()->findChild<QQuickText*>("textItem");
QVERIFY(text != 0);
+ // Try to check whether alignment works by checking the number of black
+ // pixels in the thirds of the grabbed image.
+ const int windowWidth = 200;
+ const int textWidth = qCeil(text->implicitWidth());
+ QVERIFY2(textWidth < windowWidth, "System font too large.");
+ const int sectionWidth = textWidth / 3;
+ const int centeredSection1 = (windowWidth - textWidth) / 2;
+ const int centeredSection2 = centeredSection1 + sectionWidth;
+ const int centeredSection3 = centeredSection2 + sectionWidth;
+ const int centeredSection3End = centeredSection3 + sectionWidth;
+
{
// Left Align
QImage image = view.grabWindow();
- int left = numberOfNonWhitePixels(0, image.width() / 3, image);
- int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image);
- int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image);
- QVERIFY(left > mid);
- QVERIFY(mid > right);
+ const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image);
+ const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image);
+ const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image);
+ QVERIFY2(left > mid, msgNotGreaterThan(left, mid).constData());
+ QVERIFY2(mid > right, msgNotGreaterThan(mid, right).constData());
}
{
// HCenter Align
text->setHAlign(QQuickText::AlignHCenter);
QImage image = view.grabWindow();
- int left = numberOfNonWhitePixels(0, image.width() / 3, image);
- int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image);
- int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image);
- QVERIFY(left < mid);
- QVERIFY(mid > right);
+ const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image);
+ const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image);
+ const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image);
+ QVERIFY2(left < mid, msgNotLessThan(left, mid).constData());
+ QVERIFY2(mid > right, msgNotGreaterThan(mid, right).constData());
}
{
// Right Align
text->setHAlign(QQuickText::AlignRight);
QImage image = view.grabWindow();
- int left = numberOfNonWhitePixels(0, image.width() / 3, image);
- int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image);
- int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image);
- QVERIFY(left < mid);
- QVERIFY(mid < right);
+ const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image);
+ const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image);
+ const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image);
+ QVERIFY2(left < mid, msgNotLessThan(left, mid).constData());
+ QVERIFY2(mid < right, msgNotLessThan(mid, right).constData());
}
}
diff --git a/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml b/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml
index 136e5d21a2..017bab97a7 100644
--- a/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml
+++ b/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml
@@ -6,8 +6,9 @@ Rectangle {
Text {
objectName: "textItem"
- text: "AA\nBBBBB\nCCCCCCCCCCCCCCCC"
+ text: "AA\nBBBBBBB\nCCCCCCCCCCCCCCCC"
anchors.centerIn: parent
horizontalAlignment: Text.AlignLeft
+ font.pointSize: 12
}
}
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 6a136aeb7e..ff9554718b 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -657,7 +657,7 @@ void tst_qquicktextedit::hAlign_RightToLeft()
QQuickView window(testFileUrl("horizontalAlignment_RightToLeft.qml"));
QQuickTextEdit *textEdit = window.rootObject()->findChild<QQuickTextEdit*>("text");
QVERIFY(textEdit != 0);
- window.show();
+ window.showNormal();
const QString rtlText = textEdit->text();
@@ -821,42 +821,66 @@ static int numberOfNonWhitePixels(int fromX, int toX, const QImage &image)
return pixels;
}
+static inline QByteArray msgNotGreaterThan(int n1, int n2)
+{
+ return QByteArray::number(n1) + QByteArrayLiteral(" is not greater than ") + QByteArray::number(n2);
+}
+
+static inline QByteArray msgNotLessThan(int n1, int n2)
+{
+ return QByteArray::number(n1) + QByteArrayLiteral(" is not less than ") + QByteArray::number(n2);
+}
+
void tst_qquicktextedit::hAlignVisual()
{
QQuickView view(testFileUrl("hAlignVisual.qml"));
- view.show();
+ view.setFlags(view.flags() | Qt::WindowStaysOnTopHint); // Prevent being obscured by other windows.
+ view.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&view));
QQuickText *text = view.rootObject()->findChild<QQuickText*>("textItem");
QVERIFY(text != 0);
+
+ // Try to check whether alignment works by checking the number of black
+ // pixels in the thirds of the grabbed image.
+ const int windowWidth = 200;
+ const int textWidth = qCeil(text->implicitWidth());
+ QVERIFY2(textWidth < windowWidth, "System font too large.");
+ const int sectionWidth = textWidth / 3;
+ const int centeredSection1 = (windowWidth - textWidth) / 2;
+ const int centeredSection2 = centeredSection1 + sectionWidth;
+ const int centeredSection3 = centeredSection2 + sectionWidth;
+ const int centeredSection3End = centeredSection3 + sectionWidth;
+
{
// Left Align
QImage image = view.grabWindow();
- int left = numberOfNonWhitePixels(0, image.width() / 3, image);
- int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image);
- int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image);
- QVERIFY(left > mid);
- QVERIFY(mid > right);
+ const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image);
+ const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image);
+ const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image);
+ QVERIFY2(left > mid, msgNotGreaterThan(left, mid).constData());
+ QVERIFY2(mid > right, msgNotGreaterThan(mid, right).constData());
}
{
// HCenter Align
text->setHAlign(QQuickText::AlignHCenter);
QImage image = view.grabWindow();
- int left = numberOfNonWhitePixels(0, image.width() / 3, image);
- int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image);
- int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image);
- QVERIFY(left < mid);
- QVERIFY(mid > right);
+ const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image);
+ const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image);
+ const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image);
+ QVERIFY2(left < mid, msgNotLessThan(left, mid).constData());
+ QVERIFY2(mid > right, msgNotGreaterThan(mid, right).constData());
}
{
// Right Align
text->setHAlign(QQuickText::AlignRight);
QImage image = view.grabWindow();
- int left = numberOfNonWhitePixels(0, image.width() / 3, image);
- int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image);
- int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image);
- QVERIFY(left < mid);
- QVERIFY(mid < right);
+ const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image);
+ const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image);
+ const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image);
+ image.save("test3.png");
+ QVERIFY2(left < mid, msgNotLessThan(left, mid).constData());
+ QVERIFY2(mid < right, msgNotLessThan(mid, right).constData());
}
text->setWidth(200);
@@ -867,8 +891,8 @@ void tst_qquicktextedit::hAlignVisual()
int x = qCeil(text->implicitWidth());
int left = numberOfNonWhitePixels(0, x, image);
int right = numberOfNonWhitePixels(x, image.width() - x, image);
- QVERIFY(left > 0);
- QVERIFY(right == 0);
+ QVERIFY2(left > 0, msgNotGreaterThan(left, 0).constData());
+ QCOMPARE(right, 0);
}
{
// HCenter Align
@@ -879,9 +903,9 @@ void tst_qquicktextedit::hAlignVisual()
int left = numberOfNonWhitePixels(0, x1, image);
int mid = numberOfNonWhitePixels(x1, x2 - x1, image);
int right = numberOfNonWhitePixels(x2, image.width() - x2, image);
- QVERIFY(left == 0);
- QVERIFY(mid > 0);
- QVERIFY(right == 0);
+ QCOMPARE(left, 0);
+ QVERIFY2(mid > 0, msgNotGreaterThan(left, 0).constData());
+ QCOMPARE(right, 0);
}
{
// Right Align
@@ -890,8 +914,8 @@ void tst_qquicktextedit::hAlignVisual()
int x = image.width() - qCeil(text->implicitWidth());
int left = numberOfNonWhitePixels(0, x, image);
int right = numberOfNonWhitePixels(x, image.width() - x, image);
- QVERIFY(left == 0);
- QVERIFY(right > 0);
+ QCOMPARE(left, 0);
+ QVERIFY2(right > 0, msgNotGreaterThan(left, 0).constData());
}
}
@@ -1241,7 +1265,7 @@ void tst_qquicktextedit::focusOnPress()
QQuickWindow window;
window.resize(100, 50);
textEditObject->setParentItem(window.contentItem());
- window.show();
+ window.showNormal();
window.requestActivate();
QTest::qWaitForWindowActive(&window);
@@ -2520,7 +2544,7 @@ void tst_qquicktextedit::remoteCursorDelegate()
view.rootContext()->setContextProperty("contextDelegate", &component);
view.setSource(testFileUrl("cursorTestRemote.qml"));
- view.show();
+ view.showNormal();
view.requestActivate();
QTest::qWaitForWindowActive(&view);
QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
@@ -2534,10 +2558,6 @@ void tst_qquicktextedit::remoteCursorDelegate()
textEditObject->setFocus(true);
QVERIFY(textEditObject->isCursorVisible());
- QCOMPARE(component.status(), QQmlComponent::Loading);
- QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance"));
- server.sendDelayedItem();
-
// Wait for component to load.
QTRY_COMPARE(component.status(), QQmlComponent::Ready);
QVERIFY(textEditObject->findChild<QQuickItem*>("cursorInstance"));
@@ -3047,7 +3067,7 @@ void tst_qquicktextedit::openInputPanel()
inputMethodPrivate->testContext = &platformInputContext;
QQuickView view(testFileUrl("openInputPanel.qml"));
- view.show();
+ view.showNormal();
view.requestActivate();
QTest::qWaitForWindowActive(&view);
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 7a61ceb7fd..1c2ab4d948 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -1574,7 +1574,7 @@ void tst_qquicktextinput::verticalAlignment()
QQuickView window(testFileUrl("horizontalAlignment.qml"));
QQuickTextInput *textInput = window.rootObject()->findChild<QQuickTextInput*>("text");
QVERIFY(textInput != 0);
- window.show();
+ window.showNormal();
QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignTop);
QVERIFY(textInput->boundingRect().bottom() < window.height() / 2);
@@ -2776,7 +2776,6 @@ void tst_qquicktextinput::cursorDelegate()
void tst_qquicktextinput::remoteCursorDelegate()
{
- QSKIP("This test is unstable");
TestHTTPServer server(SERVER_PORT);
server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
@@ -2800,10 +2799,6 @@ void tst_qquicktextinput::remoteCursorDelegate()
textInputObject->setFocus(true);
QVERIFY(textInputObject->isCursorVisible());
- QCOMPARE(component.status(), QQmlComponent::Loading);
- QVERIFY(!textInputObject->findChild<QQuickItem*>("cursorInstance"));
- server.sendDelayedItem();
-
// Wait for component to load.
QTRY_COMPARE(component.status(), QQmlComponent::Ready);
QVERIFY(textInputObject->findChild<QQuickItem*>("cursorInstance"));
@@ -3315,7 +3310,7 @@ void tst_qquicktextinput::focusOnPress()
QQuickWindow window;
window.resize(100, 50);
textInputObject->setParentItem(window.contentItem());
- window.show();
+ window.showNormal();
window.requestActivate();
QTest::qWaitForWindowActive(&window);
@@ -3378,7 +3373,7 @@ void tst_qquicktextinput::openInputPanel()
inputMethodPrivate->testContext = &platformInputContext;
QQuickView view(testFileUrl("openInputPanel.qml"));
- view.show();
+ view.showNormal();
view.requestActivate();
QTest::qWaitForWindowActive(&view);
@@ -3770,7 +3765,7 @@ void tst_qquicktextinput::inputContextMouseHandler()
input->setFocus(true);
input->setText("");
- view.show();
+ view.showNormal();
view.requestActivate();
QTest::qWaitForWindowActive(&view);
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index e2bb6b431c..fbbc77c31c 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -1072,7 +1072,7 @@ void tst_qquickwindow::noUpdateWhenNothingChanges()
QQuickRectangle rect(window.contentItem());
- window.show();
+ window.showNormal();
QTRY_VERIFY(window.isExposed());
if (window.openglContext()->thread() == QGuiApplication::instance()->thread()) {
diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp
index 509b209654..04b32499ff 100644
--- a/tests/auto/quick/rendernode/tst_rendernode.cpp
+++ b/tests/auto/quick/rendernode/tst_rendernode.cpp
@@ -59,7 +59,7 @@ public:
QQuickView view;
view.setSource(testFileUrl(fileName));
- view.show();
+ view.showNormal();
QTest::qWaitForWindowExposed(&view);
return view.grabWindow();
diff --git a/tests/auto/quick/touchmouse/touchmouse.pro b/tests/auto/quick/touchmouse/touchmouse.pro
index e7c50e6f54..445bee08ae 100644
--- a/tests/auto/quick/touchmouse/touchmouse.pro
+++ b/tests/auto/quick/touchmouse/touchmouse.pro
@@ -14,5 +14,3 @@ TESTDATA = data/*
# OTHER_FILES += data/foo.qml
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-
-mac:CONFIG+=insignificant_test # QTBUG-27890