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_back_forward_list_next_item_get : public utc_blink_ewk_base
10 void LoadFinished(Evas_Object*) override { EventLoopStop(Success); }
13 static const char* const TEST_URL1;
14 static const char* const TEST_URL2;
15 static const char* const TEST_URL3;
18 const char* const utc_blink_ewk_back_forward_list_next_item_get::TEST_URL1 = "ewk_history/page1.html";
19 const char* const utc_blink_ewk_back_forward_list_next_item_get::TEST_URL2 = "ewk_history/page2.html";
20 const char* const utc_blink_ewk_back_forward_list_next_item_get::TEST_URL3 = "ewk_history/page3.html";
22 TEST_F(utc_blink_ewk_back_forward_list_next_item_get, POS_TEST)
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 std::string expectedTitle1(ewk_view_title_get(GetEwkWebView()));
28 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(TEST_URL2).c_str()));
29 ASSERT_EQ(Success, EventLoopStart());
30 std::string expectedTitle2(ewk_view_title_get(GetEwkWebView()));
31 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(TEST_URL3).c_str()));
32 ASSERT_EQ(Success, EventLoopStart());
33 std::string expectedTitle3(ewk_view_title_get(GetEwkWebView()));
35 // get back-forward list
36 Ewk_Back_Forward_List *list = ewk_view_back_forward_list_get(GetEwkWebView());
39 // get next item and check URL, original URL and title
40 Ewk_Back_Forward_List_Item *item = ewk_back_forward_list_next_item_get(list);
43 ASSERT_EQ(NULL, item);
46 ASSERT_EQ(EINA_TRUE, ewk_view_back(GetEwkWebView()));
47 ASSERT_EQ(Success, EventLoopStart());
49 // get next item and check URL, original URL and title
50 item = ewk_back_forward_list_next_item_get(list);
52 ASSERT_STREQ(GetResourceUrl(TEST_URL3).c_str(), ewk_back_forward_list_item_url_get(item));
53 ASSERT_STREQ(GetResourceUrl(TEST_URL3).c_str(), ewk_back_forward_list_item_original_url_get(item));
54 ASSERT_STREQ(expectedTitle3.c_str(), ewk_back_forward_list_item_title_get(item));
57 ASSERT_EQ(EINA_TRUE, ewk_view_back(GetEwkWebView()));
58 ASSERT_EQ(Success, EventLoopStart());
60 // get next item and check URL, original URL and title
61 item = ewk_back_forward_list_next_item_get(list);
63 ASSERT_STREQ(GetResourceUrl(TEST_URL2).c_str(), ewk_back_forward_list_item_url_get(item));
64 ASSERT_STREQ(GetResourceUrl(TEST_URL2).c_str(), ewk_back_forward_list_item_original_url_get(item));
65 ASSERT_STREQ(expectedTitle2.c_str(), ewk_back_forward_list_item_title_get(item));
67 // load page so the list should change
68 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(TEST_URL3).c_str()));
69 ASSERT_EQ(Success, EventLoopStart());
71 // get next item and check URL, original URL and title
72 ASSERT_EQ(NULL, ewk_back_forward_list_next_item_get(list)) << "there should not be any next item, but there is!";
75 ASSERT_EQ(EINA_TRUE, ewk_view_back(GetEwkWebView()));
76 ASSERT_EQ(Success, EventLoopStart());
78 // get next item and check URL, original URL and title
79 item = ewk_back_forward_list_next_item_get(list);
81 ASSERT_STREQ(GetResourceUrl(TEST_URL3).c_str(), ewk_back_forward_list_item_url_get(item));
82 ASSERT_STREQ(GetResourceUrl(TEST_URL3).c_str(), ewk_back_forward_list_item_original_url_get(item));
83 ASSERT_STREQ(expectedTitle3.c_str(), ewk_back_forward_list_item_title_get(item));
86 TEST_F(utc_blink_ewk_back_forward_list_next_item_get, EMPTY_TEST)
88 Ewk_Back_Forward_List *list = ewk_view_back_forward_list_get(GetEwkWebView());
90 ASSERT_EQ(NULL, ewk_back_forward_list_next_item_get(list));
93 TEST_F(utc_blink_ewk_back_forward_list_next_item_get, NULL_TEST)
95 ASSERT_EQ(NULL, ewk_back_forward_list_next_item_get(NULL));