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

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

Issue 2784483003: Respect UTF-8 detection result for local file resources (Closed)
Patch Set: Created 3 years, 8 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 "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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 TEST(TextEncodingDetectorTest, UTF8DetectionShouldFail) { 89 TEST(TextEncodingDetectorTest, UTF8DetectionShouldFail) {
90 std::string utf8Bytes = 90 std::string utf8Bytes =
91 "tnegirjji gosa gii beare s\xC3\xA1htt\xC3\xA1 \xC4\x8D\xC3" 91 "tnegirjji gosa gii beare s\xC3\xA1htt\xC3\xA1 \xC4\x8D\xC3"
92 "\xA1llit artihkkaliid. Maid don s\xC3\xA1ht\xC3\xA1t dievasmah"; 92 "\xA1llit artihkkaliid. Maid don s\xC3\xA1ht\xC3\xA1t dievasmah";
93 WTF::TextEncoding encoding; 93 WTF::TextEncoding encoding;
94 bool result = detectTextEncoding(utf8Bytes.c_str(), utf8Bytes.length(), 94 bool result = detectTextEncoding(utf8Bytes.c_str(), utf8Bytes.length(),
95 nullptr, nullptr, nullptr, &encoding); 95 nullptr, nullptr, nullptr, &encoding);
96 EXPECT_FALSE(result); 96 EXPECT_FALSE(result);
97 } 97 }
98 98
99 TEST(TextEncodingDetectorTest, RespectUTF8DetectionForFileResource) {
100 std::string utf8Bytes =
101 "tnegirjji gosa gii beare s\xC3\xA1htt\xC3\xA1 \xC4\x8D\xC3"
102 "\xA1llit artihkkaliid. Maid don s\xC3\xA1ht\xC3\xA1t dievasmah";
103 WTF::TextEncoding encoding;
104 bool result = detectTextEncoding(utf8Bytes.c_str(), utf8Bytes.length(),
105 nullptr, "file:///text", nullptr, &encoding);
106 EXPECT_TRUE(result);
107 }
108
99 } // namespace blink 109 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698