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

Side by Side Diff: third_party/WebKit/Source/platform/text/TextEncodingDetectorTest.cpp

Issue 2697213002: Do not guess UTF8 encoding (Closed)
Patch Set: webkit layout htmls Created 3 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "platform/text/TextEncodingDetector.h" 5 #include "platform/text/TextEncodingDetector.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "wtf/text/TextEncoding.h" 8 #include "wtf/text/TextEncoding.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 EXPECT_EQ(WTF::TextEncoding("GBK"), encoding) 66 EXPECT_EQ(WTF::TextEncoding("GBK"), encoding)
67 << "Without language hint, it's detected as GBK"; 67 << "Without language hint, it's detected as GBK";
68 68
69 result = detectTextEncoding(eucjpBytes.c_str(), eucjpBytes.length(), nullptr, 69 result = detectTextEncoding(eucjpBytes.c_str(), eucjpBytes.length(), nullptr,
70 nullptr, "ja", &encoding); 70 nullptr, "ja", &encoding);
71 EXPECT_TRUE(result); 71 EXPECT_TRUE(result);
72 EXPECT_EQ(WTF::TextEncoding("EUC-JP"), encoding) 72 EXPECT_EQ(WTF::TextEncoding("EUC-JP"), encoding)
73 << "With language hint 'ja', it's detected as EUC-JP"; 73 << "With language hint 'ja', it's detected as EUC-JP";
74 } 74 }
75 75
76 TEST(TextEncodingDetectorTest, UTF8DetectionShouldFail) {
77 std::string utf8Bytes =
78 "tnegirjji gosa gii beare s\xC3\xA1htt\xC3\xA1 \xC4\x8D\xC3"
79 "\xA1llit artihkkaliid. Maid don s\xC3\xA1ht\xC3\xA1t dievasmah";
80 WTF::TextEncoding encoding;
81 bool result = detectTextEncoding(utf8Bytes.c_str(), utf8Bytes.length(),
82 nullptr, nullptr, nullptr, &encoding);
83 EXPECT_FALSE(result);
84 }
85
76 } // namespace blink 86 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698