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

Unified Diff: third_party/WebKit/Source/wtf/text/TextCodecTest.cpp

Issue 1709293002: Add support for CSS unicod encoding to the text codec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a unit test Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/text/TextCodecICU.cpp ('k') | third_party/WebKit/Source/wtf/wtf.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/TextCodecTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebUserGestureTokenTest.cpp b/third_party/WebKit/Source/wtf/text/TextCodecTest.cpp
similarity index 50%
copy from third_party/WebKit/Source/web/tests/WebUserGestureTokenTest.cpp
copy to third_party/WebKit/Source/wtf/text/TextCodecTest.cpp
index 9fb0fc9fb0b50c9b3e10d466bac07a79f35120aa..2541e20542beb6fd04a22388493492254d1cc4cf 100644
--- a/third_party/WebKit/Source/web/tests/WebUserGestureTokenTest.cpp
+++ b/third_party/WebKit/Source/wtf/text/TextCodecTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,52 +28,59 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "public/web/WebUserGestureToken.h"
+#include "wtf/text/TextCodec.h"
-#include "platform/UserGestureIndicator.h"
-#include "public/web/WebScopedUserGesture.h"
-#include "public/web/WebUserGestureIndicator.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace blink {
+namespace WTF {
-TEST(WebUserGestureTokenTest, Basic)
-{
- WebUserGestureToken token;
- EXPECT_FALSE(token.hasGestures());
- UserGestureIndicator::clearProcessedUserGestureSinceLoad();
- EXPECT_FALSE(UserGestureIndicator::processedUserGestureSinceLoad());
+namespace {
+ TEST(TextCodec, QuestionMarkEncoding)
{
- WebScopedUserGesture indicator(token);
- EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture());
+ UnencodableReplacementArray replacement;
+ int size = TextCodec::getUnencodableReplacement(0xE003,
+ QuestionMarksForUnencodables,
+ replacement);
+ EXPECT_EQ(size, 1);
+ EXPECT_EQ(replacement[0], '?');
+ EXPECT_EQ(replacement[1], 0);
}
+ TEST(TextCodec, HTMLEntityEncoding)
{
- UserGestureIndicator indicator(DefinitelyProcessingNewUserGesture);
- EXPECT_TRUE(WebUserGestureIndicator::isProcessingUserGesture());
- token = WebUserGestureIndicator::currentUserGestureToken();
- EXPECT_TRUE(UserGestureIndicator::processedUserGestureSinceLoad());
+ UnencodableReplacementArray replacement;
+ int size = TextCodec::getUnencodableReplacement(0xE003,
+ EntitiesForUnencodables,
+ replacement);
+ EXPECT_EQ(size, 8);
+ EXPECT_EQ(std::string(replacement), "");
+ EXPECT_EQ(replacement[8], 0);
}
- EXPECT_TRUE(token.hasGestures());
- EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture());
-
+ TEST(TextCodec, URLEntityEncoding)
{
- WebScopedUserGesture indicator(token);
- EXPECT_TRUE(WebUserGestureIndicator::isProcessingUserGesture());
- WebUserGestureIndicator::consumeUserGesture();
- EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture());
+ UnencodableReplacementArray replacement;
+ int size = TextCodec::getUnencodableReplacement(
+ 0xE003,
+ URLEncodedEntitiesForUnencodables,
+ replacement);
+ EXPECT_EQ(size, 14);
+ EXPECT_EQ(std::string(replacement), "%26%2357347%3B");
+ EXPECT_EQ(replacement[14], 0);
}
- EXPECT_FALSE(token.hasGestures());
-
+ TEST(TextCodec, CSSEntityEncoding)
{
- WebScopedUserGesture indicator(token);
- EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture());
+ UnencodableReplacementArray replacement;
+ int size = TextCodec::getUnencodableReplacement(
+ 0xE003,
+ CSSEncodedEntitiesForUnencodables,
+ replacement);
+ EXPECT_EQ(size, 6);
+ EXPECT_EQ(std::string(replacement), "\\e003 ");
+ EXPECT_EQ(replacement[6], 0);
}
- EXPECT_TRUE(UserGestureIndicator::processedUserGestureSinceLoad());
-}
-
-} // namespace blink
+} // anonymous namespace
+} // namespace WTF
« no previous file with comments | « third_party/WebKit/Source/wtf/text/TextCodecICU.cpp ('k') | third_party/WebKit/Source/wtf/wtf.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698