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

Unified Diff: third_party/WebKit/Source/core/page/DragControllerTest.cpp

Issue 2934233002: In-place modification of drag related functionality present in LocalFrame (Closed)
Patch Set: updatedPS Created 3 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
Index: third_party/WebKit/Source/core/page/DragControllerTest.cpp
diff --git a/third_party/WebKit/Source/core/page/DragControllerTest.cpp b/third_party/WebKit/Source/core/page/DragControllerTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..73d8a6f28b21b77d19fd49d133ace4fd5db62baa
--- /dev/null
+++ b/third_party/WebKit/Source/core/page/DragControllerTest.cpp
@@ -0,0 +1,69 @@
+// 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/page/DragController.h"
+
+#include "core/editing/FrameSelection.h"
+#include "core/frame/LocalFrame.h"
+#include "core/frame/LocalFrameView.h"
+#include "core/frame/PerformanceMonitor.h"
+#include "core/frame/VisualViewport.h"
+#include "core/html/HTMLElement.h"
+#include "core/layout/LayoutObject.h"
+#include "core/testing/DummyPageHolder.h"
+#include "core/timing/Performance.h"
+#include "platform/DragImage.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+class DragControllerTest : public ::testing::Test {
+ protected:
+ DragControllerTest() = default;
+ ~DragControllerTest() override = default;
+
+ Document& GetDocument() const { return dummy_page_holder_->GetDocument(); }
+ LocalFrame& GetFrame() const { return *GetDocument().GetFrame(); }
+ Performance* GetPerformance() const { return performance_; }
+
+ void SetBodyContent(const std::string& body_content) {
+ GetDocument().body()->setInnerHTML(String::FromUTF8(body_content.c_str()));
+ UpdateAllLifecyclePhases();
+ }
+
+ void UpdateAllLifecyclePhases() {
+ GetDocument().View()->UpdateAllLifecyclePhases();
+ }
+
+ private:
+ void SetUp() override {
+ dummy_page_holder_ = DummyPageHolder::Create(IntSize(800, 600));
+ performance_ = Performance::Create(&GetFrame());
+ }
+
+ std::unique_ptr<DummyPageHolder> dummy_page_holder_;
+ Persistent<Performance> performance_;
+};
+
+TEST_F(DragControllerTest, dragImageForSelectionUsesPageScaleFactor) {
+ SetBodyContent(
+ "<div>Hello world! This tests that the bitmap for drag image is scaled "
+ "by page scale factor</div>");
+ GetFrame().GetPage()->GetVisualViewport().SetScale(1);
+ GetFrame().Selection().SelectAll();
+ UpdateAllLifecyclePhases();
+ const std::unique_ptr<DragImage> image1(
+ DragController::DragImageForSelection(GetFrame(), 0.75f));
+ GetFrame().GetPage()->GetVisualViewport().SetScale(2);
+ GetFrame().Selection().SelectAll();
+ UpdateAllLifecyclePhases();
+ const std::unique_ptr<DragImage> image2(
+ DragController::DragImageForSelection(GetFrame(), 0.75f));
+
+ EXPECT_GT(image1->Size().Width(), 0);
+ EXPECT_GT(image1->Size().Height(), 0);
+ EXPECT_EQ(image1->Size().Width() * 2, image2->Size().Width());
+ EXPECT_EQ(image1->Size().Height() * 2, image2->Size().Height());
+}
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/page/DragController.cpp ('k') | third_party/WebKit/Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698