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

Unified Diff: third_party/WebKit/Source/core/dom/DocumentUserGestureTokenTest.cpp

Issue 2408333004: Move persistent gesture state to Document, add DocumentUserGestureToken (Closed)
Patch Set: Re-add dropped null check Created 4 years, 2 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
Index: third_party/WebKit/Source/core/dom/DocumentUserGestureTokenTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/DocumentUserGestureTokenTest.cpp b/third_party/WebKit/Source/core/dom/DocumentUserGestureTokenTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5df9cf43fa5cef849f70e8f43b26cdb7e04ca442
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/DocumentUserGestureTokenTest.cpp
@@ -0,0 +1,36 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/dom/DocumentUserGestureToken.h"
+
+#include "core/testing/DummyPageHolder.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+TEST(DocumentUserGestureTokenTest, DocumentUserGestureState) {
+ std::unique_ptr<DummyPageHolder> dummyPageHolder =
+ DummyPageHolder::create(IntSize(800, 600));
+ Document& document = dummyPageHolder->document();
+ ASSERT_FALSE(document.hasReceivedUserGesture());
+
+ // A nullptr Document* will not set user gesture state.
+ DocumentUserGestureToken::create(nullptr);
+ EXPECT_FALSE(document.hasReceivedUserGesture());
+
+ // A non-null Document* will set state, but a subsequent nullptr Document*
+ // token will not override it.
+ DocumentUserGestureToken::create(&document);
+ EXPECT_TRUE(document.hasReceivedUserGesture());
+ DocumentUserGestureToken::create(nullptr);
+ EXPECT_TRUE(document.hasReceivedUserGesture());
+ document.clearHasReceivedUserGesture();
+ ASSERT_FALSE(document.hasReceivedUserGesture());
+
+ // UserGestureToken::Status doesn't impact Document gesture state.
+ DocumentUserGestureToken::create(&document, UserGestureToken::NewGesture);
+ EXPECT_TRUE(document.hasReceivedUserGesture());
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/DocumentUserGestureToken.h ('k') | third_party/WebKit/Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698