[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_view_screenshot_contents_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_screenshot_contents_get : public utc_blink_ewk_base
8 {
9  protected:
10   /* Callback for load finished */
11   void LoadFinished(Evas_Object* webview) override { EventLoopStop(Success); }
12
13  protected:
14   static const char*const url;
15 };
16
17 /**
18  * @brief Checking whether the evas image object of the specified viewArea of page is returned.
19  */
20
21 TEST_F(utc_blink_ewk_view_screenshot_contents_get, POS_TEST)
22 {
23   char htmlBuffer[] = "<html>"
24                         "<head></head>"
25                         "<body>"
26                         "</body>"
27                       "</html>";
28
29   bool result = ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL);
30
31   if (!result)
32     utc_fail();
33
34   if (Success!=EventLoopStart())
35     utc_fail();
36
37   Eina_Rectangle snapshot_rect;
38   snapshot_rect.x = snapshot_rect.y = 0;
39   evas_object_geometry_get(GetEwkWebView(), NULL, NULL, &snapshot_rect.w, &snapshot_rect.h);
40
41   Evas_Object *webview = ewk_view_screenshot_contents_get(GetEwkWebView(), snapshot_rect, 1.0f, evas_object_evas_get(GetEwkWebView()));
42
43   if (webview)
44     result = EINA_TRUE;
45
46   utc_check_eq(result, EINA_TRUE);
47 }
48
49 /**
50  * @brief Checking whether function works properly in case that webview and canvas object are NULL.
51  */
52 TEST_F(utc_blink_ewk_view_screenshot_contents_get, NEG_TEST)
53 {
54   Eina_Rectangle snapshot_rect;
55   snapshot_rect.x = snapshot_rect.y = 0;
56   evas_object_geometry_get(GetEwkWebView(), NULL, NULL, &snapshot_rect.w, &snapshot_rect.h);
57
58   utc_check_eq(NULL, ewk_view_screenshot_contents_get(NULL, snapshot_rect, 1.0f, NULL));
59 }