Chromium Code Reviews| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 | 45 |
| 46 // Default to "not optimized for mobile" page. | 46 // Default to "not optimized for mobile" page. |
| 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, frame()) | |
| 56 .WillByDefault(Return(nullptr)); | |
| 55 ON_CALL(*this, absoluteBoundingBoxRect()) | 57 ON_CALL(*this, absoluteBoundingBoxRect()) |
| 56 .WillByDefault(Return( | 58 .WillByDefault(Return( |
| 57 IntRect(10, 10, 100, 100))); | 59 IntRect(10, 10, 100, 100))); |
| 58 | 60 |
| 59 // Normally, the autoplay experiment should not modify lots of other | 61 // Normally, the autoplay experiment should not modify lots of other |
| 60 // state unless we explicitly expect it. | 62 // state unless we explicitly expect it. |
| 61 EXPECT_CALL(*this, setMuted(_)) | 63 EXPECT_CALL(*this, setMuted(_)) |
| 62 .Times(0); | 64 .Times(0); |
| 63 EXPECT_CALL(*this, removeUserGestureRequirement()) | 65 EXPECT_CALL(*this, removeUserGestureRequirement()) |
| 64 .Times(0); | 66 .Times(0); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 78 MOCK_METHOD0(playInternal, void()); | 80 MOCK_METHOD0(playInternal, void()); |
| 79 MOCK_CONST_METHOD0(isUserGestureRequiredForPlay, bool()); | 81 MOCK_CONST_METHOD0(isUserGestureRequiredForPlay, bool()); |
| 80 MOCK_METHOD0(removeUserGestureRequirement, void()); | 82 MOCK_METHOD0(removeUserGestureRequirement, void()); |
| 81 MOCK_METHOD1(recordAutoplayMetric, void(AutoplayMetrics)); | 83 MOCK_METHOD1(recordAutoplayMetric, void(AutoplayMetrics)); |
| 82 MOCK_METHOD0(shouldAutoplay, bool()); | 84 MOCK_METHOD0(shouldAutoplay, bool()); |
| 83 MOCK_CONST_METHOD0(isHTMLVideoElement, bool()); | 85 MOCK_CONST_METHOD0(isHTMLVideoElement, bool()); |
| 84 MOCK_CONST_METHOD0(isHTMLAudioElement, bool()); | 86 MOCK_CONST_METHOD0(isHTMLAudioElement, bool()); |
| 85 MOCK_METHOD0(isLegacyViewportType, bool()); | 87 MOCK_METHOD0(isLegacyViewportType, bool()); |
| 86 MOCK_CONST_METHOD0(pageVisibilityState, PageVisibilityState()); | 88 MOCK_CONST_METHOD0(pageVisibilityState, PageVisibilityState()); |
| 87 MOCK_CONST_METHOD0(autoplayExperimentMode, String()); | 89 MOCK_CONST_METHOD0(autoplayExperimentMode, String()); |
| 90 MOCK_CONST_METHOD0(frame, LocalFrame*()); | |
|
mlamouri (slow - plz ping)
2016/04/26 14:41:40
I wish we had more tests for this. Are there layou
liberato (no reviews please)
2016/04/26 18:30:24
yes, there are layout tests for this also:
https:
| |
| 88 MOCK_METHOD1(setRequestPositionUpdates, void(bool)); | 91 MOCK_METHOD1(setRequestPositionUpdates, void(bool)); |
| 89 MOCK_CONST_METHOD0(absoluteBoundingBoxRect, IntRect()); | 92 MOCK_CONST_METHOD0(absoluteBoundingBoxRect, IntRect()); |
| 90 | 93 |
| 91 const char* m_mode; | 94 const char* m_mode; |
| 92 // const since changes to it won't affect the mocked value. | 95 // const since changes to it won't affect the mocked value. |
| 93 const double m_duration; | 96 const double m_duration; |
| 94 }; | 97 }; |
| 95 | 98 |
| 96 class AutoplayExperimentTest : public ::testing::Test { | 99 class AutoplayExperimentTest : public ::testing::Test { |
| 97 public: | 100 public: |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 | 430 |
| 428 EXPECT_CALL(*m_client, removeUserGestureRequirement()) | 431 EXPECT_CALL(*m_client, removeUserGestureRequirement()) |
| 429 .Times(1); | 432 .Times(1); |
| 430 EXPECT_CALL(*m_client, playInternal()) | 433 EXPECT_CALL(*m_client, playInternal()) |
| 431 .Times(1); | 434 .Times(1); |
| 432 EXPECT_CALL(*m_client, setRequestPositionUpdates(false)) | 435 EXPECT_CALL(*m_client, setRequestPositionUpdates(false)) |
| 433 .Times(1); | 436 .Times(1); |
| 434 moveIntoViewport(); | 437 moveIntoViewport(); |
| 435 } | 438 } |
| 436 } | 439 } |
| OLD | NEW |