summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/image/qicoimageformat/icons/valid/yellow.curbin0 -> 4286 bytes
-rw-r--r--tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp19
-rw-r--r--tests/auto/tools/rcc/data/images/images.expected39
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp163
-rw-r--r--tests/manual/widgets/itemviews/itemviews.pro2
-rw-r--r--tests/manual/widgets/itemviews/tableview-span-navigation/main.cpp67
-rw-r--r--tests/manual/widgets/itemviews/tableview-span-navigation/tableview-span-navigation.pro8
7 files changed, 276 insertions, 22 deletions
diff --git a/tests/auto/gui/image/qicoimageformat/icons/valid/yellow.cur b/tests/auto/gui/image/qicoimageformat/icons/valid/yellow.cur
new file mode 100644
index 0000000000..0a649aa7f7
--- /dev/null
+++ b/tests/auto/gui/image/qicoimageformat/icons/valid/yellow.cur
Binary files differ
diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
index cd9d4b448e..71adbabb84 100644
--- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
+++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
@@ -111,9 +111,17 @@ void tst_QIcoImageFormat::cleanupTestCase()
void tst_QIcoImageFormat::format()
{
- QImageReader reader(m_IconPath + "/valid/35FLOPPY.ICO", "ico");
- QByteArray fmt = reader.format();
- QCOMPARE(const_cast<const char*>(fmt.data()), "ico" );
+ {
+ QImageReader reader(m_IconPath + "/valid/35FLOPPY.ICO", "ico");
+ QByteArray fmt = reader.format();
+ QCOMPARE(const_cast<const char*>(fmt.data()), "ico" );
+ }
+
+ {
+ QImageReader reader(m_IconPath + "/valid/yellow.cur", "ico");
+ QByteArray fmt = reader.format();
+ QCOMPARE(const_cast<const char*>(fmt.data()), "ico" );
+ }
}
void tst_QIcoImageFormat::canRead_data()
@@ -133,6 +141,7 @@ void tst_QIcoImageFormat::canRead_data()
QTest::newRow("103x16px, 24BPP") << "valid/trolltechlogo_tiny.ico" << 1;
QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 1;
QTest::newRow("PNG compression") << "valid/Qt.ico" << 1;
+ QTest::newRow("CUR file") << "valid/yellow.cur" << 1;
}
void tst_QIcoImageFormat::canRead()
@@ -203,7 +212,7 @@ void tst_QIcoImageFormat::imageCount_data()
QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << 0;
QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9;
QTest::newRow("PNG compression") << "valid/Qt.ico" << 4;
-
+ QTest::newRow("CUR file") << "valid/yellow.cur" << 1;
}
void tst_QIcoImageFormat::imageCount()
@@ -231,6 +240,7 @@ void tst_QIcoImageFormat::jumpToNextImage_data()
QTest::newRow("16px16c, 32px32c, 32px256c 2") << "valid/WORLDH.ico" << 3;
QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9;
QTest::newRow("PNG compression") << "valid/Qt.ico" << 4;
+ QTest::newRow("CUR file") << "valid/yellow.cur" << 1;
}
void tst_QIcoImageFormat::jumpToNextImage()
@@ -281,6 +291,7 @@ void tst_QIcoImageFormat::nextImageDelay_data()
QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << -1;
QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9;
QTest::newRow("PNG compression") << "valid/Qt.ico" << 4;
+ QTest::newRow("CUR file") << "valid/yellow.cur" << 1;
}
void tst_QIcoImageFormat::nextImageDelay()
diff --git a/tests/auto/tools/rcc/data/images/images.expected b/tests/auto/tools/rcc/data/images/images.expected
index 9334443ccc..2577b6319b 100644
--- a/tests/auto/tools/rcc/data/images/images.expected
+++ b/tests/auto/tools/rcc/data/images/images.expected
@@ -1,13 +1,11 @@
/****************************************************************************
** Resource object code
**
-IGNORE: ** Created by: The Resource Compiler for Qt version 5.0.0
+IGNORE: ** Created by: The Resource Compiler for Qt version 5.3.1
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
-#include <QtCore/qglobal.h>
-
static const unsigned char qt_resource_data[] = {
IGNORE: // /dev/qt5/qtbase/tests/auto/tools/rcc/data/images/images/circle.png
0x0,0x0,0x0,0xa5,
@@ -94,16 +92,29 @@ static const unsigned char qt_resource_struct[] = {
};
-QT_BEGIN_NAMESPACE
+#ifdef QT_NAMESPACE
+# define QT_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
+# define QT_MANGLE_NAMESPACE0(x) x
+# define QT_MANGLE_NAMESPACE1(a, b) a##_##b
+# define QT_MANGLE_NAMESPACE2(a, b) QT_MANGLE_NAMESPACE1(a,b)
+# define QT_MANGLE_NAMESPACE(name) QT_MANGLE_NAMESPACE2( \
+ QT_MANGLE_NAMESPACE0(name), QT_MANGLE_NAMESPACE0(QT_NAMESPACE))
+#else
+# define QT_PREPEND_NAMESPACE(name) name
+# define QT_MANGLE_NAMESPACE(name) name
+#endif
-extern Q_CORE_EXPORT bool qRegisterResourceData
- (int, const unsigned char *, const unsigned char *, const unsigned char *);
+#ifdef QT_NAMESPACE
+namespace QT_NAMESPACE {
+#endif
-extern Q_CORE_EXPORT bool qUnregisterResourceData
- (int, const unsigned char *, const unsigned char *, const unsigned char *);
+bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
-QT_END_NAMESPACE
+bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
+#ifdef QT_NAMESPACE
+}
+#endif
int QT_MANGLE_NAMESPACE(qInitResources)()
{
@@ -112,8 +123,6 @@ int QT_MANGLE_NAMESPACE(qInitResources)()
return 1;
}
-Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources))
-
int QT_MANGLE_NAMESPACE(qCleanupResources)()
{
QT_PREPEND_NAMESPACE(qUnregisterResourceData)
@@ -121,5 +130,9 @@ int QT_MANGLE_NAMESPACE(qCleanupResources)()
return 1;
}
-Q_DESTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qCleanupResources))
-
+namespace {
+ struct initializer {
+ initializer() { QT_MANGLE_NAMESPACE(qInitResources)(); }
+ ~initializer() { QT_MANGLE_NAMESPACE(qCleanupResources)(); }
+ } dummy;
+}
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 38367fb4ee..33af273284 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -178,6 +178,8 @@ private slots:
void spansAfterColumnInsertion();
void spansAfterRowRemoval();
void spansAfterColumnRemoval();
+ void editSpanFromDirections_data();
+ void editSpanFromDirections();
void checkHeaderReset();
void checkHeaderMinSize();
@@ -1240,28 +1242,28 @@ void tst_QTableView::moveCursorStrikesBack_data()
<< IntList()
<< QRect(1, 2, 2, 3)
<< 2 << 0 << (IntList() << int(QtTestTableView::MoveNext))
- << 2 << 2;
+ << 2 << 1;
QTest::newRow("Span, anchor column disabled") << -1 << -1
<< IntList()
<< (IntList() << 1)
<< QRect(1, 2, 2, 3)
<< 2 << 0 << (IntList() << int(QtTestTableView::MoveNext))
- << 2 << 2;
+ << 2 << 1;
QTest::newRow("Span, anchor row hidden") << 2 << -1
<< IntList()
<< IntList()
<< QRect(1, 2, 2, 3)
<< 1 << 2 << (IntList() << int(QtTestTableView::MoveDown))
- << 3 << 2;
+ << 2 << 1;
QTest::newRow("Span, anchor row disabled") << -1 << -1
<< (IntList() << 2)
<< IntList()
<< QRect(1, 2, 2, 3)
<< 1 << 2 << (IntList() << int(QtTestTableView::MoveDown))
- << 3 << 2;
+ << 2 << 1;
QTest::newRow("Move through span right") << -1 << -1
<< IntList()
@@ -3278,6 +3280,159 @@ void tst_QTableView::spansAfterColumnRemoval()
VERIFY_SPANS_CONSISTENCY(&view);
}
+Q_DECLARE_METATYPE(Qt::Key)
+
+void tst_QTableView::editSpanFromDirections_data()
+{
+ QTest::addColumn<QList<Qt::Key> >("keyPresses");
+ QTest::addColumn<QSharedPointer<QStandardItemModel> >("model");
+ QTest::addColumn<int>("row");
+ QTest::addColumn<int>("column");
+ QTest::addColumn<int>("rowSpan");
+ QTest::addColumn<int>("columnSpan");
+ QTest::addColumn<QModelIndex>("expectedVisualCursorIndex");
+ QTest::addColumn<QModelIndex>("expectedEditedIndex");
+
+ /* x = the cell that should be edited
+ c = the cell that should actually be the current index
+ +---+---+
+ | | |
+ +---+---+
+ | | x |
+ +---+ +
+ | | c |
+ +---+---+
+ | | ^ |
+ +---+---+ */
+ QList<Qt::Key> keyPresses;
+ keyPresses << Qt::Key_Right << Qt::Key_PageDown << Qt::Key_Up;
+ QSharedPointer<QStandardItemModel> model(new QStandardItemModel(4, 2));
+ QTest::newRow("row span, bottom up")
+ << keyPresses << model << 1 << 1 << 2 << 1 << model->index(2, 1) << model->index(1, 1);
+
+ /* +---+---+
+ | | v |
+ +---+---+
+ | |x,c|
+ +---+ +
+ | | |
+ +---+---+
+ | | |
+ +---+---+ */
+ keyPresses.clear();
+ keyPresses << Qt::Key_Right << Qt::Key_Down;
+ model.reset(new QStandardItemModel(4, 2));
+ QTest::newRow("row span, top down")
+ << keyPresses << model << 1 << 1 << 2 << 1 << model->index(1, 1) << model->index(1, 1);
+
+ /* +---+---+---+
+ | | | |
+ +---+---+---+
+ | |x,c| < |
+ +---+ +---+
+ | | | |
+ +---+---+---+ */
+ keyPresses.clear();
+ keyPresses << Qt::Key_End << Qt::Key_Down << Qt::Key_Left;
+ model.reset(new QStandardItemModel(3, 3));
+ QTest::newRow("row span, right to left")
+ << keyPresses << model << 1 << 1 << 2 << 1 << model->index(1, 1) << model->index(1, 1);
+
+ /* +---+---+---+
+ | | | |
+ +---+---+---+
+ | | x | |
+ +---+ +---+
+ | > | c | |
+ +---+---+---+ */
+ keyPresses.clear();
+ keyPresses << Qt::Key_PageDown << Qt::Key_Right;
+ model.reset(new QStandardItemModel(3, 3));
+ QTest::newRow("row span, left to right")
+ << keyPresses << model << 1 << 1 << 2 << 1 << model->index(2, 1) << model->index(1, 1);
+
+ /* +---+---+---+
+ | | | |
+ +---+---+---+
+ |x,c |
+ +---+---+---+
+ | ^ | | |
+ +---+---+---+ */
+ keyPresses.clear();
+ keyPresses << Qt::Key_PageDown << Qt::Key_Up;
+ model.reset(new QStandardItemModel(3, 3));
+ QTest::newRow("col span, bottom up")
+ << keyPresses << model << 1 << 0 << 1 << 3 << model->index(1, 0) << model->index(1, 0);
+
+ /* +---+---+---+
+ | | | |
+ +---+---+---+
+ | x c |
+ +---+---+---+
+ | | ^ | |
+ +---+---+---+ */
+ keyPresses.clear();
+ keyPresses << Qt::Key_PageDown << Qt::Key_Right << Qt::Key_Up;
+ model.reset(new QStandardItemModel(3, 3));
+ QTest::newRow("col span, bottom up #2")
+ << keyPresses << model << 1 << 0 << 1 << 3 << model->index(1, 1) << model->index(1, 0);
+
+ /* +---+---+---+
+ | | | v |
+ +---+---+---+
+ | x c |
+ +---+---+---+
+ | | | |
+ +---+---+---+ */
+ keyPresses.clear();
+ keyPresses << Qt::Key_End << Qt::Key_Down;
+ model.reset(new QStandardItemModel(3, 3));
+ QTest::newRow("col span, top down")
+ << keyPresses << model << 1 << 0 << 1 << 3 << model->index(1, 2) << model->index(1, 0);
+}
+
+class TableViewWithCursorExposed : public QTableView
+{
+public:
+ TableViewWithCursorExposed() :
+ QTableView() {
+ }
+
+public:
+ QModelIndex visualCursorIndex() {
+ QTableViewPrivate *d = static_cast<QTableViewPrivate*>(qt_widget_private(this));
+ return d->model->index(d->visualCursor.y(), d->visualCursor.x());
+ }
+};
+
+void tst_QTableView::editSpanFromDirections()
+{
+ QFETCH(QList<Qt::Key>, keyPresses);
+ QFETCH(QSharedPointer<QStandardItemModel>, model);
+ QFETCH(int, row);
+ QFETCH(int, column);
+ QFETCH(int, rowSpan);
+ QFETCH(int, columnSpan);
+ QFETCH(QModelIndex, expectedVisualCursorIndex);
+ QFETCH(QModelIndex, expectedEditedIndex);
+
+ TableViewWithCursorExposed view;
+ view.setModel(model.data());
+ view.setSpan(row, column, rowSpan, columnSpan);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ foreach (Qt::Key key, keyPresses) {
+ QTest::keyClick(&view, key);
+ }
+ QCOMPARE(view.visualCursorIndex(), expectedVisualCursorIndex);
+ QCOMPARE(view.selectionModel()->currentIndex(), expectedEditedIndex);
+
+ QTest::keyClick(&view, Qt::Key_X);
+ QTest::keyClick(QApplication::focusWidget(), Qt::Key_Enter);
+ QTRY_COMPARE(view.model()->data(expectedEditedIndex).toString(), QLatin1String("x"));
+}
+
class Model : public QAbstractTableModel {
Q_OBJECT
diff --git a/tests/manual/widgets/itemviews/itemviews.pro b/tests/manual/widgets/itemviews/itemviews.pro
index 6b91531a87..53f658d54d 100644
--- a/tests/manual/widgets/itemviews/itemviews.pro
+++ b/tests/manual/widgets/itemviews/itemviews.pro
@@ -1,2 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS = delegate qheaderview qtreeview qtreewidget
+SUBDIRS = delegate qheaderview qtreeview qtreewidget tableview-span-navigation
diff --git a/tests/manual/widgets/itemviews/tableview-span-navigation/main.cpp b/tests/manual/widgets/itemviews/tableview-span-navigation/main.cpp
new file mode 100644
index 0000000000..8421d0661b
--- /dev/null
+++ b/tests/manual/widgets/itemviews/tableview-span-navigation/main.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module 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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QStandardItemModel>
+#include <QTableView>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QStandardItemModel model(4, 4);
+ QTableView tableView;
+ tableView.setSizeAdjustPolicy(QTableView::AdjustToContents);
+ tableView.setModel(&model);
+
+ for (int row = 0; row < model.rowCount(); ++row) {
+ for (int column = 0; column < model.columnCount(); ++column) {
+ QModelIndex index = model.index(row, column, QModelIndex());
+ model.setData(index, QVariant(QString("%1,%2").arg(row).arg(column)));
+ }
+ }
+
+ tableView.setSpan(1, 1, 2, 2);
+
+ tableView.show();
+
+ return app.exec();
+}
diff --git a/tests/manual/widgets/itemviews/tableview-span-navigation/tableview-span-navigation.pro b/tests/manual/widgets/itemviews/tableview-span-navigation/tableview-span-navigation.pro
new file mode 100644
index 0000000000..ffa006a2d8
--- /dev/null
+++ b/tests/manual/widgets/itemviews/tableview-span-navigation/tableview-span-navigation.pro
@@ -0,0 +1,8 @@
+
+TEMPLATE = app
+TARGET = tableview-span-navigation
+INCLUDEPATH += .
+
+QT += widgets
+
+SOURCES += main.cpp