[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_error_type_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_error_type_get : public utc_blink_ewk_base {
8  protected:
9   utc_blink_ewk_error_type_get()
10     : error_type(EWK_ERROR_TYPE_NONE)
11   {
12   }
13
14   /* Callback for load error */
15   bool LoadError(Evas_Object* webview, Ewk_Error* error) override {
16     utc_message("[load_error] :: ");
17     error_type = ewk_error_type_get(error);
18     EventLoopStop(utc_blink_ewk_base::Success);
19     return true;
20   }
21
22 protected:
23   Ewk_Error_Type error_type;
24   static const char* const test_url;
25 };
26
27 const char* const utc_blink_ewk_error_type_get::test_url = "http://page_that_does_not_exist";
28
29 /**
30  * @brief Positive test case of ewk_error_type_get(). Page is loaded and stopped in between to generate loadError
31  */
32 TEST_F(utc_blink_ewk_error_type_get, POS_TEST)
33 {
34   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), test_url));
35   ASSERT_EQ(utc_blink_ewk_base::Success, EventLoopStart());
36   ASSERT_EQ(EWK_ERROR_TYPE_NETWORK, error_type); // right now this is the only error type supported
37 }
38
39 /**
40 * @brief Checking whether function works properly in case of NULL argument.
41 */
42 TEST_F(utc_blink_ewk_error_type_get, NEG_TEST)
43 {
44   ASSERT_EQ(EWK_ERROR_TYPE_NONE, ewk_error_type_get(NULL));
45 }