summaryrefslogtreecommitdiff
path: root/tests/auto/controls/data/tst_tableview.qml
diff options
context:
space:
mode:
authorCaroline Chao <caroline.chao@digia.com>2013-06-18 15:00:52 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-19 17:38:23 +0200
commitd66245f1e8ebee65354a37c30d421a115dd0e383 (patch)
treede900f667c17b9f125340094d4513961bf6c8dd1 /tests/auto/controls/data/tst_tableview.qml
parentb0f3a519289511ad89b99a449176a1aff72d2a99 (diff)
downloadqtquickcontrols-d66245f1e8ebee65354a37c30d421a115dd0e383.tar.gz
TableView: let delegates handle mouse events
Includes auto tests. Task-number: QTBUG-31206 Change-Id: I683363f70f7e360cc70f84fd460cbde5e70a61af Reviewed-by: Caroline Chao <caroline.chao@digia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'tests/auto/controls/data/tst_tableview.qml')
-rw-r--r--tests/auto/controls/data/tst_tableview.qml138
1 files changed, 117 insertions, 21 deletions
diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml
index a54bbdcb..9a5e9c78 100644
--- a/tests/auto/controls/data/tst_tableview.qml
+++ b/tests/auto/controls/data/tst_tableview.qml
@@ -173,10 +173,104 @@ TestCase {
table.destroy();
}
- function test_forwardClickToChild() {
- var component = Qt.createComponent("tableview/table_delegate.qml")
+ function test_buttonDelegate() {
+ var component = Qt.createComponent("tableview/table_buttondelegate.qml")
+ compare(component.status, Component.Ready)
+ var table = component.createObject(container)
+ verify(table !== null, "table created is null")
+ compare(table.currentRow, -1)
+ waitForRendering(table)
+
+ // wait for items to be created
+ var timeout = 2000
+ while (timeout >= 0 && table.rowAt(20, 50) === -1) {
+ timeout -= 50
+ wait(50)
+ }
+
+ mousePress(table, 50, 20, Qt.LeftButton)
+ compare(table.currentRow, 0)
+ compare(table.tableClickCount, 0)
+ compare(table.buttonPressCount, 1)
+ compare(table.buttonReleaseCount, 0)
+
+ mouseRelease(table, 50, 20, Qt.LeftButton)
+ compare(table.currentRow, 0)
+ compare(table.tableClickCount, 0)
+ compare(table.buttonPressCount, 1)
+ compare(table.buttonReleaseCount, 1)
+
+ mouseClick(table, 50, 60, Qt.LeftButton)
+ compare(table.currentRow, 1)
+ compare(table.tableClickCount, 0)
+ compare(table.buttonPressCount, 2)
+ compare(table.buttonReleaseCount, 2)
+
+ table.destroy()
+ }
+
+ function test_QTBUG_31206() {
+ var component = Qt.createComponent("tableview/table_delegate2.qml")
+ compare(component.status, Component.Ready)
+ var table = component.createObject(container);
+ verify(table !== null, "table created is null")
+
+ // wait for items to be created
+ var timeout = 2000
+ while (timeout >= 0 && table.rowAt(15, 55) === -1) {
+ timeout -= 50
+ wait(50)
+ }
+
+ compare(table.test, false)
+ mouseClick(table, 15 , 10, Qt.LeftButton)
+ compare(table.test, true)
+ table.destroy()
+ }
+
+ function test_forwardMouseEventsToChildDelegate() {
+ var component = Qt.createComponent("tableview/table_delegate3.qml")
+ compare(component.status, Component.Ready)
+ var table = component.createObject(container);
+ table.forceActiveFocus();
+ verify(table !== null, "table created is null")
+
+ // wait for items to be created
+ var timeout = 2000
+ while (timeout >= 0 && table.rowAt(15, 55) === -1) {
+ timeout -= 50
+ wait(50)
+ }
+
+ compare(table._pressed, false)
+ compare(table._clicked, false)
+ compare(table._released, false)
+ compare(table._doubleClicked, false)
+
+ mousePress(table, 25 , 10, Qt.LeftButton)
+ compare(table._pressed, true)
+ table.clearTestData()
+
+ mouseRelease(table, 25 , 10, Qt.LeftButton)
+ compare(table._released, true)
+ table.clearTestData()
+
+ mouseClick(table, 25 , 10, Qt.LeftButton)
+ compare(table._clicked, true)
+ table.clearTestData()
+
+ mouseDoubleClick(table, 25 , 10, Qt.LeftButton)
+ compare(table._doubleClicked, true)
+ table.clearTestData()
+
+ table.destroy()
+ }
+
+ function test_rightClickOnMouseAreaOverTableView() {
+ var component = Qt.createComponent("tableview/table_mousearea.qml")
compare(component.status, Component.Ready)
var table = component.createObject(container);
+ table.forceActiveFocus();
verify(table !== null, "table created is null")
// wait for items to be created
@@ -186,9 +280,27 @@ TestCase {
wait(50)
}
- compare(table.test, 0)
- mouseClick(table, 15 , 55, Qt.LeftButton)
- compare(table.test, 1)
+ compare(table._pressed, false)
+ compare(table._clicked, false)
+ compare(table._released, false)
+ compare(table._doubleClicked, false)
+
+ mousePress(table, 25, 10, Qt.RightButton)
+ compare(table._pressed, true)
+ table.clearTestData()
+
+ mouseRelease(table, 25, 10, Qt.RightButton)
+ compare(table._released, true)
+ table.clearTestData()
+
+ mouseClick(table, 25, 10, Qt.RightButton)
+ compare(table._clicked, true)
+ table.clearTestData()
+
+ mouseDoubleClick(table, 25, 10, Qt.RightButton)
+ compare(table._doubleClicked, true)
+ table.clearTestData()
+
table.destroy()
}
@@ -222,22 +334,6 @@ TestCase {
table.destroy()
}
- function test_activated_withItemDelegate() {
- var component = Qt.createComponent("tableview/table_delegate.qml")
- compare(component.status, Component.Ready)
- var table = component.createObject(container);
- verify(table !== null, "table created is null")
- table.forceActiveFocus();
- compare(table.activatedTest, false)
- waitForRendering(table)
- if (!table.__activateItemOnSingleClick)
- mouseDoubleClick(table, 15 , 50, Qt.LeftButton)
- else
- mouseClick(table, 15, 50, Qt.LeftButton)
- compare(table.activatedTest, true)
- table.destroy()
- }
-
function test_columnCount() {
var component = Qt.createComponent("tableview/table_multicolumns.qml")
compare(component.status, Component.Ready)