[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_cb_protocolhandler_unregistration_requested.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 class utc_blink_cb_protocolhandler_unregistration_requested : public utc_blink_ewk_base
8 {
9 protected:
10   utc_blink_cb_protocolhandler_unregistration_requested()
11     : handler_target_(NULL)
12     , handler_base_url_(NULL)
13     , handler_url_(NULL)
14   {}
15
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_);
20   }
21
22   void LoadFinished(Evas_Object *) override
23   {
24     EventLoopStop(Failure);
25   }
26
27   void PostSetUp() override
28   {
29     evas_object_smart_callback_add(GetEwkWebView(), "protocolhandler,unregistration,requested", cb_protocolhandler_unregistration_requested, this);
30   }
31
32   void PreTearDown() override
33   {
34     evas_object_smart_callback_del(GetEwkWebView(), "protocolhandler,unregistration,requested", cb_protocolhandler_unregistration_requested);
35   }
36
37   static void cb_protocolhandler_unregistration_requested(void *data, Evas_Object *, void *info)
38   {
39     ASSERT_TRUE(data != NULL);
40     utc_message("protocol handler unregistered");
41     utc_blink_cb_protocolhandler_unregistration_requested *owner;
42     OwnerFromVoid(data, &owner);
43     EXPECT_TRUE(info);
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);
49   }
50
51 protected:
52   char *handler_target_;
53   char *handler_base_url_;
54   char *handler_url_;
55 };
56
57 TEST_F(utc_blink_cb_protocolhandler_unregistration_requested, MAILTO_PROTOCOL_UNREGISTRATION)
58 {
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_);
65 }