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

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

Issue 2940583002: Move drag related functionality out of 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..df25d6c99c6e956574bf27b06aaa1ce03c2202b8
--- /dev/null
+++ b/third_party/WebKit/Source/core/page/DragControllerTest.cpp
@@ -0,0 +1,70 @@
+// Copyright 2017 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 DataControllerTest : public ::testing::Test {
+ protected:
+ DataControllerTest() = default;
+ ~DataControllerTest() 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(DataControllerTest, 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