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 /* Define those macros _before_ you include the utc_blink_ewk.h header file. */
7 #include "utc_blink_ewk_base.h"
9 class utc_blink_ewk_context_web_storage_delete_all : public utc_blink_ewk_base
12 void PostSetUp() override {
13 evas_object_smart_callback_add(GetEwkWebView(), "title,changed",
17 void PreTearDown() override {
18 evas_object_smart_callback_del(GetEwkWebView(), "title,changed", title_changed);
21 static void title_changed(void* data, Evas_Object* webview, void* event_info)
23 ASSERT_TRUE(data != NULL);
25 utc_blink_ewk_context_web_storage_delete_all* owner = static_cast<utc_blink_ewk_context_web_storage_delete_all*>(data);
27 owner->EventLoopStop(utc_blink_ewk_base::Success);
32 * @brief Tests if can delete all web storages
34 TEST_F(utc_blink_ewk_context_web_storage_delete_all, POS_TEST)
36 std::string storageItemValue;
38 // Set web storage item StorageTest=STORAGE_TEST_VALUE
39 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl("ewk_context_web_storage/webStorageSet.html").c_str()));
40 ASSERT_EQ(Success, EventLoopStart());
42 // Check if the storage was properly set
43 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl("ewk_context_web_storage/webStorageGet.html").c_str()));
44 ASSERT_EQ(Success, EventLoopStart());
46 storageItemValue = ewk_view_title_get(GetEwkWebView());
47 ASSERT_EQ("STORAGE_TEST_VALUE", storageItemValue);
48 // Local storage item may be set in renderer cache but setting it in physical
49 // memory may be delayed. ewk_context_web_storage_delete_all removes all data
50 // of origins present in physical memory. In case of no line below, item may
51 // not be saved in physical memory before ewk_context_web_storage_delete_all
55 // Delete all web storage
56 Ewk_Context* context = ewk_view_context_get(GetEwkWebView());
57 ASSERT_EQ(EINA_TRUE, ewk_context_web_storage_delete_all(context));
59 // Check if the storage was really deleted
60 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl("ewk_context_web_storage/webStorageGet.html").c_str()));
61 ASSERT_EQ(Success, EventLoopStart());
63 storageItemValue = ewk_view_title_get(GetEwkWebView());
64 EXPECT_EQ("EMPTY", storageItemValue);
68 * @brief Tests if returns false when context is null.
70 TEST_F(utc_blink_ewk_context_web_storage_delete_all, NEG_TEST)
72 EXPECT_FALSE(ewk_context_web_storage_delete_all(0));