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 #define baseURL "http://google.com"
9 class utc_blink_ewk_policy_decision_http_method_get : public utc_blink_ewk_base
12 void PostSetUp() override {
13 evas_object_smart_callback_add(GetEwkWebView(), "policy,navigation,decide", ToSmartCallback(policy_navigation_decide), this);
16 void PreTearDown() override {
17 evas_object_smart_callback_del(GetEwkWebView(), "policy,navigation,decide", ToSmartCallback(policy_navigation_decide));
20 static void policy_navigation_decide(utc_blink_ewk_policy_decision_http_method_get* owner,
21 Evas_Object* webview, Ewk_Policy_Decision* policy_decision)
24 const char* method = ewk_policy_decision_http_method_get(policy_decision);
25 owner->receivedMethod = method ? method : "";
26 owner->EventLoopStop(Success);
29 std::string getDocumentForMethod(const std::string& method)
34 "<form id='theForm' method='" + method + "' action='" + baseURL + "'>"
35 "<input name='x' value='y'/>"
39 "document.getElementById('theForm').submit();"
45 std::string receivedMethod;
46 std::string currentMethod;
50 * @brief Tests if the method for policy decision is returned properly.
52 TEST_F(utc_blink_ewk_policy_decision_http_method_get, TEST_DEFALUT_METHOD)
54 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), baseURL));
55 ASSERT_EQ(Success, EventLoopStart());
56 ASSERT_EQ("GET", receivedMethod);
59 TEST_F(utc_blink_ewk_policy_decision_http_method_get, TEST_METHOD_GET)
62 ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), getDocumentForMethod(currentMethod).c_str(), baseURL, 0));
63 ASSERT_EQ(Success, EventLoopStart());
64 ASSERT_EQ(currentMethod, receivedMethod);
67 TEST_F(utc_blink_ewk_policy_decision_http_method_get, TEST_METHOD_POST)
70 ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), getDocumentForMethod(currentMethod).c_str(), baseURL, 0));
71 ASSERT_EQ(Success, EventLoopStart());
72 ASSERT_EQ(currentMethod, receivedMethod);
75 TEST_F(utc_blink_ewk_policy_decision_http_method_get, TEST_INVALID_PARAM)
77 ASSERT_EQ(NULL, ewk_policy_decision_http_method_get(NULL));