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.
5 #include "utc_blink_ewk_base.h"
7 class utc_blink_ewk_view_back_forward_list_get : public utc_blink_ewk_base
10 void LoadFinished(Evas_Object *) {
11 EventLoopStop(Success);
15 static const char* const TEST_URL1;
16 static const char* const TEST_URL2;
17 static const char* const TEST_URL3;
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";
24 TEST_F(utc_blink_ewk_view_back_forward_list_get, POS_TEST)
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()));
37 // get back-forward list
38 Ewk_Back_Forward_List *list = ewk_view_back_forward_list_get(GetEwkWebView());
42 ASSERT_EQ(3, ewk_back_forward_list_count(list));
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);
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));
52 ASSERT_EQ(EINA_TRUE, ewk_view_back(GetEwkWebView()));
53 ASSERT_EQ(Success, EventLoopStart());
56 ASSERT_EQ(3, ewk_back_forward_list_count(list));
58 // get current item and check URL, original URL and title
59 item = ewk_back_forward_list_current_item_get(list);
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));
66 ASSERT_EQ(EINA_TRUE, ewk_view_back(GetEwkWebView()));
67 ASSERT_EQ(Success, EventLoopStart());
70 ASSERT_EQ(3, ewk_back_forward_list_count(list));
72 // get current item and check URL, original URL and title
73 item = ewk_back_forward_list_current_item_get(list);
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));
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());
84 ASSERT_EQ(2, ewk_back_forward_list_count(list));
86 // get current item and check URL, original URL and title
87 item = ewk_back_forward_list_current_item_get(list);
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));
94 TEST_F(utc_blink_ewk_view_back_forward_list_get, EMPTY_TEST)
96 Ewk_Back_Forward_List *list = ewk_view_back_forward_list_get(GetEwkWebView());
98 ASSERT_EQ(0, ewk_back_forward_list_count(list));
101 TEST_F(utc_blink_ewk_view_back_forward_list_get, NULL_TEST)
103 ASSERT_FALSE(ewk_view_back_forward_list_get(NULL));