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

Unified Diff: Source/core/html/shadow/MediaControlsTest.cpp

Issue 1319433003: Don't change the media controls visibility in MediaControls::reset() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/shadow/MediaControls.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/shadow/MediaControlsTest.cpp
diff --git a/Source/core/html/shadow/MediaControlsTest.cpp b/Source/core/html/shadow/MediaControlsTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..31a29ae0c5c6582c085350615c01d1cee3193ccf
--- /dev/null
+++ b/Source/core/html/shadow/MediaControlsTest.cpp
@@ -0,0 +1,106 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/html/shadow/MediaControls.h"
+
+#include "core/HTMLNames.h"
+#include "core/css/StylePropertySet.h"
+#include "core/dom/Document.h"
+#include "core/dom/ElementTraversal.h"
+#include "core/html/HTMLVideoElement.h"
+#include "core/testing/DummyPageHolder.h"
+#include <gtest/gtest.h>
+
+namespace blink {
+
+namespace {
+
+Element* getElementByShadowPseudoId(Node& rootNode, const char* shadowPseudoId)
+{
+ for (Element& element : ElementTraversal::descendantsOf(rootNode)) {
+ if (element.fastGetAttribute(HTMLNames::pseudoAttr) == shadowPseudoId)
+ return &element;
+ }
+ return nullptr;
+}
+
+bool isElementVisible(Element& element)
+{
+ const StylePropertySet* inlineStyle = element.inlineStyle();
+
+ if (!inlineStyle)
+ return true;
+
+ if (inlineStyle->getPropertyValue(CSSPropertyDisplay) == "none")
+ return false;
+
+ if (inlineStyle->hasProperty(CSSPropertyOpacity)
+ && inlineStyle->getPropertyValue(CSSPropertyOpacity).toDouble() == 0.0)
+ return false;
+
+ if (inlineStyle->getPropertyValue(CSSPropertyVisibility) == "hidden")
+ return false;
+
+ if (Element* parent = element.parentElement())
+ return isElementVisible(*parent);
+
+ return true;
+}
+
+} // namespace
+
+class MediaControlsTest : public testing::Test {
+protected:
+ virtual void SetUp()
+ {
+ m_pageHolder = DummyPageHolder::create(IntSize(800, 600));
+ Document& document = m_pageHolder->document();
+ document.write("<video controls>");
+ HTMLVideoElement& video = toHTMLVideoElement(*document.querySelector("video", ASSERT_NO_EXCEPTION));
+ m_mediaControls = video.mediaControls();
+ }
+
+ MediaControls& mediaControls() { return *m_mediaControls; }
+
+private:
+ OwnPtr<DummyPageHolder> m_pageHolder;
+ MediaControls* m_mediaControls;
+};
+
+TEST_F(MediaControlsTest, HideAndShow)
+{
+ Element* panel = getElementByShadowPseudoId(mediaControls(), "-webkit-media-controls-panel");
+ ASSERT_NE(nullptr, panel);
+
+ ASSERT_TRUE(isElementVisible(*panel));
+ mediaControls().hide();
+ ASSERT_FALSE(isElementVisible(*panel));
+ mediaControls().show();
+ ASSERT_TRUE(isElementVisible(*panel));
+}
+
+TEST_F(MediaControlsTest, Reset)
+{
+ Element* panel = getElementByShadowPseudoId(mediaControls(), "-webkit-media-controls-panel");
+ ASSERT_NE(nullptr, panel);
+
+ ASSERT_TRUE(isElementVisible(*panel));
+ mediaControls().reset();
+ ASSERT_TRUE(isElementVisible(*panel));
+}
+
+TEST_F(MediaControlsTest, HideAndReset)
+{
+ Element* panel = getElementByShadowPseudoId(mediaControls(), "-webkit-media-controls-panel");
+ ASSERT_NE(nullptr, panel);
+
+ ASSERT_TRUE(isElementVisible(*panel));
+ mediaControls().hide();
+ ASSERT_FALSE(isElementVisible(*panel));
+ mediaControls().reset();
+ ASSERT_FALSE(isElementVisible(*panel));
+}
+
+} // namespace blink
« no previous file with comments | « Source/core/html/shadow/MediaControls.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698