mirror of
https://github.com/august-alt/gpui.git
synced 2025-02-01 13:47:04 +03:00
tests: add test for files widget
This commit is contained in:
parent
fdd762d0be
commit
d056d39212
28
tests/auto/plugins/preferences/files/CMakeLists.txt
Normal file
28
tests/auto/plugins/preferences/files/CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
find_package(Qt5 COMPONENTS Core Gui Widgets Test REQUIRED)
|
||||||
|
|
||||||
|
find_package(XercesC REQUIRED)
|
||||||
|
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
|
set(SOURCES
|
||||||
|
fileswidgettest.cpp
|
||||||
|
../../../../../src/plugins/preferences/files/fileswidget.cpp
|
||||||
|
../../../../../src/plugins/preferences/files/filesschema.cpp
|
||||||
|
../../../../../src/plugins/preferences/files/modelbuilder.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(UI_FORMS
|
||||||
|
../../../../../src/plugins/preferences/files/fileswidget.ui
|
||||||
|
)
|
||||||
|
|
||||||
|
set(MOC_HEADERS
|
||||||
|
fileswidgettest.h
|
||||||
|
../../../../../src/plugins/preferences/files/fileswidget.h
|
||||||
|
)
|
||||||
|
|
||||||
|
qt5_wrap_ui(UI_SOURCES ${UI_FORMS})
|
||||||
|
qt5_wrap_cpp(MOC_SOURCES ${MOC_HEADERS})
|
||||||
|
|
||||||
|
add_executable(fileswidgettest ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES})
|
||||||
|
target_link_libraries(fileswidgettest ${GPUI_LIBRARIES} files-plugin Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Test XercesC::XercesC)
|
||||||
|
add_gpui_test(plugins.fileswidgettest fileswidgettest)
|
60
tests/auto/plugins/preferences/files/fileswidgettest.cpp
Normal file
60
tests/auto/plugins/preferences/files/fileswidgettest.cpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/***********************************************************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
|
||||||
|
**
|
||||||
|
** 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 2
|
||||||
|
** 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, write to the Free Software
|
||||||
|
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
**
|
||||||
|
***********************************************************************************************************************/
|
||||||
|
|
||||||
|
#include "fileswidgettest.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include "../../../../../src/plugins/preferences/files/modelbuilder.h"
|
||||||
|
#include "../../../../../src/plugins/preferences/files/fileroles.h"
|
||||||
|
#include "../../../../../src/plugins/preferences/files/filesschema.h"
|
||||||
|
#include "../../../../../src/plugins/preferences/files/fileswidget.h"
|
||||||
|
|
||||||
|
const std::string dataPath = "../../../../data/";
|
||||||
|
|
||||||
|
namespace tests {
|
||||||
|
|
||||||
|
void FilesWidgetTest::show()
|
||||||
|
{
|
||||||
|
std::ifstream file;
|
||||||
|
|
||||||
|
file.open(dataPath + "files.xml", std::ifstream::in);
|
||||||
|
if (file.good()) {
|
||||||
|
auto modelSource = Files_(file, ::xsd::cxx::tree::flags::dont_validate);
|
||||||
|
auto modelBuilder = std::make_unique<gpui::ModelBuilder>();
|
||||||
|
auto model = modelBuilder->schemaToModel(modelSource);
|
||||||
|
|
||||||
|
auto selectionModel = std::make_unique<QItemSelectionModel>(model.get());
|
||||||
|
|
||||||
|
auto widget = std::make_unique<gpui::FilesWidget>(*model, *selectionModel);
|
||||||
|
widget->show();
|
||||||
|
|
||||||
|
selectionModel->setCurrentIndex(model->item(0, 0)->index(),
|
||||||
|
QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||||
|
|
||||||
|
QTest::qWait(10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QTEST_MAIN(tests::FilesWidgetTest)
|
36
tests/auto/plugins/preferences/files/fileswidgettest.h
Normal file
36
tests/auto/plugins/preferences/files/fileswidgettest.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/***********************************************************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
|
||||||
|
**
|
||||||
|
** 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 2
|
||||||
|
** 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, write to the Free Software
|
||||||
|
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
**
|
||||||
|
***********************************************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef GPUI_FILES_WIDGET_TEST_H
|
||||||
|
#define GPUI_FILES_WIDGET_TEST_H
|
||||||
|
|
||||||
|
#include <QtTest>
|
||||||
|
|
||||||
|
namespace tests {
|
||||||
|
class FilesWidgetTest : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void show();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GPUI_FILES_WIDGET_TEST_H
|
Loading…
x
Reference in New Issue
Block a user