Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
|
tkent
2017/06/19 00:12:45
Though git failed to detect file copy, this file i
tanvir
2017/06/19 07:01:33
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/page/DragController.h" | |
| 6 | |
| 7 #include "core/editing/FrameSelection.h" | |
| 8 #include "core/frame/LocalFrame.h" | |
| 9 #include "core/frame/LocalFrameView.h" | |
| 10 #include "core/frame/PerformanceMonitor.h" | |
| 11 #include "core/frame/VisualViewport.h" | |
| 12 #include "core/html/HTMLElement.h" | |
| 13 #include "core/layout/LayoutObject.h" | |
| 14 #include "core/testing/DummyPageHolder.h" | |
| 15 #include "core/timing/Performance.h" | |
| 16 #include "platform/DragImage.h" | |
| 17 #include "testing/gtest/include/gtest/gtest.h" | |
| 18 | |
| 19 namespace blink { | |
| 20 | |
| 21 class DragControllerTest : public ::testing::Test { | |
| 22 protected: | |
| 23 DragControllerTest() = default; | |
| 24 ~DragControllerTest() override = default; | |
| 25 | |
| 26 Document& GetDocument() const { return dummy_page_holder_->GetDocument(); } | |
| 27 LocalFrame& GetFrame() const { return *GetDocument().GetFrame(); } | |
| 28 Performance* GetPerformance() const { return performance_; } | |
| 29 | |
| 30 void SetBodyContent(const std::string& body_content) { | |
| 31 GetDocument().body()->setInnerHTML(String::FromUTF8(body_content.c_str())); | |
| 32 UpdateAllLifecyclePhases(); | |
| 33 } | |
| 34 | |
| 35 void UpdateAllLifecyclePhases() { | |
| 36 GetDocument().View()->UpdateAllLifecyclePhases(); | |
| 37 } | |
| 38 | |
| 39 private: | |
| 40 void SetUp() override { | |
| 41 dummy_page_holder_ = DummyPageHolder::Create(IntSize(800, 600)); | |
| 42 performance_ = Performance::Create(&GetFrame()); | |
| 43 } | |
| 44 | |
| 45 std::unique_ptr<DummyPageHolder> dummy_page_holder_; | |
| 46 Persistent<Performance> performance_; | |
| 47 }; | |
| 48 | |
| 49 TEST_F(DragControllerTest, dragImageForSelectionUsesPageScaleFactor) { | |
| 50 SetBodyContent( | |
| 51 "<div>Hello world! This tests that the bitmap for drag image is scaled " | |
| 52 "by page scale factor</div>"); | |
| 53 GetFrame().GetPage()->GetVisualViewport().SetScale(1); | |
| 54 GetFrame().Selection().SelectAll(); | |
| 55 UpdateAllLifecyclePhases(); | |
| 56 const std::unique_ptr<DragImage> image1( | |
| 57 DragController::DragImageForSelection(GetFrame(), 0.75f)); | |
| 58 GetFrame().GetPage()->GetVisualViewport().SetScale(2); | |
| 59 GetFrame().Selection().SelectAll(); | |
| 60 UpdateAllLifecyclePhases(); | |
| 61 const std::unique_ptr<DragImage> image2( | |
| 62 DragController::DragImageForSelection(GetFrame(), 0.75f)); | |
| 63 | |
| 64 EXPECT_GT(image1->Size().Width(), 0); | |
| 65 EXPECT_GT(image1->Size().Height(), 0); | |
| 66 EXPECT_EQ(image1->Size().Width() * 2, image2->Size().Width()); | |
| 67 EXPECT_EQ(image1->Size().Height() * 2, image2->Size().Height()); | |
| 68 } | |
| 69 } // namespace blink | |
| OLD | NEW |