| 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
|
|
|