[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_view_back_forward_list_get_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_view_back_forward_list_get : public utc_blink_ewk_base
8 {
9 protected:
10   void LoadFinished(Evas_Object *) {
11     EventLoopStop(Success);
12   }
13
14 protected:
15   static const char* const TEST_URL1;
16   static const char* const TEST_URL2;
17   static const char* const TEST_URL3;
18 };
19
20 const char* const utc_blink_ewk_view_back_forward_list_get::TEST_URL1 = "ewk_history/page1.html";
21 const char* const utc_blink_ewk_view_back_forward_list_get::TEST_URL2 = "ewk_history/page2.html";
22 const char* const utc_blink_ewk_view_back_forward_list_get::TEST_URL3 = "ewk_history/page3.html";
23
24 TEST_F(utc_blink_ewk_view_back_forward_list_get, POS_TEST)
25 {
26   // load 3 pages to get some interesting history
27   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(TEST_URL1).c_str()));
28   ASSERT_EQ(Success, EventLoopStart());
29   std::string expectedTitle1(ewk_view_title_get(GetEwkWebView()));
30   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(TEST_URL2).c_str()));
31   ASSERT_EQ(Success, EventLoopStart());
32   std::string expectedTitle2(ewk_view_title_get(GetEwkWebView()));
33   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(TEST_URL3).c_str()));
34   ASSERT_EQ(Success, EventLoopStart());
35   std::string expectedTitle3(ewk_view_title_get(GetEwkWebView()));
36
37   // get back-forward list
38   Ewk_Back_Forward_List *list = ewk_view_back_forward_list_get(GetEwkWebView());
39   ASSERT_TRUE(list);
40
41   // check list count
42   ASSERT_EQ(3, ewk_back_forward_list_count(list));
43
44   // get current item and check URL, original URL and title
45   Ewk_Back_Forward_List_Item *item = ewk_back_forward_list_current_item_get(list);
46
47   ASSERT_STREQ(GetResourceUrl(TEST_URL3).c_str(), ewk_back_forward_list_item_url_get(item));
48   ASSERT_STREQ(GetResourceUrl(TEST_URL3).c_str(), ewk_back_forward_list_item_original_url_get(item));
49   ASSERT_STREQ(expectedTitle3.c_str(), ewk_back_forward_list_item_title_get(item));
50
51   // go back
52   ASSERT_EQ(EINA_TRUE, ewk_view_back(GetEwkWebView()));
53   ASSERT_EQ(Success, EventLoopStart());
54
55   // check list count
56   ASSERT_EQ(3, ewk_back_forward_list_count(list));
57
58   // get current item and check URL, original URL and title
59   item = ewk_back_forward_list_current_item_get(list);
60
61   ASSERT_STREQ(GetResourceUrl(TEST_URL2).c_str(), ewk_back_forward_list_item_url_get(item));
62   ASSERT_STREQ(GetResourceUrl(TEST_URL2).c_str(), ewk_back_forward_list_item_original_url_get(item));
63   ASSERT_STREQ(expectedTitle2.c_str(), ewk_back_forward_list_item_title_get(item));
64
65   // go back
66   ASSERT_EQ(EINA_TRUE, ewk_view_back(GetEwkWebView()));
67   ASSERT_EQ(Success, EventLoopStart());
68
69   // check list count
70   ASSERT_EQ(3, ewk_back_forward_list_count(list));
71
72   // get current item and check URL, original URL and title
73   item = ewk_back_forward_list_current_item_get(list);
74
75   ASSERT_STREQ(GetResourceUrl(TEST_URL1).c_str(), ewk_back_forward_list_item_url_get(item));
76   ASSERT_STREQ(GetResourceUrl(TEST_URL1).c_str(), ewk_back_forward_list_item_original_url_get(item));
77   ASSERT_STREQ(expectedTitle1.c_str(), ewk_back_forward_list_item_title_get(item));
78
79   // load page so the list should be changed
80   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(TEST_URL3).c_str()));
81   ASSERT_EQ(Success, EventLoopStart());
82
83   // check list count
84   ASSERT_EQ(2, ewk_back_forward_list_count(list));
85
86   // get current item and check URL, original URL and title
87   item = ewk_back_forward_list_current_item_get(list);
88
89   ASSERT_STREQ(GetResourceUrl(TEST_URL3).c_str(), ewk_back_forward_list_item_url_get(item));
90   ASSERT_STREQ(GetResourceUrl(TEST_URL3).c_str(), ewk_back_forward_list_item_original_url_get(item));
91   ASSERT_STREQ(expectedTitle3.c_str(), ewk_back_forward_list_item_title_get(item));
92 }
93
94 TEST_F(utc_blink_ewk_view_back_forward_list_get, EMPTY_TEST)
95 {
96   Ewk_Back_Forward_List *list = ewk_view_back_forward_list_get(GetEwkWebView());
97   ASSERT_TRUE(list);
98   ASSERT_EQ(0, ewk_back_forward_list_count(list));
99 }
100
101 TEST_F(utc_blink_ewk_view_back_forward_list_get, NULL_TEST)
102 {
103   ASSERT_FALSE(ewk_view_back_forward_list_get(NULL));
104 }