forked from qt-creator/qt-creator
AutoTest: Update unit test projects
Replaced deprecated API by nowadays recommended code. Add missing include. Change-Id: I4012ea3ada02cd874fe534ae45d6a1c37ccbdbc7 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
var FileInfo = loadExtension("qbs.FileInfo")
|
var FileInfo = require("qbs.FileInfo")
|
||||||
|
|
||||||
function getGTestDir(str) {
|
function getGTestDir(Qbs, str) {
|
||||||
if (!str) {
|
if (!str) {
|
||||||
if (qbs.hostOS.contains("linux"))
|
if (Qbs.hostOS.contains("linux"))
|
||||||
return "/usr/include/gtest";
|
return "/usr/include/gtest";
|
||||||
} else {
|
} else {
|
||||||
return FileInfo.joinPaths(str, "googletest");
|
return FileInfo.joinPaths(str, "googletest");
|
||||||
@@ -10,9 +10,9 @@ function getGTestDir(str) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGMockDir(str) {
|
function getGMockDir(Qbs, str) {
|
||||||
if (!str) {
|
if (!str) {
|
||||||
if (qbs.hostOS.contains("linux"))
|
if (Qbs.hostOS.contains("linux"))
|
||||||
return "/usr/include/gmock";
|
return "/usr/include/gmock";
|
||||||
} else {
|
} else {
|
||||||
return FileInfo.joinPaths(str, "googlemock");
|
return FileInfo.joinPaths(str, "googlemock");
|
||||||
@@ -20,29 +20,29 @@ function getGMockDir(str) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGTestAll(str) {
|
function getGTestAll(Qbs, str) {
|
||||||
var gtest = getGTestDir(str);
|
var gtest = getGTestDir(Qbs, str);
|
||||||
if (!gtest)
|
if (!gtest)
|
||||||
return [];
|
return [];
|
||||||
return [FileInfo.joinPaths(gtest, "src/gtest-all.cc")];
|
return [FileInfo.joinPaths(gtest, "src/gtest-all.cc")];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGMockAll(str) {
|
function getGMockAll(Qbs, str) {
|
||||||
var gmock = getGMockDir(str);
|
var gmock = getGMockDir(Qbs, str);
|
||||||
if (!gmock)
|
if (!gmock)
|
||||||
return [];
|
return [];
|
||||||
return [FileInfo.joinPaths(gmock, "src/gmock-all.cc")];
|
return [FileInfo.joinPaths(gmock, "src/gmock-all.cc")];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGTestIncludes(str) {
|
function getGTestIncludes(Qbs, str) {
|
||||||
var gtest = getGTestDir(str);
|
var gtest = getGTestDir(Qbs, str);
|
||||||
if (!gtest)
|
if (!gtest)
|
||||||
return [];
|
return [];
|
||||||
return [gtest, FileInfo.joinPaths(gtest, "include")];
|
return [gtest, FileInfo.joinPaths(gtest, "include")];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGMockIncludes(str) {
|
function getGMockIncludes(Qbs, str) {
|
||||||
var mock = getGMockDir(str);
|
var mock = getGMockDir(Qbs, str);
|
||||||
if (!mock)
|
if (!mock)
|
||||||
return [];
|
return [];
|
||||||
return [mock, FileInfo.joinPaths(mock, "include")];
|
return [mock, FileInfo.joinPaths(mock, "include")];
|
||||||
|
@@ -7,8 +7,8 @@ CppApplication {
|
|||||||
type: "application"
|
type: "application"
|
||||||
name: "googletest1"
|
name: "googletest1"
|
||||||
|
|
||||||
property string gtestDir: googleCommon.getGTestDir(project.googletestDir)
|
property string gtestDir: googleCommon.getGTestDir(qbs, project.googletestDir)
|
||||||
property string gmockDir: googleCommon.getGMockDir(project.googletestDir)
|
property string gmockDir: googleCommon.getGMockDir(qbs, project.googletestDir)
|
||||||
|
|
||||||
condition: {
|
condition: {
|
||||||
if (File.exists(gtestDir) && File.exists(gmockDir))
|
if (File.exists(gtestDir) && File.exists(gmockDir))
|
||||||
@@ -19,8 +19,8 @@ CppApplication {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpp.includePaths: [].concat(googleCommon.getGTestIncludes(project.googletestDir))
|
cpp.includePaths: [].concat(googleCommon.getGTestIncludes(qbs, project.googletestDir))
|
||||||
.concat(googleCommon.getGMockIncludes(project.googletestDir))
|
.concat(googleCommon.getGMockIncludes(qbs, project.googletestDir))
|
||||||
|
|
||||||
cpp.cxxLanguageVersion: "c++11"
|
cpp.cxxLanguageVersion: "c++11"
|
||||||
cpp.defines: ["GTEST_LANG_CXX11"]
|
cpp.defines: ["GTEST_LANG_CXX11"]
|
||||||
@@ -30,6 +30,6 @@ CppApplication {
|
|||||||
// own stuff
|
// own stuff
|
||||||
"further.cpp",
|
"further.cpp",
|
||||||
"main.cpp",
|
"main.cpp",
|
||||||
].concat(googleCommon.getGTestAll(project.googletestDir))
|
].concat(googleCommon.getGTestAll(qbs, project.googletestDir))
|
||||||
.concat(googleCommon.getGMockAll(project.googletestDir))
|
.concat(googleCommon.getGMockAll(qbs, project.googletestDir))
|
||||||
}
|
}
|
||||||
|
@@ -7,8 +7,8 @@ CppApplication {
|
|||||||
type: "application"
|
type: "application"
|
||||||
name: "googletest2"
|
name: "googletest2"
|
||||||
|
|
||||||
property string gtestDir: googleCommon.getGTestDir(project.googletestDir)
|
property string gtestDir: googleCommon.getGTestDir(qbs, project.googletestDir)
|
||||||
property string gmockDir: googleCommon.getGMockDir(project.googletestDir)
|
property string gmockDir: googleCommon.getGMockDir(qbs, project.googletestDir)
|
||||||
|
|
||||||
Depends { name: "Qt.core" }
|
Depends { name: "Qt.core" }
|
||||||
|
|
||||||
@@ -21,8 +21,8 @@ CppApplication {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpp.includePaths: [].concat(googleCommon.getGTestIncludes(project.googletestDir))
|
cpp.includePaths: [].concat(googleCommon.getGTestIncludes(qbs, project.googletestDir))
|
||||||
.concat(googleCommon.getGMockIncludes(project.googletestDir))
|
.concat(googleCommon.getGMockIncludes(qbs, project.googletestDir))
|
||||||
|
|
||||||
cpp.cxxLanguageVersion: "c++11"
|
cpp.cxxLanguageVersion: "c++11"
|
||||||
cpp.defines: ["GTEST_LANG_CXX11"]
|
cpp.defines: ["GTEST_LANG_CXX11"]
|
||||||
@@ -31,6 +31,6 @@ CppApplication {
|
|||||||
// own stuff
|
// own stuff
|
||||||
"queuetest.h",
|
"queuetest.h",
|
||||||
"main.cpp",
|
"main.cpp",
|
||||||
].concat(googleCommon.getGTestAll(project.googletestDir))
|
].concat(googleCommon.getGTestAll(qbs, project.googletestDir))
|
||||||
.concat(googleCommon.getGMockAll(project.googletestDir))
|
.concat(googleCommon.getGMockAll(qbs, project.googletestDir))
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
|
|
||||||
class QueueTest : public ::testing::Test
|
class QueueTest : public ::testing::Test
|
||||||
|
@@ -7,8 +7,8 @@ CppApplication {
|
|||||||
type: "application"
|
type: "application"
|
||||||
name: "googletest3"
|
name: "googletest3"
|
||||||
|
|
||||||
property string gtestDir: googleCommon.getGTestDir(project.googletestDir)
|
property string gtestDir: googleCommon.getGTestDir(qbs, project.googletestDir)
|
||||||
property string gmockDir: googleCommon.getGMockDir(project.googletestDir)
|
property string gmockDir: googleCommon.getGMockDir(qbs, project.googletestDir)
|
||||||
|
|
||||||
Depends { name: "Qt.core" }
|
Depends { name: "Qt.core" }
|
||||||
|
|
||||||
@@ -21,8 +21,8 @@ CppApplication {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpp.includePaths: [].concat(googleCommon.getGTestIncludes(project.googletestDir))
|
cpp.includePaths: [].concat(googleCommon.getGTestIncludes(qbs, project.googletestDir))
|
||||||
.concat(googleCommon.getGMockIncludes(project.googletestDir))
|
.concat(googleCommon.getGMockIncludes(qbs, project.googletestDir))
|
||||||
|
|
||||||
cpp.cxxLanguageVersion: "c++11"
|
cpp.cxxLanguageVersion: "c++11"
|
||||||
cpp.defines: ["GTEST_LANG_CXX11"]
|
cpp.defines: ["GTEST_LANG_CXX11"]
|
||||||
@@ -31,6 +31,6 @@ CppApplication {
|
|||||||
// own stuff
|
// own stuff
|
||||||
"dummytest.h",
|
"dummytest.h",
|
||||||
"main.cpp",
|
"main.cpp",
|
||||||
].concat(googleCommon.getGTestAll(project.googletestDir))
|
].concat(googleCommon.getGTestAll(qbs, project.googletestDir))
|
||||||
.concat(googleCommon.getGMockAll(project.googletestDir))
|
.concat(googleCommon.getGMockAll(qbs, project.googletestDir))
|
||||||
}
|
}
|
||||||
|
@@ -56,8 +56,8 @@ static QMap<const char *, QStringList> testValuesSec = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(First, DummyTest, ::testing::ValuesIn(testValues.keys()));
|
INSTANTIATE_TEST_SUITE_P(First, DummyTest, ::testing::ValuesIn(testValues.keys()));
|
||||||
INSTANTIATE_TEST_CASE_P(Second, DummyTest, ::testing::ValuesIn(testValuesSec.keys()));
|
INSTANTIATE_TEST_SUITE_P(Second, DummyTest, ::testing::ValuesIn(testValuesSec.keys()));
|
||||||
|
|
||||||
TEST_P(DummyTest, Easy)
|
TEST_P(DummyTest, Easy)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user