[EFL][WK2] EWK2UnitTestBase.ewk_view_page_contents_get API test is sometimes failing
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2013 18:49:45 +0000 (18:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2013 18:49:45 +0000 (18:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108634

Patch by Christophe Dumez <dchris@gmail.com> on 2013-02-07
Reviewed by Alexey Proskuryakov.

Use more robust data validation in EWK2UnitTestBase.ewk_view_page_contents_get
so that the test passes consistently. The issue was that the header before the
data includes the current date. Depending on the date, the data may start at a
different index in the returned string. Instead of hardcoding the data start
index in the test, we now use String::contains().

* UIProcess/API/efl/tests/test_ewk2_view.cpp:
(PageContentsCallback):
(TEST_F):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142153 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp

index df0ed45d69ee9ba9466ba8d01408f978ce461e93..b9887026a464e9a67db6bc809d3138873e5fd568 100644 (file)
@@ -1,3 +1,20 @@
+2013-02-07  Christophe Dumez  <dchris@gmail.com>
+
+        [EFL][WK2] EWK2UnitTestBase.ewk_view_page_contents_get API test is sometimes failing
+        https://bugs.webkit.org/show_bug.cgi?id=108634
+
+        Reviewed by Alexey Proskuryakov.
+
+        Use more robust data validation in EWK2UnitTestBase.ewk_view_page_contents_get
+        so that the test passes consistently. The issue was that the header before the
+        data includes the current date. Depending on the date, the data may start at a
+        different index in the returned string. Instead of hardcoding the data start
+        index in the test, we now use String::contains().
+
+        * UIProcess/API/efl/tests/test_ewk2_view.cpp:
+        (PageContentsCallback):
+        (TEST_F):
+
 2013-02-07  Gavin Peters  <gavinp@chromium.org>
 
         Unreviewed, rolling out r142141.
index ac89821e784d795bd3fdd3af44f47d2336f52300..8e08f9e96da56d3aea2a6e356df6f62ba7457a21 100644 (file)
@@ -917,7 +917,7 @@ TEST_F(EWK2UnitTestBase, ewk_view_contents_size_changed)
     evas_object_smart_callback_del(webView(), "contents,size,changed", onContentsSizeChanged);
 }
 
-static bool isObtainedPageContents = false;
+static bool obtainedPageContents = false;
 
 static void PageContentsCallback(Ewk_Page_Contents_Type type, const char* data)
 {
@@ -925,14 +925,15 @@ static void PageContentsCallback(Ewk_Page_Contents_Type type, const char* data)
     ASSERT_EQ(EWK_PAGE_CONTENTS_TYPE_MHTML, type);
 
     // The variable data should have below text block.
-    const char lines[] = "<=00h=00t=00m=00l=00>=00<=00h=00e=00a=00d=00>=00<=00m=00e=00t=00a=00 =00c=\r\n"
+    const String expectedMHTML = "\r\n\r\n<=00h=00t=00m=00l=00>=00<=00h=00e=00a=00d=00>=00<=00m=00e=00t=00a=00 =00c=\r\n"
         "=00h=00a=00r=00s=00e=00t=00=3D=00\"=00U=00T=00F=00-=001=006=00L=00E=00\"=00>=\r\n"
         "=00<=00/=00h=00e=00a=00d=00>=00<=00b=00o=00d=00y=00>=00<=00p=00>=00S=00i=00=\r\n"
         "m=00p=00l=00e=00 =00H=00T=00M=00L=00<=00/=00p=00>=00<=00/=00b=00o=00d=00y=\r\n"
-        "=00>=00<=00/=00h=00t=00m=00l=00>=00";
-    ASSERT_EQ(0, strncmp(data + 359, lines, strlen(lines)));
+        "=00>=00<=00/=00h=00t=00m=00l=00>=00\r\n";
 
-    isObtainedPageContents = true;
+    ASSERT_TRUE(String(data).contains(expectedMHTML));
+
+    obtainedPageContents = true;
 }
 
 TEST_F(EWK2UnitTestBase, ewk_view_page_contents_get)
@@ -942,7 +943,7 @@ TEST_F(EWK2UnitTestBase, ewk_view_page_contents_get)
     waitUntilLoadFinished();
 
     ASSERT_TRUE(ewk_view_page_contents_get(webView(), EWK_PAGE_CONTENTS_TYPE_MHTML, PageContentsCallback));
-    while (!isObtainedPageContents)
+    while (!obtainedPageContents)
         ecore_main_loop_iterate();
 }