[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_settings_extra_feature_set_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_settings_extra_feature_set : public utc_blink_ewk_base {
8 protected:
9   utc_blink_ewk_settings_extra_feature_set():
10     settings(NULL)
11   {
12   }
13
14   void LoadFinished(Evas_Object*) override { EventLoopStop(Success); }
15
16   void PostSetUp() override {
17     // load file just to initialize everything
18     ewk_view_url_set(GetEwkWebView(), GetResourceUrl("/common/sample.html").c_str());
19     ASSERT_EQ(Success, EventLoopStart());
20     settings = ewk_view_settings_get(GetEwkWebView());
21     ASSERT_TRUE(settings);
22   }
23
24 protected:
25   Ewk_Settings* settings;
26 };
27
28 TEST_F(utc_blink_ewk_settings_extra_feature_set, EXISTING_FEATURES)
29 {
30   static const char* features[] = {
31     "longpress,enable",
32     "link,magnifier",
33     "detect,contents",
34     "web,login",
35     "doubletap,enable",
36     "zoom,enable",
37     "openpanel,enable",
38     "allow,restrictedurl",
39     "urlbar,hide",
40     NULL};
41
42   for (const char** feat = features; *feat; feat++) {
43     Eina_Bool defaultValue = ewk_settings_extra_feature_get(settings, *feat);
44     Eina_Bool newValue = defaultValue == EINA_TRUE ? EINA_FALSE : EINA_TRUE;
45     ewk_settings_extra_feature_set(settings, *feat, newValue);
46     ASSERT_EQ(newValue, ewk_settings_extra_feature_get(settings, *feat)) << *feat << " value did not change!";
47   }
48 }
49
50 TEST_F(utc_blink_ewk_settings_extra_feature_set, NON_EXISTING_FEATURE)
51 {
52   static const char* feat = "nonexistent,feature";
53   ASSERT_EQ(EINA_FALSE, ewk_settings_extra_feature_get(settings, feat));
54   ewk_settings_extra_feature_set(settings, feat, EINA_TRUE);
55   ASSERT_EQ(EINA_FALSE, ewk_settings_extra_feature_get(settings, feat));
56 }
57
58 TEST_F(utc_blink_ewk_settings_extra_feature_set, INVALID_ARGS)
59 {
60   // The only thing we can do is expect that it won't crash
61   ewk_settings_extra_feature_set(NULL, NULL, EINA_TRUE);
62   ewk_settings_extra_feature_set(settings, NULL, EINA_TRUE);
63   ewk_settings_extra_feature_set(NULL, "invalid", EINA_TRUE);
64 }