[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_frame_is_main_frame_func.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_ewk_frame_is_main_frame: public utc_blink_ewk_base
8 {
9 protected:
10   static void main_frame_check(void* data, Evas_Object* webview, void* event_info)
11   {
12     utc_message("  [ %s ]", __PRETTY_FUNCTION__);
13     CheckIsMainFrame(data, event_info, EINA_TRUE);
14   }
15
16   static void sub_frame_check(void* data, Evas_Object* webview, void* event_info)
17   {
18     CheckIsMainFrame(data, event_info, EINA_FALSE);
19   }
20
21   static void CheckIsMainFrame(void* data, void* event_info, Eina_Bool expected_value)
22   {
23     utc_message("  [ %s ]", __PRETTY_FUNCTION__);
24     ASSERT_TRUE(data);
25     ASSERT_TRUE(event_info);
26
27     utc_blink_ewk_frame_is_main_frame* owner = NULL;
28     OwnerFromVoid(data, &owner);
29
30     Ewk_Policy_Decision* policy_decision = static_cast<Ewk_Policy_Decision*>(event_info);
31     Ewk_Frame_Ref frame = ewk_policy_decision_frame_get(policy_decision);
32
33     ASSERT_TRUE(frame);
34     if (ewk_frame_is_main_frame(frame) == expected_value) {
35       owner->EventLoopStop(Success);
36     }
37   }
38 };
39
40 TEST_F(utc_blink_ewk_frame_is_main_frame, MAIN_FRAME)
41 {
42   evas_object_smart_callback_auto scb(GetEwkWebView(), "policy,navigation,decide", main_frame_check, this);
43
44   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), "http://www.google.com"));
45   ASSERT_EQ(Success, EventLoopStart());
46 }
47
48 TEST_F(utc_blink_ewk_frame_is_main_frame, SUB_FRAME)
49 {
50   evas_object_smart_callback_auto scb(GetEwkWebView(), "policy,navigation,decide", sub_frame_check, this);
51   std::string resurl = GetResourceUrl("ewk_frame/iframetest.html");
52   ASSERT_NE(resurl.length(), 0);
53
54   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), resurl.c_str()));
55   ASSERT_EQ(Success, EventLoopStart());
56 }
57
58 TEST_F(utc_blink_ewk_frame_is_main_frame, INVALID_ARGS)
59 {
60   EXPECT_EQ(EINA_FALSE, ewk_frame_is_main_frame(NULL));
61 }