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

Side by Side Diff: third_party/WebKit/Source/core/loader/TextResourceDecoderBuilderTest.cpp

Issue 2940933003: DO NOT SUBMIT results of new clang-format (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/loader/TextResourceDecoderBuilder.h" 5 #include "core/loader/TextResourceDecoderBuilder.h"
6 6
7 #include <memory>
7 #include "core/testing/DummyPageHolder.h" 8 #include "core/testing/DummyPageHolder.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 #include <memory>
10 10
11 namespace blink { 11 namespace blink {
12 12
13 static const WTF::TextEncoding DefaultEncodingForURL(const char* url) { 13 static const WTF::TextEncoding DefaultEncodingForURL(const char* url) {
14 std::unique_ptr<DummyPageHolder> page_holder = 14 std::unique_ptr<DummyPageHolder> page_holder =
15 DummyPageHolder::Create(IntSize(0, 0)); 15 DummyPageHolder::Create(IntSize(0, 0));
16 Document& document = page_holder->GetDocument(); 16 Document& document = page_holder->GetDocument();
17 document.SetURL(KURL(KURL(), url)); 17 document.SetURL(KURL(KURL(), url));
18 TextResourceDecoderBuilder decoder_builder("text/html", g_null_atom); 18 TextResourceDecoderBuilder decoder_builder("text/html", g_null_atom);
19 return decoder_builder.BuildFor(&document)->Encoding(); 19 return decoder_builder.BuildFor(&document)->Encoding();
20 } 20 }
21 21
22 TEST(TextResourceDecoderBuilderTest, defaultEncodingComesFromTopLevelDomain) { 22 TEST(TextResourceDecoderBuilderTest, defaultEncodingComesFromTopLevelDomain) {
23 EXPECT_EQ(WTF::TextEncoding("Shift_JIS"), 23 EXPECT_EQ(WTF::TextEncoding("Shift_JIS"),
24 DefaultEncodingForURL("http://tsubotaa.la.coocan.jp")); 24 DefaultEncodingForURL("http://tsubotaa.la.coocan.jp"));
25 EXPECT_EQ(WTF::TextEncoding("windows-1251"), 25 EXPECT_EQ(WTF::TextEncoding("windows-1251"),
26 DefaultEncodingForURL("http://udarenieru.ru/index.php")); 26 DefaultEncodingForURL("http://udarenieru.ru/index.php"));
27 } 27 }
28 28
29 TEST(TextResourceDecoderBuilderTest, 29 TEST(TextResourceDecoderBuilderTest,
30 NoCountryDomainURLDefaultsToLatin1Encoding) { 30 NoCountryDomainURLDefaultsToLatin1Encoding) {
31 // Latin1 encoding is set in |TextResourceDecoder::defaultEncoding()|. 31 // Latin1 encoding is set in |TextResourceDecoder::defaultEncoding()|.
32 EXPECT_EQ(WTF::Latin1Encoding(), 32 EXPECT_EQ(WTF::Latin1Encoding(),
33 DefaultEncodingForURL("http://arstechnica.com/about-us")); 33 DefaultEncodingForURL("http://arstechnica.com/about-us"));
34 } 34 }
35 35
36 } // namespace blink 36 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698