Changeset 144652 in webkit


Ignore:
Timestamp:
Mar 4, 2013 11:32:03 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK] Some WebKit2 GTK+ unit tests are failing in 32 bits bot
https://bugs.webkit.org/show_bug.cgi?id=111346

Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2013-03-04
Reviewed by Martin Robinson.

The problem is the use of a temporary CString object in the macro
g_assert_cmpstr. It's a common mistake because we usually forget
that g_assert_cmpstr is not a function but a macro, that expands
to multiple lines. This patch adds a new macro ASSERT_CMP_CSTRING
with the same implementation that g_assert_cmpstr, but using
CStrings instead of const char*. It fixes all the cases where a
temporary CString was used in g_assert_cmpstr, and uses the new
macro also for the cases where we were caching the CString just
for g_assert_cmpstr.

  • UIProcess/API/gtk/tests/TestDownloads.cpp:

(testDownloadRemoteFile):

  • UIProcess/API/gtk/tests/TestInspectorServer.cpp:

(testInspectorServerPageList):

  • UIProcess/API/gtk/tests/TestLoaderClient.cpp:
  • UIProcess/API/gtk/tests/TestMain.h:
  • UIProcess/API/gtk/tests/TestResources.cpp:
  • UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp:

(testGetFaviconURI):

  • UIProcess/API/gtk/tests/TestWebKitSettings.cpp:

(assertThatUserAgentIsSentInHeaders):
(testWebKitSettingsUserAgent):

Location:
trunk/Source/WebKit2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r144614 r144652  
     12013-03-04  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Some WebKit2 GTK+ unit tests are failing in 32 bits bot
     4        https://bugs.webkit.org/show_bug.cgi?id=111346
     5
     6        Reviewed by Martin Robinson.
     7
     8        The problem is the use of a temporary CString object in the macro
     9        g_assert_cmpstr. It's a common mistake because we usually forget
     10        that g_assert_cmpstr is not a function but a macro, that expands
     11        to multiple lines. This patch adds a new macro ASSERT_CMP_CSTRING
     12        with the same implementation that g_assert_cmpstr, but using
     13        CStrings instead of const char*. It fixes all the cases where a
     14        temporary CString was used in g_assert_cmpstr, and uses the new
     15        macro also for the cases where we were caching the CString just
     16        for g_assert_cmpstr.
     17
     18        * UIProcess/API/gtk/tests/TestDownloads.cpp:
     19        (testDownloadRemoteFile):
     20        * UIProcess/API/gtk/tests/TestInspectorServer.cpp:
     21        (testInspectorServerPageList):
     22        * UIProcess/API/gtk/tests/TestLoaderClient.cpp:
     23        * UIProcess/API/gtk/tests/TestMain.h:
     24        * UIProcess/API/gtk/tests/TestResources.cpp:
     25        * UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp:
     26        (testGetFaviconURI):
     27        * UIProcess/API/gtk/tests/TestWebKitSettings.cpp:
     28        (assertThatUserAgentIsSentInHeaders):
     29        (testWebKitSettingsUserAgent):
     30
    1312013-03-04  Kunihiko Sakamoto  <ksakamoto@chromium.org>
    232
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp

    r132323 r144652  
    342342    WebKitURIRequest* request = webkit_download_get_request(download.get());
    343343    g_assert(request);
    344     CString requestURI = kServer->getURIForPath("/test.pdf");
    345     g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, requestURI.data());
     344    ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, kServer->getURIForPath("/test.pdf"));
    346345
    347346    g_assert(webkit_download_get_destination(download.get()));
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestInspectorServer.cpp

    r134600 r144652  
    191191    valueString.set(WebViewTest::javascriptResultToCString(javascriptResult));
    192192    String validInspectorURL = String("/webinspector/inspector.html?page=") + String::number(pageId);
    193     g_assert_cmpstr(valueString.get(), ==, validInspectorURL.utf8().data());
     193    ASSERT_CMP_CSTRING(valueString.get(), ==, validInspectorURL.utf8());
    194194}
    195195
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp

    r130507 r144652  
    215215    void checkActiveURI(const char* uri)
    216216    {
    217         // g_assert_cmpstr is a macro, so we need to cache the temporary string.
    218         CString serverURI = kServer->getURIForPath(uri);
    219         g_assert_cmpstr(m_activeURI.data(), ==, serverURI.data());
     217        ASSERT_CMP_CSTRING(m_activeURI, ==, kServer->getURIForPath(uri));
    220218    }
    221219};
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h

    r122547 r144652  
    4040        g_test_add(testPath.get(), ClassName, 0, ClassName::setUp, testFunc, ClassName::tearDown); \
    4141    }
     42
     43#define ASSERT_CMP_CSTRING(s1, cmp, s2) \
     44    do { CString __s1 = (s1); CString __s2 = (s2); \
     45        if (g_strcmp0(__s1.data(), __s2.data()) cmp 0) ; else \
     46            g_assertion_message_cmpstr(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
     47                #s1 " " #cmp " " #s2, __s1.data(), #cmp, __s2.data()); } while (0)
    4248
    4349class Test {
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp

    r143302 r144652  
    504504    void checkActiveURI(const char* uri)
    505505    {
    506         // g_assert_cmpstr is a macro, so we need to cache the temporary string.
    507         CString serverURI = kServer->getURIForPath(uri);
    508         g_assert_cmpstr(m_activeURI.data(), ==, serverURI.data());
     506        ASSERT_CMP_CSTRING(m_activeURI, ==, kServer->getURIForPath(uri));
    509507    }
    510508};
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp

    r133867 r144652  
    203203    WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext);
    204204
    205     const char* baseURI = kServer->getURIForPath("/foo").data();
    206     GOwnPtr<char> iconURI(webkit_favicon_database_get_favicon_uri(database, baseURI));
    207     g_assert_cmpstr(iconURI.get(), ==, kServer->getURIForPath("/icon/favicon.ico").data());
     205    CString baseURI = kServer->getURIForPath("/foo");
     206    GOwnPtr<char> iconURI(webkit_favicon_database_get_favicon_uri(database, baseURI.data()));
     207    ASSERT_CMP_CSTRING(iconURI.get(), ==, kServer->getURIForPath("/icon/favicon.ico"));
    208208}
    209209
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp

    r130642 r144652  
    275275    test->loadURI(gServer->getURIForPath("/").data());
    276276    test->waitUntilLoadFinished();
    277     g_assert_cmpstr(convertWebViewMainResourceDataToCString(test).data(), ==, userAgent.data());
     277    ASSERT_CMP_CSTRING(convertWebViewMainResourceDataToCString(test), ==, userAgent);
    278278}
    279279
     
    301301
    302302    webkit_settings_set_user_agent_with_application_details(settings.get(), "WebKitGTK+", 0);
    303     CString userAgentWithNullVersion = webkit_settings_get_user_agent(settings.get());
    304     g_assert_cmpstr(g_strstr_len(userAgentWithNullVersion.data(), -1, defaultUserAgent.data()), ==, userAgentWithNullVersion.data());
    305     g_assert(g_strstr_len(userAgentWithNullVersion.data(), -1, "WebKitGTK+"));
     303    const char* userAgentWithNullVersion = webkit_settings_get_user_agent(settings.get());
     304    g_assert_cmpstr(g_strstr_len(userAgentWithNullVersion, -1, defaultUserAgent.data()), ==, userAgentWithNullVersion);
     305    g_assert(g_strstr_len(userAgentWithNullVersion, -1, "WebKitGTK+"));
    306306
    307307    webkit_settings_set_user_agent_with_application_details(settings.get(), "WebKitGTK+", "");
    308     g_assert_cmpstr(webkit_settings_get_user_agent(settings.get()), ==, userAgentWithNullVersion.data());
     308    g_assert_cmpstr(webkit_settings_get_user_agent(settings.get()), ==, userAgentWithNullVersion);
    309309
    310310    webkit_settings_set_user_agent_with_application_details(settings.get(), "WebCatGTK+", "3.4.5");
Note: See TracChangeset for help on using the changeset viewer.