1 // Copyright 2016 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.
7 #include "utc_blink_ewk_intercept_request_response_base.h"
9 class utc_blink_ewk_intercept_request_response_body_set
10 : public utc_blink_ewk_intercept_request_response_base {
12 std::string get_js_title_test() override {
13 return std::string(body_ajax_test_);
16 void pos_func(Ewk_Intercept_Request* intercept_request) override {}
18 bool neg_func(Ewk_Intercept_Request* intercept_request) override {
19 return ewk_intercept_request_response_body_set(
20 intercept_request, body_ajax_response_, body_ajax_length_);
23 const char* body_ajax_test_ =
24 "document.title = this.responseText + ': ' + this.responseText.length;";
26 int body_ajax_length_;
30 * @brief Tests if headers are correctly added from header map.
32 TEST_F(utc_blink_ewk_intercept_request_response_body_set,
33 POS_TEST_RESPONSE_BODY_SET) {
34 body_ajax_response_ = "HELLO EWK API";
36 // title set in JS after ajax response:
37 // <AJAX_RESPONSE>: length(<AJAX_RESPONSE>)
38 EXPECT_STREQ("HELLO EWK API: 13", ewk_view_title_get(GetEwkWebView()));
42 * @brief Tests if EINA_FALSE is returned for NULL body
44 TEST_F(utc_blink_ewk_intercept_request_response_body_set, NEG_TEST_NULL_BODY) {
45 body_ajax_response_ = nullptr;
46 // some positive value, so safety checks for length won't interfere
47 body_ajax_length_ = 1;
52 * @brief Tests if EINA_FALSE is returned for negative body length
54 TEST_F(utc_blink_ewk_intercept_request_response_body_set,
55 NEG_TEST_NEGATIVE_BODY_LENGTH) {
56 body_ajax_length_ = -1;
61 * @brief Tests if EINA_FALSE is returned for null intercept request.
63 TEST_F(utc_blink_ewk_intercept_request_response_body_set,
64 NEG_TEST_NULL_INTERCEPT_RESPONSE) {
65 intercept_request_null_ = true;
66 body_ajax_length_ = strlen(body_ajax_response_);