[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_history_back_list_length_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_history_back_list_length_get : 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_history_back_list_length_get::TEST_URL1 = "ewk_history/page1.html";
19 const char* const utc_blink_ewk_history_back_list_length_get::TEST_URL2 = "ewk_history/page2.html";
20 const char* const utc_blink_ewk_history_back_list_length_get::TEST_URL3 = "ewk_history/page3.html";
21
22 TEST_F(utc_blink_ewk_history_back_list_length_get, EMPTY_TEST)
23 {
24   Ewk_History *history = ewk_view_history_get(GetEwkWebView());
25   ASSERT_TRUE(history);
26   ASSERT_EQ(0, ewk_history_back_list_length_get(history));
27
28   // free history
29   ewk_history_free(history);
30 }
31
32 TEST_F(utc_blink_ewk_history_back_list_length_get, NOT_EMPTY_TEST)
33 {
34   // load first page
35   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(TEST_URL1).c_str()));
36   ASSERT_EQ(Success, EventLoopStart());
37   // get history
38   Ewk_History *history = ewk_view_history_get(GetEwkWebView());
39
40   ASSERT_EQ(0, ewk_history_back_list_length_get(history));
41
42   // free history
43   ewk_history_free(history);
44
45   // load second page
46   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(TEST_URL2).c_str()));
47   ASSERT_EQ(Success, EventLoopStart());
48   // get history
49   history = ewk_view_history_get(GetEwkWebView());
50   ASSERT_TRUE(history);
51
52   ASSERT_EQ(1, ewk_history_back_list_length_get(history));
53
54   // free history
55   ewk_history_free(history);
56
57   // load third page
58   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(TEST_URL3).c_str()));
59   ASSERT_EQ(Success, EventLoopStart());
60   // get history
61   history = ewk_view_history_get(GetEwkWebView());
62   ASSERT_TRUE(history);
63
64   ASSERT_EQ(2, ewk_history_back_list_length_get(history));
65
66   // free history
67   ewk_history_free(history);
68
69   // go back
70   ASSERT_EQ(EINA_TRUE, ewk_view_back(GetEwkWebView()));
71   // get history
72   history = ewk_view_history_get(GetEwkWebView());
73   ASSERT_TRUE(history);
74
75   ASSERT_EQ(1, ewk_history_back_list_length_get(history));
76
77   // free history
78   ewk_history_free(history);
79 }
80
81 TEST_F(utc_blink_ewk_history_back_list_length_get, NULL_HISTORY_TEST)
82 {
83   ASSERT_EQ(0, ewk_history_back_list_length_get(NULL));
84 }