OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/dom/Document.h" | 5 #include "core/dom/Document.h" |
| 6 #include "core/dom/DocumentUserGestureToken.h" |
6 #include "core/html/AutoplayExperimentHelper.h" | 7 #include "core/html/AutoplayExperimentHelper.h" |
7 #include "platform/UserGestureIndicator.h" | 8 #include "platform/UserGestureIndicator.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
10 | 11 |
11 // msvc refuses to compile if we use all of ::testing, due to a conflict with | 12 // msvc refuses to compile if we use all of ::testing, due to a conflict with |
12 // WTF::NotNull. So, we just use what we need. | 13 // WTF::NotNull. So, we just use what we need. |
13 using ::testing::Return; | 14 using ::testing::Return; |
14 using ::testing::NiceMock; | 15 using ::testing::NiceMock; |
15 using ::testing::_; | 16 using ::testing::_; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 EXPECT_CALL(*m_client, recordAutoplayMetric(AnyPlaybackStarted)).Times(1); | 128 EXPECT_CALL(*m_client, recordAutoplayMetric(AnyPlaybackStarted)).Times(1); |
128 m_helper->playbackStarted(); | 129 m_helper->playbackStarted(); |
129 } | 130 } |
130 | 131 |
131 void startPlaybackWithoutUserGesture() { | 132 void startPlaybackWithoutUserGesture() { |
132 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 133 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
133 startPlayback(); | 134 startPlayback(); |
134 } | 135 } |
135 | 136 |
136 void startPlaybackWithUserGesture() { | 137 void startPlaybackWithUserGesture() { |
137 UserGestureIndicator indicator(UserGestureToken::create()); | 138 UserGestureIndicator indicator(DocumentUserGestureToken::create(nullptr)); |
138 EXPECT_TRUE(UserGestureIndicator::processingUserGesture()); | 139 EXPECT_TRUE(UserGestureIndicator::processingUserGesture()); |
139 startPlayback(); | 140 startPlayback(); |
140 } | 141 } |
141 | 142 |
142 void setUserGestureRequiredForPlay(bool required) { | 143 void setUserGestureRequiredForPlay(bool required) { |
143 ON_CALL(*m_client, isLockedPendingUserGesture()) | 144 ON_CALL(*m_client, isLockedPendingUserGesture()) |
144 .WillByDefault(Return(required)); | 145 .WillByDefault(Return(required)); |
145 } | 146 } |
146 | 147 |
147 void setShouldAutoplay(bool should) { | 148 void setShouldAutoplay(bool should) { |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 ON_CALL(*m_client, paused()).WillByDefault(Return(false)); | 445 ON_CALL(*m_client, paused()).WillByDefault(Return(false)); |
445 setIsMuted(true); | 446 setIsMuted(true); |
446 m_helper->mutedChanged(); | 447 m_helper->mutedChanged(); |
447 | 448 |
448 // Verify that unmuting pauses playback. | 449 // Verify that unmuting pauses playback. |
449 setIsMuted(false); | 450 setIsMuted(false); |
450 EXPECT_CALL(*m_client, pauseInternal()).Times(1); | 451 EXPECT_CALL(*m_client, pauseInternal()).Times(1); |
451 m_helper->mutedChanged(); | 452 m_helper->mutedChanged(); |
452 } | 453 } |
453 } | 454 } |
OLD | NEW |