Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: third_party/WebKit/Source/wtf/text/CompressibleStringTest.cpp

Issue 1389383003: WIP: Introduce CompressibleString Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto crrev.com/1564773002 Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/text/CompressibleString.cpp ('k') | third_party/WebKit/Source/wtf/wtf.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/CompressibleStringTest.cpp
diff --git a/third_party/WebKit/Source/wtf/text/CompressibleStringTest.cpp b/third_party/WebKit/Source/wtf/text/CompressibleStringTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9ae54a27835004f280f252810b3ec53a04e5475c
--- /dev/null
+++ b/third_party/WebKit/Source/wtf/text/CompressibleStringTest.cpp
@@ -0,0 +1,40 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "wtf/text/CompressibleString.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace WTF {
+
+// The input and compressed data is copied from
+// components/compression/compression_utils_unittest.cc
+const char InputData[] = {
+ 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f,
+ 0x72, 0x6c, 0x64};
+
+const char CompressedData[] = {
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xcb, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x28, 0xcf,
+ 0x2f, 0xca, 0x49, 0x01, 0x00, 0x85, 0x11, 0x4a, 0x0d,
+ 0x0b, 0x00, 0x00, 0x00};
+
+TEST(CompressibleStringTest, compress)
+{
+ RefPtr<StringImpl> impl = StringImpl::create(InputData, sizeof(InputData));
+ RefPtr<CompressibleStringImpl> string = adoptRef(new CompressibleStringImpl(impl));
+ EXPECT_TRUE(!string->isCompressed());
+ EXPECT_EQ(sizeof(InputData), string->originalContentSizeInBytes());
+ EXPECT_EQ(sizeof(InputData), string->currentSizeInBytes());
+ string->compressString();
+ EXPECT_TRUE(string->isCompressed());
+ EXPECT_EQ(sizeof(InputData), string->originalContentSizeInBytes());
+ EXPECT_EQ(sizeof(CompressedData), string->currentSizeInBytes());
+ string->uncompressString();
+ EXPECT_TRUE(!string->isCompressed());
+ EXPECT_EQ(sizeof(InputData), string->originalContentSizeInBytes());
+ EXPECT_EQ(sizeof(InputData), string->currentSizeInBytes());
+}
+
+} // namespace WTF
« no previous file with comments | « third_party/WebKit/Source/wtf/text/CompressibleString.cpp ('k') | third_party/WebKit/Source/wtf/wtf.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698