Title: [198507] trunk
Revision
198507
Author
bfulg...@apple.com
Date
2016-03-21 17:06:53 -0700 (Mon, 21 Mar 2016)

Log Message

Improve SharedBuffer testing
https://bugs.webkit.org/show_bug.cgi?id=93078
<rdar://problem/25277829>

Reviewed by Ryosuke Niwa.

Source/WebCore:

* platform/SharedBuffer.h: Mark a few methods as WEBCORE_EXPORT so they
can be used by TestWebKitAPI.

Tools:

Based on a Blink patch by Huang Dongsung <luxte...@company100.net>.
<https://src.chromium.org/viewvc/blink?revision=153850&view=revision,
and a Blink patch by <tyosh...@chromium.org>
<https://src.chromium.org/viewvc/blink?view=rev&revision=151617>

Add three test cases from the Blink project that cover various append,
copy, and createArrayBuffer calls.

* TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp:
(TestWebKitAPI::TEST_F):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (198506 => 198507)


--- trunk/Source/WebCore/ChangeLog	2016-03-21 23:29:58 UTC (rev 198506)
+++ trunk/Source/WebCore/ChangeLog	2016-03-22 00:06:53 UTC (rev 198507)
@@ -1,3 +1,14 @@
+2016-03-21  Brent Fulgham  <bfulg...@apple.com>
+
+        Improve SharedBuffer testing
+        https://bugs.webkit.org/show_bug.cgi?id=93078
+        <rdar://problem/25277829>
+
+        Reviewed by Ryosuke Niwa.
+
+        * platform/SharedBuffer.h: Mark a few methods as WEBCORE_EXPORT so they
+        can be used by TestWebKitAPI.
+
 2016-03-21  Zalan Bujtas  <za...@apple.com>
 
         WebCore::RenderTableCell::setCol should put a cap on the column value. 

Modified: trunk/Source/WebCore/platform/SharedBuffer.h (198506 => 198507)


--- trunk/Source/WebCore/platform/SharedBuffer.h	2016-03-21 23:29:58 UTC (rev 198506)
+++ trunk/Source/WebCore/platform/SharedBuffer.h	2016-03-22 00:06:53 UTC (rev 198507)
@@ -83,7 +83,7 @@
     WEBCORE_EXPORT const char* data() const;
     // Creates an ArrayBuffer and copies this SharedBuffer's contents to that
     // ArrayBuffer without merging segmented buffers into a flat buffer.
-    RefPtr<ArrayBuffer> createArrayBuffer() const;
+    WEBCORE_EXPORT RefPtr<ArrayBuffer> createArrayBuffer() const;
 
     WEBCORE_EXPORT unsigned size() const;
 
@@ -92,7 +92,7 @@
 
     WEBCORE_EXPORT void append(SharedBuffer*);
     WEBCORE_EXPORT void append(const char*, unsigned);
-    void append(const Vector<char>&);
+    WEBCORE_EXPORT void append(const Vector<char>&);
 
     WEBCORE_EXPORT void clear();
     const char* platformData() const;

Modified: trunk/Tools/ChangeLog (198506 => 198507)


--- trunk/Tools/ChangeLog	2016-03-21 23:29:58 UTC (rev 198506)
+++ trunk/Tools/ChangeLog	2016-03-22 00:06:53 UTC (rev 198507)
@@ -1,3 +1,22 @@
+2016-03-21  Brent Fulgham  <bfulg...@apple.com>
+
+        Improve SharedBuffer testing
+        https://bugs.webkit.org/show_bug.cgi?id=93078
+        <rdar://problem/25277829>
+
+        Reviewed by Ryosuke Niwa.
+
+        Based on a Blink patch by Huang Dongsung <luxte...@company100.net>.
+        <https://src.chromium.org/viewvc/blink?revision=153850&view=revision,
+        and a Blink patch by <tyosh...@chromium.org>
+        <https://src.chromium.org/viewvc/blink?view=rev&revision=151617>
+
+        Add three test cases from the Blink project that cover various append,
+        copy, and createArrayBuffer calls.
+
+        * TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2016-03-21  Hyungwook Lee  <hyungwook....@navercorp.com>
 
         [Win] Connect layoutTestController.findString() to support testing

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp (198506 => 198507)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp	2016-03-21 23:29:58 UTC (rev 198506)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp	2016-03-22 00:06:53 UTC (rev 198507)
@@ -1,5 +1,7 @@
 /*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
  * Copyright (C) 2015 Canon Inc. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -116,4 +118,77 @@
     EXPECT_EQ('a', buffer->data()[strlen(SharedBufferTestData)]);
 }
 
+TEST_F(SharedBufferTest, createArrayBuffer)
+{
+    char testData0[] = "Hello";
+    char testData1[] = "World";
+    char testData2[] = "Goodbye";
+    RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(testData0, strlen(testData0));
+    sharedBuffer->append(testData1, strlen(testData1));
+    sharedBuffer->append(testData2, strlen(testData2));
+    RefPtr<ArrayBuffer> arrayBuffer = sharedBuffer->createArrayBuffer();
+    char expectedConcatenation[] = "HelloWorldGoodbye";
+    ASSERT_EQ(strlen(expectedConcatenation), arrayBuffer->byteLength());
+    EXPECT_EQ(0, memcmp(expectedConcatenation, arrayBuffer->data(), strlen(expectedConcatenation)));
 }
+
+TEST_F(SharedBufferTest, createArrayBufferLargeSegments)
+{
+    Vector<char> vector0(0x4000, 'a');
+    Vector<char> vector1(0x4000, 'b');
+    Vector<char> vector2(0x4000, 'c');
+
+    RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::adoptVector(vector0);
+    sharedBuffer->append(vector1);
+    sharedBuffer->append(vector2);
+    RefPtr<ArrayBuffer> arrayBuffer = sharedBuffer->createArrayBuffer();
+    ASSERT_EQ(0x4000U + 0x4000U + 0x4000U, arrayBuffer->byteLength());
+    int position = 0;
+    for (int i = 0; i < 0x4000; ++i) {
+        EXPECT_EQ('a', static_cast<char*>(arrayBuffer->data())[position]);
+        ++position;
+    }
+    for (int i = 0; i < 0x4000; ++i) {
+        EXPECT_EQ('b', static_cast<char*>(arrayBuffer->data())[position]);
+        ++position;
+    }
+    for (int i = 0; i < 0x4000; ++i) {
+        EXPECT_EQ('c', static_cast<char*>(arrayBuffer->data())[position]);
+        ++position;
+    }
+}
+
+TEST_F(SharedBufferTest, copy)
+{
+    char testData[] = "Habitasse integer eros tincidunt a scelerisque! Enim elit? Scelerisque magnis,"
+    "et montes ultrices tristique a! Pid. Velit turpis, dapibus integer rhoncus sociis amet facilisis,"
+    "adipiscing pulvinar nascetur magnis tempor sit pulvinar, massa urna enim porttitor sociis sociis proin enim?"
+    "Lectus, platea dolor, integer a. A habitasse hac nunc, nunc, nec placerat vut in sit nunc nec, sed. Sociis,"
+    "vut! Hac, velit rhoncus facilisis. Rhoncus et, enim, sed et in tristique nunc montes,"
+    "natoque nunc sagittis elementum parturient placerat dolor integer? Pulvinar,"
+    "magnis dignissim porttitor ac pulvinar mid tempor. A risus sed mid! Magnis elit duis urna,"
+    "cras massa, magna duis. Vut magnis pid a! Penatibus aliquet porttitor nunc, adipiscing massa odio lundium,"
+    "risus elementum ac turpis massa pellentesque parturient augue. Purus amet turpis pid aliquam?"
+    "Dolor est tincidunt? Dolor? Dignissim porttitor sit in aliquam! Tincidunt, non nunc, rhoncus dictumst!"
+    "Porta augue etiam. Cursus augue nunc lacus scelerisque. Rhoncus lectus, integer hac, nec pulvinar augue massa,"
+    "integer amet nisi facilisis? A! A, enim velit pulvinar elit in non scelerisque in et ultricies amet est!"
+    "in porttitor montes lorem et, hac aliquet pellentesque a sed? Augue mid purus ridiculus vel dapibus,"
+    "sagittis sed, tortor auctor nascetur rhoncus nec, rhoncus, magna integer. Sit eu massa vut?"
+    "Porta augue porttitor elementum, enim, rhoncus pulvinar duis integer scelerisque rhoncus natoque,"
+    "mattis dignissim massa ac pulvinar urna, nunc ut. Sagittis, aliquet penatibus proin lorem, pulvinar lectus,"
+    "augue proin! Ac, arcu quis. Placerat habitasse, ridiculus ridiculus.";
+    unsigned length = strlen(testData);
+    RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(testData, length);
+    sharedBuffer->append(testData, length);
+    sharedBuffer->append(testData, length);
+    sharedBuffer->append(testData, length);
+    // sharedBuffer must contain data more than segmentSize (= 0x1000) to check copy().
+    ASSERT_EQ(length * 4, sharedBuffer->size());
+    RefPtr<SharedBuffer> clone = sharedBuffer->copy();
+    ASSERT_EQ(length * 4, clone->size());
+    ASSERT_EQ(0, memcmp(clone->data(), sharedBuffer->data(), clone->size()));
+    clone->append(testData, length);
+    ASSERT_EQ(length * 5, clone->size());
+}
+
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to