| Index: third_party/WebKit/Source/core/loader/TextResourceDecoderBuilderTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/loader/TextResourceDecoderBuilderTest.cpp b/third_party/WebKit/Source/core/loader/TextResourceDecoderBuilderTest.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..eaf7950bc2994f73c81caa335869e9c49f77e8c2
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/loader/TextResourceDecoderBuilderTest.cpp
|
| @@ -0,0 +1,33 @@
|
| +// 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 "core/loader/TextResourceDecoderBuilder.h"
|
| +
|
| +#include "core/testing/DummyPageHolder.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace blink {
|
| +
|
| +static const WTF::TextEncoding defaultEncodingForURL(const char* url)
|
| +{
|
| + OwnPtr<DummyPageHolder> pageHolder = DummyPageHolder::create(IntSize(0, 0));
|
| + Document& document = pageHolder->document();
|
| + document.setURL(KURL(KURL(), url));
|
| + TextResourceDecoderBuilder decoderBuilder("text/html", nullAtom);
|
| + return decoderBuilder.buildFor(&document)->encoding();
|
| +}
|
| +
|
| +TEST(TextResourceDecoderBuilderTest, defaultEncodingComesFromTopLevelDomain)
|
| +{
|
| + EXPECT_EQ(WTF::TextEncoding("Shift_JIS"), defaultEncodingForURL("http://tsubotaa.la.coocan.jp"));
|
| + EXPECT_EQ(WTF::TextEncoding("windows-1251"), defaultEncodingForURL("http://udarenieru.ru/index.php"));
|
| +}
|
| +
|
| +TEST(TextResourceDecoderBuilderTest, NoCountryDomainURLDefaultsToLatin1Encoding)
|
| +{
|
| + // Latin1 encoding is set in |TextResourceDecoder::defaultEncoding()|.
|
| + EXPECT_EQ(WTF::Latin1Encoding(), defaultEncodingForURL("http://arstechnica.com/about-us"));
|
| +}
|
| +
|
| +} // namespace blink
|
|
|