[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_context_web_storage_origins_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_context_web_storage_origins_get: public utc_blink_ewk_base
8 {
9 protected:
10   utc_blink_ewk_context_web_storage_origins_get()
11     : ctx(NULL)
12   {
13   }
14
15   void LoadFinished(Evas_Object*) override { EventLoopStop(Success); }
16
17   void PostSetUp() override {
18     ctx = ewk_view_context_get(GetEwkWebView());
19     ASSERT_TRUE(ctx);
20   }
21
22   static void origins_get_cb(Eina_List* origins, void* user_data)
23   {
24     // We don't need origins here
25     if (origins) {
26       ewk_context_origins_free(origins);
27     }
28
29     ASSERT_TRUE(user_data);
30
31     utc_blink_ewk_context_web_storage_origins_get* owner = static_cast<utc_blink_ewk_context_web_storage_origins_get*>(user_data);
32     owner->EventLoopStop(Success);
33   }
34
35 protected:
36   Ewk_Context* ctx;
37   static const char* const web_storage_sample_url;
38 };
39
40 const char* const utc_blink_ewk_context_web_storage_origins_get::web_storage_sample_url = "http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_webstorage_local";
41
42 TEST_F(utc_blink_ewk_context_web_storage_origins_get, callback)
43 {
44   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), web_storage_sample_url));
45   ASSERT_EQ(Success, EventLoopStart());
46   ASSERT_EQ(EINA_TRUE, ewk_context_web_storage_origins_get(ctx, origins_get_cb, this));
47   ASSERT_EQ(Success, EventLoopStart());
48 }
49
50 TEST_F(utc_blink_ewk_context_web_storage_origins_get, invalid_args)
51 {
52   ASSERT_EQ(EINA_FALSE, ewk_context_web_storage_origins_get(NULL, NULL, NULL));
53   ASSERT_EQ(EINA_FALSE, ewk_context_web_storage_origins_get(ctx, NULL, NULL));
54   ASSERT_EQ(EINA_FALSE, ewk_context_web_storage_origins_get(NULL, origins_get_cb, NULL));
55 }
56