diff --git a/plugins/autotest/autotestunittests.cpp b/plugins/autotest/autotestunittests.cpp index 9582a23c68e..95bc954502f 100644 --- a/plugins/autotest/autotestunittests.cpp +++ b/plugins/autotest/autotestunittests.cpp @@ -205,19 +205,22 @@ void AutoTestUnitTests::testCodeParserGTest() QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished())); QVERIFY(parserSpy.wait(20000)); - QCOMPARE(m_model->gtestNamesCount(), 4); - QCOMPARE(m_model->parser()->gtestNamesAndSetsCount(), 9); // 9 == 3 + 2 + 2 + 2, see below + QCOMPARE(m_model->gtestNamesCount(), 6); + // 11 == 3 + 2 + 2 + 2 + 1 + 1, see below + QCOMPARE(m_model->parser()->gtestNamesAndSetsCount(), 11); - QMap expectedNamesAndSets; + QMultiMap expectedNamesAndSets; expectedNamesAndSets.insert(QStringLiteral("FactorialTest"), 3); expectedNamesAndSets.insert(QStringLiteral("FactorialTest_Iterative"), 2); expectedNamesAndSets.insert(QStringLiteral("Sum"), 2); expectedNamesAndSets.insert(QStringLiteral("QueueTest"), 2); + expectedNamesAndSets.insert(QStringLiteral("DummyTest"), 1); // used as parameterized test + expectedNamesAndSets.insert(QStringLiteral("DummyTest"), 1); // used as 'normal' test - QMap foundNamesAndSets = m_model->gtestNamesAndSets(); + QMultiMap foundNamesAndSets = m_model->gtestNamesAndSets(); QCOMPARE(expectedNamesAndSets.size(), foundNamesAndSets.size()); foreach (const QString &name, expectedNamesAndSets.keys()) - QCOMPARE(expectedNamesAndSets.value(name), foundNamesAndSets.value(name)); + QCOMPARE(expectedNamesAndSets.values(name), foundNamesAndSets.values(name)); // check also that no Qt related tests have been found QCOMPARE(m_model->autoTestsCount(), 0); diff --git a/plugins/autotest/autotestunittests.qrc b/plugins/autotest/autotestunittests.qrc index 96e5b05a31a..861f5c26654 100644 --- a/plugins/autotest/autotestunittests.qrc +++ b/plugins/autotest/autotestunittests.qrc @@ -50,5 +50,8 @@ unit_test/simple_gt/tests/tests.pro unit_test/simple_gt/simple_gt.pro unit_test/simple_gt/tests/gtest_dependency.pri + unit_test/simple_gt/tests/gt3/dummytest.h + unit_test/simple_gt/tests/gt3/gt3.pro + unit_test/simple_gt/tests/gt3/main.cpp diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp index b52a768ef2b..d6e4d1d724d 100644 --- a/plugins/autotest/testtreemodel.cpp +++ b/plugins/autotest/testtreemodel.cpp @@ -824,9 +824,9 @@ int TestTreeModel::gtestNamesCount() const return m_googleTestRootItem ? m_googleTestRootItem->childCount() : 0; } -QMap TestTreeModel::gtestNamesAndSets() const +QMultiMap TestTreeModel::gtestNamesAndSets() const { - QMap result; + QMultiMap result; if (m_googleTestRootItem) { for (int row = 0, count = m_googleTestRootItem->childCount(); row < count; ++row) { diff --git a/plugins/autotest/testtreemodel.h b/plugins/autotest/testtreemodel.h index 2f7f00a4e87..c8eefd042fc 100644 --- a/plugins/autotest/testtreemodel.h +++ b/plugins/autotest/testtreemodel.h @@ -70,7 +70,7 @@ public: int unnamedQuickTestsCount() const; int dataTagsCount() const; int gtestNamesCount() const; - QMap gtestNamesAndSets() const; + QMultiMap gtestNamesAndSets() const; #endif signals: diff --git a/plugins/autotest/unit_test/simple_gt/tests/gt3/dummytest.h b/plugins/autotest/unit_test/simple_gt/tests/gt3/dummytest.h new file mode 100644 index 00000000000..b8fac8e799d --- /dev/null +++ b/plugins/autotest/unit_test/simple_gt/tests/gt3/dummytest.h @@ -0,0 +1,37 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd +** All rights reserved. +** For any questions to The Qt Company, please use contact form at +** http://www.qt.io/contact-us +** +** 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 The Qt Company. +** +** If you have questions regarding the use of this file, please use +** contact form at http://www.qt.io/contact-us +** +****************************************************************************/ +#include + +#include + +class DummyTest : public ::testing::TestWithParam +{ +protected: + virtual void SetUp() { + m_str1 = QString::fromLatin1(GetParam()).toLower(); + + m_str2 = QString::fromLatin1(GetParam()).toUpper(); + + m_str3 = QString::fromLatin1(GetParam()).toHtmlEscaped(); + } + + QString m_str1; + QString m_str2; + QString m_str3; +}; diff --git a/plugins/autotest/unit_test/simple_gt/tests/gt3/gt3.pro b/plugins/autotest/unit_test/simple_gt/tests/gt3/gt3.pro new file mode 100644 index 00000000000..4830351f08f --- /dev/null +++ b/plugins/autotest/unit_test/simple_gt/tests/gt3/gt3.pro @@ -0,0 +1,12 @@ +include(../gtest_dependency.pri) + +TEMPLATE = app +CONFIG += qt console c++11 +CONFIG -= app_bundle + +HEADERS += \ + dummytest.h + +SOURCES += \ + main.cpp + diff --git a/plugins/autotest/unit_test/simple_gt/tests/gt3/main.cpp b/plugins/autotest/unit_test/simple_gt/tests/gt3/main.cpp new file mode 100644 index 00000000000..088506ec555 --- /dev/null +++ b/plugins/autotest/unit_test/simple_gt/tests/gt3/main.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd +** All rights reserved. +** For any questions to The Qt Company, please use contact form at +** http://www.qt.io/contact-us +** +** 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 The Qt Company. +** +** If you have questions regarding the use of this file, please use +** contact form at http://www.qt.io/contact-us +** +****************************************************************************/ +#include +#include + +#include "dummytest.h" + +using namespace testing; + +#include +#include + +static QMap testValues = { + { "DummyTest", + {QStringLiteral("dummytest"), QStringLiteral("DUMMYTEST"), QStringLiteral("DummyTest")} + }, + { "Hello World", + {QStringLiteral("hello world"), QStringLiteral("HELLO WORLD"), QStringLiteral("Hello World")} + }, + { "#include \n#include \"test.h\"", + {QStringLiteral("#include \n#include \"test.h\""), + QStringLiteral("#INCLUDE \n#INCLUDE \"TEST.H\""), + QStringLiteral("#include <QString>\n#include "test.h"") + } + } +}; + +static QMap testValuesSec = { + { "BlAh", + {QStringLiteral("blah"), QStringLiteral("BLAH"), QStringLiteral("BlAh")} + }, + { "", + {QStringLiteral(""), QStringLiteral(""), QStringLiteral("<html>")} + }, +}; + +INSTANTIATE_TEST_CASE_P(First, DummyTest, ::testing::ValuesIn(testValues.keys())); +INSTANTIATE_TEST_CASE_P(Second, DummyTest, ::testing::ValuesIn(testValuesSec.keys())); + +TEST_P(DummyTest, Easy) +{ + // total wrong usage, but this is for testing purpose + bool first = testValues.contains(GetParam()); + bool second = testValuesSec.contains(GetParam()); + QStringList expected; + if (first) + expected = testValues.value(GetParam()); + else if (second) + expected = testValuesSec.value(GetParam()); + else + FAIL(); + + ASSERT_EQ(3, expected.size()); + + EXPECT_EQ(m_str1, expected.at(0)); + EXPECT_EQ(m_str2, expected.at(1)); + EXPECT_EQ(m_str3, expected.at(2)); +} + +TEST(DummyTest, BlaBlubb) +{ + ASSERT_EQ(3, testValues.size()); +} + +int main(int argc, char *argv[]) +{ + InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/plugins/autotest/unit_test/simple_gt/tests/tests.pro b/plugins/autotest/unit_test/simple_gt/tests/tests.pro index 77f3621946d..424362adbdf 100644 --- a/plugins/autotest/unit_test/simple_gt/tests/tests.pro +++ b/plugins/autotest/unit_test/simple_gt/tests/tests.pro @@ -1,4 +1,5 @@ TEMPLATE = subdirs SUBDIRS += gt1 \ - gt2 + gt2 \ + gt3