Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: third_party/WebKit/Source/core/html/AutoplayExperimentTest.cpp

Issue 1931363002: Autoplay experiment: ignore viewport visibility requirements for audio. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@autoplay-htmlmedialement
Patch Set: update tests Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 public: 103 public:
104 AutoplayExperimentTest() {} 104 AutoplayExperimentTest() {}
105 105
106 ~AutoplayExperimentTest() {} 106 ~AutoplayExperimentTest() {}
107 107
108 bool isEligible() 108 bool isEligible()
109 { 109 {
110 return m_helper->isEligible(); 110 return m_helper->isEligible();
111 } 111 }
112 112
113 bool meetsVisibilityRequirements()
114 {
115 return m_helper->meetsVisibilityRequirements();
116 }
117
113 void setInterface(MockAutoplayClient* client) 118 void setInterface(MockAutoplayClient* client)
114 { 119 {
115 m_client = client; 120 m_client = client;
116 121
117 // Set some defaults. 122 // Set some defaults.
118 setUserGestureRequiredForPlay(true); 123 setUserGestureRequiredForPlay(true);
119 setShouldAutoplay(true); 124 setShouldAutoplay(true);
120 setIsMuted(false); 125 setIsMuted(false);
121 126
122 m_helper = AutoplayExperimentHelper::create(m_client.get()); 127 m_helper = AutoplayExperimentHelper::create(m_client.get());
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 454
450 TEST_F(AutoplayExperimentTest, WithoutSameOriginTests) 455 TEST_F(AutoplayExperimentTest, WithoutSameOriginTests)
451 { 456 {
452 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl ayClient::Video)); 457 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl ayClient::Video));
453 ON_CALL(*m_client, isCrossOrigin()).WillByDefault(Return(false)); 458 ON_CALL(*m_client, isCrossOrigin()).WillByDefault(Return(false));
454 EXPECT_TRUE(isEligible()); 459 EXPECT_TRUE(isEligible());
455 ON_CALL(*m_client, isCrossOrigin()).WillByDefault(Return(true)); 460 ON_CALL(*m_client, isCrossOrigin()).WillByDefault(Return(true));
456 EXPECT_TRUE(isEligible()); 461 EXPECT_TRUE(isEligible());
457 } 462 }
458 463
464 TEST_F(AutoplayExperimentTest, AudioPageVisibility)
465 {
466 setInterface(new NiceMock<MockAutoplayClient>("enabled-foraudio-ifpagevisibl e", MockAutoplayClient::Audio));
467 ON_CALL(*m_client, pageVisibilityState()).WillByDefault(Return(PageVisibilit yStateVisible));
468 EXPECT_TRUE(isEligible());
469 EXPECT_TRUE(meetsVisibilityRequirements());
470
471 ON_CALL(*m_client, pageVisibilityState()).WillByDefault(Return(PageVisibilit yStateHidden));
472 EXPECT_TRUE(isEligible());
473 EXPECT_FALSE(meetsVisibilityRequirements());
459 } 474 }
475
476 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698