[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_auth_challenge_realm_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 static const char* const kUrl = "https://review.tizen.org/gerrit/#/";
8
9 class utc_blink_ewk_auth_challenge_realm_get : public utc_blink_ewk_base
10 {
11 protected:
12
13   void PostSetUp() override
14   {
15     ewk_view_authentication_callback_set(GetEwkWebView(), AuthenticationChallenge, this);
16   }
17
18   void PreTearDown() override
19   {
20     ewk_view_authentication_callback_set(GetEwkWebView(), nullptr, nullptr);
21   }
22
23   void LoadFinished(Evas_Object* webview) override {
24     EventLoopStop( utc_blink_ewk_base::Failure ); // will noop if EventLoopStop was alraedy called
25   }
26
27   static void AuthenticationChallenge(Evas_Object* o, Ewk_Auth_Challenge* auth_challenge, void* data)
28   {
29     ASSERT_TRUE(data != NULL);
30
31     utc_blink_ewk_auth_challenge_realm_get *owner = static_cast<utc_blink_ewk_auth_challenge_realm_get*>(data);
32
33     if (auth_challenge)
34     {
35       std::string realm = ewk_auth_challenge_realm_get(auth_challenge);
36       if (realm == "Tizen.org ACCOUNT") {
37         owner->EventLoopStop(utc_blink_ewk_base::Success);
38         return;
39       }
40     }
41     owner->EventLoopStop(utc_blink_ewk_base::Failure);
42   }
43 };
44
45 /**
46  * @brief Checking whether the realm of authentication challenge is returned properly.
47  */
48 TEST_F(utc_blink_ewk_auth_challenge_realm_get, POS_TEST)
49 {
50   ASSERT_TRUE(ewk_view_url_set(GetEwkWebView(), kUrl));
51   EXPECT_EQ(Success, EventLoopStart());
52 }
53
54 /**
55  * @brief Checking whether function works properly in case of NULL of a webview.
56  */
57 TEST_F(utc_blink_ewk_auth_challenge_realm_get, NEG_TEST)
58 {
59   ASSERT_FALSE(ewk_view_url_set(NULL, kUrl));
60 }