From dadca9e62d3db831c24bdb5d70515adc2617f0b2 Mon Sep 17 00:00:00 2001
From: Caroline Chao <caroline.chao@digia.com>
Date: Thu, 10 Jan 2013 16:01:22 +0100
Subject: [PATCH] Add first autotests for TableView

Testing behavior when using qml and c++ based models. Autotests
based on manual test: tableviewmodels.

Make the tree currentItem available from TableView. Add also
object names for testing purpose.

Including the use of a plugin. The plugin can be used to load other
cpp code needed while testing.

The plugin testplugin will go under qml/QtDesktopTest.

Change-Id: I76e66f35296c6142764bb6027ed9ee49ca50e47b
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
---
 src/qtdesktop/TableView.qml                   |   2 +
 tests/auto/auto.pro                           |   2 +-
 .../data/tableview/table1_qobjectmodel.qml    |  52 ++++++
 .../tableview/table2_qabstractitemmodel.qml   |  52 ++++++
 .../data/tableview/table3_qobjectlist.qml     |  52 ++++++
 .../data/tableview/table4_qstringlist.qml     |  51 ++++++
 .../data/tableview/table5_listmodel.qml       |  56 ++++++
 .../data/tableview/table6_countmodel.qml      |  50 ++++++
 .../data/tableview/table7_arraymodel.qml      |  50 ++++++
 .../data/tableview/table8_itemmodel.qml       |  51 ++++++
 tests/auto/qtdesktop/data/tst_tableview.qml   | 169 ++++++++++++++++++
 tests/auto/qtdesktop/qtdesktop.pro            |  17 +-
 tests/auto/testplugin/qmldir                  |   2 +
 tests/auto/testplugin/testcppmodels.h         | 102 +++++++++++
 tests/auto/testplugin/testplugin.cpp          |  68 +++++++
 tests/auto/testplugin/testplugin.h            |  56 ++++++
 tests/auto/testplugin/testplugin.json         |   1 +
 tests/auto/testplugin/testplugin.pro          |  31 ++++
 18 files changed, 859 insertions(+), 5 deletions(-)
 create mode 100644 tests/auto/qtdesktop/data/tableview/table1_qobjectmodel.qml
 create mode 100644 tests/auto/qtdesktop/data/tableview/table2_qabstractitemmodel.qml
 create mode 100644 tests/auto/qtdesktop/data/tableview/table3_qobjectlist.qml
 create mode 100644 tests/auto/qtdesktop/data/tableview/table4_qstringlist.qml
 create mode 100644 tests/auto/qtdesktop/data/tableview/table5_listmodel.qml
 create mode 100644 tests/auto/qtdesktop/data/tableview/table6_countmodel.qml
 create mode 100644 tests/auto/qtdesktop/data/tableview/table7_arraymodel.qml
 create mode 100644 tests/auto/qtdesktop/data/tableview/table8_itemmodel.qml
 create mode 100644 tests/auto/qtdesktop/data/tst_tableview.qml
 create mode 100644 tests/auto/testplugin/qmldir
 create mode 100644 tests/auto/testplugin/testcppmodels.h
 create mode 100644 tests/auto/testplugin/testplugin.cpp
 create mode 100644 tests/auto/testplugin/testplugin.h
 create mode 100644 tests/auto/testplugin/testplugin.json
 create mode 100644 tests/auto/testplugin/testplugin.pro

diff --git a/src/qtdesktop/TableView.qml b/src/qtdesktop/TableView.qml
index 019a0ef06..ff4e3ec69 100644
--- a/src/qtdesktop/TableView.qml
+++ b/src/qtdesktop/TableView.qml
@@ -139,6 +139,7 @@ FocusScope{
     default property alias header: tree.columnheader
     property alias contentHeader: tree.header
     property alias contentFooter: tree.footer
+    property alias currentItem: tree.currentItem
 
     property alias horizontalScrollBar: scroller.horizontalScrollBar
     property alias verticalScrollBar: scroller.verticalScrollBar
@@ -168,6 +169,7 @@ FocusScope{
             property int implicitWidth: sizehint.paintedWidth + 4
             Text {
                 id: label
+                objectName: "label"
                 width: parent.width
                 anchors.margins: 6
                 font: itemstyle.font
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index e51392c4b..7f65bddf0 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,2 +1,2 @@
 TEMPLATE = subdirs
-SUBDIRS += qtdesktop
+SUBDIRS += qtdesktop testplugin
diff --git a/tests/auto/qtdesktop/data/tableview/table1_qobjectmodel.qml b/tests/auto/qtdesktop/data/tableview/table1_qobjectmodel.qml
new file mode 100644
index 000000000..60d95553d
--- /dev/null
+++ b/tests/auto/qtdesktop/data/tableview/table1_qobjectmodel.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Components project.
+**
+** $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.0
+import QtDesktop 1.0
+import QtDesktopTest 1.0
+
+TableView {
+    model: TestObject {}
+    height: 70
+    TableColumn {
+        role: "value"
+        width: 100
+    }
+}
diff --git a/tests/auto/qtdesktop/data/tableview/table2_qabstractitemmodel.qml b/tests/auto/qtdesktop/data/tableview/table2_qabstractitemmodel.qml
new file mode 100644
index 000000000..4e9efaf64
--- /dev/null
+++ b/tests/auto/qtdesktop/data/tableview/table2_qabstractitemmodel.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Components project.
+**
+** $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.0
+import QtDesktop 1.0
+import QtDesktopTest 1.0
+
+TableView {
+    model: TestItemModel {}
+    height: 70
+    TableColumn {
+        role: "test"
+        width: 100
+    }
+}
diff --git a/tests/auto/qtdesktop/data/tableview/table3_qobjectlist.qml b/tests/auto/qtdesktop/data/tableview/table3_qobjectlist.qml
new file mode 100644
index 000000000..8ffb126f6
--- /dev/null
+++ b/tests/auto/qtdesktop/data/tableview/table3_qobjectlist.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Components project.
+**
+** $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.0
+import QtDesktop 1.0
+import QtDesktopTest 1.0
+
+TableView {
+    model: model_qobjectlist
+    height: 70
+    TableColumn {
+        role: "value"
+        width: 100
+    }
+}
diff --git a/tests/auto/qtdesktop/data/tableview/table4_qstringlist.qml b/tests/auto/qtdesktop/data/tableview/table4_qstringlist.qml
new file mode 100644
index 000000000..6733165e6
--- /dev/null
+++ b/tests/auto/qtdesktop/data/tableview/table4_qstringlist.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Components project.
+**
+** $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.0
+import QtDesktop 1.0
+import QtDesktopTest 1.0
+
+TableView {
+    model: model_qstringlist
+    height: 70
+    TableColumn {
+        width: 100
+    }
+}
diff --git a/tests/auto/qtdesktop/data/tableview/table5_listmodel.qml b/tests/auto/qtdesktop/data/tableview/table5_listmodel.qml
new file mode 100644
index 000000000..151fff4f9
--- /dev/null
+++ b/tests/auto/qtdesktop/data/tableview/table5_listmodel.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Components project.
+**
+** $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.0
+import QtDesktop 1.0
+
+TableView {
+
+    model:  ListModel {
+        ListElement { value: "A" }
+        ListElement { value: "B" }
+        ListElement { value: "C" }
+    } // qml
+    height: 70
+    TableColumn {
+        role: "value"
+        width: 100
+    }
+}
diff --git a/tests/auto/qtdesktop/data/tableview/table6_countmodel.qml b/tests/auto/qtdesktop/data/tableview/table6_countmodel.qml
new file mode 100644
index 000000000..3df45b479
--- /dev/null
+++ b/tests/auto/qtdesktop/data/tableview/table6_countmodel.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Components project.
+**
+** $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.0
+import QtDesktop 1.0
+
+TableView {
+    model: 3 // qml
+    height: 70
+    TableColumn {
+        width: 100
+    }
+}
diff --git a/tests/auto/qtdesktop/data/tableview/table7_arraymodel.qml b/tests/auto/qtdesktop/data/tableview/table7_arraymodel.qml
new file mode 100644
index 000000000..1c91528ef
--- /dev/null
+++ b/tests/auto/qtdesktop/data/tableview/table7_arraymodel.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Components project.
+**
+** $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.0
+import QtDesktop 1.0
+
+TableView {
+    model: ["A", "B", "C"] // qml
+    height: 70
+    TableColumn {
+        width: 100
+    }
+}
diff --git a/tests/auto/qtdesktop/data/tableview/table8_itemmodel.qml b/tests/auto/qtdesktop/data/tableview/table8_itemmodel.qml
new file mode 100644
index 000000000..0d2316683
--- /dev/null
+++ b/tests/auto/qtdesktop/data/tableview/table8_itemmodel.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Components project.
+**
+** $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.0
+import QtDesktop 1.0
+
+TableView {
+    model: Item { x: 10 }// qml
+    height: 70
+    TableColumn {
+        role: "x"
+        width: 100
+    }
+}
diff --git a/tests/auto/qtdesktop/data/tst_tableview.qml b/tests/auto/qtdesktop/data/tst_tableview.qml
new file mode 100644
index 000000000..fde2c24ef
--- /dev/null
+++ b/tests/auto/qtdesktop/data/tst_tableview.qml
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Components project.
+**
+** $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.0
+import QtTest 1.0
+import QtDesktop 1.0
+import QtDesktopTest 1.0
+
+TestCase {
+    id: testCase
+    name: "Tests_TableView"
+    when:windowShown
+    width:400
+    height:400
+
+    function test_usingqmlmodel_data() {
+        return [
+                    {tag: "listmodel", a: "tableview/table5_listmodel.qml", expected: "A"},
+                    {tag: "countmodel", a: "tableview/table6_countmodel.qml", expected: 0},
+                    {tag: "arraymodel", a: "tableview/table7_arraymodel.qml", expected: "A"},
+                    {tag: "itemmodel", a: "tableview/table8_itemmodel.qml", expected: 10},
+                ]
+    }
+
+    function test_usingqmlmodel(data) {
+
+        var component = Qt.createComponent(data.a)
+        compare(component.status, Component.Ready)
+        var table =  component.createObject(testCase);
+        verify(table !== null, "table created is null")
+        table.forceActiveFocus();
+
+        verify(table.currentItem !== undefined, "No current item found")
+        var label = findAChild(table.currentItem, "label")
+        verify(label !== undefined)
+        compare(label.text, data.expected.toString());
+    }
+
+    function test_usingcppqobjectmodel() {
+
+        var component = Qt.createComponent("tableview/table1_qobjectmodel.qml")
+        compare(component.status, Component.Ready)
+        var table =  component.createObject(testCase);
+        verify(table !== null, "table created is null")
+        table.forceActiveFocus();
+
+        // read data from the model directly
+        var valuefrommodel = table.model.value;
+        verify(valuefrommodel !== undefined, "The model has no defined value")
+
+        verify(table.currentItem !== undefined, "No current item found")
+        var label = findAChild(table.currentItem, "label")
+        verify(label !== undefined)
+        compare(label.text, valuefrommodel.toString());
+    }
+
+    function test_usingcppqabstractitemmodel() {
+
+        var component = Qt.createComponent("tableview/table2_qabstractitemmodel.qml")
+        compare(component.status, Component.Ready)
+        var table =  component.createObject(testCase);
+        verify(table !== null, "table created is null")
+        table.forceActiveFocus();
+
+        // to go to next row (this model has 10 rows)
+        table.incrementCurrentIndex()
+
+        // read data from the model directly
+        var valuefrommodel = table.model.dataAt(table.currentIndex)
+        verify(valuefrommodel !== undefined, "The model has no defined value")
+
+        verify(table.currentItem !== undefined, "No current item found")
+        var label = findAChild(table.currentItem, "label")
+        verify(label !== undefined)
+        compare(label.text, valuefrommodel.toString())
+    }
+
+    function test_usingcpplistmodel_data() {
+        return [
+                    {tag: "qobjectlistmodel", a: "tableview/table3_qobjectlist.qml", expected: 1},
+                    {tag: "qstringlistmodel", a: "tableview/table4_qstringlist.qml", expected: "B"},
+                ]
+    }
+
+    function test_usingcpplistmodel(data) {
+
+        var component = Qt.createComponent(data.a)
+        compare(component.status, Component.Ready)
+        var table =  component.createObject(testCase);
+        verify(table !== null, "table created is null")
+        table.forceActiveFocus();
+
+        // to go to next row (this model has 3 rows, read the second row)
+        table.incrementCurrentIndex()
+
+        verify(table.currentItem !== undefined, "No current item found")
+        var label = findAChild(table.currentItem, "label")
+        verify(label !== undefined)
+        compare(label.text, data.expected.toString());
+    }
+
+    // In TableView, drawn text = table.currentItem.children[1].children[1].itemAt(0).children[0].children[0].text
+
+    function findAChild(item, name)
+    {
+        if (item.count === undefined) {
+            var i = 0
+            while (item.children[i] !== undefined) {
+                var child = item.children[i]
+                if (child.objectName === name)
+                    return child
+                else {
+                    var found = findAChild(child, name)
+                    if (found !== undefined)
+                        return found
+                }
+                i++
+            }
+
+        } else { // item with count => columns
+            for (var j = 0; j < item.count ; j++) {
+                var tempitem = item.itemAt(j)
+                if (tempitem.objectName === name)
+                    return tempitem
+                var found = findAChild(tempitem, name)
+                if (found !== undefined)
+                    return found
+            }
+        }
+        return undefined // no matching child found
+    }
+}
diff --git a/tests/auto/qtdesktop/qtdesktop.pro b/tests/auto/qtdesktop/qtdesktop.pro
index c848d5aa0..90530d1eb 100644
--- a/tests/auto/qtdesktop/qtdesktop.pro
+++ b/tests/auto/qtdesktop/qtdesktop.pro
@@ -6,12 +6,21 @@ QT += widgets
 CONFIG += qmltestcase
 
 INCLUDEPATH += $$PWD/../../shared
-SOURCES += tst_qtdesktop.cpp
+SOURCES += $$PWD/tst_qtdesktop.cpp
 
-TESTDATA = data/*
+TESTDATA = $$PWD/data/*
 
 OTHER_FILES += \
-    data/tst_button.qml \
-    data/tst_spinbox.qml
+    $$PWD/data/tst_button.qml \
+    $$PWD/data/tst_spinbox.qml \
+    $$PWD/data/tst_tableview.qml \
+    $$PWD/data/tableview/table2_qabstractitemmodel.qml \
+    $$PWD/data/tableview/table1_qobjectmodel.qml \
+    $$PWD/data/tableview/table3_qobjectlist.qml \
+    $$PWD/data/tableview/table4_qstringlist.qml \
+    $$PWD/data/tableview/table8_itemmodel.qml \
+    $$PWD/data/tableview/table7_arraymodel.qml \
+    $$PWD/data/tableview/table6_countmodel.qml \
+    $$PWD/data/tableview/table5_listmodel.qml
 
 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/testplugin/qmldir b/tests/auto/testplugin/qmldir
new file mode 100644
index 000000000..8b6dadac2
--- /dev/null
+++ b/tests/auto/testplugin/qmldir
@@ -0,0 +1,2 @@
+module QtDesktopTest
+plugin testplugin
diff --git a/tests/auto/testplugin/testcppmodels.h b/tests/auto/testplugin/testcppmodels.h
new file mode 100644
index 000000000..92899e1cf
--- /dev/null
+++ b/tests/auto/testplugin/testcppmodels.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Components project.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef TESTCPPMODELS_H
+#define TESTCPPMODELS_H
+
+#include <QAbstractListModel>
+#include <QVariant>
+
+class TestObject : public QObject
+{
+    Q_OBJECT
+    Q_PROPERTY(int value READ value CONSTANT)
+
+public:
+    TestObject(int val = 0) : m_value(val) {}
+    int value() const { return m_value; }
+private:
+    int m_value;
+};
+
+class TestItemModel : public QAbstractListModel
+{
+    Q_OBJECT
+
+public:
+    explicit TestItemModel(QObject *parent = 0)
+        : QAbstractListModel(parent) {}
+
+    enum {
+        TestRole = Qt::UserRole + 1
+    };
+
+    Q_INVOKABLE QVariant dataAt(int index) const
+    {
+        return QString("Row %1").arg(index);
+    }
+
+    QVariant data(const QModelIndex &index, int role) const
+    {
+        if (role == TestRole)
+            return dataAt(index.row());
+        else
+            return QVariant();
+    }
+
+    int rowCount(const QModelIndex & /*parent*/) const
+    {
+        return 10;
+    }
+
+    QHash<int, QByteArray> roleNames() const
+    {
+        QHash<int, QByteArray> rn = QAbstractItemModel::roleNames();
+        rn[TestRole] = "test";
+        return rn;
+    }
+
+private:
+    QList<TestObject> m_testobject;
+};
+
+
+#endif // TESTCPPMODELS_H
+
diff --git a/tests/auto/testplugin/testplugin.cpp b/tests/auto/testplugin/testplugin.cpp
new file mode 100644
index 000000000..13a9e00e6
--- /dev/null
+++ b/tests/auto/testplugin/testplugin.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Components project.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtQml/qqml.h>
+#include <QQmlEngine>
+#include <QVariant>
+#include "testplugin.h"
+#include "testcppmodels.h"
+
+void TestPlugin::registerTypes(const char *uri)
+{
+    // cpp models
+    qmlRegisterType<TestObject>(uri, 1, 0, "TestObject");
+    qmlRegisterType<TestItemModel>(uri, 1, 0, "TestItemModel");
+}
+
+void TestPlugin::initializeEngine(QQmlEngine *engine, const char * /*uri*/)
+{
+    QObjectList model_qobjectlist;
+    model_qobjectlist << new TestObject(0);
+    model_qobjectlist << new TestObject(1);
+    model_qobjectlist << new TestObject(2);
+    engine->rootContext()->setContextProperty("model_qobjectlist", QVariant::fromValue(model_qobjectlist));
+
+    QStringList model_qstringlist;
+    model_qstringlist << QStringLiteral("A");
+    model_qstringlist << QStringLiteral("B");
+    model_qstringlist << QStringLiteral("C");
+    engine->rootContext()->setContextProperty("model_qstringlist", model_qstringlist);
+
+}
diff --git a/tests/auto/testplugin/testplugin.h b/tests/auto/testplugin/testplugin.h
new file mode 100644
index 000000000..ee0d58ac9
--- /dev/null
+++ b/tests/auto/testplugin/testplugin.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Components project.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef TESTPLUGIN_H
+#define TESTPLUGIN_H
+
+#include <QQmlExtensionPlugin>
+#include <QQmlContext>
+
+class TestPlugin : public QQmlExtensionPlugin
+{
+    Q_OBJECT
+    Q_PLUGIN_METADATA(IID "org.qt-project.playground.qtdesktopcomponents.QQmlExtensionInterface" FILE "testplugin.json")
+public:
+    void registerTypes(const char *uri);
+    void initializeEngine(QQmlEngine *engine, const char *uri);
+};
+
+#endif // TESTPLUGIN_H
diff --git a/tests/auto/testplugin/testplugin.json b/tests/auto/testplugin/testplugin.json
new file mode 100644
index 000000000..0967ef424
--- /dev/null
+++ b/tests/auto/testplugin/testplugin.json
@@ -0,0 +1 @@
+{}
diff --git a/tests/auto/testplugin/testplugin.pro b/tests/auto/testplugin/testplugin.pro
new file mode 100644
index 000000000..aab9427fa
--- /dev/null
+++ b/tests/auto/testplugin/testplugin.pro
@@ -0,0 +1,31 @@
+CXX_MODULE = qml
+TARGET  = testplugin
+TARGETPATH = QtDesktopTest
+
+QT += qml quick widgets
+
+OTHER_FILES += \
+    $$PWD/testplugin.json \
+    $$PWD/qmldir
+
+SOURCES += \
+    $$PWD/testplugin.cpp
+
+HEADERS += \
+    $$PWD/testplugin.h \
+    $$PWD/testcppmodels.h
+
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+mac {
+    LIBS += -framework Carbon
+}
+
+load(qml_plugin)
+
+qmldir_path = $$PWD$${QMAKE_DIR_SEP}qmldir
+win*: qmldir_path = $$replace(qmldir_path, /, \\)
+destdir_path = $$DESTDIR
+win*: destdir_path = $$replace(destdir_path, /, \\)
+
+QMAKE_POST_LINK = $(MAKE) -f $(MAKEFILE) install
-- 
GitLab