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

Unified Diff: third_party/WebKit/Source/core/frame/LocalFrameTest.cpp

Issue 2094653002: Make LocalFrame::nodeImage() to take an image for the element with :-webkit-drag pseudo class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-06-24T14:46:18 Created 4 years, 6 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 | « third_party/WebKit/Source/core/frame/LocalFrame.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/frame/LocalFrameTest.cpp
diff --git a/third_party/WebKit/Source/core/frame/LocalFrameTest.cpp b/third_party/WebKit/Source/core/frame/LocalFrameTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4de8c359654cb9f878fd075a1a7dee389343d5cb
--- /dev/null
+++ b/third_party/WebKit/Source/core/frame/LocalFrameTest.cpp
@@ -0,0 +1,82 @@
+// Copyright 2016 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 "core/frame/LocalFrame.h"
+
+#include "core/frame/FrameView.h"
+#include "core/html/HTMLElement.h"
+#include "core/testing/DummyPageHolder.h"
+#include "platform/DragImage.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+class LocalFrameTest : public ::testing::Test {
+protected:
+ LocalFrameTest() = default;
+ ~LocalFrameTest() override = default;
+
+ Document& document() const { return m_dummyPageHolder->document(); }
+ LocalFrame& frame() const { return *document().frame(); }
+
+ void setBodyContent(const std::string& bodyContent)
+ {
+ document().body()->setInnerHTML(String::fromUTF8(bodyContent.c_str()), ASSERT_NO_EXCEPTION);
+ }
+
+ void updateAllLifecyclePhases()
+ {
+ document().view()->updateAllLifecyclePhases();
+ }
+
+private:
+ void SetUp() override
+ {
+ m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
+ }
+
+ std::unique_ptr<DummyPageHolder> m_dummyPageHolder;
+};
+
+TEST_F(LocalFrameTest, nodeImage)
+{
+ setBodyContent(
+ "<style>"
+ "#sample { width: 100px; height: 100px; }"
+ "</style>"
+ "<div id=sample></div>");
+ Element* sample = document().getElementById("sample");
+ const std::unique_ptr<DragImage> image = frame().nodeImage(*sample);
+ EXPECT_EQ(IntSize(100, 100), image->size());
+}
+
+TEST_F(LocalFrameTest, nodeImageWithPsuedoClassWebKitDrag)
+{
+ setBodyContent(
+ "<style>"
+ "#sample { width: 100px; height: 100px; }"
+ "#sample:-webkit-drag { width: 200px; height: 200px; }"
+ "</style>"
+ "<div id=sample></div>");
+ Element* sample = document().getElementById("sample");
+ const std::unique_ptr<DragImage> image = frame().nodeImage(*sample);
+ EXPECT_EQ(IntSize(200, 200), image->size())
+ << ":-webkit-drag should affect dragged image.";
+}
+
+TEST_F(LocalFrameTest, nodeImageWithoutDraggedLayoutObject)
+{
+ setBodyContent(
+ "<style>"
+ "#sample { width: 100px; height: 100px; }"
+ "#sample:-webkit-drag { display:none }"
+ "</style>"
+ "<div id=sample></div>");
+ Element* sample = document().getElementById("sample");
+ const std::unique_ptr<DragImage> image = frame().nodeImage(*sample);
+ EXPECT_EQ(nullptr, image.get())
+ << ":-webkit-drag blows away layout object";
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalFrame.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698