-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #12772 (GUI: information messages are shown even though informati…
…on tool button is deselected) (#6440)
- Loading branch information
Showing
7 changed files
with
203 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
add_subdirectory(cppchecklibrarydata) | ||
add_subdirectory(filelist) | ||
add_subdirectory(projectfile) | ||
# FIXME does not work in CI | ||
#add_subdirectory(resultstree) | ||
add_subdirectory(translationhandler) | ||
add_subdirectory(xmlreportv2) | ||
# TODO: add all tests to CTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
qt_wrap_cpp(test-resultstree_SRC testresultstree.h ${CMAKE_SOURCE_DIR}/gui/resultstree.h) | ||
add_custom_target(build-resultstree-deps SOURCES ${test-resultstree_SRC}) | ||
add_dependencies(gui-build-deps build-resultstree-deps) | ||
add_executable(test-resultstree | ||
${test-resultstree_SRC} | ||
testresultstree.cpp | ||
${CMAKE_SOURCE_DIR}/gui/resultstree.cpp | ||
${CMAKE_SOURCE_DIR}/gui/erroritem.cpp | ||
${CMAKE_SOURCE_DIR}/gui/showtypes.cpp | ||
${CMAKE_SOURCE_DIR}/gui/report.cpp | ||
${CMAKE_SOURCE_DIR}/gui/xmlreportv2.cpp | ||
) | ||
target_include_directories(test-resultstree PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/lib) | ||
target_compile_definitions(test-resultstree PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}") | ||
target_link_libraries(test-resultstree ${QT_CORE_LIB} ${QT_GUI_LIB} ${QT_WIDGETS_LIB} ${QT_TEST_LIB}) | ||
|
||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
# Q_UNUSED() in generated code | ||
target_compile_options_safe(test-resultstree -Wno-extra-semi-stmt) | ||
endif() | ||
|
||
if (REGISTER_GUI_TESTS) | ||
add_test(NAME test-resultstree COMMAND $<TARGET_FILE:test-resultstree>) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
TEMPLATE = app | ||
TARGET = test-resultstree | ||
DEPENDPATH += . | ||
INCLUDEPATH += . ../../../lib | ||
OBJECTS_DIR = ../../temp | ||
MOC_DIR = ../../temp | ||
|
||
QT += widgets core | ||
QT += testlib | ||
|
||
include(../common.pri) | ||
|
||
DEFINES += SRCDIR=\\\"$$PWD\\\" | ||
|
||
# tests | ||
SOURCES += testresultstree.cpp \ | ||
../../resultstree.cpp \ | ||
../../erroritem.cpp \ | ||
../../showtypes.cpp \ | ||
../../report.cpp \ | ||
../../xmlreportv2.cpp | ||
|
||
HEADERS += testresultstree.h \ | ||
../../resultstree.h \ | ||
../../erroritem.h \ | ||
../../showtypes.h \ | ||
../../report.h \ | ||
../../xmlreportv2.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* Cppcheck - A tool for static C/C++ code analysis | ||
* Copyright (C) 2007-2021 Cppcheck team. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "testresultstree.h" | ||
#include "resultstree.h" | ||
|
||
// headers that declare mocked functions/variables | ||
#include "applicationlist.h" | ||
#include "common.h" | ||
#include "threadhandler.h" | ||
#include "projectfile.h" | ||
#include "xmlreportv2.h" | ||
|
||
#include "cppcheck.h" | ||
#include "errorlogger.h" | ||
#include "path.h" | ||
#include "settings.h" | ||
|
||
#include <QtTest> | ||
|
||
// Mock GUI... | ||
ProjectFile *ProjectFile::mActiveProject; | ||
void ProjectFile::addSuppression(const SuppressionList::Suppression & /*unused*/) {} | ||
QString ProjectFile::getWarningTags(std::size_t /*unused*/) const { | ||
return QString(); | ||
} | ||
void ProjectFile::setWarningTags(std::size_t /*unused*/, const QString& /*unused*/) {} | ||
bool ProjectFile::write(const QString & /*unused*/) { | ||
return true; | ||
} | ||
std::string severityToString(Severity severity) { | ||
return std::to_string((int)severity); | ||
} | ||
int ApplicationList::getApplicationCount() const { | ||
return 0; | ||
} | ||
bool ThreadHandler::isChecking() const { | ||
return false; | ||
} | ||
Application& ApplicationList::getApplication(const int /*unused*/) { | ||
throw 1; | ||
} | ||
const Application& ApplicationList::getApplication(const int index) const { | ||
return mApplications.at(index); | ||
} | ||
QString getPath(const QString &type) { | ||
return "/" + type; | ||
} | ||
void setPath(const QString & /*unused*/, const QString & /*unused*/) {} | ||
QString XmlReport::quoteMessage(const QString &message) { | ||
return message; | ||
} | ||
QString XmlReport::unquoteMessage(const QString &message) { | ||
return message; | ||
} | ||
XmlReport::XmlReport(const QString& filename) : Report(filename) {} | ||
|
||
// Mock LIB... | ||
bool Path::isHeader(std::string const& /*unused*/) { | ||
return false; | ||
} | ||
const std::set<std::string> ErrorLogger::mCriticalErrorIds; | ||
std::string ErrorMessage::FileLocation::getfile(bool /*unused*/) const { | ||
return std::string(); | ||
} | ||
const char* CppCheck::version() { | ||
return "1.0"; | ||
} | ||
std::pair<std::string, std::string> Settings::getNameAndVersion(const std::string& /*unused*/) { | ||
throw 1; | ||
} | ||
Severity severityFromString(const std::string& severity) { | ||
return (Severity)std::stoi(severity); | ||
} | ||
|
||
// Test... | ||
|
||
void TestResultsTree::test1() const | ||
{ | ||
// #12772 : GUI: information messages are shown even though information tool button is deselected | ||
ResultsTree tree(nullptr); | ||
tree.showResults(ShowTypes::ShowType::ShowInformation, false); | ||
ErrorItem errorItem; | ||
errorItem.errorPath << QErrorPathItem(); | ||
errorItem.severity = Severity::information; | ||
tree.addErrorItem(errorItem); | ||
QCOMPARE(tree.isRowHidden(0,QModelIndex()), true); // Added item is hidden | ||
tree.showResults(ShowTypes::ShowType::ShowInformation, true); | ||
QCOMPARE(tree.isRowHidden(0,QModelIndex()), false); // Show item | ||
} | ||
|
||
QTEST_MAIN(TestResultsTree) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Cppcheck - A tool for static C/C++ code analysis | ||
* Copyright (C) 2007-2021 Cppcheck team. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <QObject> | ||
|
||
class TestResultsTree : public QObject { | ||
Q_OBJECT | ||
|
||
private slots: | ||
void test1() const; | ||
}; |