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 #include "utc_blink_ewk_base.h"
7 class utc_blink_ewk_view_contents_pdf_get : public utc_blink_ewk_base
11 void PreSetUp() override {
13 evas_object_smart_callback_add(GetEwkWebView(), "frame,rendered", FrameRendered, this);
16 void PostTearDown() override {
17 evas_object_smart_callback_del(GetEwkWebView(), "frame,rendered", FrameRendered);
20 /* Callback for load finished */
21 void LoadFinished(Evas_Object* webview) override { EventLoopStop(Success); }
23 static void FrameRendered(void* data, Evas_Object* obj, void* event_info)
25 utc_blink_ewk_view_contents_pdf_get*owner=static_cast<utc_blink_ewk_view_contents_pdf_get*>(data);
26 utc_message("[Frame rendered] ::");
28 owner->EventLoopStop( Success );
31 static Eina_Bool VerifyFile(void* data)
35 utc_blink_ewk_view_contents_pdf_get*owner=static_cast<utc_blink_ewk_view_contents_pdf_get*>(data);
36 owner->file_exists = ecore_file_exists("/tmp/sample.pdf");
37 owner->EventLoopStop( Success );
39 return ECORE_CALLBACK_CANCEL;
44 * @brief Positive test case of ewk_view_contents_pdf_get().
45 * Page is loaded and API is called to save pdf file.
46 * Then existence of file is verified by 3 second timer.
48 TEST_F(utc_blink_ewk_view_contents_pdf_get, POS_TEST)
50 char htmlBuffer[] = "<html>"
56 bool result = ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL);
59 if(Success!=EventLoopStart())
63 Evas_Coord height = 0;
64 result = ewk_view_contents_size_get(GetEwkWebView(), &width, &height);
65 if(!result || !width || !height)
68 result = ewk_view_contents_pdf_get(GetEwkWebView(), width, height, "/tmp/sample.pdf");
71 // waiting for 3 seconds to pdf printer to work.
72 ecore_timer_add(3, VerifyFile, this);
75 utc_check_true(file_exists);
79 * @brief Checking whether function works properly in case of NULL of a webview.
81 TEST_F(utc_blink_ewk_view_contents_pdf_get, NEG_TEST)
83 bool result = ewk_view_contents_pdf_get(NULL, 200, 200, "/tmp/sample.pdf");
84 utc_check_false(result);