TestRunnerEfl.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 "TestRunner.h"
  21. #include "InjectedBundle.h"
  22. #include <Ecore.h>
  23. #include <JavaScriptCore/OpaqueJSString.h>
  24. #include <wtf/text/CString.h>
  25. #include <wtf/text/WTFString.h>
  26. namespace WTR {
  27. static Eina_Bool waitToDumpWatchdogTimerCallback(void*)
  28. {
  29. InjectedBundle::shared().testRunner()->waitToDumpWatchdogTimerFired();
  30. return false;
  31. }
  32. void TestRunner::platformInitialize()
  33. {
  34. m_waitToDumpWatchdogTimer = 0;
  35. }
  36. void TestRunner::invalidateWaitToDumpWatchdogTimer()
  37. {
  38. if (!m_waitToDumpWatchdogTimer)
  39. return;
  40. ecore_timer_del(m_waitToDumpWatchdogTimer);
  41. m_waitToDumpWatchdogTimer = 0;
  42. }
  43. void TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded()
  44. {
  45. if (m_waitToDumpWatchdogTimer)
  46. return;
  47. m_waitToDumpWatchdogTimer = ecore_timer_loop_add(waitToDumpWatchdogTimerInterval,
  48. waitToDumpWatchdogTimerCallback, 0);
  49. }
  50. JSRetainPtr<JSStringRef> TestRunner::pathToLocalResource(JSStringRef url)
  51. {
  52. String requestedUrl(url->characters(), url->length());
  53. String resourceRoot;
  54. String requestedRoot;
  55. if (requestedUrl.find("LayoutTests") != notFound) {
  56. // If the URL contains LayoutTests we need to remap that to
  57. // LOCAL_RESOURCE_ROOT which is the path of the LayoutTests directory
  58. // within the WebKit source tree.
  59. requestedRoot = "/tmp/LayoutTests";
  60. resourceRoot = getenv("LOCAL_RESOURCE_ROOT");
  61. } else if (requestedUrl.find("tmp") != notFound) {
  62. // If the URL is a child of /tmp we need to convert it to be a child
  63. // DUMPRENDERTREE_TEMP replace tmp with DUMPRENDERTREE_TEMP
  64. requestedRoot = "/tmp";
  65. resourceRoot = getenv("DUMPRENDERTREE_TEMP");
  66. }
  67. size_t indexOfRootStart = requestedUrl.reverseFind(requestedRoot);
  68. size_t indexOfSeparatorAfterRoot = indexOfRootStart + requestedRoot.length();
  69. String fullPathToUrl = "file://" + resourceRoot + requestedUrl.substring(indexOfSeparatorAfterRoot);
  70. return JSStringCreateWithUTF8CString(fullPathToUrl.utf8().data());
  71. }
  72. JSRetainPtr<JSStringRef> TestRunner::platformName()
  73. {
  74. JSRetainPtr<JSStringRef> platformName(Adopt, JSStringCreateWithUTF8CString("efl"));
  75. return platformName;
  76. }
  77. } // namespace WTR