Skip to content
Snippets Groups Projects
Commit 5ec1faa6 authored by Christian Stenger's avatar Christian Stenger
Browse files

AutoTest: Provide additional test project...


...to also test combination of Qbs using Google Test.

Change-Id: I4a5d32a32bfaadd0dfaaa4884b58d2ac1a952bd3
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@theqtcompany.com>
parent f6bf3344
No related branches found
No related tags found
No related merge requests found
......@@ -194,9 +194,9 @@ void AutoTestUnitTests::testCodeParserGTest()
if (qgetenv("GOOGLETEST_DIR").isEmpty())
QSKIP("This test needs googletest - set GOOGLETEST_DIR (point to googletest repository)");
QFETCH(QString, projectFilePath);
CppTools::Tests::ProjectOpenerAndCloser projectManager;
CppTools::ProjectInfo projectInfo = projectManager.open(
QString(m_tmpDir->path() + QLatin1String("/simple_gt/simple_gt.pro")), true);
CppTools::ProjectInfo projectInfo = projectManager.open(projectFilePath, true);
QVERIFY(projectInfo.isValid());
QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished()));
......@@ -226,5 +226,14 @@ void AutoTestUnitTests::testCodeParserGTest()
QCOMPARE(m_model->dataTagsCount(), 0);
}
void AutoTestUnitTests::testCodeParserGTest_data()
{
QTest::addColumn<QString>("projectFilePath");
QTest::newRow("simpleGoogletest")
<< QString(m_tmpDir->path() + QLatin1String("/simple_gt/simple_gt.pro"));
QTest::newRow("simpleGoogletestQbs")
<< QString(m_tmpDir->path() + QLatin1String("/simple_gt/simple_gt.qbs"));
}
} // namespace Internal
} // namespace Autotest
......@@ -52,6 +52,7 @@ private slots:
void testCodeParserSwitchStartup();
void testCodeParserSwitchStartup_data();
void testCodeParserGTest();
void testCodeParserGTest_data();
private:
TestTreeModel *m_model;
......
......@@ -41,17 +41,24 @@
<file>unit_test/mixed_atp/tests/auto/quickauto2/quickauto2.qbs</file>
<file>unit_test/simple_gt/src/main.cpp</file>
<file>unit_test/simple_gt/src/src.pro</file>
<file>unit_test/simple_gt/src/src.qbs</file>
<file>unit_test/simple_gt/tests/gt1/further.cpp</file>
<file>unit_test/simple_gt/tests/gt1/gt1.pro</file>
<file>unit_test/simple_gt/tests/gt1/gt1.qbs</file>
<file>unit_test/simple_gt/tests/gt1/main.cpp</file>
<file>unit_test/simple_gt/tests/gt2/gt2.pro</file>
<file>unit_test/simple_gt/tests/gt2/gt2.qbs</file>
<file>unit_test/simple_gt/tests/gt2/main.cpp</file>
<file>unit_test/simple_gt/tests/gt2/queuetest.h</file>
<file>unit_test/simple_gt/tests/tests.pro</file>
<file>unit_test/simple_gt/tests/tests.qbs</file>
<file>unit_test/simple_gt/simple_gt.pro</file>
<file>unit_test/simple_gt/simple_gt.qbs</file>
<file>unit_test/simple_gt/tests/gtest_dependency.pri</file>
<file>unit_test/simple_gt/tests/gt3/dummytest.h</file>
<file>unit_test/simple_gt/tests/gt3/gt3.pro</file>
<file>unit_test/simple_gt/tests/gt3/gt3.qbs</file>
<file>unit_test/simple_gt/tests/gt3/main.cpp</file>
<file>unit_test/simple_gt/tests/common/functions.js</file>
</qresource>
</RCC>
import qbs
Project {
name: "Simple GT"
references: [
"src/src.qbs",
"tests/tests.qbs"
]
}
import qbs
CppApplication {
type: "application"
name: "Dummy application"
Depends { name: "Qt.core" }
files: [ "main.cpp" ]
}
var FileInfo = loadExtension("qbs.FileInfo")
function getGTestDir(str) {
if (!str) {
if (qbs.hostOS.contains("linux"))
return "/usr/include/gtest";
} else {
return FileInfo.joinPaths(str, "googletest");
}
return "";
}
function getGMockDir(str) {
if (!str) {
if (qbs.hostOS.contains("linux"))
return "/usr/include/gmock";
} else {
return FileInfo.joinPaths(str, "googlemock");
}
return "";
}
function getGTestAll(str) {
var gtest = getGTestDir(str);
if (!gtest)
return [];
return [FileInfo.joinPaths(gtest, "src/gtest-all.cc")];
}
function getGMockAll(str) {
var gmock = getGMockDir(str);
if (!gmock)
return [];
return [FileInfo.joinPaths(gmock, "src/gmock-all.cc")];
}
function getGTestIncludes(str) {
var gtest = getGTestDir(str);
if (!gtest)
return [];
return [gtest, FileInfo.joinPaths(gtest, "include")];
}
function getGMockIncludes(str) {
var mock = getGMockDir(str);
if (!mock)
return [];
return [mock, FileInfo.joinPaths(mock, "include")];
}
import qbs
import qbs.File
import qbs.FileInfo
import "../common/functions.js" as googleCommon
CppApplication {
type: "application"
name: "googletest1"
property string gtestDir: googleCommon.getGTestDir(project.googletestDir)
property string gmockDir: googleCommon.getGMockDir(project.googletestDir)
condition: {
if (File.exists(gtestDir) && File.exists(gmockDir))
return true;
console.error("Cannot find Google Test - specify environment variable GOOGLETEST_DIR "
+ "or qbs property " + project.name + ".googletestDir" );
return false;
}
cpp.includePaths: [].concat(googleCommon.getGTestIncludes(project.googletestDir))
.concat(googleCommon.getGMockIncludes(project.googletestDir))
cpp.cxxLanguageVersion: "c++11"
cpp.defines: ["GTEST_LANG_CXX11"]
cpp.dynamicLibraries: [ "pthread" ]
files: [
// own stuff
"further.cpp",
"main.cpp",
].concat(googleCommon.getGTestAll(project.googletestDir))
.concat(googleCommon.getGMockAll(project.googletestDir))
}
import qbs
import qbs.File
import qbs.FileInfo
import "../common/functions.js" as googleCommon
CppApplication {
type: "application"
name: "googletest2"
property string gtestDir: googleCommon.getGTestDir(project.googletestDir)
property string gmockDir: googleCommon.getGMockDir(project.googletestDir)
Depends { name: "Qt.core" }
condition: {
if (File.exists(gtestDir) && File.exists(gmockDir))
return true;
console.error("Cannot find Google Test - specify environment variable GOOGLETEST_DIR "
+ "or qbs property " + project.name + ".googletestDir" );
return false;
}
cpp.includePaths: [].concat(googleCommon.getGTestIncludes(project.googletestDir))
.concat(googleCommon.getGMockIncludes(project.googletestDir))
cpp.cxxLanguageVersion: "c++11"
cpp.defines: ["GTEST_LANG_CXX11"]
files: [
// own stuff
"queuetest.h",
"main.cpp",
].concat(googleCommon.getGTestAll(project.googletestDir))
.concat(googleCommon.getGMockAll(project.googletestDir))
}
import qbs
import qbs.File
import qbs.FileInfo
import "../common/functions.js" as googleCommon
CppApplication {
type: "application"
name: "googletest3"
property string gtestDir: googleCommon.getGTestDir(project.googletestDir)
property string gmockDir: googleCommon.getGMockDir(project.googletestDir)
Depends { name: "Qt.core" }
condition: {
if (File.exists(gtestDir) && File.exists(gmockDir))
return true;
console.error("Cannot find Google Test - specify environment variable GOOGLETEST_DIR "
+ "or qbs property " + project.name + ".googletestDir" );
return false;
}
cpp.includePaths: [].concat(googleCommon.getGTestIncludes(project.googletestDir))
.concat(googleCommon.getGMockIncludes(project.googletestDir))
cpp.cxxLanguageVersion: "c++11"
cpp.defines: ["GTEST_LANG_CXX11"]
files: [
// own stuff
"dummytest.h",
"main.cpp",
].concat(googleCommon.getGTestAll(project.googletestDir))
.concat(googleCommon.getGMockAll(project.googletestDir))
}
import qbs
import qbs.Environment
Project {
name: "Tests"
property string googletestDir: Environment.getEnv("GOOGLETEST_DIR")
references: [
"gt1/gt1.qbs",
"gt2/gt2.qbs",
"gt3/gt3.qbs"
]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment