OLD | NEW |
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/html/media/AutoplayPolicy.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 void HandlePlayingEvent() { AutoplayUmaHelper::HandlePlayingEvent(); } | 29 void HandlePlayingEvent() { AutoplayUmaHelper::HandlePlayingEvent(); } |
30 | 30 |
31 MOCK_METHOD0(HandleContextDestroyed, void()); | 31 MOCK_METHOD0(HandleContextDestroyed, void()); |
32 | 32 |
33 // Making this a wrapper function to avoid calling the mocked version. | 33 // Making this a wrapper function to avoid calling the mocked version. |
34 void ReallyHandleContextDestroyed() { | 34 void ReallyHandleContextDestroyed() { |
35 AutoplayUmaHelper::HandleContextDestroyed(); | 35 AutoplayUmaHelper::HandleContextDestroyed(); |
36 } | 36 } |
37 }; | 37 }; |
38 | 38 |
39 class AutoplayUmaHelperTest : public testing::Test { | 39 class AutoplayUmaHelperTest : public ::testing::Test { |
40 protected: | 40 protected: |
41 Document& GetDocument() { return page_holder_->GetDocument(); } | 41 Document& GetDocument() { return page_holder_->GetDocument(); } |
42 | 42 |
43 HTMLMediaElement& MediaElement() { | 43 HTMLMediaElement& MediaElement() { |
44 Element* element = GetDocument().getElementById("video"); | 44 Element* element = GetDocument().getElementById("video"); |
45 DCHECK(element); | 45 DCHECK(element); |
46 return toHTMLVideoElement(*element); | 46 return toHTMLVideoElement(*element); |
47 } | 47 } |
48 | 48 |
49 MockAutoplayUmaHelper& UmaHelper() { return *uma_helper_; } | 49 MockAutoplayUmaHelper& UmaHelper() { return *uma_helper_; } |
(...skipping 21 matching lines...) Expand all Loading... |
71 EXPECT_CALL(UmaHelper(), HandleContextDestroyed()); | 71 EXPECT_CALL(UmaHelper(), HandleContextDestroyed()); |
72 | 72 |
73 MediaElement().setMuted(true); | 73 MediaElement().setMuted(true); |
74 UmaHelper().OnAutoplayInitiated(AutoplaySource::kMethod); | 74 UmaHelper().OnAutoplayInitiated(AutoplaySource::kMethod); |
75 UmaHelper().HandlePlayingEvent(); | 75 UmaHelper().HandlePlayingEvent(); |
76 PageHolder().reset(); | 76 PageHolder().reset(); |
77 ::testing::Mock::VerifyAndClear(&UmaHelper()); | 77 ::testing::Mock::VerifyAndClear(&UmaHelper()); |
78 } | 78 } |
79 | 79 |
80 } // namespace blink | 80 } // namespace blink |
OLD | NEW |