| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/UserGestureIndicator.h" | 5 #include "platform/UserGestureIndicator.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 class TestUserGestureToken final : public UserGestureToken { | 11 class TestUserGestureToken final : public UserGestureToken { |
| 12 WTF_MAKE_NONCOPYABLE(TestUserGestureToken); | 12 WTF_MAKE_NONCOPYABLE(TestUserGestureToken); |
| 13 | 13 |
| 14 public: | 14 public: |
| 15 static PassRefPtr<UserGestureToken> create( | 15 static PassRefPtr<UserGestureToken> create( |
| 16 Status status = PossiblyExistingGesture) { | 16 Status status = PossiblyExistingGesture) { |
| 17 return adoptRef(new TestUserGestureToken(status)); | 17 return adoptRef(new TestUserGestureToken(status)); |
| 18 } | 18 } |
| 19 | 19 |
| 20 ~TestUserGestureToken() final {} | |
| 21 | |
| 22 private: | 20 private: |
| 23 TestUserGestureToken(Status status) : UserGestureToken(status) {} | 21 TestUserGestureToken(Status status) : UserGestureToken(status) {} |
| 24 }; | 22 }; |
| 25 | 23 |
| 26 // Checks for the initial state of UserGestureIndicator. | 24 // Checks for the initial state of UserGestureIndicator. |
| 27 TEST(UserGestureIndicatorTest, InitialState) { | 25 TEST(UserGestureIndicatorTest, InitialState) { |
| 28 EXPECT_FALSE(UserGestureIndicator::utilizeUserGesture()); | 26 EXPECT_FALSE(UserGestureIndicator::utilizeUserGesture()); |
| 29 EXPECT_EQ(nullptr, UserGestureIndicator::currentToken()); | 27 EXPECT_EQ(nullptr, UserGestureIndicator::currentToken()); |
| 30 EXPECT_FALSE(UserGestureIndicator::consumeUserGesture()); | 28 EXPECT_FALSE(UserGestureIndicator::consumeUserGesture()); |
| 31 } | 29 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 167 } |
| 170 | 168 |
| 171 // The callback isn't invoked outside the scope of the UGI | 169 // The callback isn't invoked outside the scope of the UGI |
| 172 EXPECT_FALSE(UserGestureIndicator::utilizeUserGesture()); | 170 EXPECT_FALSE(UserGestureIndicator::utilizeUserGesture()); |
| 173 EXPECT_EQ(0u, cb.getAndResetUsedCount()); | 171 EXPECT_EQ(0u, cb.getAndResetUsedCount()); |
| 174 EXPECT_FALSE(UserGestureIndicator::consumeUserGesture()); | 172 EXPECT_FALSE(UserGestureIndicator::consumeUserGesture()); |
| 175 EXPECT_EQ(0u, cb.getAndResetUsedCount()); | 173 EXPECT_EQ(0u, cb.getAndResetUsedCount()); |
| 176 } | 174 } |
| 177 | 175 |
| 178 } // namespace blink | 176 } // namespace blink |
| OLD | NEW |