ctkMatrixWidgetTest.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 <QApplication>
  16. #include <QString>
  17. #include <QTimer>
  18. // CTK includes
  19. #include "ctkMatrixWidget.h"
  20. #include "ctkTest.h"
  21. // ----------------------------------------------------------------------------
  22. class ctkMatrixWidgetTester: public QObject
  23. {
  24. Q_OBJECT
  25. private slots:
  26. void testUI();
  27. void testDecimals();
  28. };
  29. // ----------------------------------------------------------------------------
  30. void ctkMatrixWidgetTester::testUI()
  31. {
  32. ctkMatrixWidget matrix;
  33. matrix.setMinimum(-100.);
  34. matrix.setMaximum(100.);
  35. matrix.show();
  36. QTest::qWaitForWindowShown(&matrix);
  37. //qApp->exec();
  38. }
  39. // ----------------------------------------------------------------------------
  40. void ctkMatrixWidgetTester::testDecimals()
  41. {
  42. ctkMatrixWidget matrix;
  43. matrix.setDecimalsOption(
  44. ctkDoubleSpinBox::DecimalsByKey | ctkDoubleSpinBox::DecimalsByShortcuts );
  45. matrix.setDecimals(10);
  46. matrix.setValue(0, 0, 1.000000001);
  47. matrix.show();
  48. QTest::qWaitForWindowShown(&matrix);
  49. //qApp->exec();
  50. QCOMPARE(matrix.value(0, 0), 1.000000001);
  51. }
  52. // ----------------------------------------------------------------------------
  53. CTK_TEST_MAIN(ctkMatrixWidgetTest)
  54. #include "moc_ctkMatrixWidgetTest.cpp"