| 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
|
|
|