-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Notify DragController of the view drag start
This CL adds a views::DragController API that gets called when view drag will start. This CL should not bring any noticeable UI difference. Bug: b/271490637 Change-Id: Ideedd9c11a2f344b4b485fdd9000c708f24aeccc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4327347 Reviewed-by: Scott Violet <sky@chromium.org> Commit-Queue: Andrew Xu <andrewxu@chromium.org> Reviewed-by: Allen Bauer <kylixrd@chromium.org> Cr-Commit-Position: refs/heads/main@{#1115834}
- Loading branch information
andrewxu
authored and
Chromium LUCI CQ
committed
Mar 10, 2023
1 parent
051a822
commit 088b85c
Showing
6 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ui/views/test/mock_drag_controller.h" | ||
|
||
#include "ui/base/dragdrop/drag_drop_types.h" | ||
#include "ui/base/dragdrop/os_exchange_data.h" | ||
|
||
namespace views { | ||
|
||
MockDragController::MockDragController() = default; | ||
|
||
MockDragController::~MockDragController() = default; | ||
|
||
void MockDragController::WriteDragDataForView(View* sender, | ||
const gfx::Point& press_pt, | ||
ui::OSExchangeData* data) { | ||
data->SetString(u"test"); | ||
} | ||
|
||
int MockDragController::GetDragOperationsForView(View* sender, | ||
const gfx::Point& p) { | ||
return ui::DragDropTypes::DRAG_COPY; | ||
} | ||
|
||
bool MockDragController::CanStartDragForView(View* sender, | ||
const gfx::Point& press_pt, | ||
const gfx::Point& p) { | ||
return true; | ||
} | ||
|
||
} // namespace views |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef UI_VIEWS_TEST_MOCK_DRAG_CONTROLLER_H_ | ||
#define UI_VIEWS_TEST_MOCK_DRAG_CONTROLLER_H_ | ||
|
||
#include "ui/views/drag_controller.h" | ||
|
||
#include "testing/gmock/include/gmock/gmock.h" | ||
|
||
namespace gfx { | ||
class Point; | ||
} // namespace gfx | ||
|
||
namespace ui { | ||
class OSExchangeData; | ||
} // namespace ui | ||
|
||
namespace views { | ||
class View; | ||
|
||
// A mocked drag controller for testing. | ||
class MockDragController : public DragController { | ||
public: | ||
MockDragController(); | ||
MockDragController(const MockDragController&) = delete; | ||
MockDragController& operator=(const MockDragController&) = delete; | ||
~MockDragController() override; | ||
|
||
// DragController: | ||
void WriteDragDataForView(View* sender, | ||
const gfx::Point& press_pt, | ||
ui::OSExchangeData* data) override; | ||
int GetDragOperationsForView(View* sender, const gfx::Point& p) override; | ||
bool CanStartDragForView(View* sender, | ||
const gfx::Point& press_pt, | ||
const gfx::Point& p) override; | ||
MOCK_METHOD(void, OnWillStartDragForView, (View * dragged_view), (override)); | ||
}; | ||
|
||
} // namespace views | ||
|
||
#endif // UI_VIEWS_TEST_MOCK_DRAG_CONTROLLER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters