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.
5 #include "utc_blink_ewk_base.h"
6 #define URL "https://review.tizen.org/gerrit/#/"
8 static Eina_Bool is_failed;
9 static Eina_Bool is_Authenticated;
11 class utc_blink_ewk_auth_challenge_credential_cancel : public utc_blink_ewk_base {
13 void PostSetUp() override
15 ewk_view_authentication_callback_set(GetEwkWebView(), AuthenticationChallenge, this);
18 void PreTearDown() override
20 ewk_view_authentication_callback_set(GetEwkWebView(), nullptr, nullptr);
23 void LoadFinished(Evas_Object* webview) override {
24 EventLoopStop(utc_blink_ewk_base::Failure); // will noop if EventLoopStop
28 static void AuthenticationChallenge(Evas_Object* o, Ewk_Auth_Challenge* auth_challenge, void* data)
30 utc_blink_ewk_auth_challenge_credential_cancel *owner = static_cast<utc_blink_ewk_auth_challenge_credential_cancel*>(data);
31 utc_message("[authentication_challenge] :: ");
33 if (!auth_challenge) {
34 owner->EventLoopStop(utc_blink_ewk_base::Failure);
38 const char* realm = ewk_auth_challenge_realm_get(auth_challenge);
39 const char* url = ewk_auth_challenge_url_get(auth_challenge);
42 owner->EventLoopStop(utc_blink_ewk_base::Failure);
47 // this test does not check if cancel was successful. It checks if authentication,challange was called
48 ewk_auth_challenge_credential_cancel(auth_challenge);
49 owner->EventLoopStop(utc_blink_ewk_base::Success);
54 * @brief Checking whether sending cancellation notification for authentication challenge works properly.
56 TEST_F(utc_blink_ewk_auth_challenge_credential_cancel, POS_TEST)
58 is_failed = EINA_FALSE;
59 is_Authenticated = EINA_FALSE;
61 Eina_Bool result = ewk_view_url_set(GetEwkWebView(), URL);
65 utc_blink_ewk_base::MainLoopResult main_result = EventLoopStart();
67 if (main_result != utc_blink_ewk_base::Success)
70 evas_object_show(GetEwkWebView());
71 evas_object_show(GetEwkWindow());
74 // TODO: this case does nothing. It didn't even start event loop, so callback wouldn't be ever called.
76 * @brief Checking whether function works properly in case of NULL of a webview.
79 TEST_F(utc_blink_ewk_auth_challenge_credential_cancel, NEG_TEST)
81 Eina_Bool result = ewk_view_url_set(NULL, URL);
85 utc_blink_ewk_base::MainLoopResult main_result = EventLoopStart(15.0);
86 evas_object_show(GetEwkWebView());
87 evas_object_show(GetEwkWindow());
91 EXPECT_NE(main_result, utc_blink_ewk_base::Success);