<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[151428] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/151428">151428</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2013-06-11 01:35:48 -0700 (Tue, 11 Jun 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>[EFL][WK2] Fix test_ewk2_context_menu
https://bugs.webkit.org/show_bug.cgi?id=116601

Patch by Michał Pakuła vel Rutka &lt;m.pakula@samsung.com&gt; on 2013-06-11
Reviewed by Gyuyoung Kim.

test_ewk2_context_menu is always passing, it does not test any context menu feature
as it ends before context menu is called.
One single test was divided into two tests: testing WebKit2 created context menu and
testing menus and items created by application.

* UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp:
(EWK2UnitTest::EWK2UnitTestBase::waitUntilTrue): added function introducing internal loop until boolean value is changed to true
* UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h:
* UIProcess/API/efl/tests/test_ewk2_context_menu.cpp:
(customItemSelected):
(showContextMenu):
(showContextMenuForRemoveAndAppend):
(showContextMenuForSubmenu):
(hideContextMenu):
(TEST_F):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIefltestsUnitTestUtilsEWK2UnitTestBasecpp">trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIefltestsUnitTestUtilsEWK2UnitTestBaseh">trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIeflteststest_ewk2_context_menucpp">trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context_menu.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (151427 => 151428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2013-06-11 08:10:24 UTC (rev 151427)
+++ trunk/Source/WebKit2/ChangeLog        2013-06-11 08:35:48 UTC (rev 151428)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2013-06-11  Michał Pakuła vel Rutka  &lt;m.pakula@samsung.com&gt;
+
+        [EFL][WK2] Fix test_ewk2_context_menu
+        https://bugs.webkit.org/show_bug.cgi?id=116601
+
+        Reviewed by Gyuyoung Kim.
+
+        test_ewk2_context_menu is always passing, it does not test any context menu feature
+        as it ends before context menu is called.
+        One single test was divided into two tests: testing WebKit2 created context menu and
+        testing menus and items created by application.
+
+        * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp:
+        (EWK2UnitTest::EWK2UnitTestBase::waitUntilTrue): added function introducing internal loop until boolean value is changed to true
+        * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h:
+        * UIProcess/API/efl/tests/test_ewk2_context_menu.cpp:
+        (customItemSelected):
+        (showContextMenu):
+        (showContextMenuForRemoveAndAppend):
+        (showContextMenuForSubmenu):
+        (hideContextMenu):
+        (TEST_F):
+
</ins><span class="cx"> 2013-06-11  Ryuan Choi  &lt;ryuan.choi@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [EFL][WK2] Add ewk_view_navigate API
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIefltestsUnitTestUtilsEWK2UnitTestBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp (151427 => 151428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp        2013-06-11 08:10:24 UTC (rev 151427)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp        2013-06-11 08:35:48 UTC (rev 151428)
</span><span class="lines">@@ -224,6 +224,16 @@
</span><span class="cx">     return !data.didTimeOut();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool EWK2UnitTestBase::waitUntilTrue(bool &amp;flag, double timeoutSeconds)
+{
+    CallbackDataExpectedValue&lt;bool&gt; data(true, timeoutSeconds);
+
+    while (!data.isDone() &amp;&amp; !flag)
+        ecore_main_loop_iterate();
+
+    return !data.didTimeOut();
+}
+
</ins><span class="cx"> void EWK2UnitTestBase::mouseClick(int x, int y, int button)
</span><span class="cx"> {
</span><span class="cx">     Evas* evas = evas_object_evas_get(m_webView);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIefltestsUnitTestUtilsEWK2UnitTestBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h (151427 => 151428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h        2013-06-11 08:10:24 UTC (rev 151427)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h        2013-06-11 08:35:48 UTC (rev 151428)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx">     bool waitUntilLoadFinished(double timeoutSeconds = defaultTimeoutSeconds);
</span><span class="cx">     bool waitUntilTitleChangedTo(const char* expectedTitle, double timeoutSeconds = defaultTimeoutSeconds);
</span><span class="cx">     bool waitUntilURLChangedTo(const char* expectedURL, double timeoutSeconds = defaultTimeoutSeconds);
</span><ins>+    bool waitUntilTrue(bool &amp;flag, double timeoutSeconds = defaultTimeoutSeconds);
</ins><span class="cx"> 
</span><span class="cx">     void mouseClick(int x, int y, int button = 1 /*Left*/);
</span><span class="cx">     void mouseDown(int x, int y, int button = 1 /*Left*/);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIeflteststest_ewk2_context_menucpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context_menu.cpp (151427 => 151428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context_menu.cpp        2013-06-11 08:10:24 UTC (rev 151427)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context_menu.cpp        2013-06-11 08:35:48 UTC (rev 151428)
</span><span class="lines">@@ -27,6 +27,20 @@
</span><span class="cx"> 
</span><span class="cx"> extern EWK2UnitTestEnvironment* environment;
</span><span class="cx"> 
</span><ins>+static bool testFinished = false;
+
+static const Ewk_Context_Menu_Item_Type customItemType = EWK_ACTION_TYPE;
+static const Ewk_Context_Menu_Item_Action customItemTag = EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG;
+static const char customItemTitle[] = &quot;Custom Item&quot;;
+static const bool customItemChecked = false;
+static const bool customItemEnabled = true;
+
+static const char webkitItemTitle1[] = &quot;Open Link&quot;;
+static const char webkitItemTitle2[] = &quot;Open Link in New Window&quot;;
+static const char webkitItemTitle3[] = &quot;Download Linked File&quot;;
+static const char webkitItemTitle4[] = &quot;Copy Link Location&quot;;
+static const char webkitItemNewTitle[] = &quot;Copy Link&quot;;
+
</ins><span class="cx"> static inline void checkBasicContextMenuItem(Ewk_Context_Menu_Item* item, Ewk_Context_Menu_Item_Type type, Ewk_Context_Menu_Item_Action action, const char* title, Eina_Bool checked, Eina_Bool enabled)
</span><span class="cx"> {
</span><span class="cx">     ASSERT_TRUE(item);
</span><span class="lines">@@ -38,34 +52,69 @@
</span><span class="cx">     EXPECT_EQ(enabled, ewk_context_menu_item_enabled_get(item));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Eina_Bool showContextMenu(Ewk_View_Smart_Data* smartData, Evas_Coord x, Evas_Coord y, Ewk_Context_Menu* contextMenu)
</del><ins>+static Eina_Bool customItemSelected(Ewk_View_Smart_Data*, Ewk_Context_Menu_Item* item)
</ins><span class="cx"> {
</span><ins>+    checkBasicContextMenuItem(item, customItemType, static_cast&lt;Ewk_Context_Menu_Item_Action&gt;(customItemTag), customItemTitle, customItemChecked, customItemEnabled);
+
+    return true;
+}
+
+/**
+ * This callback receives context menu called upon link with items generated by WebKit2.
+ * Items have their properties modified, and one of items is selected.
+ */
+static Eina_Bool showContextMenu(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
+{
</ins><span class="cx">     const Eina_List* list = ewk_context_menu_items_get(contextMenu);
</span><span class="cx">     EXPECT_EQ(4, eina_list_count(list));
</span><span class="cx"> 
</span><span class="cx">     Ewk_Context_Menu_Item* item = static_cast&lt;Ewk_Context_Menu_Item*&gt;(eina_list_nth(list, 0));
</span><del>-    checkBasicContextMenuItem(item, EWK_ACTION_TYPE, EWK_CONTEXT_MENU_ITEM_TAG_GO_BACK, &quot;Go Back&quot;, false, true);
</del><ins>+    checkBasicContextMenuItem(item, EWK_ACTION_TYPE, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK, webkitItemTitle1, false, true);
</ins><span class="cx"> 
</span><del>-    // When context menu is created by WebKit, an item should have parent menu.
-    EXPECT_EQ(contextMenu, ewk_context_menu_item_parent_menu_get(item));
-
</del><span class="cx">     item = static_cast&lt;Ewk_Context_Menu_Item*&gt;(eina_list_nth(list, 1));
</span><del>-    checkBasicContextMenuItem(item, EWK_ACTION_TYPE, EWK_CONTEXT_MENU_ITEM_TAG_GO_FORWARD, &quot;Go Forward&quot;, false, true);
</del><ins>+    checkBasicContextMenuItem(item, EWK_ACTION_TYPE, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW, webkitItemTitle2, false, true);
</ins><span class="cx">     ewk_context_menu_item_enabled_set(item, false);
</span><span class="cx">     EXPECT_FALSE(ewk_context_menu_item_enabled_get(item));
</span><span class="cx"> 
</span><span class="cx">     item = static_cast&lt;Ewk_Context_Menu_Item*&gt;(eina_list_nth(list, 2));
</span><del>-    checkBasicContextMenuItem(item, EWK_ACTION_TYPE, EWK_CONTEXT_MENU_ITEM_TAG_STOP, &quot;Stop&quot;, false, true);
</del><ins>+    checkBasicContextMenuItem(item, EWK_ACTION_TYPE, EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK, webkitItemTitle3, false, true);
</ins><span class="cx">     ewk_context_menu_item_checked_set(item, true);
</span><span class="cx">     EXPECT_TRUE(ewk_context_menu_item_checked_get(item));
</span><span class="cx"> 
</span><span class="cx">     item = static_cast&lt;Ewk_Context_Menu_Item*&gt;(eina_list_nth(list, 3));
</span><del>-    checkBasicContextMenuItem(item, EWK_ACTION_TYPE, EWK_CONTEXT_MENU_ITEM_TAG_RELOAD, &quot;Reload&quot;, false, true);
-    ewk_context_menu_item_title_set(item, &quot;Refresh&quot;);
-    EXPECT_STREQ(&quot;Refresh&quot;, ewk_context_menu_item_title_get(item));
</del><ins>+    checkBasicContextMenuItem(item, EWK_ACTION_TYPE, EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD, webkitItemTitle4, false, true);
+    ewk_context_menu_item_title_set(item, webkitItemNewTitle);
+    EXPECT_STREQ(webkitItemNewTitle, ewk_context_menu_item_title_get(item));
</ins><span class="cx"> 
</span><del>-    // Makes new context menu items.
-    Ewk_Context_Menu_Item* newItem = ewk_context_menu_item_new(EWK_ACTION_TYPE, EWK_CONTEXT_MENU_ITEM_TAG_OTHER, &quot;New Custom Item&quot;, false, true);
</del><ins>+    // When context menu is created by WebKit, an item should have parent menu.
+    EXPECT_EQ(contextMenu, ewk_context_menu_item_parent_menu_get(item));
+
+    item = static_cast&lt;Ewk_Context_Menu_Item*&gt;(eina_list_nth(list, 0));
+
+    EXPECT_TRUE(ewk_context_menu_item_select(contextMenu, item));
+
+    return true;
+}
+
+/**
+ * This callback receives context menu called upon link with items generated by WebKit2.
+ * Received items are removed, then custom item is created and selected.
+ */
+static Eina_Bool showContextMenuForRemoveAndAppend(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
+{
+    const Eina_List* list = ewk_context_menu_items_get(contextMenu);
+    EXPECT_EQ(4, eina_list_count(list));
+
+    const Eina_List* listIterator;
+    void* data;
+    EINA_LIST_FOREACH(list, listIterator, data)
+        ewk_context_menu_item_remove(contextMenu, static_cast&lt;Ewk_Context_Menu_Item*&gt;(data));
+
+    list = ewk_context_menu_items_get(contextMenu);
+    EXPECT_EQ(0, eina_list_count(list));
+
+    Ewk_Context_Menu_Item* newItem = ewk_context_menu_item_new(customItemType, customItemTag, customItemTitle, customItemChecked, customItemEnabled);
+
</ins><span class="cx">     // When context menu item is created using ewk_context_menu_item_new, it should not have parent menu.
</span><span class="cx">     EXPECT_EQ(0, ewk_context_menu_item_parent_menu_get(newItem));
</span><span class="cx">     ewk_context_menu_item_append(contextMenu, newItem);
</span><span class="lines">@@ -73,13 +122,26 @@
</span><span class="cx">     // When context menu item is added to menu using ewk_context_menu_item_append, it should have parent menu.
</span><span class="cx">     EXPECT_EQ(contextMenu, ewk_context_menu_item_parent_menu_get(newItem));
</span><span class="cx"> 
</span><del>-    // When context menu item was created using ewk_context_menu_item_new, submenu should be 0.
</del><ins>+    // When non submenu type context menu item was created using ewk_context_menu_item_new, submenu should be 0.
</ins><span class="cx">     EXPECT_EQ(0, ewk_context_menu_item_submenu_get(newItem));
</span><span class="cx"> 
</span><ins>+    EXPECT_TRUE(ewk_context_menu_item_select(contextMenu, newItem));
+
+    ewk_context_menu_hide(contextMenu);
+
+    return true;
+}
+
+/**
+ * This callback receives context menu called upon link with items generated by WebKit2.
+ * New submenus are created, one of submenu's item is selected.
+ */
+static Eina_Bool showContextMenuForSubmenu(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
+{
</ins><span class="cx">     Eina_List* subMenuItemList = 0;
</span><del>-    Ewk_Context_Menu_Item* subMenuItem1 = ewk_context_menu_item_new(EWK_ACTION_TYPE, EWK_CONTEXT_MENU_ITEM_TAG_OTHER, &quot;New SubMenu Item 1&quot;, false, true);
-    Ewk_Context_Menu_Item* subMenuItem2 = ewk_context_menu_item_new(EWK_ACTION_TYPE, EWK_CONTEXT_MENU_ITEM_TAG_OTHER, &quot;New SubMenu Item 2&quot;, false, true);
-    Ewk_Context_Menu_Item* subMenuItem3 = ewk_context_menu_item_new(EWK_ACTION_TYPE, EWK_CONTEXT_MENU_ITEM_TAG_OTHER, &quot;New SubMenu Item 3&quot;, false, true);
</del><ins>+    Ewk_Context_Menu_Item* subMenuItem1 = ewk_context_menu_item_new(customItemType, customItemTag, customItemTitle, customItemChecked, customItemEnabled);
+    Ewk_Context_Menu_Item* subMenuItem2 = ewk_context_menu_item_new(EWK_ACTION_TYPE, static_cast&lt;Ewk_Context_Menu_Item_Action&gt;(customItemTag + 1), &quot;New SubMenu Item 2&quot;, false, true);
+    Ewk_Context_Menu_Item* subMenuItem3 = ewk_context_menu_item_new(EWK_ACTION_TYPE, static_cast&lt;Ewk_Context_Menu_Item_Action&gt;(customItemTag + 2), &quot;New SubMenu Item 3&quot;, false, true);
</ins><span class="cx">     subMenuItemList = eina_list_append(subMenuItemList, subMenuItem1);
</span><span class="cx">     subMenuItemList = eina_list_append(subMenuItemList, subMenuItem2);
</span><span class="cx">     subMenuItemList = eina_list_append(subMenuItemList, subMenuItem3);
</span><span class="lines">@@ -88,32 +150,32 @@
</span><span class="cx">     // When context menu is created using ewk_context_menu_new_with_items, items should have parent menu.
</span><span class="cx">     EXPECT_EQ(subMenu, ewk_context_menu_item_parent_menu_get(subMenuItem1));
</span><span class="cx"> 
</span><del>-    Ewk_Context_Menu_Item* newItem2 = ewk_context_menu_item_new_with_submenu(EWK_CONTEXT_MENU_ITEM_TAG_OTHER, &quot;New Custom Item 2&quot;, true, subMenu);
</del><ins>+    Ewk_Context_Menu_Item* newItem = ewk_context_menu_item_new_with_submenu(EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG, &quot;New Custom Item&quot;, true, subMenu);
</ins><span class="cx">     // When context menu item is created using ewk_context_menu_item_new_with_submenu, it should not have parent menu.
</span><span class="cx">     EXPECT_EQ(0, ewk_context_menu_item_parent_menu_get(newItem));
</span><del>-    ewk_context_menu_item_append(contextMenu, newItem2);
</del><ins>+    ewk_context_menu_item_append(contextMenu, newItem);
</ins><span class="cx"> 
</span><span class="cx">     // Context menu received from ewk_context_menu_item_submenu_get should be the same as one used to create sub menu.
</span><del>-    EXPECT_EQ(subMenu, ewk_context_menu_item_submenu_get(newItem2));
</del><ins>+    EXPECT_EQ(subMenu, ewk_context_menu_item_submenu_get(newItem));
</ins><span class="cx"> 
</span><span class="cx">     // When context menu item is created using ewk_context_menu_item_new_with_submenu and added using ewk_context_menu_item_append it should have parent menu.
</span><span class="cx">     EXPECT_EQ(contextMenu, ewk_context_menu_item_parent_menu_get(newItem));
</span><span class="cx"> 
</span><span class="cx">     Ewk_Context_Menu* subMenu2 = ewk_context_menu_new();
</span><del>-    Ewk_Context_Menu_Item* newItem3 = ewk_context_menu_item_new_with_submenu(EWK_CONTEXT_MENU_ITEM_TAG_OTHER, &quot;New Custom Item 3&quot;, true, subMenu2);
-    ewk_context_menu_item_append(contextMenu, newItem3);
</del><ins>+    Ewk_Context_Menu_Item* newItem2 = ewk_context_menu_item_new_with_submenu(EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG, &quot;New Custom Item 2&quot;, true, subMenu2);
+    ewk_context_menu_item_append(contextMenu, newItem2);
</ins><span class="cx"> 
</span><del>-    list = ewk_context_menu_items_get(contextMenu);
-    EXPECT_EQ(7, eina_list_count(list));
</del><ins>+    EXPECT_TRUE(ewk_context_menu_item_select(ewk_context_menu_item_parent_menu_get(subMenuItem1), subMenuItem1));
</ins><span class="cx"> 
</span><del>-    ewk_context_menu_item_remove(contextMenu, newItem);
-    ewk_context_menu_item_remove(contextMenu, newItem2);
-    ewk_context_menu_item_remove(contextMenu, newItem3);
-    list = ewk_context_menu_items_get(contextMenu);
-    EXPECT_EQ(4, eina_list_count(list));
</del><ins>+    ewk_context_menu_hide(ewk_context_menu_item_parent_menu_get(subMenuItem1));
</ins><span class="cx"> 
</span><del>-    EXPECT_TRUE(ewk_context_menu_item_select(contextMenu, item));
</del><ins>+    return true;
+}
</ins><span class="cx"> 
</span><ins>+static Eina_Bool hideContextMenu(Ewk_View_Smart_Data*)
+{
+    testFinished = true;
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -122,11 +184,35 @@
</span><span class="cx">     const char* itemSelectHTML =
</span><span class="cx">         &quot;&lt;html&gt;&quot;
</span><span class="cx">         &quot;&lt;body&gt;&lt;a href=http://www.google.com&gt;Test Link&lt;/a&gt;&lt;/body&gt;&quot;
</span><del>-        &quot;&lt;/body&gt;&lt;/html&gt;&quot;; 
</del><ins>+        &quot;&lt;/html&gt;&quot;;
</ins><span class="cx"> 
</span><span class="cx">     ewkViewClass()-&gt;context_menu_show = showContextMenu;
</span><span class="cx"> 
</span><span class="cx">     ewk_view_html_string_load(webView(), itemSelectHTML, &quot;file:///&quot;, 0);
</span><del>-    mouseClick(20, 30, /*Right*/ 3);
</del><span class="cx">     ASSERT_TRUE(waitUntilLoadFinished());
</span><ins>+    mouseClick(10, 20, /*Right*/ 3);
+    ASSERT_TRUE(waitUntilLoadFinished());
</ins><span class="cx"> }
</span><ins>+
+TEST_F(EWK2UnitTestBase, ewk_context_menu_custom_items)
+{
+    const char* itemSelectHTML =
+        &quot;&lt;html&gt;&quot;
+        &quot;&lt;body&gt;&lt;a href=http://www.google.com&gt;Test Link&lt;/a&gt;&lt;/body&gt;&quot;
+        &quot;&lt;/html&gt;&quot;;
+
+    ewkViewClass()-&gt;custom_item_selected = customItemSelected;
+    ewkViewClass()-&gt;context_menu_show = showContextMenuForRemoveAndAppend;
+    ewkViewClass()-&gt;context_menu_hide = hideContextMenu;
+
+    ewk_view_html_string_load(webView(), itemSelectHTML, &quot;file:///&quot;, 0);
+    ASSERT_TRUE(waitUntilLoadFinished());
+    mouseClick(10, 20, /*Right*/ 3);
+    testFinished = false;
+    ASSERT_TRUE(waitUntilTrue(testFinished));
+
+    ewkViewClass()-&gt;context_menu_show = showContextMenuForSubmenu;
+    mouseClick(10, 20, /*Right*/ 3);
+    testFinished = false;
+    ASSERT_TRUE(waitUntilTrue(testFinished));
+}
</ins></span></pre>
</div>
</div>

</body>
</html>