OLD | NEW |
(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 |
OLD | NEW |