[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_view_session_data_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_session_data_get_func : public utc_blink_ewk_base
8 {
9 protected:
10   std::string firstPage;
11   const char *sessionData;
12
13   void PreSetUp() override {
14     firstPage = GetResourceUrl("common/sample.html");
15     sessionData = NULL;
16   }
17
18   void LoadFinished(Evas_Object*) override { EventLoopStop(Success); }
19
20   void PostTearDown() override {
21     if (sessionData)
22       free(const_cast<char *>(sessionData));
23   }
24 };
25
26
27 /**
28  * @brief Tests if returns valid webview when called with correct Evas object.
29  */
30 TEST_F(utc_blink_ewk_view_session_data_get_func, POS_TEST)
31 {
32   ewk_view_url_set(GetEwkWebView(), firstPage.c_str());
33   EventLoopStart();
34
35   unsigned length = 0;
36   ewk_view_session_data_get(GetEwkWebView(), &sessionData, &length);
37
38   ASSERT_TRUE(sessionData);
39   ASSERT_NE(length, 0);
40 }
41
42 /**
43  * @brief Tests if returns NULL when called with NULL webview object.
44  */
45 TEST_F(utc_blink_ewk_view_session_data_get_func, NEG_TEST_NULL_WEBVIEW)
46 {
47   ewk_view_url_set(GetEwkWebView(), firstPage.c_str());
48   EventLoopStart();
49
50   const char *data;
51   unsigned length;
52   ewk_view_session_data_get(NULL, &data, &length);
53
54   ASSERT_FALSE(data);
55   ASSERT_EQ(length, 0);
56 }
57
58 /**
59  * @brief Tests if returns NULL when called with NULL data.
60  */
61 TEST_F(utc_blink_ewk_view_session_data_get_func, NEG_TEST_NULL_DATA)
62 {
63   ewk_view_url_set(GetEwkWebView(), firstPage.c_str());
64   EventLoopStart();
65
66   unsigned length;
67   // Should not crash
68   ewk_view_session_data_get(GetEwkWebView(), NULL, &length);
69 }
70
71 /**
72  * @brief Tests if returns NULL when called with NULL length.
73  */
74 TEST_F(utc_blink_ewk_view_session_data_get_func, NEG_TEST_NULL_LENGTH)
75 {
76   ewk_view_url_set(GetEwkWebView(), firstPage.c_str());
77   EventLoopStart();
78
79   const char *data;
80   // Should not crash
81   ewk_view_session_data_get(GetEwkWebView(), &data, NULL);
82 }