diff options
Diffstat (limited to 'tests/auto/controls/data')
-rw-r--r-- | tests/auto/controls/data/tableview/table_activated.qml | 17 | ||||
-rw-r--r-- | tests/auto/controls/data/tableview/table_delegate.qml | 6 | ||||
-rw-r--r-- | tests/auto/controls/data/tableview/table_dynamiccolumns.qml | 65 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 10 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_rowlayout.qml | 86 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_shortcuts.qml | 2 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_slider.qml | 11 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_spinbox.qml | 20 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_stack.qml | 6 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_stackview.qml (renamed from tests/auto/controls/data/tst_pagestack.qml) | 4 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_tableview.qml | 206 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_tabview.qml | 48 |
12 files changed, 419 insertions, 62 deletions
diff --git a/tests/auto/controls/data/tableview/table_activated.qml b/tests/auto/controls/data/tableview/table_activated.qml index 52d420c4..227fbd88 100644 --- a/tests/auto/controls/data/tableview/table_activated.qml +++ b/tests/auto/controls/data/tableview/table_activated.qml @@ -42,11 +42,22 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 TableView { - height: 70 + height: 120 model: 10 - property bool test: false - onActivated: test = true + headerVisible: false + frameVisible: false + rowDelegate: Rectangle { + width: parent.width + height: 20 + } + + property int test: -1 + property int testClick: -1 + property int testDoubleClick: -1 + onActivated: test = row + onClicked: testClick = row + onDoubleClicked: testDoubleClick = row TableViewColumn { width: 100 diff --git a/tests/auto/controls/data/tableview/table_delegate.qml b/tests/auto/controls/data/tableview/table_delegate.qml index a3ab621d..82b08ba5 100644 --- a/tests/auto/controls/data/tableview/table_delegate.qml +++ b/tests/auto/controls/data/tableview/table_delegate.qml @@ -56,14 +56,14 @@ TableView { } headerDelegate: Text { height: 40 - text: itemValue + text: styleData.value } itemDelegate: Text { width: parent.width anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter - text: itemValue !== undefined ? itemValue : "" - color: itemTextColor + text: styleData.value !== undefined ? styleData.value : "" + color: styleData.textColor MouseArea { anchors.fill: parent onClicked: table.test = 1 diff --git a/tests/auto/controls/data/tableview/table_dynamiccolumns.qml b/tests/auto/controls/data/tableview/table_dynamiccolumns.qml new file mode 100644 index 00000000..ce2cb93c --- /dev/null +++ b/tests/auto/controls/data/tableview/table_dynamiccolumns.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module 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 QtQuick.Controls 1.0 + +TableView { + id: tableView + + TableViewColumn { title: "static" } + + Component { + id: component + TableViewColumn { } + } + + Component.onCompleted: { + addColumn(component.createObject(tableView, {title: "added item"})) + + var col1 = addColumn(component) + col1.title = "added component" + + insertColumn(0, component.createObject(tableView, {title: "inserted item"})) + + var col2 = insertColumn(0, component) + col2.title = "inserted component" + } +} diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index c36218a3..4cb57351 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -217,20 +217,20 @@ TestCase { } function test_activeFocusOnPress(){ - if (Qt.platform.os === "mac") + if (Qt.platform.os === "osx") skip("When the menu pops up on OS X, it does not return and the test fails after time out") var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox { model: 4 }', container, ''); comboBox.activeFocusOnPress = false verify(!comboBox.activeFocus) - if (Qt.platform.os === "mac") // on mac when the menu open, the __popup function does not return + if (Qt.platform.os === "osx") // on mac when the menu open, the __popup function does not return timer.start() else // two mouse clicks to open and close the popup menu mouseClick(comboBox, comboBox.x + 1, comboBox.y + 1) mouseClick(comboBox, comboBox.x + 1, comboBox.y + 1) verify(!comboBox.activeFocus) comboBox.activeFocusOnPress = true - if (Qt.platform.os === "mac") // on mac when the menu open, the __popup function does not return + if (Qt.platform.os === "osx") // on mac when the menu open, the __popup function does not return timer.start() else // two mouse clicks to open and close the popup menu mouseClick(comboBox, comboBox.x + 1, comboBox.y + 1) @@ -240,7 +240,7 @@ TestCase { } function test_spaceKey(){ - if (Qt.platform.os === "mac") + if (Qt.platform.os === "osx") skip("When the menu pops up on OS X, it does not return and the test fails after time out") var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox { model: 4 }', container, ''); @@ -259,7 +259,7 @@ TestCase { } function test_currentIndexInMenu() { - if (Qt.platform.os === "mac") + if (Qt.platform.os === "osx") skip("When the menu pops up on OS X, it does not return and the test fails after time out") var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox { model: 4 }', container, ''); diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml index fd21f475..d04419f0 100644 --- a/tests/auto/controls/data/tst_rowlayout.qml +++ b/tests/auto/controls/data/tst_rowlayout.qml @@ -459,6 +459,12 @@ Item { { tag: "propagateMaximumWidth", layoutHints: [10, 20, -1], childHints: [11, 21, 30], expected:[10, 20, 30]}, { tag: "propagateAll", layoutHints: [-1, -1, -1], childHints: [10, 20, 30], expected:[10, 20, 30]}, { tag: "propagateCrazy", layoutHints: [-1, -1, -1], childHints: [40, 21, 30], expected:[30, 30, 30]}, + { tag: "expandMinToExplicitPref", layoutHints: [-1, 1, -1], childHints: [11, 21, 31], expected:[ 1, 1, 31]}, + { tag: "expandMaxToExplicitPref", layoutHints: [-1, 99, -1], childHints: [11, 21, 31], expected:[11, 99, 99]}, + { tag: "expandAllToExplicitMin", layoutHints: [99, -1, -1], childHints: [11, 21, 31], expected:[99, 99, 99]}, + { tag: "expandPrefToExplicitMin", layoutHints: [24, -1, -1], childHints: [11, 21, 31], expected:[24, 24, 31]}, + { tag: "boundPrefToExplicitMax", layoutHints: [-1, -1, 19], childHints: [11, 21, 31], expected:[11, 19, 19]}, + { tag: "boundAllToExplicitMax", layoutHints: [-1, -1, 9], childHints: [11, 21, 31], expected:[ 9, 9, 9]}, ]; } @@ -468,22 +474,21 @@ Item { function test_sizeHint(data) { var layout = layout_sizeHint_Component.createObject(container) - layout.Layout.minimumWidth = data.layoutHints[0] - layout.Layout.preferredWidth = data.layoutHints[1] - layout.Layout.maximumWidth = data.layoutHints[2] - var child = layout.children[0].children[0] + var grid = layout.children[0] + grid.Layout.minimumWidth = data.layoutHints[0] + grid.Layout.preferredWidth = data.layoutHints[1] + grid.Layout.maximumWidth = data.layoutHints[2] + + var child = grid.children[0] if (data.implicitWidth !== undefined) { child.implicitWidth = data.implicitWidth } - child.Layout.minimumWidth = data.childHints[0] child.Layout.preferredWidth = data.childHints[1] child.Layout.maximumWidth = data.childHints[2] - var grid = layout.children[0] - var preferredWidth = layout.Layout.preferredWidth >= 0 ? layout.Layout.preferredWidth : layout.implicitWidth - var effectiveSizeHintResult = [layout.Layout.minimumWidth, preferredWidth, layout.Layout.maximumWidth] + var effectiveSizeHintResult = [layout.Layout.minimumWidth, layout.implicitWidth, layout.Layout.maximumWidth] compare(effectiveSizeHintResult, data.expected) layout.destroy() } @@ -633,5 +638,70 @@ Item { compare(r1.y, 6) // 5.5 layout.destroy(); } + + + Component { + id: layout_deleteLayout + ColumnLayout { + property int dummyproperty: 0 // yes really - its needed + RowLayout { + Text { text: "label1" } // yes, both are needed + Text { text: "label2" } + } + } + } + + function test_destroyLayout() + { + var layout = layout_deleteLayout.createObject(container) + layout.children[0].children[0].visible = true + layout.visible = false + layout.destroy() // Do not crash + } + + + Component { + id: rearrangeNestedLayouts_Component + RowLayout { + id: layout + anchors.fill: parent + width: 200 + height: 20 + RowLayout { + id: row + spacing: 0 + + Rectangle { + id: fixed + color: 'red' + implicitWidth: 20 + implicitHeight: 20 + } + Rectangle { + id: filler + color: 'grey' + Layout.fillWidth: true + implicitHeight: 20 + } + } + } + } + + function test_rearrangeNestedLayouts() + { + var layout = rearrangeNestedLayouts_Component.createObject(container) + var fixed = layout.children[0].children[0] + var filler = layout.children[0].children[1] + + compare(itemRect(fixed), [0,0,20,20]) + compare(itemRect(filler), [20,0,180,20]) + + fixed.implicitWidth = 100 + wait(20); // wait for at least 20 ms (this matches the time between two frame + // repaints for 50hz displays) + compare(itemRect(fixed), [0,0,100,20]) + compare(itemRect(filler), [100,0,100,20]) + + } } } diff --git a/tests/auto/controls/data/tst_shortcuts.qml b/tests/auto/controls/data/tst_shortcuts.qml index c0a668d4..b28d24a9 100644 --- a/tests/auto/controls/data/tst_shortcuts.qml +++ b/tests/auto/controls/data/tst_shortcuts.qml @@ -78,7 +78,7 @@ TestCase { { key: Qt.Key_D, modifier: Qt.AltModifier, expected: "alt d pressed" }, { key: Qt.Key_T, modifier: Qt.NoModifier, expected: "no key press" }, // on mac we don't have mnemonics - { key: Qt.Key_T, modifier: Qt.AltModifier, expected: Qt.platform.os === "mac" ? "no key press" : "alt t pressed" }, + { key: Qt.Key_T, modifier: Qt.AltModifier, expected: Qt.platform.os === "osx" ? "no key press" : "alt t pressed" }, ] } diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index 96b4d422..177a8fcb 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -282,5 +282,16 @@ Item { verify(control.value > 0.5) control.destroy() } + + function test_valueAndHandlePosition() + { + var slider = Qt.createQmlObject('import QtQuick.Controls 1.0; Slider {minimumValue: 0; maximumValue: 100; width: 100; height: 20; stepSize: 1}', container, ''); + slider.forceActiveFocus() + slider.value = 0 + compare(slider.__handlePos, 0) + slider.value = 50 + compare(slider.__handlePos, 50) + slider.destroy() + } } } diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index 9cc0662e..15ac98b9 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -178,22 +178,22 @@ Item { setCoordinates(spinbox) mouseMove(spinbox, mainCoord.x, mainCoord.y) - compare(spinbox.__controlState.containsMouse, true) - compare(spinbox.__controlState.upHovered, false) - compare(spinbox.__controlState.downHovered, false) + compare(spinbox.hovered, true) + compare(spinbox.__styleData.upHovered, false) + compare(spinbox.__styleData.downHovered, false) mouseMove(spinbox.parent, upCoord.x, upCoord.y) - compare(spinbox.__controlState.upHovered, true) - compare(spinbox.__controlState.downHovered, false) + compare(spinbox.__styleData.upHovered, true) + compare(spinbox.__styleData.downHovered, false) mouseMove(spinbox, downCoord.x, downCoord.y) - compare(spinbox.__controlState.upHovered, false) - compare(spinbox.__controlState.downHovered, true) + compare(spinbox.__styleData.upHovered, false) + compare(spinbox.__styleData.downHovered, true) mouseMove(spinbox, mainCoord.x - 2, mainCoord.y - 2) - compare(spinbox.__controlState.containsMouse, false) - compare(spinbox.__controlState.upHovered, false) - compare(spinbox.__controlState.downHovered, false) + compare(spinbox.hovered, false) + compare(spinbox.__styleData.upHovered, false) + compare(spinbox.__styleData.downHovered, false) spinbox.destroy() } diff --git a/tests/auto/controls/data/tst_stack.qml b/tests/auto/controls/data/tst_stack.qml index fa833680..a7363de7 100644 --- a/tests/auto/controls/data/tst_stack.qml +++ b/tests/auto/controls/data/tst_stack.qml @@ -58,8 +58,8 @@ TestCase { compare(item.status, 0); // Stack.Inactive } - function test_pageStack() { - var item = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; Item { property StackView pageStack: Stack.pageStack }', testCase, ''); - compare(item.pageStack, null); + function test_view() { + var item = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; Item { property StackView view: Stack.view }', testCase, ''); + compare(item.view, null); } } diff --git a/tests/auto/controls/data/tst_pagestack.qml b/tests/auto/controls/data/tst_stackview.qml index b20556fb..3daac785 100644 --- a/tests/auto/controls/data/tst_pagestack.qml +++ b/tests/auto/controls/data/tst_stackview.qml @@ -60,10 +60,10 @@ TestCase { StackView {} } - function test_pagestack() { + function test_stackview() { var component = stackComponent var stack = component.createObject(testCase); - verify (stack !== null, "pagestack created is null") + verify (stack !== null, "stackview created is null") verify (stack.depth === 0) stack.push(anItem) verify (stack.depth === 1) diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml index 6de8d577..a54bbdcb 100644 --- a/tests/auto/controls/data/tst_tableview.qml +++ b/tests/auto/controls/data/tst_tableview.qml @@ -55,6 +55,11 @@ TestCase { width:400 height:400 + Component { + id: newColumn + TableViewColumn { } + } + function test_usingqmlmodel_data() { return [ {tag: "listmodel", a: "tableview/table5_listmodel.qml", expected: "A"}, @@ -173,7 +178,14 @@ TestCase { compare(component.status, Component.Ready) var table = component.createObject(container); verify(table !== null, "table created is null") - table.forceActiveFocus(); + + // wait for items to be created + var timeout = 2000 + while (timeout >= 0 && table.rowAt(15, 55) === -1) { + timeout -= 50 + wait(50) + } + compare(table.test, 0) mouseClick(table, 15 , 55, Qt.LeftButton) compare(table.test, 1) @@ -186,12 +198,27 @@ TestCase { var table = component.createObject(container); verify(table !== null, "table created is null") table.forceActiveFocus(); - compare(table.test, false) + compare(table.test, -1) + compare(table.testClick, table.currentRow) + + if (!table.__activateItemOnSingleClick) + mouseDoubleClick(table, 15 , 45, Qt.LeftButton) + else + mouseClick(table, 15, 45, Qt.LeftButton) + + compare(table.testDoubleClick, table.currentRow) + compare(table.test, table.currentRow) + compare(table.testClick, table.currentRow) + if (!table.__activateItemOnSingleClick) mouseDoubleClick(table, 15 , 15, Qt.LeftButton) else mouseClick(table, 15, 15, Qt.LeftButton) - compare(table.test, true) + + compare(table.testDoubleClick, table.currentRow) + compare(table.testClick, table.currentRow) + compare(table.test, table.currentRow) + table.destroy() } @@ -202,6 +229,7 @@ TestCase { 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 @@ -228,6 +256,178 @@ TestCase { table.destroy() } + function test_columnWidth() { + var tableView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TableView { }', testCase, ''); + compare(tableView.columnCount, 0) + var column = newColumn.createObject(testCase, {title: "title 1"}); + verify(column.__view === null) + compare(column.width, 160) + compare(column.title, "title 1") + tableView.addColumn(column) + compare(column.__view, tableView) + compare(column.width, tableView.viewport.width) + var tableView2 = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TableView { }', testCase, ''); + tableView2.addColumn(column) // should not work + compare(column.__view, tableView) //same as before + tableView2.destroy() + tableView.destroy() + } + + function test_dynamicColumns() { + var component = Qt.createComponent("tableview/table_dynamiccolumns.qml") + compare(component.status, Component.Ready) + var table = component.createObject(container) + + // insertColumn(component), insertColumn(item), + // addColumn(component), addColumn(item), and static TableViewColumn {} + compare(table.columnCount, 5) + compare(table.getColumn(0).title, "inserted component") + compare(table.getColumn(1).title, "inserted item") + table.destroy() + } + + function test_addRemoveColumn() { + var tableView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TableView { }', testCase, ''); + compare(tableView.columnCount, 0) + tableView.addColumn(newColumn.createObject(testCase, {title: "title 1"})) + compare(tableView.columnCount, 1) + tableView.addColumn(newColumn.createObject(testCase, {title: "title 2"})) + compare(tableView.columnCount, 2) + compare(tableView.getColumn(0).title, "title 1") + compare(tableView.getColumn(1).title, "title 2") + + tableView.insertColumn(1, newColumn.createObject(testCase, {title: "title 3"})) + compare(tableView.columnCount, 3) + compare(tableView.getColumn(0).title, "title 1") + compare(tableView.getColumn(1).title, "title 3") + compare(tableView.getColumn(2).title, "title 2") + + tableView.insertColumn(0, newColumn.createObject(testCase, {title: "title 4"})) + compare(tableView.columnCount, 4) + compare(tableView.getColumn(0).title, "title 4") + compare(tableView.getColumn(1).title, "title 1") + compare(tableView.getColumn(2).title, "title 3") + compare(tableView.getColumn(3).title, "title 2") + + tableView.removeColumn(0) + compare(tableView.columnCount, 3) + compare(tableView.getColumn(0).title, "title 1") + compare(tableView.getColumn(1).title, "title 3") + compare(tableView.getColumn(2).title, "title 2") + + tableView.removeColumn(1) + compare(tableView.columnCount, 2) + compare(tableView.getColumn(0).title, "title 1") + compare(tableView.getColumn(1).title, "title 2") + + tableView.removeColumn(1) + compare(tableView.columnCount, 1) + compare(tableView.getColumn(0).title, "title 1") + + tableView.removeColumn(0) + compare(tableView.columnCount, 0) + tableView.destroy() + } + + function test_moveColumn_data() { + return [ + {tag:"0->1 (0)", from: 0, to: 1}, + {tag:"0->1 (1)", from: 0, to: 1}, + {tag:"0->1 (2)", from: 0, to: 1}, + + {tag:"0->2 (0)", from: 0, to: 2}, + {tag:"0->2 (1)", from: 0, to: 2}, + {tag:"0->2 (2)", from: 0, to: 2}, + + {tag:"1->0 (0)", from: 1, to: 0}, + {tag:"1->0 (1)", from: 1, to: 0}, + {tag:"1->0 (2)", from: 1, to: 0}, + + {tag:"1->2 (0)", from: 1, to: 2}, + {tag:"1->2 (1)", from: 1, to: 2}, + {tag:"1->2 (2)", from: 1, to: 2}, + + {tag:"2->0 (0)", from: 2, to: 0}, + {tag:"2->0 (1)", from: 2, to: 0}, + {tag:"2->0 (2)", from: 2, to: 0}, + + {tag:"2->1 (0)", from: 2, to: 1}, + {tag:"2->1 (1)", from: 2, to: 1}, + {tag:"2->1 (2)", from: 2, to: 1}, + + {tag:"0->0", from: 0, to: 0}, + {tag:"-1->0", from: -1, to: 0}, + {tag:"0->-1", from: 0, to: -1}, + {tag:"1->10", from: 1, to: 10}, + {tag:"10->2", from: 10, to: 2}, + {tag:"10->-1", from: 10, to: -1} + ] + } + + function test_moveColumn(data) { + var tableView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TableView { }', testCase, ''); + compare(tableView.columnCount, 0) + + var titles = ["title 1", "title 2", "title 3"] + + var i = 0; + for (i = 0; i < titles.length; ++i) + tableView.addColumn(newColumn.createObject(testCase, {title: titles[i]})) + + compare(tableView.columnCount, titles.length) + for (i = 0; i < tableView.columnCount; ++i) + compare(tableView.getColumn(i).title, titles[i]) + + tableView.moveColumn(data.from, data.to) + + compare(tableView.columnCount, titles.length) + + if (data.from >= 0 && data.from < tableView.columnCount && data.to >= 0 && data.to < tableView.columnCount) { + var title = titles[data.from] + titles.splice(data.from, 1) + titles.splice(data.to, 0, title) + } + + compare(tableView.columnCount, titles.length) + for (i = 0; i < tableView.columnCount; ++i) + compare(tableView.getColumn(i).title, titles[i]) + + tableView.destroy() + } + + function test_positionViewAtRow() { + var test_instanceStr = + 'import QtQuick 2.1; \ + import QtQuick.Controls 1.0; \ + TableView { \ + TableViewColumn { \ + } \ + model: 1000; \ + headerVisible: false; \ + }' + + var table = Qt.createQmlObject(test_instanceStr, testCase, '') + waitForRendering(table) + + var beginPos = table.mapFromItem(table.viewport, 0, 0) + + table.positionViewAtRow(0, ListView.Beginning) + compare(table.rowAt(beginPos.x, beginPos.y), 0) + + table.positionViewAtRow(100, ListView.Beginning) + compare(table.rowAt(beginPos.x, beginPos.y), 100) + + var endPos = table.mapFromItem(table.viewport, 0, table.viewport.height - 1) + + table.positionViewAtRow(900, ListView.End) + compare(table.rowAt(endPos.x, endPos.y), 900) + + table.positionViewAtRow(999, ListView.End) + compare(table.rowAt(endPos.x, endPos.y), 999) + + table.destroy() + } + // In TableView, drawn text = table.__currentRowItem.children[1].children[1].itemAt(0).children[0].children[0].text function findAChild(item, name) diff --git a/tests/auto/controls/data/tst_tabview.qml b/tests/auto/controls/data/tst_tabview.qml index 992baf22..8093ebc3 100644 --- a/tests/auto/controls/data/tst_tabview.qml +++ b/tests/auto/controls/data/tst_tabview.qml @@ -72,12 +72,12 @@ TestCase { function test_changeIndex() { var tabView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TabView { Repeater { model: 3; Tab { Text { text: index } } } }', testCase, ''); compare(tabView.count, 3) - verify(tabView.tabAt(1).item == undefined) + verify(tabView.getTab(1).item == undefined) tabView.currentIndex = 1 - verify(tabView.tabAt(1).item !== undefined) - verify(tabView.tabAt(2).item == undefined) + verify(tabView.getTab(1).item !== undefined) + verify(tabView.getTab(2).item == undefined) tabView.currentIndex = 1 - verify(tabView.tabAt(2).item !== undefined) + verify(tabView.getTab(2).item !== undefined) tabView.destroy() } @@ -89,36 +89,36 @@ TestCase { compare(tabView.count, 1) tabView.addTab("title 2", newTab) compare(tabView.count, 2) - compare(tabView.tabAt(0).title, "title 1") - compare(tabView.tabAt(1).title, "title 2") + compare(tabView.getTab(0).title, "title 1") + compare(tabView.getTab(1).title, "title 2") tabView.insertTab(1, "title 3") compare(tabView.count, 3) - compare(tabView.tabAt(0).title, "title 1") - compare(tabView.tabAt(1).title, "title 3") - compare(tabView.tabAt(2).title, "title 2") + compare(tabView.getTab(0).title, "title 1") + compare(tabView.getTab(1).title, "title 3") + compare(tabView.getTab(2).title, "title 2") tabView.insertTab(0, "title 4") compare(tabView.count, 4) - compare(tabView.tabAt(0).title, "title 4") - compare(tabView.tabAt(1).title, "title 1") - compare(tabView.tabAt(2).title, "title 3") - compare(tabView.tabAt(3).title, "title 2") + compare(tabView.getTab(0).title, "title 4") + compare(tabView.getTab(1).title, "title 1") + compare(tabView.getTab(2).title, "title 3") + compare(tabView.getTab(3).title, "title 2") tabView.removeTab(0) compare(tabView.count, 3) - compare(tabView.tabAt(0).title, "title 1") - compare(tabView.tabAt(1).title, "title 3") - compare(tabView.tabAt(2).title, "title 2") + compare(tabView.getTab(0).title, "title 1") + compare(tabView.getTab(1).title, "title 3") + compare(tabView.getTab(2).title, "title 2") tabView.removeTab(1) compare(tabView.count, 2) - compare(tabView.tabAt(0).title, "title 1") - compare(tabView.tabAt(1).title, "title 2") + compare(tabView.getTab(0).title, "title 1") + compare(tabView.getTab(1).title, "title 2") tabView.removeTab(1) compare(tabView.count, 1) - compare(tabView.tabAt(0).title, "title 1") + compare(tabView.getTab(0).title, "title 1") tabView.removeTab(0) compare(tabView.count, 0) @@ -172,7 +172,7 @@ TestCase { compare(tabView.count, titles.length) for (i = 0; i < tabView.count; ++i) - compare(tabView.tabAt(i).title, titles[i]) + compare(tabView.getTab(i).title, titles[i]) tabView.currentIndex = data.currentBefore tabView.moveTab(data.from, data.to) @@ -186,7 +186,7 @@ TestCase { compare(tabView.count, titles.length) for (i = 0; i < tabView.count; ++i) - compare(tabView.tabAt(i).title, titles[i]) + compare(tabView.getTab(i).title, titles[i]) tabView.destroy() } @@ -212,11 +212,11 @@ TestCase { var tabView = Qt.createQmlObject(test_tabView, testCase, '') // insertTab(), addTab(), createObject() and static Tab {} compare(tabView.count, 4) - compare(tabView.tabAt(0).title, "inserted") + compare(tabView.getTab(0).title, "inserted") var tab = tabView.tabComponent.createObject(tabView) compare(tabView.count, 5) - compare(tabView.tabAt(4).title, "dynamic") + compare(tabView.getTab(4).title, "dynamic") tab.destroy() wait(0) compare(tabView.count, 4) @@ -365,7 +365,7 @@ TestCase { waitForRendering(tab3) mouseClick(tab3, tab3.width/2, tab3.height/2) - verify(tab3.activeFocus) + verify(!tab3.activeFocus) verify(!textField.activeFocus) tabView.destroy() |