ctkVTKScalarBarWidgetEventTranslatorPlayerTest1.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. // Qt includes
  15. #include <QAction>
  16. #include <QApplication>
  17. #include <QDebug>
  18. #include <QStandardItemModel>
  19. #include <QTimer>
  20. #include <QTreeView>
  21. // VTK includes
  22. #include <vtkScalarBarWidget.h>
  23. #include <vtkSmartPointer.h>
  24. // CTK includes
  25. #include "ctkCallback.h"
  26. #include "ctkConfig.h"
  27. #include "ctkVTKScalarBarWidget.h"
  28. #include "ctkEventTranslatorPlayerWidget.h"
  29. // STD includes
  30. #include <cstdlib>
  31. #include <iostream>
  32. namespace
  33. {
  34. //-----------------------------------------------------------------------------
  35. void checkFinalWidgetState(void* data)
  36. {
  37. ctkVTKScalarBarWidget* widget = reinterpret_cast<ctkVTKScalarBarWidget*>(data);
  38. CTKCOMPARE(widget->title(), "Test QtTesting");
  39. CTKCOMPARE(widget->labelsFormat(), "%-#6.3g..ghtkd");
  40. CTKCOMPARE(widget->maxNumberOfColors(), 25);
  41. CTKCOMPARE(widget->numberOfLabels(), 2);
  42. }
  43. }
  44. //-----------------------------------------------------------------------------
  45. int ctkVTKScalarBarWidgetEventTranslatorPlayerTest1(int argc, char * argv [] )
  46. {
  47. QApplication app(argc, argv);
  48. QString xmlDirectory = CTK_SOURCE_DIR "/Libs/Visualization/VTK/Widgets/Testing/Cpp/";
  49. // ------------------------
  50. ctkEventTranslatorPlayerWidget etpWidget;
  51. // Test case 1
  52. vtkSmartPointer<vtkScalarBarWidget> scalarBar =
  53. vtkSmartPointer<vtkScalarBarWidget>::New();
  54. ctkVTKScalarBarWidget widget;
  55. widget.setScalarBarWidget(scalarBar);
  56. widget.setScalarBarWidget(0);
  57. widget.setScalarBarWidget(scalarBar);
  58. etpWidget.addTestCase(&widget,
  59. xmlDirectory + "ctkVTKScalarBarWidgetEventTranslatorPlayerTest1.xml",
  60. &checkFinalWidgetState);
  61. // ------------------------
  62. if (!app.arguments().contains("-I"))
  63. {
  64. QTimer::singleShot(0, &etpWidget, SLOT(play()));
  65. }
  66. etpWidget.show();
  67. return app.exec();
  68. }