| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "public/web/WebUserGestureToken.h" | 31 #include "public/web/WebUserGestureToken.h" |
| 32 | 32 |
| 33 #include "core/dom/DocumentUserGestureToken.h" |
| 33 #include "platform/UserGestureIndicator.h" | 34 #include "platform/UserGestureIndicator.h" |
| 34 #include "public/web/WebScopedUserGesture.h" | 35 #include "public/web/WebScopedUserGesture.h" |
| 35 #include "public/web/WebUserGestureIndicator.h" | 36 #include "public/web/WebUserGestureIndicator.h" |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
| 37 | 38 |
| 38 namespace blink { | 39 namespace blink { |
| 39 | 40 |
| 40 TEST(WebUserGestureTokenTest, Basic) { | 41 TEST(WebUserGestureTokenTest, Basic) { |
| 41 WebUserGestureToken token; | 42 WebUserGestureToken token; |
| 42 EXPECT_FALSE(token.hasGestures()); | 43 EXPECT_FALSE(token.hasGestures()); |
| 43 UserGestureIndicator::clearProcessedUserGestureSinceLoad(); | |
| 44 EXPECT_FALSE(UserGestureIndicator::processedUserGestureSinceLoad()); | |
| 45 | 44 |
| 46 { | 45 { |
| 47 WebScopedUserGesture indicator(token); | 46 WebScopedUserGesture indicator(token); |
| 48 EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture()); | 47 EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture()); |
| 49 } | 48 } |
| 50 | 49 |
| 51 { | 50 { |
| 52 UserGestureIndicator indicator( | 51 UserGestureIndicator indicator(DocumentUserGestureToken::create( |
| 53 UserGestureToken::create(UserGestureToken::NewGesture)); | 52 nullptr, UserGestureToken::NewGesture)); |
| 54 EXPECT_TRUE(WebUserGestureIndicator::isProcessingUserGesture()); | 53 EXPECT_TRUE(WebUserGestureIndicator::isProcessingUserGesture()); |
| 55 token = WebUserGestureIndicator::currentUserGestureToken(); | 54 token = WebUserGestureIndicator::currentUserGestureToken(); |
| 56 EXPECT_TRUE(UserGestureIndicator::processedUserGestureSinceLoad()); | |
| 57 } | 55 } |
| 58 | 56 |
| 59 EXPECT_TRUE(token.hasGestures()); | 57 EXPECT_TRUE(token.hasGestures()); |
| 60 EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture()); | 58 EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture()); |
| 61 | 59 |
| 62 { | 60 { |
| 63 WebScopedUserGesture indicator(token); | 61 WebScopedUserGesture indicator(token); |
| 64 EXPECT_TRUE(WebUserGestureIndicator::isProcessingUserGesture()); | 62 EXPECT_TRUE(WebUserGestureIndicator::isProcessingUserGesture()); |
| 65 WebUserGestureIndicator::consumeUserGesture(); | 63 WebUserGestureIndicator::consumeUserGesture(); |
| 66 EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture()); | 64 EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture()); |
| 67 } | 65 } |
| 68 | 66 |
| 69 EXPECT_FALSE(token.hasGestures()); | 67 EXPECT_FALSE(token.hasGestures()); |
| 70 | 68 |
| 71 { | 69 { |
| 72 WebScopedUserGesture indicator(token); | 70 WebScopedUserGesture indicator(token); |
| 73 EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture()); | 71 EXPECT_FALSE(WebUserGestureIndicator::isProcessingUserGesture()); |
| 74 } | 72 } |
| 75 | |
| 76 EXPECT_TRUE(UserGestureIndicator::processedUserGestureSinceLoad()); | |
| 77 } | 73 } |
| 78 | 74 |
| 79 } // namespace blink | 75 } // namespace blink |
| OLD | NEW |