Source/WebKit: [EFL] Add support for Unit Tests, based on the gtest library.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Jun 2012 01:20:20 +0000 (01:20 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Jun 2012 01:20:20 +0000 (01:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68509

Patch by Krzysztof Czech <k.czech@samsung.com> on 2012-06-29
Reviewed by Chang Shu.

Add configuration for building gtest library, testing framework and unit tests.

* PlatformEfl.cmake:

Source/WebKit/efl: [EFL] Implementation of testing framework and unit tests for WebKit-EFL port.
https://bugs.webkit.org/show_bug.cgi?id=68509

Patch by Krzysztof Czech  <k.czech@samsung.com>, Tomasz Morawski <t.morawski@samsung.com> on 2012-06-29
Reviewed by Chang Shu.

Testing framework is based on gtest library. Gtest library is part of the WebKit project. Framework is devided into base part and view part.
Base part takes care of efl initialization, defines test macros and prepares test to run. View part is a context of each test.

* tests/UnitTestUtils/EWKTestBase.cpp: Added.
(EWKUnitTests):
(EWKUnitTests::EWKTestBase::init):
(EWKUnitTests::EWKTestBase::shutdown):
(EWKUnitTests::EWKTestBase::shutdownAll):
(EWKUnitTests::EWKTestBase::startTest):
(EWKUnitTests::EWKTestBase::endTest):
(EWKUnitTests::EWKTestBase::createTest):
(EWKUnitTests::EWKTestBase::runTest):
* tests/UnitTestUtils/EWKTestBase.h: Added.
(EWKUnitTests):
(EWKTestBase):
* tests/UnitTestUtils/EWKTestConfig.h: Added.
(Config):
* tests/UnitTestUtils/EWKTestView.cpp: Added.
(EWKUnitTests):
(EWKUnitTests::EWKTestEcoreEvas::EWKTestEcoreEvas):
(EWKUnitTests::EWKTestEcoreEvas::evas):
(EWKUnitTests::EWKTestEcoreEvas::show):
(EWKUnitTests::EWKTestView::EWKTestView):
(EWKUnitTests::EWKTestView::init):
(EWKUnitTests::EWKTestView::show):
(EWKUnitTests::EWKTestView::mainFrame):
(EWKUnitTests::EWKTestView::evas):
(EWKUnitTests::EWKTestView::bindEvents):
* tests/UnitTestUtils/EWKTestView.h: Added.
(EWKUnitTests):
(EWKTestEcoreEvas):
(EWKTestView):
(EWKUnitTests::EWKTestView::webView):
* tests/resources/default_test_page.html: Added.
* tests/test_ewk_view.cpp: Added.
(ewkViewEditableGetCb):
(TEST):
(ewkViewUriGetCb):
* tests/test_runner.cpp: Added.
(parseCustomArguments):
(main):

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

Source/WebKit/ChangeLog
Source/WebKit/PlatformEfl.cmake
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/tests/UnitTestUtils/EWKTestBase.cpp [new file with mode: 0644]
Source/WebKit/efl/tests/UnitTestUtils/EWKTestBase.h [new file with mode: 0644]
Source/WebKit/efl/tests/UnitTestUtils/EWKTestConfig.h [new file with mode: 0644]
Source/WebKit/efl/tests/UnitTestUtils/EWKTestView.cpp [new file with mode: 0644]
Source/WebKit/efl/tests/UnitTestUtils/EWKTestView.h [new file with mode: 0644]
Source/WebKit/efl/tests/resources/default_test_page.html [new file with mode: 0644]
Source/WebKit/efl/tests/test_ewk_view.cpp [new file with mode: 0644]
Source/WebKit/efl/tests/test_runner.cpp [new file with mode: 0644]

index 1226571..273da6b 100644 (file)
@@ -1,3 +1,14 @@
+2012-06-29  Krzysztof Czech  <k.czech@samsung.com>
+
+        [EFL] Add support for Unit Tests, based on the gtest library.
+        https://bugs.webkit.org/show_bug.cgi?id=68509
+
+        Reviewed by Chang Shu.
+
+        Add configuration for building gtest library, testing framework and unit tests.
+
+        * PlatformEfl.cmake:
+
 2012-06-27  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r121398.
index e1a99e2..ff3248c 100644 (file)
@@ -293,3 +293,81 @@ INSTALL(FILES ${EWebKit_HEADERS}
 
 INSTALL(FILES ${WebKit_THEME}
         DESTINATION ${DATA_INSTALL_DIR}/themes)
+
+INCLUDE_DIRECTORIES(${THIRDPARTY_DIR}/gtest
+                    ${THIRDPARTY_DIR}/gtest/include
+)
+
+SET(GTEST_SOURCES "${THIRDPARTY_DIR}/gtest/src")
+
+ADD_LIBRARY(gtest
+    ${GTEST_SOURCES}/gtest.cc
+    ${GTEST_SOURCES}/gtest-death-test.cc
+    ${GTEST_SOURCES}/gtest_main.cc
+    ${GTEST_SOURCES}/gtest-filepath.cc
+    ${GTEST_SOURCES}/gtest-port.cc
+    ${GTEST_SOURCES}/gtest-test-part.cc
+    ${GTEST_SOURCES}/gtest-typed-test.cc
+)
+
+SET(EWKUnitTests_LIBRARIES
+    ${JavaScriptCore_LIBRARY_NAME}
+    ${WebCore_LIBRARY_NAME}
+    ${WebKit_LIBRARY_NAME}
+    ${ECORE_LIBRARIES}
+    ${ECORE_EVAS_LIBRARIES}
+    ${EVAS_LIBRARIES}
+    ${EDJE_LIBRARIES}
+)
+
+SET(EWKUnitTests_INCLUDE_DIRECTORIES
+    "${CMAKE_SOURCE_DIR}/Source"
+    "${WEBKIT_DIR}/efl/ewk"
+    "${WEBKIT_DIR}/efl/tests/src/UnitTestUtils"
+    "${JAVASCRIPTCORE_DIR}"
+    "${WTF_DIR}"
+    "${WTF_DIR}/wtf"
+    ${ECORE_INCLUDE_DIRS}
+    ${ECORE_EVAS_INCLUDE_DIRS}
+    ${EVAS_INCLUDE_DIRS}
+    ${EDJE_INCLUDE_DIRS}
+)
+
+SET(EWKUnitTests_LINK_FLAGS
+    ${ECORE_LDFLAGS}
+    ${ECORE_EVAS_LDFLAGS}
+    ${EVAS_LDFLAGS}
+    ${EDJE_LDFLAGS}
+)
+
+IF (ENABLE_GLIB_SUPPORT)
+    LIST(APPEND EWKUnitTests_INCLUDE_DIRECTORIES "${WTF_DIR}/wtf/gobject")
+    LIST(APPEND EWKUnitTests_LIBRARIES
+        ${Glib_LIBRARIES}
+        ${Gthread_LIBRARIES}
+    )
+ENDIF ()
+
+SET(DEFAULT_TEST_PAGE_DIR ${CMAKE_SOURCE_DIR}/Source/WebKit/efl/tests/resources)
+
+ADD_DEFINITIONS(-DDEFAULT_TEST_PAGE_DIR=\"${DEFAULT_TEST_PAGE_DIR}\")
+ADD_DEFINITIONS(-DDEFAULT_THEME_PATH=\"${THEME_BINARY_DIR}\")
+
+ADD_LIBRARY(ewkTestUtils
+    ${WEBKIT_DIR}/efl/tests/UnitTestUtils/EWKTestBase.cpp
+    ${WEBKIT_DIR}/efl/tests/UnitTestUtils/EWKTestView.cpp
+)
+TARGET_LINK_LIBRARIES(ewkTestUtils ${EWKUnitTests_LIBRARIES})
+
+SET(WEBKIT_EFL_TEST_DIR "${WEBKIT_DIR}/efl/tests/")
+
+SET(EWKUnitTests_BINARIES
+    test_ewk_view
+)
+
+FOREACH(testName ${EWKUnitTests_BINARIES})
+    ADD_EXECUTABLE(${testName} ${WEBKIT_EFL_TEST_DIR}/${testName}.cpp ${WEBKIT_EFL_TEST_DIR}/test_runner.cpp)
+    TARGET_LINK_LIBRARIES(${testName} ${EWKUnitTests_LIBRARIES} ewkTestUtils gtest pthread)
+    ADD_TARGET_PROPERTIES(${testName} LINK_FLAGS "${EWKUnitTests_LINK_FLAGS}")
+    SET_TARGET_PROPERTIES(${testName} PROPERTIES FOLDER "WebKit")
+ENDFOREACH()
index 93bb450..1dbfdad 100644 (file)
@@ -1,3 +1,52 @@
+2012-06-29  Krzysztof Czech  <k.czech@samsung.com>, Tomasz Morawski <t.morawski@samsung.com>
+
+        [EFL] Implementation of testing framework and unit tests for WebKit-EFL port.
+        https://bugs.webkit.org/show_bug.cgi?id=68509
+
+        Reviewed by Chang Shu.
+
+        Testing framework is based on gtest library. Gtest library is part of the WebKit project. Framework is devided into base part and view part.
+        Base part takes care of efl initialization, defines test macros and prepares test to run. View part is a context of each test.
+
+        * tests/UnitTestUtils/EWKTestBase.cpp: Added.
+        (EWKUnitTests):
+        (EWKUnitTests::EWKTestBase::init):
+        (EWKUnitTests::EWKTestBase::shutdown):
+        (EWKUnitTests::EWKTestBase::shutdownAll):
+        (EWKUnitTests::EWKTestBase::startTest):
+        (EWKUnitTests::EWKTestBase::endTest):
+        (EWKUnitTests::EWKTestBase::createTest):
+        (EWKUnitTests::EWKTestBase::runTest):
+        * tests/UnitTestUtils/EWKTestBase.h: Added.
+        (EWKUnitTests):
+        (EWKTestBase):
+        * tests/UnitTestUtils/EWKTestConfig.h: Added.
+        (Config):
+        * tests/UnitTestUtils/EWKTestView.cpp: Added.
+        (EWKUnitTests):
+        (EWKUnitTests::EWKTestEcoreEvas::EWKTestEcoreEvas):
+        (EWKUnitTests::EWKTestEcoreEvas::evas):
+        (EWKUnitTests::EWKTestEcoreEvas::show):
+        (EWKUnitTests::EWKTestView::EWKTestView):
+        (EWKUnitTests::EWKTestView::init):
+        (EWKUnitTests::EWKTestView::show):
+        (EWKUnitTests::EWKTestView::mainFrame):
+        (EWKUnitTests::EWKTestView::evas):
+        (EWKUnitTests::EWKTestView::bindEvents):
+        * tests/UnitTestUtils/EWKTestView.h: Added.
+        (EWKUnitTests):
+        (EWKTestEcoreEvas):
+        (EWKTestView):
+        (EWKUnitTests::EWKTestView::webView):
+        * tests/resources/default_test_page.html: Added.
+        * tests/test_ewk_view.cpp: Added.
+        (ewkViewEditableGetCb):
+        (TEST):
+        (ewkViewUriGetCb):
+        * tests/test_runner.cpp: Added.
+        (parseCustomArguments):
+        (main):
+
 2012-06-29  Konrad Piascik  <kpiascik@rim.com>
 
         Don't hardcode target dpi of 160 (it should be 96 on desktop)
diff --git a/Source/WebKit/efl/tests/UnitTestUtils/EWKTestBase.cpp b/Source/WebKit/efl/tests/UnitTestUtils/EWKTestBase.cpp
new file mode 100644 (file)
index 0000000..608300a
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+    Copyright (C) 2012 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with this library; if not, write to the Free Software Foundation,
+    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "config.h"
+#include "EWKTestBase.h"
+
+#include "EWKTestConfig.h"
+#include "EWKTestView.h"
+#include <EWebKit.h>
+
+#include <Ecore.h>
+#include <Edje.h>
+
+int EWKUnitTests::EWKTestBase::useX11Window;
+
+namespace EWKUnitTests {
+
+bool EWKTestBase::init()
+{
+    if (!ecore_evas_init())
+        return false;
+
+    if (!edje_init()) {
+        ecore_evas_shutdown();
+        return false;
+    }
+
+    int ret = ewk_init();
+    const char* proxyUri = getenv("http_proxy");
+
+    if (ret && proxyUri)
+        ewk_network_proxy_uri_set(proxyUri);
+
+    return ret;
+}
+
+void EWKTestBase::shutdown()
+{
+    ecore_evas_shutdown();
+    edje_shutdown();
+    ewk_shutdown();
+}
+
+void EWKTestBase::shutdownAll()
+{
+    int count = 0;
+
+    while ((count = ecore_evas_shutdown()) > 0) { }
+    while ((count = edje_shutdown()) > 0) { }
+    while ((count = ewk_shutdown()) > 0) { }
+}
+
+void EWKTestBase::startTest()
+{
+    ecore_main_loop_begin();
+}
+
+void EWKTestBase::endTest()
+{
+    ecore_main_loop_quit();
+}
+
+bool EWKTestBase::createTest(const char* url, void (*event_callback)(void*, Evas_Object*, void*), const char* event_name, void* event_data)
+{
+    EFL_INIT_RET();
+
+    EWKTestEcoreEvas evas(useX11Window);
+    if (!evas.evas())
+        return false;
+    evas.show();
+
+    EWKTestView view(evas.evas(), url);
+    if (!view.init())
+        return false;
+
+    view.bindEvents(event_callback, event_name, event_data);
+    view.show();
+
+    START_TEST();
+
+    return true;
+}
+
+bool EWKTestBase::runTest(void (*event_callback)(void*, Evas_Object*, void*), const char* event_name, void* event_data)
+{
+    return createTest(Config::defaultTestPage, event_callback, event_name, event_data);
+}
+
+bool EWKTestBase::runTest(const char* url, void (*event_callback)(void*, Evas_Object*, void*), const char* event_name, void* event_data)
+{
+    return createTest(url, event_callback, event_name, event_data);
+}
+
+}
diff --git a/Source/WebKit/efl/tests/UnitTestUtils/EWKTestBase.h b/Source/WebKit/efl/tests/UnitTestUtils/EWKTestBase.h
new file mode 100644 (file)
index 0000000..c0d3776
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+    Copyright (C) 2012 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with this library; if not, write to the Free Software Foundation,
+    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef EWKTestBase_h
+#define EWKTestBase_h
+
+#include <Evas.h>
+#include <gtest/gtest.h>
+
+#define RUN_TEST(args...)   \
+    do {    \
+        ASSERT_EQ(true, EWKTestBase::runTest(args));    \
+    } while (0)
+
+#define START_TEST()    \
+    do {    \
+        EWKTestBase::startTest();   \
+    } while (0)
+
+#define END_TEST()    \
+    do {    \
+        EWKTestBase::endTest(); \
+    } while (0)
+
+#define EFL_INIT_RET()  \
+    do {    \
+        if (!EWKTestBase::init())   \
+            return false;    \
+    } while (0)
+
+#define EFL_INIT()  \
+    do {    \
+        EWKTestBase::init();    \
+    } while (0)
+
+namespace EWKUnitTests {
+
+class EWKTestBase {
+    static bool createTest(const char* url, void (*event_callback)(void*, Evas_Object*, void*), const char* event_name, void* event_data);
+public:
+    static bool init();
+    static void shutdown();
+    static void shutdownAll();
+    static void startTest();
+    static void endTest();
+
+    static bool runTest(const char* url, void (*event_callback)(void*, Evas_Object*, void*), const char* event_name, void* event_data);
+    static bool runTest(void (*event_callback)(void*, Evas_Object*, void*), const char* event_name, void* event_data);
+
+    static int useX11Window;
+};
+
+}
+
+#endif
diff --git a/Source/WebKit/efl/tests/UnitTestUtils/EWKTestConfig.h b/Source/WebKit/efl/tests/UnitTestUtils/EWKTestConfig.h
new file mode 100644 (file)
index 0000000..a1cf6ea
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+    Copyright (C) 2012 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with this library; if not, write to the Free Software Foundation,
+    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef EWKTestConfig_h
+#define EWKTestConfig_h
+
+namespace EWKUnitTests {
+namespace Config {
+static const int defaultViewWidth = 600;
+static const int defaultViewHeight = 800;
+static const char* const defaultThemePath = DEFAULT_THEME_PATH"/default.edj";
+static const char* const defaultTestPage = "file://"DEFAULT_TEST_PAGE_DIR"/default_test_page.html";
+}
+}
+
+#endif
diff --git a/Source/WebKit/efl/tests/UnitTestUtils/EWKTestView.cpp b/Source/WebKit/efl/tests/UnitTestUtils/EWKTestView.cpp
new file mode 100644 (file)
index 0000000..fd29b81
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+    Copyright (C) 2012 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with this library; if not, write to the Free Software Foundation,
+    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "config.h"
+#include "EWKTestView.h"
+
+#include "EWKTestConfig.h"
+#include <EWebKit.h>
+
+#include <wtf/PassOwnPtr.h>
+
+namespace EWKUnitTests {
+
+EWKTestEcoreEvas::EWKTestEcoreEvas(int useX11Window)
+{
+    if (useX11Window)
+        m_ecoreEvas = adoptPtr(ecore_evas_new(0, 0, 0, Config::defaultViewWidth, Config::defaultViewHeight, 0));
+    else
+        m_ecoreEvas = adoptPtr(ecore_evas_buffer_new(Config::defaultViewWidth, Config::defaultViewHeight));
+}
+
+EWKTestEcoreEvas::EWKTestEcoreEvas(const char* engine_name, int viewport_x, int viewport_y, int viewport_w, int viewport_h, const char* extra_options, int useX11Window)
+{
+    if (useX11Window)
+        m_ecoreEvas = adoptPtr(ecore_evas_new(engine_name, viewport_x, viewport_y, viewport_w, viewport_h, extra_options));
+    else
+        m_ecoreEvas = adoptPtr(ecore_evas_buffer_new(viewport_x, viewport_y));
+}
+
+Evas* EWKTestEcoreEvas::evas()
+{
+    if (m_ecoreEvas.get())
+        return ecore_evas_get(m_ecoreEvas.get());
+    return 0;
+}
+
+void EWKTestEcoreEvas::show()
+{
+    if (m_ecoreEvas.get())
+        ecore_evas_show(m_ecoreEvas.get());
+}
+
+EWKTestView::EWKTestView(Evas* evas)
+    : m_evas(evas)
+    , m_url(Config::defaultTestPage)
+    , m_defaultViewType(TiledView)
+    , m_width(Config::defaultViewWidth)
+    , m_height(Config::defaultViewHeight)
+{
+}
+
+EWKTestView::EWKTestView(Evas* evas, const char* url)
+    : m_evas(evas)
+    , m_url(url)
+    , m_defaultViewType(TiledView)
+    , m_width(Config::defaultViewWidth)
+    , m_height(Config::defaultViewHeight)
+{
+}
+
+EWKTestView::EWKTestView(Evas* evas, EwkViewType type, const char* url)
+    : m_evas(evas)
+    , m_url(url)
+    , m_defaultViewType(type)
+    , m_width(Config::defaultViewWidth)
+    , m_height(Config::defaultViewHeight)
+{
+}
+
+EWKTestView::EWKTestView(Evas* evas, EwkViewType type, const char* url, int width, int height)
+    : m_evas(evas)
+    , m_url(url)
+    , m_defaultViewType(type)
+    , m_width(width)
+    , m_height(height)
+{
+}
+
+bool EWKTestView::init()
+{
+    if (!m_evas || m_url.empty())
+        return false;
+
+    switch (m_defaultViewType) {
+    case SingleView:
+        m_webView = adoptPtr(ewk_view_single_add(m_evas));
+        break;
+
+    case TiledView:
+        m_webView = adoptPtr(ewk_view_tiled_add(m_evas));
+        break;
+    }
+
+    if (!m_webView.get())
+        return false;
+
+    ewk_view_theme_set(m_webView.get(), Config::defaultThemePath);
+    ewk_view_uri_set(m_webView.get(), m_url.c_str());
+}
+
+void EWKTestView::show()
+{
+    if (!m_webView.get())
+        return;
+    evas_object_resize(m_webView.get(), m_width, m_height);
+    evas_object_show(m_webView.get());
+    evas_object_focus_set(m_webView.get(), EINA_TRUE);
+}
+
+Evas_Object* EWKTestView::mainFrame()
+{
+    if (m_webView.get())
+        return ewk_view_frame_main_get(m_webView.get());
+    return 0;
+}
+
+Evas* EWKTestView::evas()
+{
+    if (m_webView.get())
+        return evas_object_evas_get(m_webView.get());
+    return 0;
+}
+
+void EWKTestView::bindEvents(void (*callback)(void*, Evas_Object*, void*), const char* eventName, void* ptr)
+{
+    if (!m_webView.get())
+        return;
+
+    evas_object_smart_callback_del(m_webView.get(), eventName, callback);
+    evas_object_smart_callback_add(m_webView.get(), eventName, callback, ptr);
+}
+
+}
diff --git a/Source/WebKit/efl/tests/UnitTestUtils/EWKTestView.h b/Source/WebKit/efl/tests/UnitTestUtils/EWKTestView.h
new file mode 100644 (file)
index 0000000..6d15d0d
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+    Copyright (C) 2012 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with this library; if not, write to the Free Software Foundation,
+    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef EWKTestView_h
+#define EWKTestView_h
+
+#include <Ecore_Evas.h>
+#include <Evas.h>
+#include <string>
+#include <wtf/OwnPtr.h>
+
+namespace EWKUnitTests {
+
+class EWKTestEcoreEvas {
+public:
+    EWKTestEcoreEvas(int useX11Window);
+    EWKTestEcoreEvas(const char* engine_name, int viewport_x, int viewport_y, int viewport_w, int viewport_h, const char* extra_options, int useX11Window);
+
+    Evas* evas();
+    void show();
+
+private:
+    OwnPtr<Ecore_Evas> m_ecoreEvas;
+};
+
+class EWKTestView {
+public:
+    enum EwkViewType {
+        SingleView = 0,
+        TiledView,
+    };
+
+    explicit EWKTestView(Evas*);
+    EWKTestView(Evas*, const char* url);
+    EWKTestView(Evas*, EwkViewType, const char* url);
+    EWKTestView(Evas*, EwkViewType, const char* url, int width, int height);
+
+    Evas_Object* webView() { return m_webView.get(); }
+    Evas_Object* mainFrame();
+    Evas* evas();
+    void show();
+
+    bool init();
+    void bindEvents(void (*callback)(void*, Evas_Object*, void*), const char* eventName, void* ptr);
+
+private:
+    EWKTestView(const EWKTestView&);
+    EWKTestView operator=(const EWKTestView&);
+
+    Evas* m_evas;
+    OwnPtr<Evas_Object> m_webView;
+
+    int m_width, m_height;
+    EwkViewType m_defaultViewType;
+    std::string m_url;
+};
+
+}
+
+#endif
diff --git a/Source/WebKit/efl/tests/resources/default_test_page.html b/Source/WebKit/efl/tests/resources/default_test_page.html
new file mode 100644 (file)
index 0000000..edd81e7
--- /dev/null
@@ -0,0 +1,6 @@
+<HTML>
+<BODY>
+<H2 align="center">EFL Unit Tests</H2>
+<H2 align="center">Default Testing Web Page</H2>
+</BODY>
+</HTML>
diff --git a/Source/WebKit/efl/tests/test_ewk_view.cpp b/Source/WebKit/efl/tests/test_ewk_view.cpp
new file mode 100644 (file)
index 0000000..24a1c89
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+    Copyright (C) 2012 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with this library; if not, write to the Free Software Foundation,
+    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "config.h"
+
+#include "UnitTestUtils/EWKTestBase.h"
+#include <EWebKit.h>
+#include <gtest/gtest.h>
+
+using namespace EWKUnitTests;
+
+/**
+* @brief Checking whether function properly returns correct value.
+*/
+void ewkViewEditableGetCb(void* eventInfo, Evas_Object* o, void* data)
+{
+    ewk_view_editable_set(o, EINA_FALSE);
+    EXPECT_EQ(EINA_FALSE, ewk_view_editable_get(o));
+    END_TEST();
+}
+
+TEST(test_ewk_view, ewk_view_editable_get)
+{
+    RUN_TEST(ewkViewEditableGetCb, "load,finished", 0);
+}
+
+/**
+* @brief Checking whether function returns correct uri string.
+*/
+void ewkViewUriGetCb(void* eventInfo, Evas_Object* o, void* data)
+{
+    EXPECT_STREQ("http://www.webkit.org/", ewk_view_uri_get(o));
+    END_TEST();
+}
+
+TEST(test_ewk_view, ewk_view_uri_get)
+{
+    RUN_TEST("http://www.webkit.org", ewkViewUriGetCb, "load,finished", 0);
+}
diff --git a/Source/WebKit/efl/tests/test_runner.cpp b/Source/WebKit/efl/tests/test_runner.cpp
new file mode 100644 (file)
index 0000000..702a61f
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+    Copyright (C) 2012 Samsung Electronics
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with this library; if not, write to the Free Software Foundation,
+    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "UnitTestUtils/EWKTestBase.h"
+#include <getopt.h>
+#include <gtest/gtest.h>
+
+static void parseCustomArguments(int argc, char** argv)
+{
+    static const option options[] = {
+        {"useX11Window", no_argument, &EWKUnitTests::EWKTestBase::useX11Window, true},
+        {0, 0, 0, 0}
+    };
+
+    int option;
+    while ((option = getopt_long(argc, argv, "", options, 0)) != -1) { }
+}
+
+int main(int argc, char** argv)
+{
+    atexit(EWKUnitTests::EWKTestBase::shutdownAll);
+    parseCustomArguments(argc, argv);
+    ::testing::InitGoogleTest(&argc, argv);
+    return RUN_ALL_TESTS();
+}