Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkVTKRenderWindowSizeTest.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include <vtkRenderWindow.h>
14 #include <vtkSmartPointer.h>
15 
16 #include "mitkTestingMacros.h"
17 
18 void CheckRWSize(int width, int height)
19 {
20  MITK_TEST_OUTPUT(<< "Requesting VTK render window of size " << width << "x" << height);
21  vtkSmartPointer<vtkRenderWindow> renderWindowVTK = vtkRenderWindow::New();
22  renderWindowVTK->SetSize(width, height);
23  renderWindowVTK->SetOffScreenRendering(1); // seems to be related to off-screen rendering (only?)
24 
25  int *renderWindowSize = renderWindowVTK->GetSize();
26 
27  MITK_TEST_CONDITION(renderWindowSize[0] >= width,
28  " Window is at least " << width << "px wide (actually:" << renderWindowSize[0] << ")");
29  MITK_TEST_CONDITION(renderWindowSize[1] >= height,
30  " Window is at least " << height << "px high (actually:" << renderWindowSize[1] << ")");
31 }
32 
50 int mitkVTKRenderWindowSizeTest(int /*argc*/, char * /*argv*/ [])
51 {
52  MITK_TEST_BEGIN("mitkVTKRenderWindowSizeTest")
53 
54  // some power of two default sizes
55  CheckRWSize(128, 128);
56  CheckRWSize(256, 256);
57  CheckRWSize(512, 512);
58 
59  // some other size
60  CheckRWSize(300, 200);
61  CheckRWSize(150, 243);
62 
64 }
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
#define MITK_TEST_OUTPUT(x)
Output some text.
#define MITK_TEST_CONDITION(COND, MSG)
int mitkVTKRenderWindowSizeTest(int, char *[])
void CheckRWSize(int width, int height)
and MITK_TEST_END()