Changeset 142678 in webkit


Ignore:
Timestamp:
Feb 12, 2013 3:10:31 PM (11 years ago)
Author:
Christophe Dumez
Message:

[EFL][WK2] Reenable ewk_auth_request API tests
https://bugs.webkit.org/show_bug.cgi?id=108451

Reviewed by Benjamin Poulain.

ewk_auth_request API tests were temporarily disabled after
the C API for resource loading was removed from WebKit2.
This patches updates the tests so that they no longer rely
on the resource loading events and renables them.

This patch also corrects the naming of the static variables
in the test to follow more closely the WebKit coding style.

  • PlatformEfl.cmake:
  • UIProcess/API/efl/tests/test_ewk2_auth_request.cpp:

(serverCallback):
(TEST_F):
(onLoadFinished):

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r142672 r142678  
     12013-02-12  Christophe Dumez  <ch.dumez@sisa.samsung.com>
     2
     3        [EFL][WK2] Reenable ewk_auth_request API tests
     4        https://bugs.webkit.org/show_bug.cgi?id=108451
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        ewk_auth_request API tests were temporarily disabled after
     9        the C API for resource loading was removed from WebKit2.
     10        This patches updates the tests so that they no longer rely
     11        on the resource loading events and renables them.
     12
     13        This patch also corrects the naming of the static variables
     14        in the test to follow more closely the WebKit coding style.
     15
     16        * PlatformEfl.cmake:
     17        * UIProcess/API/efl/tests/test_ewk2_auth_request.cpp:
     18        (serverCallback):
     19        (TEST_F):
     20        (onLoadFinished):
     21
    1222013-02-12  Anders Carlsson  <andersca@apple.com>
    223
  • trunk/Source/WebKit2/PlatformEfl.cmake

    r141836 r142678  
    368368# will clash with tests from the WebKit 1 test suite.
    369369set(EWK2UnitTests_BINARIES
     370    test_ewk2_auth_request
    370371    test_ewk2_back_forward_list
    371372    test_ewk2_color_picker
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_auth_request.cpp

    r135349 r142678  
    3434extern EWK2UnitTestEnvironment* environment;
    3535
    36 static const char TEST_USERNAME[] = "username";
    37 static const char TEST_PASSWORD[] = "password";
    38 static const char EXPECTED_AUTHORIZATION[] = "Basic dXNlcm5hbWU6cGFzc3dvcmQ="; // Base64 encoding of "username:password".
    39 static const char INDEX_HTML_STRING[] =
     36static const char testUsername[] = "username";
     37static const char testPassword[] = "password";
     38static const char expectedSuccessTitle[] = "EFLWebKit2 Authentication test";
     39static const char expectedAuthorization[] = "Basic dXNlcm5hbWU6cGFzc3dvcmQ="; // Base64 encoding of "username:password".
     40static const char indexHTMLString[] =
    4041    "<html>"
    4142    "<head><title>EFLWebKit2 Authentication test</title></head>"
     
    5253        const char* authorization = soup_message_headers_get_one(message->request_headers, "Authorization");
    5354        // Require authentication
    54         if (authorization && !strcmp(authorization, EXPECTED_AUTHORIZATION)) {
     55        if (authorization && !strcmp(authorization, expectedAuthorization)) {
    5556            // Successful authentication.
    5657            soup_message_set_status(message, SOUP_STATUS_OK);
    57             soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, INDEX_HTML_STRING, strlen(INDEX_HTML_STRING));
     58            soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, indexHTMLString, strlen(indexHTMLString));
    5859        } else {
    5960            // No (valid) authorization header provided by the client, request authentication.
     
    9899    EXPECT_FALSE(ewk_auth_request_retrying_get(authenticationRequest));
    99100
    100     ASSERT_TRUE(ewk_auth_request_authenticate(authenticationRequest, TEST_USERNAME, TEST_PASSWORD));
     101    ASSERT_TRUE(ewk_auth_request_authenticate(authenticationRequest, testUsername, testPassword));
    101102
    102103    ewk_object_unref(authenticationRequest);
    103104
    104     ASSERT_TRUE(waitUntilTitleChangedTo("EFLWebKit2 Authentication test"));
     105    ASSERT_TRUE(waitUntilTitleChangedTo(expectedSuccessTitle));
    105106}
    106107
     
    124125    EXPECT_FALSE(ewk_auth_request_retrying_get(authenticationRequest));
    125126
    126     ASSERT_TRUE(ewk_auth_request_authenticate(authenticationRequest, TEST_USERNAME, "wrongpassword"));
     127    ASSERT_TRUE(ewk_auth_request_authenticate(authenticationRequest, testUsername, "wrongpassword"));
    127128
    128129    ewk_object_unref(authenticationRequest);
     
    139140
    140141    // Now provide the right password.
    141     ASSERT_TRUE(ewk_auth_request_authenticate(authenticationRequest, TEST_USERNAME, TEST_PASSWORD));
     142    ASSERT_TRUE(ewk_auth_request_authenticate(authenticationRequest, testUsername, testPassword));
    142143
    143144    ewk_object_unref(authenticationRequest);
    144145
    145     ASSERT_TRUE(waitUntilTitleChangedTo("EFLWebKit2 Authentication test"));
     146    ASSERT_TRUE(waitUntilTitleChangedTo(expectedSuccessTitle));
    146147}
    147148
    148 static void onResourceLoadResponse(void* userData, Evas_Object*, void* eventInfo)
     149static void onLoadFinished(void* userData, Evas_Object*, void*)
    149150{
    150     int* statusCode = static_cast<int*>(userData);
    151     ASSERT_TRUE(statusCode);
     151    bool* isFinished = static_cast<bool*>(userData);
     152    ASSERT_TRUE(isFinished);
    152153
    153     Ewk_Resource_Load_Response* response = static_cast<Ewk_Resource_Load_Response*>(eventInfo);
    154     ASSERT_TRUE(response);
    155 
    156     if (!ewk_resource_main_resource_get(response->resource))
    157         return;
    158 
    159     *statusCode = ewk_url_response_status_code_get(response->response);
     154    *isFinished = true;
    160155}
    161156
     
    180175    EXPECT_FALSE(ewk_auth_request_retrying_get(authenticationRequest));
    181176
    182     int statusCode = 0;
    183     evas_object_smart_callback_add(webView(), "resource,request,response", onResourceLoadResponse, &statusCode);
     177    bool isFinished = false;
     178    evas_object_smart_callback_add(webView(), "load,finished", onLoadFinished, &isFinished);
    184179
    185180    // Will attempt to continue without authentication by default.
    186181    ewk_object_unref(authenticationRequest);
    187182
    188     while (!statusCode)
     183    while (!isFinished)
    189184        ecore_main_loop_iterate();
    190185
    191     // We should get a "402 Unauthorized" error.
    192     EXPECT_EQ(SOUP_STATUS_UNAUTHORIZED, statusCode);
     186    ASSERT_STRNE(expectedSuccessTitle, ewk_view_title_get(webView()));
    193187
    194     evas_object_smart_callback_del(webView(), "resource,request,response", onResourceLoadResponse);
     188    evas_object_smart_callback_del(webView(), "load,finished", onLoadFinished);
    195189}
Note: See TracChangeset for help on using the changeset viewer.