diff options
Diffstat (limited to 'plugins/autotest/unit_test/mixed_atp/tests')
21 files changed, 601 insertions, 0 deletions
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/auto.pro b/plugins/autotest/unit_test/mixed_atp/tests/auto/auto.pro new file mode 100644 index 0000000000..cb4dc9ec32 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/auto.pro @@ -0,0 +1,15 @@ +TEMPLATE = subdirs + +SUBDIRS = \ + bench \ + dummy \ + gui + +greaterThan(QT_MAJOR_VERSION, 4) { + message("enabling quick tests") + SUBDIRS += quickauto \ + quickauto2 +} else { + message("quick tests disabled") +} + diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/bench/bench.pro b/plugins/autotest/unit_test/mixed_atp/tests/auto/bench/bench.pro new file mode 100644 index 0000000000..87f391f41d --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/bench/bench.pro @@ -0,0 +1,12 @@ +QT += testlib + +QT -= gui + +TARGET = tst_benchtest +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app + +SOURCES += tst_benchtest.cpp +DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/bench/tst_benchtest.cpp b/plugins/autotest/unit_test/mixed_atp/tests/auto/bench/tst_benchtest.cpp new file mode 100644 index 0000000000..1d968a0147 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/bench/tst_benchtest.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ +#include <QString> +#include <QtTest> + +class BenchTest : public QObject +{ + Q_OBJECT + +public: + BenchTest(); + +private Q_SLOTS: + void testCase1(); + void testCase1_data(); +}; + +BenchTest::BenchTest() +{ +} + +void BenchTest::testCase1() +{ + QFETCH(bool, localAware); + + QString str1 = QLatin1String("Hello World"); + QString str2 = QLatin1String("Hallo Welt"); + if (!localAware) { + QBENCHMARK { + str1 == str2; + } + } else { + QBENCHMARK { + str1.localeAwareCompare(str2) == 0; + } + } +} + +void BenchTest::testCase1_data() +{ + QTest::addColumn<bool>("localAware"); + QTest::newRow("localAware") << true; + QTest::newRow("simple") << false; +} + +QTEST_MAIN(BenchTest) + +#include "tst_benchtest.moc" diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/dummy.pro b/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/dummy.pro new file mode 100644 index 0000000000..40e95bcc39 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/dummy.pro @@ -0,0 +1,10 @@ +QT += testlib +QT += gui +CONFIG += qt warn_on depend_includepath testcase +TEMPLATE = app + +TARGET = tst_FooBar + +HEADERS += tst_foo.h +SOURCES += tst_foo.cpp + diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.cpp b/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.cpp new file mode 100644 index 0000000000..9dc2c9ec3a --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ +#include "tst_foo.h" +#include <QtTest> +#include <QCoreApplication> +#include <QDebug> + +Foo::Foo() +{ +} + +Foo::~Foo() +{ +} + +void Foo::initTestCase() +{ +} + +void Foo::cleanupTestCase() +{ + QWARN("Warning!"); +} + +void Foo::test_caseZero() +{ + QCOMPARE(1, 2); +} + +void Foo::test_case1() +{ + qDebug() << "test_case1"; + QFETCH(int, val); + + QEXPECT_FAIL("test2", "2", Continue); + QCOMPARE(val, 1); + QEXPECT_FAIL("test1", "bla", Abort); + QCOMPARE(val, 2); + QVERIFY2(true, "Hallo"); +} + +void Foo::test_case1_data() +{ + QTest::addColumn<int>("val"); + QTest::newRow("test1") << 1; + QTest::newRow("test2") << 2; + QTest::newRow("test3") << 3; + QTest::newRow("test4") << 4; +} + +void Foo::test_case2() +{ + QThread::sleep(1); + qDebug() << "test_case2 - all pass"; + QSKIP("Skip for now", SkipAll); + QCOMPARE(1 ,1); + QVERIFY(true); +} + +void Foo::test_case4() +{ + qDebug("äøæ"); + QSKIP("Skipping test_case4", SkipSingle); + QFAIL("bla"); +} + +QTEST_MAIN(Foo) diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.h b/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.h new file mode 100644 index 0000000000..29bb8f5f6e --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.h @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ +#ifndef FOO_H_INCLUDED +#define FOO_H_INCLUDED + +#include <QObject> + +class Foo : public QObject +{ + Q_OBJECT + +public: + Foo(); + ~Foo(); + +private slots: + void initTestCase(); + void cleanupTestCase(); + void test_case1(); + void test_case1_data(); + void test_caseZero(); + void test_case2(); +// void test_case3() {} + void test_case4(); + void test_case5() {} +}; + +#endif diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/gui/gui.pro b/plugins/autotest/unit_test/mixed_atp/tests/auto/gui/gui.pro new file mode 100644 index 0000000000..10f8f27eb8 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/gui/gui.pro @@ -0,0 +1,8 @@ +QT += testlib gui widgets + +TARGET = tst_guitest + +TEMPLATE = app + +SOURCES += tst_guitest.cpp +DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/gui/tst_guitest.cpp b/plugins/autotest/unit_test/mixed_atp/tests/auto/gui/tst_guitest.cpp new file mode 100644 index 0000000000..13d61ba151 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/gui/tst_guitest.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ +#include <QString> +#include <QtTest> +#include <QApplication> +#include <QLineEdit> + +class GuiTest : public QObject +{ + Q_OBJECT + +public: + GuiTest(); + +private Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); + void testCase1(); + void testGui_data(); + void testGui(); +}; + +GuiTest::GuiTest() +{ +} + +void GuiTest::initTestCase() +{ +} + +void GuiTest::cleanupTestCase() +{ +} + +void GuiTest::testCase1() +{ + QLatin1String str("Hello World"); + QLineEdit lineEdit; + QTest::keyClicks(&lineEdit, str); + QCOMPARE(lineEdit.text(), str); +} + +void GuiTest::testGui() +{ + QFETCH(QTestEventList, events); + QFETCH(QString, expected); + QLineEdit lineEdit; + events.simulate(&lineEdit); + QCOMPARE(lineEdit.text(), expected); +} + +void GuiTest::testGui_data() +{ + QTest::addColumn<QTestEventList>("events"); + QTest::addColumn<QString>("expected"); + + QTestEventList list1; + list1.addKeyClick('a'); + QTest::newRow("char") << list1 << "a"; + + QTestEventList list2; + list2.addKeyClick('a'); + list2.addKeyClick(Qt::Key_Backspace); + QTest::newRow("there and back again") << list2 << ""; +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + GuiTest gt; + return QTest::qExec(>, argc, argv); +} + +#include "tst_guitest.moc" diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/TestDummy.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/TestDummy.qml new file mode 100644 index 0000000000..ae30c81143 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/TestDummy.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import QtTest 1.0 + +TestCase { + name: "HalloBallo" + function test_bla() { + verify(true, "verifying true"); + } +} + diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/bar/tst_foo.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/bar/tst_foo.qml new file mode 100644 index 0000000000..ff825cd989 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/bar/tst_foo.qml @@ -0,0 +1,29 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ +import QtQuick 2.0 +import QtTest 1.0 + +TestCase { + name: "subdirTC" + + function test_blabla() { + compare(1, 2, "Bla"); + } + +} + diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/main.cpp b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/main.cpp new file mode 100644 index 0000000000..16a331e4cc --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/main.cpp @@ -0,0 +1,3 @@ +#include <QtQuickTest/quicktest.h> + +QUICK_TEST_MAIN(blob) diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/notlisted/tst_bla.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/notlisted/tst_bla.qml new file mode 100644 index 0000000000..325b7c4927 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/notlisted/tst_bla.qml @@ -0,0 +1,29 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ +import QtQuick 2.0 +import QtTest 1.0 + +TestCase { + name: "notlisted" + + function test_blablabla() { + compare(1, 2, "Blubb"); + } + +} + diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/quickauto.pro b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/quickauto.pro new file mode 100644 index 0000000000..dfe495dc1c --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/quickauto.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +TARGET = test_mal_qtquick + +CONFIG += warn_on qmltestcase + +DISTFILES += \ + tst_test1.qml \ + tst_test2.qml \ + TestDummy.qml \ + bar/tst_foo.qml \ + tst_test3.qml + +SOURCES += \ + main.cpp diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test1.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test1.qml new file mode 100644 index 0000000000..8bf1379dc9 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test1.qml @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ +import QtQuick 2.0 +import QtTest 1.0 + +TestCase { + name: "Banana" + + function test_math() { + compare(5 + 5, 10, "verifying 5 + 5 = 10"); + compare(10 - 5, 5, "verifying 10 - 5 = 5"); + } + + function test_fail() { + verify(false, "verifying false"); + } +} + diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test2.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test2.qml new file mode 100644 index 0000000000..c9a7f5286b --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test2.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ +import QtQuick 2.0 +import QtTest 1.0 + +TestCase { + function test_str() { + var bla = String(); + bla = bla.concat("Hallo", " ", "Welt"); + var blubb = String("Hallo Welt"); + compare(blubb, bla, "Comparing concat"); + verify(blubb == bla, "Comparing concat equality") + } + +// nested TestCases actually fail +// TestCase { +// name: "boo" + +// function test_boo() { +// verify(true); +// } + +// TestCase { +// name: "far" + +// function test_far() { +// verify(true); +// } +// } +// } +} + diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test3.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test3.qml new file mode 100644 index 0000000000..3575c6b313 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test3.qml @@ -0,0 +1,30 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ +import QtQuick 2.0 +import QtTest 1.0 + +TestCase { + function test_bolle() { + verify(true, "verifying true"); + } + + function test_str() { + compare("hallo", "hallo"); + } +} + diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/main.cpp b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/main.cpp new file mode 100644 index 0000000000..e496b3eb65 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/main.cpp @@ -0,0 +1,3 @@ +#include <QtQuickTest/quicktest.h> + +QUICK_TEST_MAIN(blob2) diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/quickauto2.pro b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/quickauto2.pro new file mode 100644 index 0000000000..61c76d1562 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/quickauto2.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = test_mal_qtquick + +CONFIG += warn_on qmltestcase + +DISTFILES += \ + tst_test1.qml \ + tst_test2.qml + +SOURCES += \ + main.cpp diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test1.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test1.qml new file mode 100644 index 0000000000..8bf1379dc9 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test1.qml @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ +import QtQuick 2.0 +import QtTest 1.0 + +TestCase { + name: "Banana" + + function test_math() { + compare(5 + 5, 10, "verifying 5 + 5 = 10"); + compare(10 - 5, 5, "verifying 10 - 5 = 5"); + } + + function test_fail() { + verify(false, "verifying false"); + } +} + diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test2.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test2.qml new file mode 100644 index 0000000000..a72913a84e --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test2.qml @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ +import QtQuick 2.0 +import QtTest 1.0 + +Rectangle { + TestCase { + name: "nestedTC" + + function test_str() { + var bla = String(); + bla = bla.concat("Hello", " ", "World"); + var blubb = String("Hello World"); + compare(blubb, bla, "Comparing concat"); + verify(blubb == bla, "Comparing concat equality") + } + } +} diff --git a/plugins/autotest/unit_test/mixed_atp/tests/tests.pro b/plugins/autotest/unit_test/mixed_atp/tests/tests.pro new file mode 100644 index 0000000000..f1633f70c9 --- /dev/null +++ b/plugins/autotest/unit_test/mixed_atp/tests/tests.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs + +SUBDIRS += auto + |