[M120 Migration][MM] Support W3C EME
[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  void LoadProgress(Evas_Object* webview, double progress) override {
12    EventLoopStop(utc_blink_ewk_base::Success);
13   }
14
15 protected:
16   static const char * const SAMPLE_HTML_FILE;
17   static const double cProgressComplete;
18   static const double cInvlaidLoad;
19 };
20
21 const char * const utc_blink_ewk_view_load_progress_get::SAMPLE_HTML_FILE = "/common/sample.html";
22 const double utc_blink_ewk_view_load_progress_get::cProgressComplete = 1.0;
23 const double utc_blink_ewk_view_load_progress_get::cInvlaidLoad = -1.0;
24
25 /**
26   * @brief Tests if returns TRUE when initiated with a correct context without a page load.
27   */
28 TEST_F(utc_blink_ewk_view_load_progress_get, POS_TEST1)
29 {
30   Eina_Bool result = EINA_FALSE;
31   double value = ewk_view_load_progress_get(GetEwkWebView());
32   if (value == 0) {
33     result = EINA_TRUE;
34   }
35   evas_object_show(GetEwkWebView());
36   evas_object_show(GetEwkWebView());
37   EXPECT_EQ(result, EINA_TRUE);
38 }
39
40 /**
41   * @brief Tests if returns TRUE when not initiated with correct context with a valid page load.
42   */
43 TEST_F(utc_blink_ewk_view_load_progress_get, POS_TEST2)
44 {
45   ewk_view_url_set(GetEwkWebView(), GetResourceUrl(SAMPLE_HTML_FILE).c_str());
46
47   utc_blink_ewk_base::MainLoopResult main_result = EventLoopStart();
48   if (main_result != utc_blink_ewk_base::Success) {
49     FAIL();
50   }
51
52   Eina_Bool result = EINA_FALSE;
53   double value = ewk_view_load_progress_get(GetEwkWebView());
54   if (value <= cProgressComplete) {
55     result = EINA_TRUE;
56   }
57   evas_object_show(GetEwkWebView());
58   evas_object_show(GetEwkWebView());
59   EXPECT_EQ(result, EINA_TRUE);
60 }
61
62 /**
63   * @brief Tests if returns FALSE when not initiated with NULL context.
64   */
65 TEST_F(utc_blink_ewk_view_load_progress_get, NEG_TEST)
66 {
67   Eina_Bool result = EINA_FALSE;
68   double value = ewk_view_load_progress_get(NULL);
69   if (value == cInvlaidLoad) {
70      result = EINA_TRUE;
71   }
72   evas_object_show(GetEwkWebView());
73   evas_object_show(GetEwkWebView());
74   EXPECT_EQ(result, EINA_TRUE);
75 }