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_ewk_policy_decision_frame_get: public utc_blink_ewk_base
10 void PostSetUp() override
12 Ewk_Settings* settings = ewk_view_settings_get(GetEwkWebView());
13 old_can_open_windows_setting_ = ewk_settings_scripts_can_open_windows_get(settings);
14 ewk_settings_scripts_can_open_windows_set(settings, true);
17 void PreTearDown() override {
18 Ewk_Settings* settings = ewk_view_settings_get(GetEwkWebView());
19 ewk_settings_scripts_can_open_windows_set(settings, old_can_open_windows_setting_);
22 static void frame_check(void* data, Evas_Object* webview, void* event_info)
24 utc_message(" [ %s ]", __PRETTY_FUNCTION__);
26 ASSERT_TRUE(data); // test will wait for timeout, nothing we can do here
27 utc_blink_ewk_policy_decision_frame_get* owner = NULL;
28 OwnerFromVoid(data, &owner);
31 // stop event loop so we won't have to wait for timeout
32 owner->EventLoopStop(Failure);
33 ASSERT_TRUE(event_info);
36 Ewk_Policy_Decision* policy_decision = static_cast<Ewk_Policy_Decision*>(event_info);
37 EXPECT_TRUE(ewk_policy_decision_frame_get(policy_decision));
38 owner->EventLoopStop(Success);
42 bool old_can_open_windows_setting_;
45 TEST_F(utc_blink_ewk_policy_decision_frame_get, NAVIGATION_DECIDE)
47 evas_object_smart_callback_auto scb(GetEwkWebView(), "policy,navigation,decide", frame_check, this);
48 std::string resurl = GetResourceUrl("ewk_policy_decision/iframe.html");
49 ASSERT_NE(0, resurl.length());
50 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), resurl.c_str()));
51 // Wait for stop from main frame
52 ASSERT_EQ(Success, EventLoopStart());
54 // Wait for second stop from sub frame
55 ASSERT_EQ(Success, EventLoopStart());
58 TEST_F(utc_blink_ewk_policy_decision_frame_get, RESPONSE_DECIDE)
60 evas_object_smart_callback_auto scb(GetEwkWebView(), "policy,response,decide", frame_check, this);
62 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), "http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe"));
63 // Wait for stop from main frame
64 ASSERT_EQ(Success, EventLoopStart());
66 // Wait for second stop from sub frame
67 ASSERT_EQ(Success, EventLoopStart());
70 TEST_F(utc_blink_ewk_policy_decision_frame_get, NEWWINDOW_DECIDE)
72 evas_object_smart_callback_auto scb(GetEwkWebView(), "policy,newwindow,decide", frame_check, this);
74 std::string resurl = GetResourceUrl("ewk_policy_decision/mainframe_newwindow.html");
75 ASSERT_NE(0, resurl.length());
76 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), resurl.c_str()));
77 // Wait for stop from main frame
78 ASSERT_EQ(Success, EventLoopStart());
80 // Wait for second stop from sub frame
81 ASSERT_EQ(Success, EventLoopStart());
84 TEST_F(utc_blink_ewk_policy_decision_frame_get, INVALID_ARGS)
86 EXPECT_FALSE(ewk_policy_decision_frame_get(NULL));