[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_cb_load_finished.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 #define URL  ("http://google.com")
8
9 class utc_blink_cb_load_finished : public utc_blink_ewk_base
10 {
11 public:
12     /* Callback for "load,finished" */
13  void LoadFinished(Evas_Object* webview) override {
14    EventLoopStop(utc_blink_ewk_base::Success);
15     }
16 };
17
18 /**
19  * @brief Tests "load,finished" callback with ewl_view_html_string_load
20  */
21 TEST_F(utc_blink_cb_load_finished, html_string_load)
22 {
23     char htmlBuffer[] = "<html>"
24                           "<head><title>TC ewk_view_html_load_string</title></head>"
25                           "<body><p>TC ewk_view_html_load_string</p></body>"
26                         "</html>";
27
28     Eina_Bool result = ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL);
29
30     if (!result)
31         utc_fail();
32
33     utc_check_eq(EventLoopStart(), utc_blink_ewk_base::Success);
34 }
35
36 /**
37  * @brief Tests "load,finished" callback with ewk_view_url_set http protocol
38  */
39 TEST_F(utc_blink_cb_load_finished, url_set_http)
40 {
41     utc_message("Loading url: %s", URL);
42     Eina_Bool result = ewk_view_url_set(GetEwkWebView(), URL);
43
44     if (!result)
45         utc_fail();
46
47     utc_check_eq(EventLoopStart(), utc_blink_ewk_base::Success);
48 }
49
50 /**
51  * @brief Tests "load,finished" callback with ewk_view_urls_set local file
52  */
53 TEST_F(utc_blink_cb_load_finished, url_set_file)
54 {
55     std::string resource_url = GetResourceUrl("common/sample.html");
56     utc_message("Loading file: %s", resource_url.c_str());
57     Eina_Bool result = ewk_view_url_set(GetEwkWebView(), resource_url.c_str());
58
59     if (!result)
60         utc_fail();
61
62     utc_check_eq(EventLoopStart(), utc_blink_ewk_base::Success);
63 }