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

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

Issue 2813303005: [Blink>Media] Moving autoplay logic to AutoplayPolicy (Closed)
Patch Set: addressed nits Created 3 years, 8 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/media/AutoplayUmaHelper.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/html/media/AutoplayUmaHelper.h" 5 #include "core/html/media/AutoplayUmaHelper.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/html/HTMLMediaElement.h" 8 #include "core/html/HTMLMediaElement.h"
9 #include "core/html/HTMLVideoElement.h" 9 #include "core/html/HTMLVideoElement.h"
10 #include "core/html/media/AutoplayPolicy.h"
10 #include "core/testing/DummyPageHolder.h" 11 #include "core/testing/DummyPageHolder.h"
11 12
12 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 using ::testing::Invoke; 18 using ::testing::Invoke;
18 19
19 class MockAutoplayUmaHelper : public AutoplayUmaHelper { 20 class MockAutoplayUmaHelper : public AutoplayUmaHelper {
(...skipping 29 matching lines...) Expand all
49 50
50 std::unique_ptr<DummyPageHolder>& PageHolder() { return page_holder_; } 51 std::unique_ptr<DummyPageHolder>& PageHolder() { return page_holder_; }
51 52
52 private: 53 private:
53 void SetUp() override { 54 void SetUp() override {
54 page_holder_ = DummyPageHolder::Create(IntSize(800, 600)); 55 page_holder_ = DummyPageHolder::Create(IntSize(800, 600));
55 GetDocument().documentElement()->setInnerHTML("<video id=video></video>", 56 GetDocument().documentElement()->setInnerHTML("<video id=video></video>",
56 ASSERT_NO_EXCEPTION); 57 ASSERT_NO_EXCEPTION);
57 HTMLMediaElement& element = MediaElement(); 58 HTMLMediaElement& element = MediaElement();
58 uma_helper_ = new MockAutoplayUmaHelper(&element); 59 uma_helper_ = new MockAutoplayUmaHelper(&element);
59 element.autoplay_uma_helper_ = uma_helper_; 60 element.autoplay_policy_->autoplay_uma_helper_ = uma_helper_;
60 ::testing::Mock::AllowLeak(&UmaHelper()); 61 ::testing::Mock::AllowLeak(&UmaHelper());
61 } 62 }
62 63
63 void TearDown() override { uma_helper_.Clear(); } 64 void TearDown() override { uma_helper_.Clear(); }
64 65
65 std::unique_ptr<DummyPageHolder> page_holder_; 66 std::unique_ptr<DummyPageHolder> page_holder_;
66 Persistent<MockAutoplayUmaHelper> uma_helper_; 67 Persistent<MockAutoplayUmaHelper> uma_helper_;
67 }; 68 };
68 69
69 TEST_F(AutoplayUmaHelperTest, VisibilityChangeWhenUnload) { 70 TEST_F(AutoplayUmaHelperTest, VisibilityChangeWhenUnload) {
70 EXPECT_CALL(UmaHelper(), HandleContextDestroyed()); 71 EXPECT_CALL(UmaHelper(), HandleContextDestroyed());
71 72
72 MediaElement().setMuted(true); 73 MediaElement().setMuted(true);
73 UmaHelper().OnAutoplayInitiated(AutoplaySource::kMethod); 74 UmaHelper().OnAutoplayInitiated(AutoplaySource::kMethod);
74 UmaHelper().HandlePlayingEvent(); 75 UmaHelper().HandlePlayingEvent();
75 PageHolder().reset(); 76 PageHolder().reset();
76 ::testing::Mock::VerifyAndClear(&UmaHelper()); 77 ::testing::Mock::VerifyAndClear(&UmaHelper());
77 } 78 }
78 79
79 } // namespace blink 80 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/media/AutoplayUmaHelper.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698