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

Side by Side 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, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/dom/DocumentUserGestureToken.h"
6
7 #include "core/testing/DummyPageHolder.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace blink {
11
12 TEST(DocumentUserGestureTokenTest, DocumentUserGestureState) {
13 std::unique_ptr<DummyPageHolder> dummyPageHolder =
14 DummyPageHolder::create(IntSize(800, 600));
15 Document& document = dummyPageHolder->document();
16 ASSERT_FALSE(document.hasReceivedUserGesture());
17
18 // A nullptr Document* will not set user gesture state.
19 DocumentUserGestureToken::create(nullptr);
20 EXPECT_FALSE(document.hasReceivedUserGesture());
21
22 // A non-null Document* will set state, but a subsequent nullptr Document*
23 // token will not override it.
24 DocumentUserGestureToken::create(&document);
25 EXPECT_TRUE(document.hasReceivedUserGesture());
26 DocumentUserGestureToken::create(nullptr);
27 EXPECT_TRUE(document.hasReceivedUserGesture());
28 document.clearHasReceivedUserGesture();
29 ASSERT_FALSE(document.hasReceivedUserGesture());
30
31 // UserGestureToken::Status doesn't impact Document gesture state.
32 DocumentUserGestureToken::create(&document, UserGestureToken::NewGesture);
33 EXPECT_TRUE(document.hasReceivedUserGesture());
34 }
35
36 } // namespace blink
OLDNEW
« 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