Implementation for ewk_settings_private_browsing
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_view_load_progress_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 /* Define those macros _before_ you include the utc_blink_ewk.h header file. */
6
7 #include "utc_blink_ewk_base.h"
8
9 class utc_blink_ewk_view_load_progress_get : public utc_blink_ewk_base {
10 protected:
11
12   void LoadProgress(Evas_Object* webview, double progress)
13   {
14     EventLoopStop(utc_blink_ewk_base::Success);
15   }
16
17 protected:
18   static const char * const SAMPLE_HTML_FILE;
19   static const double cProgressComplete;
20   static const double cInvlaidLoad;
21 };
22
23 const char * const utc_blink_ewk_view_load_progress_get::SAMPLE_HTML_FILE = "/common/sample.html";
24 const double utc_blink_ewk_view_load_progress_get::cProgressComplete = 1.0;
25 const double utc_blink_ewk_view_load_progress_get::cInvlaidLoad = -1.0;
26
27 /**
28   * @brief Tests if returns TRUE when initiated with a correct context without a page load.
29   */
30 TEST_F(utc_blink_ewk_view_load_progress_get, POS_TEST1)
31 {
32   Eina_Bool result = EINA_FALSE;
33   double value = ewk_view_load_progress_get(GetEwkWebView());
34   if (value == 0) {
35     result = EINA_TRUE;
36   }
37   evas_object_show(GetEwkWebView());
38   evas_object_show(GetEwkWebView());
39   EXPECT_EQ(result, EINA_TRUE);
40 }
41
42 /**
43   * @brief Tests if returns TRUE when not initiated with correct context with a valid page load.
44   */
45 TEST_F(utc_blink_ewk_view_load_progress_get, POS_TEST2)
46 {
47   ewk_view_url_set(GetEwkWebView(), GetResourceUrl(SAMPLE_HTML_FILE).c_str());
48
49   utc_blink_ewk_base::MainLoopResult main_result = EventLoopStart();
50   if (main_result != utc_blink_ewk_base::Success) {
51     FAIL();
52   }
53
54   Eina_Bool result = EINA_FALSE;
55   double value = ewk_view_load_progress_get(GetEwkWebView());
56   if (value <= cProgressComplete) {
57     result = EINA_TRUE;
58   }
59   evas_object_show(GetEwkWebView());
60   evas_object_show(GetEwkWebView());
61   EXPECT_EQ(result, EINA_TRUE);
62 }
63
64 /**
65   * @brief Tests if returns FALSE when not initiated with NULL context.
66   */
67 TEST_F(utc_blink_ewk_view_load_progress_get, NEG_TEST)
68 {
69   Eina_Bool result = EINA_FALSE;
70   double value = ewk_view_load_progress_get(NULL);
71   if (value == cInvlaidLoad) {
72      result = EINA_TRUE;
73   }
74   evas_object_show(GetEwkWebView());
75   evas_object_show(GetEwkWebView());
76   EXPECT_EQ(result, EINA_TRUE);
77 }