[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_cookie_manager_accept_policy_set_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_cookie_manager_accept_policy_set : public utc_blink_ewk_base
10 {
11 protected:
12   Ewk_Cookie_Accept_Policy cookies_policy;
13
14   static void cookies_policy_get_cb(Ewk_Cookie_Accept_Policy policy, void *event_info)
15   {
16     utc_blink_ewk_cookie_manager_accept_policy_set *owner = static_cast<utc_blink_ewk_cookie_manager_accept_policy_set*>(event_info);
17     owner->cookies_policy = policy;
18     owner->EventLoopStop(utc_blink_ewk_base::Success);
19   }
20 };
21
22 /**
23  * @brief Checking whether cookies's policy is returned to EWK_COOKIE_ACCEPT_POLICY_NEVER.
24  */
25 TEST_F(utc_blink_ewk_cookie_manager_accept_policy_set, POS_TEST1)
26 {
27   cookies_policy = EWK_COOKIE_ACCEPT_POLICY_ALWAYS;
28
29   Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(GetEwkWebView()));
30   ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
31   ewk_cookie_manager_accept_policy_async_get(cookieManager, cookies_policy_get_cb, this);
32
33   // Wait until callback finished.
34   utc_blink_ewk_base::MainLoopResult main_result = EventLoopStart();
35   if (main_result != utc_blink_ewk_base::Success)
36     FAIL();
37
38   utc_check_eq(cookies_policy, EWK_COOKIE_ACCEPT_POLICY_NEVER);
39 }
40
41 /**
42  * @brief Checking whether cookies's policy is returned to EWK_COOKIE_ACCEPT_POLICY_ALWAYS.
43  */
44 TEST_F(utc_blink_ewk_cookie_manager_accept_policy_set, POS_TEST2)
45 {
46   cookies_policy = EWK_COOKIE_ACCEPT_POLICY_NEVER;
47
48   Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(GetEwkWebView()));
49   ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
50   ewk_cookie_manager_accept_policy_async_get(cookieManager, cookies_policy_get_cb, this);
51
52   // Wait until callback finished.
53   utc_blink_ewk_base::MainLoopResult main_result = EventLoopStart();
54   if (main_result != utc_blink_ewk_base::Success)
55     FAIL();
56
57   utc_check_eq(cookies_policy, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
58 }
59
60 /**
61  * @brief Checking whether cookies's policy is returned to EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY.
62  */
63 TEST_F(utc_blink_ewk_cookie_manager_accept_policy_set, POS_TEST3)
64 {
65   cookies_policy = EWK_COOKIE_ACCEPT_POLICY_NEVER;
66
67   Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(GetEwkWebView()));
68   ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY);
69   ewk_cookie_manager_accept_policy_async_get(cookieManager, cookies_policy_get_cb, this);
70
71   // Wait until callback finished.
72   utc_blink_ewk_base::MainLoopResult main_result = EventLoopStart();
73   if (main_result != utc_blink_ewk_base::Success)
74     FAIL();
75
76   utc_check_eq(cookies_policy, EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY);
77 }
78
79 /**
80  * @brief Checking whether function works properly in case of NULL of a context.
81  */
82 TEST_F(utc_blink_ewk_cookie_manager_accept_policy_set, NEG_TEST1)
83 {
84   ewk_cookie_manager_accept_policy_set(NULL, EWK_COOKIE_ACCEPT_POLICY_NEVER);
85   ewk_cookie_manager_accept_policy_async_get(NULL, NULL, NULL);
86 }
87
88 /**
89  * @brief Checking whether function works properly in case of NULL of a context.
90  */
91 TEST_F(utc_blink_ewk_cookie_manager_accept_policy_set, NEG_TEST2)
92 {
93   ewk_cookie_manager_accept_policy_set(NULL, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
94   ewk_cookie_manager_accept_policy_async_get(NULL, NULL, NULL);
95 }
96
97 /**
98  * @brief Checking whether function works properly in case of NULL of a context.
99  */
100 TEST_F(utc_blink_ewk_cookie_manager_accept_policy_set, NEG_TEST3)
101 {
102   ewk_cookie_manager_accept_policy_set(NULL, EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY);
103   ewk_cookie_manager_accept_policy_async_get(NULL, NULL, NULL);
104 }