[CMake][EFL] Build and run TestWebKitAPI unit tests
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2012 15:07:34 +0000 (15:07 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2012 15:07:34 +0000 (15:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90671

Patch by Thiago Marcos P. Santos <thiago.santos@intel.com> on 2012-07-18
Reviewed by Daniel Bates.

This patch enables almost for free a significant amount of test for the
WebKit C API, WTF and KURL. It makes easy for CMake based ports to
enable TestWebKitAPI since the missing bits to implement are
relatively simple.

* CMakeLists.txt:
* TestWebKitAPI/CMakeLists.txt: Added.
* TestWebKitAPI/PlatformEfl.cmake: Added.
* TestWebKitAPI/PlatformWebView.h:
* TestWebKitAPI/config.h:
* TestWebKitAPI/efl/InjectedBundleController.cpp: Added.
(TestWebKitAPI):
(TestWebKitAPI::InjectedBundleController::platformInitialize):
* TestWebKitAPI/efl/PlatformUtilities.cpp: Added.
(TestWebKitAPI):
(Util):
(TestWebKitAPI::Util::run):
(TestWebKitAPI::Util::sleep):
(TestWebKitAPI::Util::createURLForResource):
(TestWebKitAPI::Util::createInjectedBundlePath):
(TestWebKitAPI::Util::URLForNonExistentResource):
* TestWebKitAPI/efl/PlatformWebView.cpp: Added.
(TestWebKitAPI):
(TestWebKitAPI::initEcoreEvas):
(TestWebKitAPI::PlatformWebView::PlatformWebView):
(TestWebKitAPI::PlatformWebView::~PlatformWebView):
(TestWebKitAPI::PlatformWebView::page):
* TestWebKitAPI/efl/main.cpp: Added.
(checkForUseX11WindowArgument):
(main):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@122973 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/CMakeLists.txt
Tools/ChangeLog
Tools/TestWebKitAPI/CMakeLists.txt [new file with mode: 0644]
Tools/TestWebKitAPI/PlatformEfl.cmake [new file with mode: 0644]
Tools/TestWebKitAPI/PlatformWebView.h
Tools/TestWebKitAPI/config.h
Tools/TestWebKitAPI/efl/InjectedBundleController.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/efl/PlatformUtilities.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/efl/PlatformWebView.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/efl/main.cpp [new file with mode: 0644]

index e9fc7e3..2f2b60c 100644 (file)
@@ -14,3 +14,7 @@ IF ("${PORT}" STREQUAL "Efl")
 ELSEIF ("${PORT}" STREQUAL "WinCE")
     ADD_SUBDIRECTORY(WinCELauncher)
 ENDIF()
+
+IF (ENABLE_WEBKIT2 AND ENABLE_API_TESTS)
+    ADD_SUBDIRECTORY(TestWebKitAPI)
+ENDIF()
index 48116be..6ca76df 100644 (file)
@@ -1,5 +1,43 @@
 2012-07-18  Thiago Marcos P. Santos  <thiago.santos@intel.com>
 
+        [CMake][EFL] Build and run TestWebKitAPI unit tests
+        https://bugs.webkit.org/show_bug.cgi?id=90671
+
+        Reviewed by Daniel Bates.
+
+        This patch enables almost for free a significant amount of test for the
+        WebKit C API, WTF and KURL. It makes easy for CMake based ports to
+        enable TestWebKitAPI since the missing bits to implement are
+        relatively simple.
+
+        * CMakeLists.txt:
+        * TestWebKitAPI/CMakeLists.txt: Added.
+        * TestWebKitAPI/PlatformEfl.cmake: Added.
+        * TestWebKitAPI/PlatformWebView.h:
+        * TestWebKitAPI/config.h:
+        * TestWebKitAPI/efl/InjectedBundleController.cpp: Added.
+        (TestWebKitAPI):
+        (TestWebKitAPI::InjectedBundleController::platformInitialize):
+        * TestWebKitAPI/efl/PlatformUtilities.cpp: Added.
+        (TestWebKitAPI):
+        (Util):
+        (TestWebKitAPI::Util::run):
+        (TestWebKitAPI::Util::sleep):
+        (TestWebKitAPI::Util::createURLForResource):
+        (TestWebKitAPI::Util::createInjectedBundlePath):
+        (TestWebKitAPI::Util::URLForNonExistentResource):
+        * TestWebKitAPI/efl/PlatformWebView.cpp: Added.
+        (TestWebKitAPI):
+        (TestWebKitAPI::initEcoreEvas):
+        (TestWebKitAPI::PlatformWebView::PlatformWebView):
+        (TestWebKitAPI::PlatformWebView::~PlatformWebView):
+        (TestWebKitAPI::PlatformWebView::page):
+        * TestWebKitAPI/efl/main.cpp: Added.
+        (checkForUseX11WindowArgument):
+        (main):
+
+2012-07-18  Thiago Marcos P. Santos  <thiago.santos@intel.com>
+
         [CMake][EFL] Building jsc causes reconfiguration
         https://bugs.webkit.org/show_bug.cgi?id=91387
 
diff --git a/Tools/TestWebKitAPI/CMakeLists.txt b/Tools/TestWebKitAPI/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6c3a59d
--- /dev/null
@@ -0,0 +1,135 @@
+SET(TESTWEBKITAPI_DIR "${TOOLS_DIR}/TestWebKitAPI")
+
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}
+    ${TESTWEBKITAPI_DIR}
+    ${CMAKE_SOURCE_DIR}/Source
+    ${DERIVED_SOURCES_WEBKIT2_DIR}/include
+    ${JAVASCRIPTCORE_DIR}
+    ${JAVASCRIPTCORE_DIR}/API
+    ${JAVASCRIPTCORE_DIR}/ForwardingHeaders
+    ${THIRDPARTY_DIR}/gtest/include
+    ${WEBCORE_DIR}/editing
+    ${WEBCORE_DIR}/platform
+    ${WEBCORE_DIR}/platform/graphics
+    ${WEBCORE_DIR}/platform/text
+    ${WEBCORE_DIR}/platform/network
+    ${WEBKIT2_DIR}/Shared
+    ${WEBKIT2_DIR}/Shared/API/c
+    ${WEBKIT2_DIR}/UIProcess
+    ${WTF_DIR}
+)
+
+WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
+
+ADD_LIBRARY(TestWebKitAPIInjectedBundle SHARED
+    ${bundle_harness_SOURCES}
+    ${TESTWEBKITAPI_DIR}/InjectedBundleController.cpp
+    ${TESTWEBKITAPI_DIR}/InjectedBundleMain.cpp
+    ${TESTWEBKITAPI_DIR}/PlatformUtilities.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/CanHandleRequest_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/DOMWindowExtensionNoCache_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/DocumentStartUserScriptAlertCrash_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/GetInjectedBundleInitializationUserDataCallback_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/HitTestResultNodeHandle_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/InjectedBundleBasic_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/LoadCanceledNoServerRedirectCallback_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/MouseMoveAfterCrash_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayoutFails_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayout_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ParentFrame_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/UserMessage_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WKConnection_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillSendSubmitEvent_Bundle.cpp
+)
+
+ADD_DEPENDENCIES(TestWebKitAPIInjectedBundle ${WebKit2_LIBRARY_NAME} ${ForwardingHeadersForTestWebKitAPI_NAME} ${ForwardingNetworkHeadersForTestWebKitAPI_NAME})
+
+GET_PROPERTY(TestWebKitAPIInjectedBundle_PATH TARGET TestWebKitAPIInjectedBundle PROPERTY LOCATION)
+
+ADD_DEFINITIONS(-DGTEST_LINKED_AS_SHARED_LIBRARY=1
+    -DTEST_WEBKIT2_RESOURCES_DIR=\"${TESTWEBKITAPI_DIR}/Tests/WebKit2\"
+    -DTEST_INJECTED_BUNDLE_PATH=\"${TestWebKitAPIInjectedBundle_PATH}\"
+)
+
+SET(test_wtf_LIBRARIES
+    ${WTF_LIBRARY_NAME}
+    gtest
+)
+
+ADD_EXECUTABLE(test_wtf
+    ${test_main_SOURCES}
+    ${TESTWEBKITAPI_DIR}/TestsController.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/CheckedArithmeticOperations.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/Functional.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/HashMap.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/MetaAllocator.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/RedBlackTree.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/StringBuilder.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/StringOperators.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/TemporaryChange.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/Vector.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/VectorBasic.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/VectorReverse.cpp
+)
+
+TARGET_LINK_LIBRARIES(test_wtf ${test_wtf_LIBRARIES})
+ADD_DEPENDENCIES(test_wtf ${ForwardingHeadersForTestWebKitAPI_NAME} ${ForwardingNetworkHeadersForTestWebKitAPI_NAME})
+ADD_TEST(test_wtf ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_wtf)
+SET_TESTS_PROPERTIES(test_wtf PROPERTIES TIMEOUT 60)
+
+SET(test_webcore_LIBRARIES
+    ${WTF_LIBRARY_NAME}
+    ${WebCore_LIBRARY_NAME}
+    gtest
+)
+
+ADD_EXECUTABLE(test_webcore
+    ${test_main_SOURCES}
+    ${TESTWEBKITAPI_DIR}/TestsController.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebCore/KURL.cpp
+)
+
+TARGET_LINK_LIBRARIES(test_webcore ${test_webcore_LIBRARIES})
+ADD_DEPENDENCIES(test_webcore ${ForwardingHeadersForTestWebKitAPI_NAME} ${ForwardingNetworkHeadersForTestWebKitAPI_NAME})
+ADD_TEST(test_webcore ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_webcore)
+SET_TESTS_PROPERTIES(test_webcore PROPERTIES TIMEOUT 60)
+
+ADD_LIBRARY(TestWebKitAPIBase
+    ${test_main_SOURCES}
+    ${webkit2_api_harness_SOURCES}
+    ${TESTWEBKITAPI_DIR}/JavaScriptTest.cpp
+    ${TESTWEBKITAPI_DIR}/PlatformUtilities.cpp
+    ${TESTWEBKITAPI_DIR}/TestsController.cpp
+)
+
+ADD_DEPENDENCIES(TestWebKitAPIBase ${WebKit2_LIBRARY_NAME} ${ForwardingHeadersForTestWebKitAPI_NAME} ${ForwardingNetworkHeadersForTestWebKitAPI_NAME})
+
+SET(test_webkit2_api_LIBRARIES
+    TestWebKitAPIBase
+    ${WTF_LIBRARY_NAME}
+    ${JavaScriptCore_LIBRARY_NAME}
+    ${WebKit2_LIBRARY_NAME}
+    gtest
+)
+
+FOREACH(testName ${test_webkit2_api_BINARIES})
+    ADD_EXECUTABLE(test_webkit2_api_${testName} ${TESTWEBKITAPI_DIR}/Tests/WebKit2/${testName}.cpp)
+    ADD_TEST(test_webkit2_api_${testName} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_webkit2_api_${testName})
+    SET_TESTS_PROPERTIES(test_webkit2_api_${testName} PROPERTIES TIMEOUT 60)
+    TARGET_LINK_LIBRARIES(test_webkit2_api_${testName} ${test_webkit2_api_LIBRARIES})
+ENDFOREACH()
+
+# We don't run tests that are expected to fail. We could use the WILL_FAIL
+# property, but it reports failure when the test crashes or timeouts and would
+# make the bot red.
+
+FOREACH(testName ${test_webkit2_api_fail_BINARIES})
+    ADD_EXECUTABLE(test_webkit2_api_fail_${testName} ${TESTWEBKITAPI_DIR}/Tests/WebKit2/${testName}.cpp)
+    TARGET_LINK_LIBRARIES(test_webkit2_api_fail_${testName} ${test_webkit2_api_LIBRARIES})
+ENDFOREACH()
diff --git a/Tools/TestWebKitAPI/PlatformEfl.cmake b/Tools/TestWebKitAPI/PlatformEfl.cmake
new file mode 100644 (file)
index 0000000..4c4c902
--- /dev/null
@@ -0,0 +1,91 @@
+ADD_CUSTOM_TARGET(forwarding-headersEflForTestWebKitAPI
+    COMMAND ${PERL_EXECUTABLE} ${WEBKIT2_DIR}/Scripts/generate-forwarding-headers.pl ${TESTWEBKITAPI_DIR} ${DERIVED_SOURCES_WEBKIT2_DIR}/include efl
+)
+SET(ForwardingHeadersForTestWebKitAPI_NAME forwarding-headersEflForTestWebKitAPI)
+
+ADD_CUSTOM_TARGET(forwarding-headersSoupForTestWebKitAPI
+    COMMAND ${PERL_EXECUTABLE} ${WEBKIT2_DIR}/Scripts/generate-forwarding-headers.pl ${TESTWEBKITAPI_DIR} ${DERIVED_SOURCES_WEBKIT2_DIR}/include soup
+)
+SET(ForwardingNetworkHeadersForTestWebKitAPI_NAME forwarding-headersSoupForTestWebKitAPI)
+
+INCLUDE_DIRECTORIES(${LIBSOUP24_INCLUDE_DIRS}
+    ${WEBKIT2_DIR}/UIProcess/API/C/soup
+    ${WEBKIT2_DIR}/UIProcess/API/C/efl
+    ${ECORE_INCLUDE_DIRS}
+    ${EINA_INCLUDE_DIRS}
+    ${EVAS_INCLUDE_DIRS}
+)
+
+SET(test_main_SOURCES
+    ${TESTWEBKITAPI_DIR}/efl/main.cpp
+)
+
+SET(bundle_harness_SOURCES
+    ${TESTWEBKITAPI_DIR}/efl/InjectedBundleController.cpp
+    ${TESTWEBKITAPI_DIR}/efl/PlatformUtilities.cpp
+)
+
+SET(webkit2_api_harness_SOURCES
+    ${TESTWEBKITAPI_DIR}/efl/PlatformUtilities.cpp
+    ${TESTWEBKITAPI_DIR}/efl/PlatformWebView.cpp
+)
+
+# The list below works like a test expectation. Tests in the
+# test_webkit2_api_BINARIES list are added to the test runner and
+# tried on the bots on every build. Tests in test_webkit2_api_fail_BINARIES
+# are compiled and suffixed with fail and skipped from the test runner.
+#
+# Make sure that the tests are passing on both Debug and
+# Release builds before adding it to test_webkit2_api_BINARIES.
+
+SET(test_webkit2_api_BINARIES
+    CookieManager
+    DOMWindowExtensionNoCache
+    DocumentStartUserScriptAlertCrash
+    EvaluateJavaScript
+    FailedLoad
+    Find
+    ForceRepaint
+    FrameMIMETypeHTML
+    FrameMIMETypePNG
+    GetInjectedBundleInitializationUserDataCallback
+    InjectedBundleBasic
+    InjectedBundleInitializationUserDataCallbackWins
+    LoadAlternateHTMLStringWithNonDirectoryURL
+    LoadCanceledNoServerRedirectCallback
+    NewFirstVisuallyNonEmptyLayout
+    NewFirstVisuallyNonEmptyLayoutFails
+    PageLoadBasic
+    PageLoadDidChangeLocationWithinPageForFrame
+    ParentFrame
+    PreventEmptyUserAgent
+    PrivateBrowsingPushStateNoHistoryCallback
+    WKConnection
+    WKString
+    WKStringJSString
+    WillSendSubmitEvent
+)
+
+SET(test_webkit2_api_fail_BINARIES
+    CanHandleRequest
+    DOMWindowExtensionBasic
+    DownloadDecideDestinationCrash
+    NewFirstVisuallyNonEmptyLayoutForImages
+    NewFirstVisuallyNonEmptyLayoutFrames
+    RestoreSessionStateContainingFormData
+    ShouldGoToBackForwardListItem
+    WKPageGetScaleFactorNotZero
+)
+
+# Tests disabled because of missing features on the test harness:
+#
+#   AboutBlankLoad
+#   HitTestResultNodeHandle
+#   MouseMoveAfterCrash
+#   ResponsivenessTimerDoesntFireEarly
+#   SpacebarScrolling
+#   WKPreferences
+#
+# Flaky test, fails on Release but passes on Debug:
+#
+#   UserMessage
index cf0132e..653a17c 100644 (file)
@@ -46,6 +46,11 @@ typedef HWND PlatformWindow;
 #elif PLATFORM(GTK)
 typedef WKViewRef PlatformWKView;
 typedef GtkWidget *PlatformWindow;
+#elif PLATFORM(EFL)
+typedef struct _Evas_Object Evas_Object;
+typedef struct _Ecore_Evas Ecore_Evas;
+typedef Evas_Object* PlatformWKView;
+typedef Ecore_Evas* PlatformWindow;
 #endif
 
 namespace TestWebKitAPI {
index 4ffcb8b..e3c2eb0 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
+#ifdef BUILDING_WITH_CMAKE
+#include "cmakeconfig.h"
+#endif
+#endif
+
 #include <wtf/Platform.h>
 #include <wtf/ExportMacros.h>
 #if USE(JSC)
diff --git a/Tools/TestWebKitAPI/efl/InjectedBundleController.cpp b/Tools/TestWebKitAPI/efl/InjectedBundleController.cpp
new file mode 100644 (file)
index 0000000..5d55002
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InjectedBundleController.h"
+
+namespace TestWebKitAPI {
+
+void InjectedBundleController::platformInitialize()
+{
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/efl/PlatformUtilities.cpp b/Tools/TestWebKitAPI/efl/PlatformUtilities.cpp
new file mode 100644 (file)
index 0000000..9674545
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformUtilities.h"
+
+#include <Ecore.h>
+#include <stdio.h>
+#include <unistd.h>
+
+namespace TestWebKitAPI {
+
+namespace Util {
+
+void run(bool* done)
+{
+    while (!*done)
+        ecore_main_loop_iterate();
+}
+
+void sleep(double seconds)
+{
+    sleep(seconds);
+}
+
+WKURLRef createURLForResource(const char* resource, const char* extension)
+{
+    char url[PATH_MAX];
+
+    snprintf(url, sizeof(url), "file://%s/%s.%s", TEST_WEBKIT2_RESOURCES_DIR, resource, extension);
+
+    return WKURLCreateWithUTF8CString(url);
+}
+
+WKStringRef createInjectedBundlePath()
+{
+    return WKStringCreateWithUTF8CString(TEST_INJECTED_BUNDLE_PATH);
+}
+
+WKURLRef URLForNonExistentResource()
+{
+    return WKURLCreateWithUTF8CString("file:///does-not-exist.html");
+}
+
+} // namespace Util
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/efl/PlatformWebView.cpp b/Tools/TestWebKitAPI/efl/PlatformWebView.cpp
new file mode 100644 (file)
index 0000000..98c2a4a
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformWebView.h"
+
+#include "WebKit2/WKAPICast.h"
+#include <Ecore_Evas.h>
+
+extern bool useX11Window;
+
+using namespace WebKit;
+
+namespace TestWebKitAPI {
+
+static Ecore_Evas* initEcoreEvas()
+{
+    ASSERT(ecore_evas_init());
+
+    Ecore_Evas* ecoreEvas;
+
+    if (useX11Window)
+        ecoreEvas = ecore_evas_new(0, 0, 0, 800, 600, 0);
+    else
+        ecoreEvas = ecore_evas_buffer_new(800, 600);
+
+    ASSERT(ecoreEvas);
+
+    ecore_evas_show(ecoreEvas);
+
+    return ecoreEvas;
+}
+
+PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+{
+    m_window = initEcoreEvas();
+    Evas* evas = ecore_evas_get(m_window);
+    m_view = toImpl(WKViewCreate(evas, contextRef, pageGroupRef));
+}
+
+PlatformWebView::~PlatformWebView()
+{
+    evas_object_del(m_view);
+    ecore_evas_free(m_window);
+    ecore_evas_shutdown();
+}
+
+WKPageRef PlatformWebView::page() const
+{
+    return WKViewGetPage(toAPI(m_view));
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/efl/main.cpp b/Tools/TestWebKitAPI/efl/main.cpp
new file mode 100644 (file)
index 0000000..7c77dbf
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TestsController.h"
+#include <Ecore.h>
+#include <Eina.h>
+#include <getopt.h>
+
+bool useX11Window = false;
+
+static bool checkForUseX11WindowArgument(int argc, char** argv)
+{
+    int hasUseX11Window = 0;
+
+    static const option options[] = {
+        {"useX11Window", no_argument, &hasUseX11Window, 1},
+        {0, 0, 0, 0}
+    };
+
+    while (getopt_long(argc, argv, "", options, 0) != -1) { }
+
+    return hasUseX11Window;
+}
+
+int main(int argc, char** argv)
+{
+    if (!eina_init())
+        return EXIT_FAILURE;
+
+    if (!ecore_init())
+        return EXIT_FAILURE;
+
+    useX11Window = checkForUseX11WindowArgument(argc, argv);
+
+    int returnCode = TestWebKitAPI::TestsController::shared().run(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE;
+
+    ecore_shutdown();
+    eina_shutdown();
+
+    return returnCode;
+}