[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_view_web_application_capable_get_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_view_web_application_capable_get : public utc_blink_ewk_base
8 {
9 protected:
10  void LoadFinished(Evas_Object*) override { EventLoopStop(Success); }
11
12  static void webAppCapableGetCallback(Eina_Bool capable, void* data) {
13    ASSERT_TRUE(data != NULL);
14    utc_blink_ewk_view_web_application_capable_get* owner = 0;
15    OwnerFromVoid(data, &owner);
16    fprintf(stderr, "[webAppCapableGetCallback] :: capable = %s\n",
17            capable == EINA_TRUE ? "EINA_TRUE" : "EINA_FALSE");
18    ASSERT_EQ(owner->expectedCapable, capable);
19    owner->EventLoopStop(Success);
20   }
21
22 protected:
23   Eina_Bool expectedCapable;
24   static const char * const appleCapableYesPage;
25   static const char * const appleCapableNoPage;
26   static const char * const googleCapableYesPage;
27   static const char * const googleCapableNoPage;
28   static const char * const noMetaTagPage;
29 };
30
31 const char * const utc_blink_ewk_view_web_application_capable_get::appleCapableYesPage = "<html>" \
32     "<head><meta name=\"apple-mobile-web-app-capable\" content=\"yes\"></head>" \
33     "<body></body>" \
34     "</html>";
35 const char * const utc_blink_ewk_view_web_application_capable_get::appleCapableNoPage = "<html>" \
36     "<head><meta name=\"apple-mobile-web-app-capable\" content=\"no\"></head>" \
37     "<body></body>" \
38     "</html>";
39 const char * const utc_blink_ewk_view_web_application_capable_get::googleCapableYesPage = "<html>" \
40     "<head><meta name=\"mobile-web-app-capable\" content=\"yes\"></head>" \
41     "<body></body>" \
42     "</html>";
43 const char * const utc_blink_ewk_view_web_application_capable_get::googleCapableNoPage = "<html>" \
44     "<head><meta name=\"mobile-web-app-capable\" content=\"no\"></head>" \
45     "<body></body>" \
46     "</html>";
47 const char * const utc_blink_ewk_view_web_application_capable_get::noMetaTagPage = "<html><body></body></html>";
48
49 TEST_F(utc_blink_ewk_view_web_application_capable_get, APPLE_CAPABLE_YES_PAGE)
50 {
51   ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), appleCapableYesPage, 0, 0));
52   ASSERT_EQ(Success, EventLoopStart());
53   expectedCapable = EINA_TRUE;
54   ASSERT_EQ(EINA_TRUE, ewk_view_web_application_capable_get(GetEwkWebView(),
55                                                             utc_blink_ewk_view_web_application_capable_get::webAppCapableGetCallback,
56                                                             this));
57   ASSERT_EQ(Success, EventLoopStart());
58 }
59
60 TEST_F(utc_blink_ewk_view_web_application_capable_get, APPLE_CAPABLE_NO_PAGE)
61 {
62   ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), appleCapableNoPage, 0, 0));
63   ASSERT_EQ(Success, EventLoopStart());
64   expectedCapable = EINA_FALSE;
65   ASSERT_EQ(EINA_TRUE, ewk_view_web_application_capable_get(GetEwkWebView(),
66                                                             utc_blink_ewk_view_web_application_capable_get::webAppCapableGetCallback,
67                                                             this));
68   ASSERT_EQ(Success, EventLoopStart());
69 }
70
71 TEST_F(utc_blink_ewk_view_web_application_capable_get, GOOGLE_CAPABLE_YES_PAGE)
72 {
73   ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), googleCapableYesPage, 0, 0));
74   ASSERT_EQ(Success, EventLoopStart());
75   expectedCapable = EINA_TRUE;
76   ASSERT_EQ(EINA_TRUE, ewk_view_web_application_capable_get(GetEwkWebView(),
77                                                             utc_blink_ewk_view_web_application_capable_get::webAppCapableGetCallback,
78                                                             this));
79   ASSERT_EQ(Success, EventLoopStart());
80 }
81
82 TEST_F(utc_blink_ewk_view_web_application_capable_get, GOOGLE_CAPABLE_NO_PAGE)
83 {
84   ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), googleCapableNoPage, 0, 0));
85   ASSERT_EQ(Success, EventLoopStart());
86   expectedCapable = EINA_FALSE;
87   ASSERT_EQ(EINA_TRUE, ewk_view_web_application_capable_get(GetEwkWebView(),
88                                                             utc_blink_ewk_view_web_application_capable_get::webAppCapableGetCallback,
89                                                             this));
90   ASSERT_EQ(Success, EventLoopStart());
91 }
92
93 TEST_F(utc_blink_ewk_view_web_application_capable_get, NO_META_TAG_PAGE)
94 {
95   ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), noMetaTagPage, 0, 0));
96   ASSERT_EQ(Success, EventLoopStart());
97   expectedCapable = EINA_FALSE;
98   ASSERT_EQ(EINA_TRUE, ewk_view_web_application_capable_get(GetEwkWebView(),
99                                                             utc_blink_ewk_view_web_application_capable_get::webAppCapableGetCallback,
100                                                             this));
101   ASSERT_EQ(Success, EventLoopStart());
102 }