ctkConsoleEventTranslatorPlayerTest1.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. // CTK includes
  22. #include "ctkCallback.h"
  23. #include "ctkConfig.h"
  24. #include "ctkConsole.h"
  25. #include "ctkConsoleEventPlayer.h"
  26. #include "ctkConsoleEventTranslator.h"
  27. #include "ctkEventTranslatorPlayerWidget.h"
  28. // QtTesting includes
  29. #include "pqTestUtility.h"
  30. // STD includes
  31. #include <cstdlib>
  32. #include <iostream>
  33. namespace
  34. {
  35. //-----------------------------------------------------------------------------
  36. void checkFinalWidgetState(void* data)
  37. {
  38. ctkConsole* widget = reinterpret_cast<ctkConsole*>(data);
  39. Q_UNUSED(widget);
  40. }
  41. }
  42. //-----------------------------------------------------------------------------
  43. int ctkConsoleEventTranslatorPlayerTest1(int argc, char * argv [] )
  44. {
  45. QApplication app(argc, argv);
  46. QString xmlDirectory = CTK_SOURCE_DIR "/Libs/Widgets/Testing/Cpp/";
  47. // ------------------------
  48. ctkEventTranslatorPlayerWidget etpWidget;
  49. pqTestUtility* testUtility = new pqTestUtility(&etpWidget);
  50. etpWidget.setTestUtility(testUtility);
  51. etpWidget.addWidgetEventTranslator(new ctkConsoleEventTranslator());
  52. etpWidget.addWidgetEventPlayer(new ctkConsoleEventPlayer());
  53. // Test case 1
  54. ctkConsole* widget = new ctkConsole();
  55. etpWidget.addTestCase(widget,
  56. xmlDirectory + "ctkConsoleEventTranslatorPlayerTest1.xml",
  57. &checkFinalWidgetState);
  58. // ------------------------
  59. if (!app.arguments().contains("-I"))
  60. {
  61. QTimer::singleShot(0, &etpWidget, SLOT(play()));
  62. }
  63. etpWidget.show();
  64. return app.exec();
  65. }