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 /* Define those macros _before_ you include the utc_blink_ewk.h header file. */
7 #include "utc_blink_ewk_base.h"
9 #define SAMPLE_HTML_FILE ("/common/sample_js_geolocation.html")
11 class utc_blink_cb_geolocation_valid : public utc_blink_ewk_base {
14 static void geolocation_valid_allow_cb(utc_blink_cb_geolocation_valid* owner, Evas_Object* webview, Eina_Bool* allow)
20 owner->EventLoopStop(Failure);
24 static void geolocation_valid_deny_cb(utc_blink_cb_geolocation_valid* owner, Evas_Object* webview, Eina_Bool* allow)
30 owner->EventLoopStop(Failure);
34 static void geolocation_valid_cb(utc_blink_cb_geolocation_valid* owner, Evas_Object* webview, Eina_Bool* allow)
37 owner->EventLoopStop(Success);
40 static void request_geolocation_permisson_success(utc_blink_cb_geolocation_valid* owner, Evas_Object* webview, void* event_info)
43 owner->EventLoopStop(Success);
46 static void request_geolocation_permisson_fail(utc_blink_cb_geolocation_valid* owner, Evas_Object* webview, void* event_info)
49 owner->EventLoopStop(Failure);
55 * @brief Test "geolocation,valid" callback
57 TEST_F(utc_blink_cb_geolocation_valid, callback)
59 // Simply check if callback is fired, if load,finished comes first then something went wrong
60 evas_object_smart_callback_auto gv(GetEwkWebView(), "geolocation,valid", ToSmartCallback(geolocation_valid_cb), this);
62 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(SAMPLE_HTML_FILE).c_str()));
63 ASSERT_EQ(Success, EventLoopStart());
67 * @brief check if control param of "geolocation,valid" callback works as it suposed to.
69 * If we block geolocation module initialization in geolocation,valid callback then no geolocation,permission,request should be triggered.
71 TEST_F(utc_blink_cb_geolocation_valid, callback_param_to_false)
73 evas_object_smart_callback_auto gp(GetEwkWebView(), "geolocation,permission,request", ToSmartCallback(request_geolocation_permisson_fail), this);
74 evas_object_smart_callback_auto gv(GetEwkWebView(), "geolocation,valid", ToSmartCallback(geolocation_valid_deny_cb), this);
76 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(SAMPLE_HTML_FILE).c_str()));
77 ASSERT_EQ(Timeout, EventLoopStart(5.0));
81 * @brief check if control param of "geolocation,valid" callback works as it suposed to.
83 * If we allow geolocation module initialization in geolocation,valid callback then geolocation,permission,request should be triggered.
85 TEST_F(utc_blink_cb_geolocation_valid, callback_param_to_true)
87 evas_object_smart_callback_auto gp(GetEwkWebView(), "geolocation,permission,request", ToSmartCallback(request_geolocation_permisson_success), this);
88 evas_object_smart_callback_auto gv(GetEwkWebView(), "geolocation,valid", ToSmartCallback(geolocation_valid_allow_cb), this);
90 ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), GetResourceUrl(SAMPLE_HTML_FILE).c_str()));
91 ASSERT_EQ(Timeout, EventLoopStart(5.0));