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"
7 class utc_blink_cb_protocolhandler_unregistration_requested : public utc_blink_ewk_base
10 utc_blink_cb_protocolhandler_unregistration_requested()
11 : handler_target_(NULL)
12 , handler_base_url_(NULL)
16 ~utc_blink_cb_protocolhandler_unregistration_requested() override {
17 if (handler_target_) free(handler_target_);
18 if (handler_base_url_) free(handler_base_url_);
19 if (handler_url_) free(handler_url_);
22 void LoadFinished(Evas_Object *) override
24 EventLoopStop(Failure);
27 void PostSetUp() override
29 evas_object_smart_callback_add(GetEwkWebView(), "protocolhandler,unregistration,requested", cb_protocolhandler_unregistration_requested, this);
32 void PreTearDown() override
34 evas_object_smart_callback_del(GetEwkWebView(), "protocolhandler,unregistration,requested", cb_protocolhandler_unregistration_requested);
37 static void cb_protocolhandler_unregistration_requested(void *data, Evas_Object *, void *info)
39 ASSERT_TRUE(data != NULL);
40 utc_message("protocol handler unregistered");
41 utc_blink_cb_protocolhandler_unregistration_requested *owner;
42 OwnerFromVoid(data, &owner);
44 Ewk_Custom_Handlers_Data *handler_data_ = static_cast<Ewk_Custom_Handlers_Data *>(info);
45 owner->handler_target_ = ewk_custom_handlers_data_target_get(handler_data_) ? strdup(ewk_custom_handlers_data_target_get(handler_data_)) : 0;
46 owner->handler_base_url_ = ewk_custom_handlers_data_base_url_get(handler_data_) ? strdup(ewk_custom_handlers_data_base_url_get(handler_data_)) : 0;
47 owner->handler_url_ = ewk_custom_handlers_data_url_get(handler_data_) ? strdup(ewk_custom_handlers_data_url_get(handler_data_)) : 0;
48 owner->EventLoopStop(Success);
52 char *handler_target_;
53 char *handler_base_url_;
57 TEST_F(utc_blink_cb_protocolhandler_unregistration_requested, MAILTO_PROTOCOL_UNREGISTRATION)
59 std::string url = GetResourceUrl("protocol_handler/unregister_protocol_handler.html");
60 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), url.c_str()));
61 ASSERT_EQ(Success, EventLoopStart());
62 ASSERT_STREQ("mailto", handler_target_);
63 ASSERT_STREQ("", handler_base_url_);
64 ASSERT_STREQ((url + "?url=%s").c_str(), handler_url_);