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 "config.h" | 5 #include "config.h" |
6 #include "core/html/shadow/MediaControls.h" | 6 #include "core/html/shadow/MediaControls.h" |
7 | 7 |
8 #include "core/HTMLNames.h" | 8 #include "core/HTMLNames.h" |
9 #include "core/css/StylePropertySet.h" | 9 #include "core/css/StylePropertySet.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
11 #include "core/dom/ElementTraversal.h" | 11 #include "core/dom/ElementTraversal.h" |
12 #include "core/html/HTMLVideoElement.h" | 12 #include "core/html/HTMLVideoElement.h" |
13 #include "core/testing/DummyPageHolder.h" | 13 #include "core/testing/DummyPageHolder.h" |
14 #include "platform/heap/Handle.h" | |
14 #include <gtest/gtest.h> | 15 #include <gtest/gtest.h> |
15 | 16 |
16 namespace blink { | 17 namespace blink { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 Element* getElementByShadowPseudoId(Node& rootNode, const char* shadowPseudoId) | 21 Element* getElementByShadowPseudoId(Node& rootNode, const char* shadowPseudoId) |
21 { | 22 { |
22 for (Element& element : ElementTraversal::descendantsOf(rootNode)) { | 23 for (Element& element : ElementTraversal::descendantsOf(rootNode)) { |
23 if (element.fastGetAttribute(HTMLNames::pseudoAttr) == shadowPseudoId) | 24 if (element.fastGetAttribute(HTMLNames::pseudoAttr) == shadowPseudoId) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 Document& document = m_pageHolder->document(); | 60 Document& document = m_pageHolder->document(); |
60 document.write("<video controls>"); | 61 document.write("<video controls>"); |
61 HTMLVideoElement& video = toHTMLVideoElement(*document.querySelector("vi deo", ASSERT_NO_EXCEPTION)); | 62 HTMLVideoElement& video = toHTMLVideoElement(*document.querySelector("vi deo", ASSERT_NO_EXCEPTION)); |
62 m_mediaControls = video.mediaControls(); | 63 m_mediaControls = video.mediaControls(); |
63 } | 64 } |
64 | 65 |
65 MediaControls& mediaControls() { return *m_mediaControls; } | 66 MediaControls& mediaControls() { return *m_mediaControls; } |
66 | 67 |
67 private: | 68 private: |
68 OwnPtr<DummyPageHolder> m_pageHolder; | 69 OwnPtr<DummyPageHolder> m_pageHolder; |
69 MediaControls* m_mediaControls; | 70 RawPtrWillBePersistent<MediaControls> m_mediaControls; |
haraken
2015/11/14 07:08:23
Nit: This could be RefPtrWillBePersistent.
| |
70 }; | 71 }; |
71 | 72 |
72 TEST_F(MediaControlsTest, HideAndShow) | 73 TEST_F(MediaControlsTest, HideAndShow) |
73 { | 74 { |
74 Element* panel = getElementByShadowPseudoId(mediaControls(), "-webkit-media- controls-panel"); | 75 Element* panel = getElementByShadowPseudoId(mediaControls(), "-webkit-media- controls-panel"); |
75 ASSERT_NE(nullptr, panel); | 76 ASSERT_NE(nullptr, panel); |
76 | 77 |
77 ASSERT_TRUE(isElementVisible(*panel)); | 78 ASSERT_TRUE(isElementVisible(*panel)); |
78 mediaControls().hide(); | 79 mediaControls().hide(); |
79 ASSERT_FALSE(isElementVisible(*panel)); | 80 ASSERT_FALSE(isElementVisible(*panel)); |
(...skipping 17 matching lines...) Expand all Loading... | |
97 ASSERT_NE(nullptr, panel); | 98 ASSERT_NE(nullptr, panel); |
98 | 99 |
99 ASSERT_TRUE(isElementVisible(*panel)); | 100 ASSERT_TRUE(isElementVisible(*panel)); |
100 mediaControls().hide(); | 101 mediaControls().hide(); |
101 ASSERT_FALSE(isElementVisible(*panel)); | 102 ASSERT_FALSE(isElementVisible(*panel)); |
102 mediaControls().reset(); | 103 mediaControls().reset(); |
103 ASSERT_FALSE(isElementVisible(*panel)); | 104 ASSERT_FALSE(isElementVisible(*panel)); |
104 } | 105 } |
105 | 106 |
106 } // namespace blink | 107 } // namespace blink |
OLD | NEW |