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

Unified Diff: Source/web/PluginPlaceholderImplTest.cpp

Issue 698533003: Implement support for closing shadow DOM plugin placeholders. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: mkwst comments Created 6 years, 1 month 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/web/PluginPlaceholderImpl.cpp ('k') | public/web/WebPluginPlaceholder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/PluginPlaceholderImplTest.cpp
diff --git a/Source/web/PluginPlaceholderImplTest.cpp b/Source/web/PluginPlaceholderImplTest.cpp
index 88c4a6410f64897e3fb8ffcd245609db689b6a3d..63faf957933dfa8709be713348c970185a7fe909 100644
--- a/Source/web/PluginPlaceholderImplTest.cpp
+++ b/Source/web/PluginPlaceholderImplTest.cpp
@@ -5,7 +5,12 @@
#include "config.h"
#include "web/PluginPlaceholderImpl.h"
+#include "core/CSSPropertyNames.h"
+#include "core/CSSValueKeywords.h"
#include "core/HTMLNames.h"
+#include "core/css/CSSPrimitiveValue.h"
+#include "core/css/CSSValue.h"
+#include "core/css/StylePropertySet.h"
#include "core/dom/DocumentFragment.h"
#include "core/dom/TagCollection.h"
#include "core/testing/DummyPageHolder.h"
@@ -29,9 +34,13 @@ public:
virtual ~MockWebPluginPlaceholder() { }
MOCK_CONST_METHOD0(message, WebString());
+ MOCK_CONST_METHOD0(isCloseable, bool());
private:
- MockWebPluginPlaceholder() { }
+ MockWebPluginPlaceholder()
+ {
+ ON_CALL(*this, message()).WillByDefault(Return(WebString()));
+ }
};
// Fixture which creates a dummy context for running these this test.
@@ -86,5 +95,34 @@ TEST_F(PluginPlaceholderImplTest, MessageDoesNotAcceptElements)
EXPECT_FALSE(documentFragment().getElementById("sentinel"));
}
+bool isHiddenWithInlineStyle(Element* element)
+{
+ if (!element->inlineStyle())
+ return false;
+ RefPtrWillBeRawPtr<CSSValue> value = element->inlineStyle()->getPropertyCSSValue(CSSPropertyDisplay);
+ return value && value->isPrimitiveValue() && toCSSPrimitiveValue(value.get())->getValueID() == CSSValueNone;
+}
+
+TEST_F(PluginPlaceholderImplTest, Closeable)
+{
+ // The closing functionality of PluginPlaceholderElement is tested in
+ // LayoutTests/fast/plugins. This test only needs to ensure that the
+ // boolean in WebPluginPlaceholder is respected.
+ EXPECT_CALL(webPluginPlaceholder(), isCloseable()).WillOnce(Return(true));
+ pluginPlaceholder().loadIntoContainer(documentFragment());
+ RefPtrWillBeRawPtr<Element> closeButton = documentFragment().getElementById("plugin-placeholder-close-button");
+ ASSERT_NE(nullptr, closeButton);
+ EXPECT_FALSE(isHiddenWithInlineStyle(closeButton.get()));
+}
+
+TEST_F(PluginPlaceholderImplTest, NotCloseable)
+{
+ EXPECT_CALL(webPluginPlaceholder(), isCloseable()).WillOnce(Return(false));
+ pluginPlaceholder().loadIntoContainer(documentFragment());
+ RefPtrWillBeRawPtr<Element> closeButton = documentFragment().getElementById("plugin-placeholder-close-button");
+ EXPECT_NE(nullptr, closeButton);
+ EXPECT_TRUE(isHiddenWithInlineStyle(closeButton.get()));
+}
+
} // namespace
} // namespace blink
« no previous file with comments | « Source/web/PluginPlaceholderImpl.cpp ('k') | public/web/WebPluginPlaceholder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698