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/html/AutoplayExperimentHelper.h" | 6 #include "core/html/AutoplayExperimentHelper.h" |
7 #include "platform/UserGestureIndicator.h" | 7 #include "platform/UserGestureIndicator.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 ON_CALL(*this, isLegacyViewportType()) | 47 ON_CALL(*this, isLegacyViewportType()) |
48 .WillByDefault(Return(false)); | 48 .WillByDefault(Return(false)); |
49 | 49 |
50 // Other handy defaults. | 50 // Other handy defaults. |
51 ON_CALL(*this, ended()) | 51 ON_CALL(*this, ended()) |
52 .WillByDefault(Return(false)); | 52 .WillByDefault(Return(false)); |
53 ON_CALL(*this, pageVisibilityState()) | 53 ON_CALL(*this, pageVisibilityState()) |
54 .WillByDefault(Return(PageVisibilityStateVisible)); | 54 .WillByDefault(Return(PageVisibilityStateVisible)); |
55 ON_CALL(*this, isCrossOrigin()) | 55 ON_CALL(*this, isCrossOrigin()) |
56 .WillByDefault(Return(false)); | 56 .WillByDefault(Return(false)); |
| 57 ON_CALL(*this, isAutoplayAllowedPerSettings()) |
| 58 .WillByDefault(Return(true)); |
57 ON_CALL(*this, absoluteBoundingBoxRect()) | 59 ON_CALL(*this, absoluteBoundingBoxRect()) |
58 .WillByDefault(Return( | 60 .WillByDefault(Return( |
59 IntRect(10, 10, 100, 100))); | 61 IntRect(10, 10, 100, 100))); |
60 | 62 |
61 // Normally, the autoplay experiment should not modify lots of other | 63 // Normally, the autoplay experiment should not modify lots of other |
62 // state unless we explicitly expect it. | 64 // state unless we explicitly expect it. |
63 EXPECT_CALL(*this, setMuted(_)) | 65 EXPECT_CALL(*this, setMuted(_)) |
64 .Times(0); | 66 .Times(0); |
65 EXPECT_CALL(*this, removeUserGestureRequirement()) | 67 EXPECT_CALL(*this, removeUserGestureRequirement()) |
66 .Times(0); | 68 .Times(0); |
(...skipping 14 matching lines...) Expand all Loading... |
81 MOCK_CONST_METHOD0(isUserGestureRequiredForPlay, bool()); | 83 MOCK_CONST_METHOD0(isUserGestureRequiredForPlay, bool()); |
82 MOCK_METHOD0(removeUserGestureRequirement, void()); | 84 MOCK_METHOD0(removeUserGestureRequirement, void()); |
83 MOCK_METHOD1(recordAutoplayMetric, void(AutoplayMetrics)); | 85 MOCK_METHOD1(recordAutoplayMetric, void(AutoplayMetrics)); |
84 MOCK_METHOD0(shouldAutoplay, bool()); | 86 MOCK_METHOD0(shouldAutoplay, bool()); |
85 MOCK_CONST_METHOD0(isHTMLVideoElement, bool()); | 87 MOCK_CONST_METHOD0(isHTMLVideoElement, bool()); |
86 MOCK_CONST_METHOD0(isHTMLAudioElement, bool()); | 88 MOCK_CONST_METHOD0(isHTMLAudioElement, bool()); |
87 MOCK_METHOD0(isLegacyViewportType, bool()); | 89 MOCK_METHOD0(isLegacyViewportType, bool()); |
88 MOCK_CONST_METHOD0(pageVisibilityState, PageVisibilityState()); | 90 MOCK_CONST_METHOD0(pageVisibilityState, PageVisibilityState()); |
89 MOCK_CONST_METHOD0(autoplayExperimentMode, String()); | 91 MOCK_CONST_METHOD0(autoplayExperimentMode, String()); |
90 MOCK_CONST_METHOD0(isCrossOrigin, bool()); | 92 MOCK_CONST_METHOD0(isCrossOrigin, bool()); |
| 93 MOCK_CONST_METHOD0(isAutoplayAllowedPerSettings, bool()); |
91 MOCK_METHOD1(setRequestPositionUpdates, void(bool)); | 94 MOCK_METHOD1(setRequestPositionUpdates, void(bool)); |
92 MOCK_CONST_METHOD0(absoluteBoundingBoxRect, IntRect()); | 95 MOCK_CONST_METHOD0(absoluteBoundingBoxRect, IntRect()); |
93 | 96 |
94 const char* m_mode; | 97 const char* m_mode; |
95 // const since changes to it won't affect the mocked value. | 98 // const since changes to it won't affect the mocked value. |
96 const double m_duration; | 99 const double m_duration; |
97 }; | 100 }; |
98 | 101 |
99 class AutoplayExperimentTest : public ::testing::Test { | 102 class AutoplayExperimentTest : public ::testing::Test { |
100 public: | 103 public: |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 TEST_F(AutoplayExperimentTest, WithoutSameOriginTests) | 450 TEST_F(AutoplayExperimentTest, WithoutSameOriginTests) |
448 { | 451 { |
449 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl
ayClient::Video)); | 452 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl
ayClient::Video)); |
450 ON_CALL(*m_client, isCrossOrigin()).WillByDefault(Return(false)); | 453 ON_CALL(*m_client, isCrossOrigin()).WillByDefault(Return(false)); |
451 EXPECT_TRUE(isEligible()); | 454 EXPECT_TRUE(isEligible()); |
452 ON_CALL(*m_client, isCrossOrigin()).WillByDefault(Return(true)); | 455 ON_CALL(*m_client, isCrossOrigin()).WillByDefault(Return(true)); |
453 EXPECT_TRUE(isEligible()); | 456 EXPECT_TRUE(isEligible()); |
454 } | 457 } |
455 | 458 |
456 } | 459 } |
OLD | NEW |