[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_back_forward_list_item_unref_func.cpp
1 // Copyright 2014 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "utc_blink_ewk_base.h"
6
7 class utc_blink_ewk_back_forward_list_item_unref : public utc_blink_ewk_base
8 {
9 protected:
10  void LoadFinished(Evas_Object*) override { EventLoopStop(Success); }
11
12 protected:
13   static const char* const TEST_URL1;
14   static const char* const TEST_URL2;
15   static const char* const TEST_URL3;
16 };
17
18 const char* const utc_blink_ewk_back_forward_list_item_unref::TEST_URL1 = "ewk_history/page1.html";
19 const char* const utc_blink_ewk_back_forward_list_item_unref::TEST_URL2 = "ewk_history/page2.html";
20 const char* const utc_blink_ewk_back_forward_list_item_unref::TEST_URL3 = "ewk_history/page3.html";
21
22 TEST_F(utc_blink_ewk_back_forward_list_item_unref, POS_TEST)
23 {
24   // load 3 pages to get some interesting history
25   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(TEST_URL1).c_str()));
26   ASSERT_EQ(Success, EventLoopStart());
27   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(TEST_URL2).c_str()));
28   ASSERT_EQ(Success, EventLoopStart());
29
30   // get back-forward list
31   Ewk_Back_Forward_List *list = ewk_view_back_forward_list_get(GetEwkWebView());
32   ASSERT_TRUE(list);
33
34   // get current item and check URL, original URL and title
35   Ewk_Back_Forward_List_Item *item = ewk_back_forward_list_current_item_get(list);
36   ASSERT_STREQ(GetResourceUrl(TEST_URL2).c_str(), ewk_back_forward_list_item_url_get(item));
37
38   // increase ref count
39   item = ewk_back_forward_list_item_ref(item);
40   ASSERT_TRUE(item);
41
42   // go back
43   ASSERT_EQ(EINA_TRUE, ewk_view_back(GetEwkWebView()));
44   ASSERT_EQ(Success, EventLoopStart());
45
46   // load page so the refed item should normally be deleted but as it is refed
47   // it should be still ins the memory
48   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(TEST_URL3).c_str()));
49   ASSERT_EQ(Success, EventLoopStart());
50
51   // lets check it url
52   ASSERT_STREQ(GetResourceUrl(TEST_URL2).c_str(), ewk_back_forward_list_item_url_get(item));
53
54   // and unref so it should be deleted
55   ewk_back_forward_list_item_unref(item);
56   // but there is no way to test it...
57   SUCCEED();
58 }
59
60 TEST_F(utc_blink_ewk_back_forward_list_item_unref, NULL_TEST)
61 {
62   ewk_back_forward_list_item_unref(NULL);
63   SUCCEED();
64 }