test: add unit test for vtkQViewport and register in CMakeLists.txt
This commit is contained in:
@@ -4,6 +4,7 @@ set(TESTS
|
||||
vtkHandlerWidget
|
||||
PuppetPropertyTest
|
||||
PuppetParentingTest
|
||||
vtkQViewportTest
|
||||
# vtkVoxImageTest
|
||||
# vtkTriangleMeshTest
|
||||
)
|
||||
|
||||
86
src/Vtk/testing/vtkQViewportTest.cpp
Normal file
86
src/Vtk/testing/vtkQViewportTest.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <QApplication>
|
||||
#include <QtGlobal>
|
||||
#include <Vtk/vtkQViewport.h>
|
||||
|
||||
#include <vtkSmartPointer.h>
|
||||
#include <vtkCubeSource.h>
|
||||
#include <vtkPolyDataMapper.h>
|
||||
#include <vtkActor.h>
|
||||
#include <vtkProperty.h>
|
||||
#include <vtkRenderer.h>
|
||||
|
||||
#include "testing-prototype.h"
|
||||
|
||||
using namespace uLib;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// Force X11 on Linux to avoid Wayland connection issues in headless/X11 environments
|
||||
#if defined(Q_OS_LINUX)
|
||||
qputenv("QT_QPA_PLATFORM", "xcb");
|
||||
#endif
|
||||
|
||||
BEGIN_TESTING(vtk QViewport Test);
|
||||
|
||||
QApplication app(argc, argv);
|
||||
app.processEvents();
|
||||
|
||||
Vtk::QViewport viewport;
|
||||
viewport.resize(800, 600);
|
||||
viewport.show();
|
||||
|
||||
vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New();
|
||||
cube->SetXLength(10);
|
||||
cube->SetYLength(10);
|
||||
cube->SetZLength(10);
|
||||
cube->Update();
|
||||
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mapper->SetInputConnection(cube->GetOutputPort());
|
||||
|
||||
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
actor->GetProperty()->SetColor(1, 0, 0);
|
||||
|
||||
viewport.addProp(actor);
|
||||
viewport.Render();
|
||||
|
||||
ASSERT_NOT_NULL(viewport.GetRenderWindow());
|
||||
ASSERT_NOT_NULL(viewport.GetRenderer());
|
||||
|
||||
if (std::getenv("CTEST_PROJECT_NAME") == nullptr) {
|
||||
// Run application for a while to see the result
|
||||
// return app.exec();
|
||||
}
|
||||
|
||||
END_TESTING;
|
||||
}
|
||||
Reference in New Issue
Block a user