ctkConsoleTest.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 "ctkConfig.h"
  20. #include "ctkConsole.h"
  21. #include "ctkTest.h"
  22. // ----------------------------------------------------------------------------
  23. class ctkConsoleTester: public QObject
  24. {
  25. Q_OBJECT
  26. private slots:
  27. void testShow();
  28. void testRunFile();
  29. void testRunFile_data();
  30. };
  31. // ----------------------------------------------------------------------------
  32. void ctkConsoleTester::testShow()
  33. {
  34. ctkConsole console;
  35. console.show();
  36. #if (QT_VERSION >= 0x50000)
  37. QTest::qWaitForWindowActive(&console);
  38. #else
  39. QTest::qWaitForWindowShown(&console);
  40. #endif
  41. }
  42. // ----------------------------------------------------------------------------
  43. void ctkConsoleTester::testRunFile()
  44. {
  45. ctkConsole console;
  46. QFETCH(QString, file);
  47. console.runFile(file);
  48. }
  49. // ----------------------------------------------------------------------------
  50. void ctkConsoleTester::testRunFile_data()
  51. {
  52. QTest::addColumn<QString>("file");
  53. QTest::newRow("null") << QString();
  54. QTest::newRow("empty") << "";
  55. QTest::newRow("invalid") << " ";
  56. QTest::newRow(".") << ".";
  57. QTest::newRow("file")
  58. << QFileInfo(QDir(CTK_SOURCE_DIR), "README").absoluteFilePath();
  59. }
  60. // ----------------------------------------------------------------------------
  61. CTK_TEST_MAIN(ctkConsoleTest)
  62. #include "moc_ctkConsoleTest.cpp"