ctkPushButtonTest.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 <QHBoxLayout>
  17. #include <QSignalSpy>
  18. #include <QTimer>
  19. #if (QT_VERSION < 0x50000)
  20. #include <QCleanlooksStyle>
  21. #endif
  22. // CTK includes
  23. #include "ctkPushButton.h"
  24. #include "ctkTest.h"
  25. //-----------------------------------------------------------------------------
  26. class ctkPushButtonTester : public QObject
  27. {
  28. Q_OBJECT
  29. private slots:
  30. void testDefaults();
  31. };
  32. // ----------------------------------------------------------------------------
  33. void ctkPushButtonTester::testDefaults()
  34. {
  35. #if (QT_VERSION < 0x50000)
  36. QApplication::setStyle( new QCleanlooksStyle );
  37. #endif
  38. ctkPushButton button("text");
  39. QCOMPARE(button.buttonTextAlignment(), Qt::AlignHCenter|Qt::AlignVCenter);
  40. QCOMPARE(button.iconAlignment(), Qt::AlignLeft|Qt::AlignVCenter);
  41. button.show();
  42. #if (QT_VERSION >= 0x50000)
  43. QTest::qWaitForWindowActive(&button);
  44. #else
  45. QTest::qWaitForWindowShown(&button);
  46. #endif
  47. //qApp->exec();
  48. }
  49. // ----------------------------------------------------------------------------
  50. CTK_TEST_MAIN(ctkPushButtonTest)
  51. #include "moc_ctkPushButtonTest.cpp"