TestControllerEfl.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (C) 2012 Samsung Electronics
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public License
  15. * along with this program; see the file COPYING.LIB. If not, write to
  16. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. #include "config.h"
  20. #include "TestController.h"
  21. #include <Ecore.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <unistd.h>
  25. #include <wtf/Platform.h>
  26. #include <wtf/text/WTFString.h>
  27. namespace WTR {
  28. static Ecore_Timer* timer = 0;
  29. static Eina_Bool timerFired(void*)
  30. {
  31. timer = 0;
  32. ecore_main_loop_quit();
  33. return ECORE_CALLBACK_CANCEL;
  34. }
  35. void TestController::notifyDone()
  36. {
  37. if (!timer)
  38. return;
  39. ecore_timer_del(timer);
  40. timer = 0;
  41. ecore_main_loop_quit();
  42. }
  43. void TestController::platformInitialize()
  44. {
  45. const char* isDebugging = getenv("WEB_PROCESS_CMD_PREFIX");
  46. if (isDebugging && *isDebugging) {
  47. m_useWaitToDumpWatchdogTimer = false;
  48. m_forceNoTimeout = true;
  49. }
  50. }
  51. void TestController::platformDestroy()
  52. {
  53. }
  54. void TestController::platformRunUntil(bool& condition, double timeout)
  55. {
  56. if (timeout == m_noTimeout) {
  57. // Never timeout if we are debugging or not meant to timeout.
  58. while (!condition)
  59. ecore_main_loop_iterate();
  60. return;
  61. }
  62. timer = ecore_timer_loop_add(timeout, timerFired, 0);
  63. ecore_main_loop_begin();
  64. }
  65. static const char* getEnvironmentVariableOrExit(const char* variableName)
  66. {
  67. const char* value = getenv(variableName);
  68. if (!value) {
  69. fprintf(stderr, "%s environment variable not found\n", variableName);
  70. exit(0);
  71. }
  72. return value;
  73. }
  74. void TestController::initializeInjectedBundlePath()
  75. {
  76. const char* bundlePath = getEnvironmentVariableOrExit("TEST_RUNNER_INJECTED_BUNDLE_FILENAME");
  77. m_injectedBundlePath.adopt(WKStringCreateWithUTF8CString(bundlePath));
  78. }
  79. void TestController::initializeTestPluginDirectory()
  80. {
  81. const char* pluginPath = getEnvironmentVariableOrExit("TEST_RUNNER_PLUGIN_PATH");
  82. m_testPluginDirectory.adopt(WKStringCreateWithUTF8CString(pluginPath));
  83. }
  84. void TestController::platformInitializeContext()
  85. {
  86. }
  87. void TestController::runModal(PlatformWebView*)
  88. {
  89. // FIXME: Need to implement this to test showModalDialog.
  90. }
  91. const char* TestController::platformLibraryPathForTesting()
  92. {
  93. return 0;
  94. }
  95. } // namespace WTR