1/*
2 * Copyright (C) 2012 Samsung Electronics
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1.  Redistributions of source code must retain the above copyright
8 *     notice, this list of conditions and the following disclaimer.
9 * 2.  Red istributions in binary form must reproduce the above copyright
10 *     notice, this list of conditions and the following disclaimer in the
11 *     documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND ITS CONTRIBUTORS
14 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
16 * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
17 * HOLDERS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27
28#include "UnitTestUtils/EWKTestBase.h"
29#include "UnitTestUtils/EWKTestConfig.h"
30#include <EWebKit.h>
31
32using namespace EWKUnitTests;
33
34static void initBuffer(char** buffer)
35{
36    free(*buffer);
37    *buffer = 0;
38}
39
40/**
41 * @brief Unit test for ewk_frame_source_get.
42 */
43TEST_F(EWKTestBase, ewk_frame_source_get)
44{
45    char* buffer = 0;
46    ssize_t failed = -1;
47
48    // Checking if function works properly without loading url.
49    ssize_t read = ewk_frame_source_get(ewk_view_frame_main_get(webView()), &buffer);
50    ASSERT_EQ(read, failed);
51    initBuffer(&buffer);
52
53    // FIXME: BUG 49246 has changed load behavior when malformed url is inputed. Timer operation might be needed to sync with WK2.
54    // See https://bugs.webkit.org/show_bug.cgi?id=105620 for more details.
55    // Checking if function works properly when loading non-existing url.
56    // loadUrl("http://www.abcdefg^^.com");
57    // read = ewk_frame_source_get(ewk_view_frame_main_get(webView()), &buffer);
58    // ASSERT_EQ(read, failed);
59    // initBuffer(&buffer);
60
61    // Checking if function works properly when finishing load url.
62    loadUrl();
63    read = ewk_frame_source_get(ewk_view_frame_main_get(webView()), &buffer);
64    ASSERT_GT(read, 0);
65    initBuffer(&buffer);
66}
67