diff --git a/src/Vtk/testing/CMakeLists.txt b/src/Vtk/testing/CMakeLists.txt index df717ea..324e41a 100644 --- a/src/Vtk/testing/CMakeLists.txt +++ b/src/Vtk/testing/CMakeLists.txt @@ -4,6 +4,7 @@ set(TESTS vtkHandlerWidget PuppetPropertyTest PuppetParentingTest + vtkQViewportTest # vtkVoxImageTest # vtkTriangleMeshTest ) diff --git a/src/Vtk/testing/vtkQViewportTest.cpp b/src/Vtk/testing/vtkQViewportTest.cpp new file mode 100644 index 0000000..2f36184 --- /dev/null +++ b/src/Vtk/testing/vtkQViewportTest.cpp @@ -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 +#include +#include + +#include +#include +#include +#include +#include +#include + +#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 cube = vtkSmartPointer::New(); + cube->SetXLength(10); + cube->SetYLength(10); + cube->SetZLength(10); + cube->Update(); + + vtkSmartPointer mapper = vtkSmartPointer::New(); + mapper->SetInputConnection(cube->GetOutputPort()); + + vtkSmartPointer actor = vtkSmartPointer::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; +}