| Differences between
and this patch
- a/Source/WebKit/efl/ChangeLog +44 lines
Lines 1-3 a/Source/WebKit/efl/ChangeLog_sec1
1
2011-09-21  Krzysztof Czech  <k.czech@samsung.com>
2
3
        [EFL] Implementation of Unit Tests framework for the WebKit-Efl port.
4
        https://bugs.webkit.org/show_bug.cgi?id=68509
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Unit Tests for the WebKit-Efl port are based on the gtest library.
9
        There's also been added a simple framework for running tests that require instance of a webview
10
        and example of unit tests.
11
12
        * tests/default_test_page.html: Added.
13
        * tests/src/EFLTestsRun.cpp: Added.
14
        (main):
15
        * tests/src/EwkEditableTests.cpp: Added.
16
        (editableSetTestCallback):
17
        (TEST):
18
        * tests/src/EwkUriTests.cpp: Added.
19
        (ewkUriSetTestCallback):
20
        (TEST):
21
        * tests/src/UnitTestLauncher/EFLTestConfig.h: Added.
22
        * tests/src/UnitTestLauncher/EFLTestLauncher.cpp: Added.
23
        (EFLUnitTests::EFLTestLauncher::init):
24
        (EFLUnitTests::EFLTestLauncher::startTest):
25
        (EFLUnitTests::EFLTestLauncher::endTest):
26
        (EFLUnitTests::EFLTestLauncher::createTest):
27
        (EFLUnitTests::EFLTestLauncher::runTest):
28
        * tests/src/UnitTestLauncher/EFLTestLauncher.h: Added.
29
        * tests/src/UnitTestLauncher/EFLTestView.cpp: Added.
30
        (EFLUnitTests::EFLTestEcoreEvas::EFLTestEcoreEvas):
31
        (EFLUnitTests::EFLTestEcoreEvas::~EFLTestEcoreEvas):
32
        (EFLUnitTests::EFLTestEcoreEvas::getEvas):
33
        (EFLUnitTests::EFLTestEcoreEvas::show):
34
        (EFLUnitTests::EFLTestView::EFLTestView):
35
        (EFLUnitTests::EFLTestView::~EFLTestView):
36
        (EFLUnitTests::EFLTestView::createTestUrl):
37
        (EFLUnitTests::EFLTestView::init):
38
        (EFLUnitTests::EFLTestView::show):
39
        (EFLUnitTests::EFLTestView::getMainFrame):
40
        (EFLUnitTests::EFLTestView::getEvas):
41
        (EFLUnitTests::EFLTestView::bindEvents):
42
        * tests/src/UnitTestLauncher/EFLTestView.h: Added.
43
        (EFLUnitTests::EFLTestView::getWebView):
44
1
2011-09-17  Mihai Parparita  <mihaip@chromium.org>
45
2011-09-17  Mihai Parparita  <mihaip@chromium.org>
2
46
3
        FrameLoaderClient BackForwardList-related methods are unsued
47
        FrameLoaderClient BackForwardList-related methods are unsued
- a/Source/WebKit/efl/tests/default_test_page.html +6 lines
Line 0 a/Source/WebKit/efl/tests/default_test_page.html_sec1
1
<HTML>
2
<BODY>
3
<H2 align="center">EFL Unit Tests</H2>
4
<H2 align="center">Default Testing Web Page</H2>
5
</BODY>
6
</HTML>
- a/Source/WebKit/efl/tests/src/EFLTestsRun.cpp +25 lines
Line 0 a/Source/WebKit/efl/tests/src/EFLTestsRun.cpp_sec1
1
/*
2
    Copyright (C) 2011 Samsung Electronics
3
4
    This library is free software; you can redistribute it and/or
5
    modify it under the terms of the GNU Lesser General Public
6
    License as published by the Free Software Foundation; either
7
    version 2.1 of the License, or (at your option) any later version.
8
9
    This library 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
    Lesser General Public License for more details.
13
14
    You should have received a copy of the GNU Lesser General Public License
15
    along with this library; if not, write to the Free Software Foundation,
16
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#include <gtest/gtest.h>
20
21
int main(int argc, char** argv)
22
{
23
    ::testing::InitGoogleTest(&argc, argv);
24
    return RUN_ALL_TESTS();
25
}
- a/Source/WebKit/efl/tests/src/EwkEditableTests.cpp +35 lines
Line 0 a/Source/WebKit/efl/tests/src/EwkEditableTests.cpp_sec1
1
/*
2
    Copyright (C) 2011 Samsung Electronics
3
4
    This library is free software; you can redistribute it and/or
5
    modify it under the terms of the GNU Lesser General Public
6
    License as published by the Free Software Foundation; either
7
    version 2.1 of the License, or (at your option) any later version.
8
9
    This library 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
    Lesser General Public License for more details.
13
14
    You should have received a copy of the GNU Lesser General Public License
15
    along with this library; if not, write to the Free Software Foundation,
16
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#include "EFLTestLauncher.h"
20
#include "EWebKit.h"
21
#include <gtest/gtest.h>
22
23
using namespace EFLUnitTests;
24
25
void editableSetTestCallback(void* eventInfo, Evas_Object* o, void* data)
26
{
27
    EXPECT_EQ(true, ewk_view_editable_set(o, EINA_FALSE));
28
    EXPECT_EQ(EINA_FALSE, ewk_view_editable_get(o));
29
    END_TEST();
30
}
31
32
TEST(EwkEditableTests, EditableSetTest)
33
{
34
    RUN_TEST(editableSetTestCallback, "load,finished", 0);
35
}
- a/Source/WebKit/efl/tests/src/EwkUriTests.cpp +34 lines
Line 0 a/Source/WebKit/efl/tests/src/EwkUriTests.cpp_sec1
1
/*
2
    Copyright (C) 2011 Samsung Electronics
3
4
    This library is free software; you can redistribute it and/or
5
    modify it under the terms of the GNU Lesser General Public
6
    License as published by the Free Software Foundation; either
7
    version 2.1 of the License, or (at your option) any later version.
8
9
    This library 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
    Lesser General Public License for more details.
13
14
    You should have received a copy of the GNU Lesser General Public License
15
    along with this library; if not, write to the Free Software Foundation,
16
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#include "EFLTestLauncher.h"
20
#include "EWebKit.h"
21
#include <gtest/gtest.h>
22
23
using namespace EFLUnitTests;
24
25
void ewkUriSetTestCallback(void* eventInfo, Evas_Object* o, void* data)
26
{
27
    EXPECT_STREQ("http://www.webkit.org/", ewk_view_uri_get(o));
28
    END_TEST();
29
}
30
31
TEST(EwkUriTests, EwkUriSetTest)
32
{
33
    RUN_TEST("http://www.webkit.org", ewkUriSetTestCallback, "load,finished", 0);
34
}
- a/Source/WebKit/efl/tests/src/UnitTestLauncher/EFLTestConfig.h +31 lines
Line 0 a/Source/WebKit/efl/tests/src/UnitTestLauncher/EFLTestConfig.h_sec1
1
/*
2
    Copyright (C) 2011 Samsung Electronics
3
4
    This library is free software; you can redistribute it and/or
5
    modify it under the terms of the GNU Lesser General Public
6
    License as published by the Free Software Foundation; either
7
    version 2.1 of the License, or (at your option) any later version.
8
9
    This library 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
    Lesser General Public License for more details.
13
14
    You should have received a copy of the GNU Lesser General Public License
15
    along with this library; if not, write to the Free Software Foundation,
16
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#ifndef EFLTestConfig_h
20
#define EFLTestConfig_h
21
22
namespace EFLUnitTests {
23
namespace Config {
24
static const int defaultViewWidth = 600;
25
static const int defaultViewHeight = 800;
26
static const char* defaultThemePath = DEFAULT_THEME_PATH"/default.edj";
27
static const char* defaultTestPage = "file://"DEFAULT_TEST_PAGE_DIR"/default_test_page.html";
28
}
29
}
30
31
#endif
- a/Source/WebKit/efl/tests/src/UnitTestLauncher/EFLTestLauncher.cpp +86 lines
Line 0 a/Source/WebKit/efl/tests/src/UnitTestLauncher/EFLTestLauncher.cpp_sec1
1
/*
2
    Copyright (C) 2011 Samsung Electronics
3
4
    This library is free software; you can redistribute it and/or
5
    modify it under the terms of the GNU Lesser General Public
6
    License as published by the Free Software Foundation; either
7
    version 2.1 of the License, or (at your option) any later version.
8
9
    This library 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
    Lesser General Public License for more details.
13
14
    You should have received a copy of the GNU Lesser General Public License
15
    along with this library; if not, write to the Free Software Foundation,
16
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#include "config.h"
20
#include "EFLTestLauncher.h"
21
22
#include "EFLTestConfig.h"
23
#include "EFLTestView.h"
24
#include "EWebKit.h"
25
26
#include <Ecore.h>
27
#include <Edje.h>
28
#include <Eina.h>
29
30
namespace EFLUnitTests {
31
32
Eina_Bool EFLTestLauncher::init()
33
{
34
    if (!ecore_evas_init())
35
        return EINA_FALSE;
36
37
    if (!edje_init()) {
38
        ecore_evas_shutdown();
39
        return EINA_FALSE;
40
    }
41
    ewk_init();
42
    return EINA_TRUE;
43
}
44
45
void EFLTestLauncher::startTest()
46
{
47
    ecore_main_loop_begin();
48
}
49
50
void EFLTestLauncher::endTest()
51
{
52
    ecore_main_loop_quit();
53
}
54
55
Eina_Bool EFLTestLauncher::createTest(const char* url, void (*event_callback)(void*, Evas_Object*, void*), const char* event_name, void* event_data)
56
{
57
    EFL_INIT_RET();
58
59
    EFLTestEcoreEvas evas;
60
    if (!evas.getEvas())
61
        return EINA_FALSE;
62
    evas.show();
63
64
    EFLTestView view(evas.getEvas(), url);
65
    if (!view.init())
66
        return EINA_FALSE;
67
68
    view.bindEvents(event_callback, event_name, event_data);
69
    view.show();
70
71
    START_TEST();
72
73
    return EINA_TRUE;
74
}
75
76
Eina_Bool EFLTestLauncher::runTest(void (*event_callback)(void*, Evas_Object*, void*), const char* event_name, void* event_data)
77
{
78
    return createTest(EFLUnitTests::Config::defaultTestPage, event_callback, event_name, event_data);
79
}
80
81
Eina_Bool EFLTestLauncher::runTest(const char* url, void (*event_callback)(void*, Evas_Object*, void*), const char* event_name, void* event_data)
82
{
83
    return createTest(url, event_callback, event_name, event_data);
84
}
85
86
}
- a/Source/WebKit/efl/tests/src/UnitTestLauncher/EFLTestLauncher.h +76 lines
Line 0 a/Source/WebKit/efl/tests/src/UnitTestLauncher/EFLTestLauncher.h_sec1
1
/*
2
    Copyright (C) 2011 Samsung Electronics
3
4
    This library is free software; you can redistribute it and/or
5
    modify it under the terms of the GNU Lesser General Public
6
    License as published by the Free Software Foundation; either
7
    version 2.1 of the License, or (at your option) any later version.
8
9
    This library 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
    Lesser General Public License for more details.
13
14
    You should have received a copy of the GNU Lesser General Public License
15
    along with this library; if not, write to the Free Software Foundation,
16
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#ifndef EFLTestLauncher_h
20
#define EFLTestLauncher_h
21
22
#include <Evas.h>
23
24
#ifdef GTEST_TEST_FRAMEWORK
25
#include <gtest/gtest.h>
26
#endif
27
28
#ifdef GTEST_TEST_FRAMEWORK
29
    #define RUN_TEST(args...)   \
30
        do {    \
31
            ASSERT_EQ(EINA_TRUE, EFLTestLauncher::runTest(args));    \
32
        } while (0)
33
#else
34
    #define RUN_TEST(args...)   \
35
    do {    \
36
        EFLTestLauncher::runTest(args); \
37
    } while (0)
38
#endif
39
40
#define START_TEST()    \
41
    do {    \
42
        EFLTestLauncher::startTest();   \
43
    } while (0)
44
45
#define END_TEST()    \
46
    do {    \
47
        EFLTestLauncher::endTest(); \
48
    } while (0)
49
50
#define EFL_INIT_RET()  \
51
    do {    \
52
        if (!EFLTestLauncher::init())   \
53
            return EINA_FALSE;    \
54
    } while (0)
55
56
#define EFL_INIT()  \
57
    do {    \
58
        EFLTestLauncher::init();    \
59
    } while (0)
60
61
namespace EFLUnitTests {
62
63
class EFLTestLauncher {
64
    static Eina_Bool createTest(const char* url, void (*event_callback)(void*, Evas_Object*, void*), const char* event_name, void* event_data);
65
public:
66
    static Eina_Bool init();
67
    static void startTest();
68
    static void endTest();
69
70
    static Eina_Bool runTest(const char* url, void (*event_callback)(void*, Evas_Object*, void*), const char* event_name, void* event_data);
71
    static Eina_Bool runTest(void (*event_callback)(void*, Evas_Object*, void*), const char* event_name, void* event_data);
72
};
73
74
}
75
76
#endif
- a/Source/WebKit/efl/tests/src/UnitTestLauncher/EFLTestView.cpp +177 lines
Line 0 a/Source/WebKit/efl/tests/src/UnitTestLauncher/EFLTestView.cpp_sec1
1
/*
2
    Copyright (C) 2011 Samsung Electronics
3
4
    This library is free software; you can redistribute it and/or
5
    modify it under the terms of the GNU Lesser General Public
6
    License as published by the Free Software Foundation; either
7
    version 2.1 of the License, or (at your option) any later version.
8
9
    This library 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
    Lesser General Public License for more details.
13
14
    You should have received a copy of the GNU Lesser General Public License
15
    along with this library; if not, write to the Free Software Foundation,
16
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#include "config.h"
20
#include "EFLTestView.h"
21
22
#include "EFLTestConfig.h"
23
#include "EWebKit.h"
24
25
#include <Ecore.h>
26
#include <Ecore_File.h>
27
#include <Edje.h>
28
#include <Eina.h>
29
30
#include <string.h>
31
32
namespace EFLUnitTests {
33
34
EFLTestEcoreEvas::EFLTestEcoreEvas()
35
    : m_ecore_evas(0)
36
{
37
    m_ecore_evas = ecore_evas_new(0, 0, 0, EFLUnitTests::Config::defaultViewWidth, EFLUnitTests::Config::defaultViewHeight, 0);
38
}
39
40
EFLTestEcoreEvas::EFLTestEcoreEvas(const char *engine_name, int viewport_x, int viewport_y, int viewport_w, int viewport_h, const char *extra_options)
41
    : m_ecore_evas(0)
42
{
43
    m_ecore_evas = ecore_evas_new(engine_name, viewport_x, viewport_y, viewport_w, viewport_h, extra_options);
44
}
45
46
EFLTestEcoreEvas::~EFLTestEcoreEvas()
47
{
48
    if (m_ecore_evas)
49
        ecore_evas_free(m_ecore_evas);
50
}
51
52
Evas* EFLTestEcoreEvas::getEvas()
53
{
54
    if (m_ecore_evas)
55
        return ecore_evas_get(m_ecore_evas);
56
    return 0;
57
}
58
59
void EFLTestEcoreEvas::show()
60
{
61
    if (m_ecore_evas)
62
        ecore_evas_show(m_ecore_evas);
63
}
64
65
EFLTestView::EFLTestView(Evas* evas)
66
    : m_webView(0)
67
    , m_evas(evas)
68
    , m_url(0)
69
    , m_defaultViewType(TiledView)
70
    , m_width(EFLUnitTests::Config::defaultViewWidth)
71
    , m_height(EFLUnitTests::Config::defaultViewHeight)
72
{
73
    m_url = createTestUrl(EFLUnitTests::Config::defaultTestPage);
74
}
75
76
EFLTestView::EFLTestView(Evas *evas, const char* url)
77
    : m_webView(0)
78
    , m_evas(evas)
79
    , m_url(0)
80
    , m_defaultViewType(TiledView)
81
    , m_width(EFLUnitTests::Config::defaultViewWidth)
82
    , m_height(EFLUnitTests::Config::defaultViewHeight)
83
{
84
    m_url = createTestUrl(url);
85
}
86
87
EFLTestView::EFLTestView(Evas *evas, EwkViewType type, const char* url)
88
    : m_webView(0)
89
    , m_evas(evas)
90
    , m_url(0)
91
    , m_defaultViewType(type)
92
    , m_width(EFLUnitTests::Config::defaultViewWidth)
93
    , m_height(EFLUnitTests::Config::defaultViewHeight)
94
{
95
    m_url = createTestUrl(url);
96
}
97
98
EFLTestView::EFLTestView(Evas *evas, EwkViewType type, const char* url, int width, int height)
99
    : m_webView(0)
100
    , m_evas(evas)
101
    , m_url(0)
102
    , m_defaultViewType(type)
103
    , m_width(width)
104
    , m_height(height)
105
{
106
    m_url = createTestUrl(url);
107
}
108
109
EFLTestView::~EFLTestView()
110
{
111
    if (m_webView)
112
        evas_object_del(m_webView);
113
    free(m_url);
114
}
115
116
char* EFLTestView::createTestUrl(const char* url)
117
{
118
    if (url)
119
        return strdup(url);
120
    return 0;
121
}
122
123
Eina_Bool EFLTestView::init()
124
{
125
    if (!m_evas || !m_url)
126
        return EINA_FALSE;
127
128
    switch (m_defaultViewType) {
129
    case SingleView:
130
        m_webView = ewk_view_single_add(m_evas);
131
        break;
132
133
    case TiledView:
134
        m_webView = ewk_view_tiled_add(m_evas);
135
        break;
136
    }
137
138
    if (!m_webView)
139
        return EINA_FALSE;
140
141
    ewk_view_theme_set(m_webView, EFLUnitTests::Config::defaultThemePath);
142
    ewk_view_uri_set(m_webView, m_url);
143
}
144
145
void EFLTestView::show()
146
{
147
    if (!m_webView)
148
        return;
149
    evas_object_resize(m_webView, m_width, m_height);
150
    evas_object_show(m_webView);
151
    evas_object_focus_set(m_webView, EINA_TRUE);
152
}
153
154
Evas_Object* EFLTestView::getMainFrame()
155
{
156
    if (m_webView)
157
        return ewk_view_frame_main_get(m_webView);
158
    return 0;
159
}
160
161
Evas* EFLTestView::getEvas()
162
{
163
    if (m_webView)
164
        return evas_object_evas_get(m_webView);
165
    return 0;
166
}
167
168
void EFLTestView::bindEvents(void (*callback)(void*, Evas_Object*, void*), const char* eventName, void* ptr)
169
{
170
    if (!m_webView)
171
        return;
172
173
    evas_object_smart_callback_del(m_webView, eventName, callback);
174
    evas_object_smart_callback_add(m_webView, eventName, callback, ptr);
175
}
176
177
}
- a/Source/WebKit/efl/tests/src/UnitTestLauncher/EFLTestView.h +77 lines
Line 0 a/Source/WebKit/efl/tests/src/UnitTestLauncher/EFLTestView.h_sec1
1
/*
2
    Copyright (C) 2011 Samsung Electronics
3
4
    This library is free software; you can redistribute it and/or
5
    modify it under the terms of the GNU Lesser General Public
6
    License as published by the Free Software Foundation; either
7
    version 2.1 of the License, or (at your option) any later version.
8
9
    This library 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
    Lesser General Public License for more details.
13
14
    You should have received a copy of the GNU Lesser General Public License
15
    along with this library; if not, write to the Free Software Foundation,
16
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#ifndef EFLTestView_h
20
#define EFLTestView_h
21
22
#include <Ecore_Evas.h>
23
#include <Evas.h>
24
25
namespace EFLUnitTests {
26
27
class EFLTestEcoreEvas {
28
public:
29
    EFLTestEcoreEvas();
30
    EFLTestEcoreEvas(const char *engine_name, int viewport_x, int viewport_y, int viewport_w, int viewport_h, const char *extra_options);
31
    ~EFLTestEcoreEvas();
32
33
    Evas* getEvas();
34
    void show();
35
36
private:
37
    Ecore_Evas *m_ecore_evas;
38
};
39
40
class EFLTestView {
41
public:
42
    enum EwkViewType {
43
        SingleView = 0,
44
        TiledView,
45
    };
46
47
    explicit EFLTestView(Evas*);
48
    EFLTestView(Evas*, const char* url);
49
    EFLTestView(Evas*, EwkViewType, const char* url);
50
    EFLTestView(Evas*, EwkViewType, const char* url, int width, int height);
51
52
    virtual ~EFLTestView();
53
54
    Evas_Object* getWebView() { return m_webView; }
55
    Evas_Object* getMainFrame();
56
    Evas* getEvas();
57
    void show();
58
59
    Eina_Bool init();
60
    void bindEvents(void (*callback)(void*, Evas_Object*, void*), const char* eventName, void* ptr);
61
protected:
62
    char* createTestUrl(const char* url);
63
private:
64
    EFLTestView(const EFLTestView&);
65
    EFLTestView operator=(const EFLTestView&);
66
67
    Evas* m_evas;
68
    Evas_Object* m_webView;
69
70
    char* m_url;
71
    int m_width, m_height;
72
    EwkViewType m_defaultViewType;
73
};
74
75
}
76
77
#endif

Return to Bug 68509