Chromium Code Reviews| 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..51cf0606ea0fa42543ebfc8f4cdd5361fe16b52e |
| --- /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://www.itojun.org/paper/keio-doctor97.html")); |
|
aelias_OOO_until_Jul13
2016/03/04 06:53:12
Since this real URL is actually not in Latin1 it's
Jinsuk Kim
2016/03/07 01:28:00
Done.
|
| +} |
| + |
| +} // namespace blink |