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

Unified Diff: services/ui/ws/drag_controller_unittest.cc

Issue 2349973010: mus drag and drop: return the completed effect to the caller. (Closed)
Patch Set: Rename some effect_taken to action_taken for consistency. Created 4 years, 3 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 | « services/ui/ws/drag_controller.cc ('k') | services/ui/ws/drag_source.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/drag_controller_unittest.cc
diff --git a/services/ui/ws/drag_controller_unittest.cc b/services/ui/ws/drag_controller_unittest.cc
index de8a5ef53ec682735bbbfec7bf20b3a2bd0d3a66..af0b94de7cdf4f7ee5ce96bb4b6b4db635c9a001 100644
--- a/services/ui/ws/drag_controller_unittest.cc
+++ b/services/ui/ws/drag_controller_unittest.cc
@@ -179,6 +179,10 @@ class DragControllerTest : public testing::Test, public DragSource {
}
DragController* drag_operation() const { return drag_operation_.get(); }
+
+ const base::Optional<uint32_t>& drag_completed_action() {
+ return drag_completed_action_;
+ }
const base::Optional<bool>& drag_completed_value() {
return drag_completed_value_;
}
@@ -207,7 +211,8 @@ class DragControllerTest : public testing::Test, public DragSource {
}
// Overridden from DragControllerSource:
- void OnDragCompleted(bool success) override {
+ void OnDragCompleted(bool success, uint32_t action_taken) override {
+ drag_completed_action_ = action_taken;
drag_completed_value_ = success;
}
@@ -236,6 +241,7 @@ class DragControllerTest : public testing::Test, public DragSource {
std::unique_ptr<DragController> drag_operation_;
+ base::Optional<uint32_t> drag_completed_action_;
base::Optional<bool> drag_completed_value_;
};
@@ -261,9 +267,37 @@ TEST_F(DragControllerTest, SimpleDragDrop) {
EXPECT_EQ(QueuedType::DROP, window->queue_response_type());
window->Respond(true);
+ EXPECT_EQ(ui::mojom::kDropEffectMove,
+ drag_completed_action().value_or(ui::mojom::kDropEffectNone));
EXPECT_TRUE(drag_completed_value().value_or(false));
}
+TEST_F(DragControllerTest, FailsOnWindowSayingNo) {
+ std::unique_ptr<DragTestWindow> window = BuildWindow();
+ mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data;
+ StartDragOperation(std::move(mime_data), window.get(),
+ ui::mojom::kDropEffectMove);
+
+ DispatchDrag(window.get(), false, ui::EF_LEFT_MOUSE_BUTTON, gfx::Point(1, 1));
+ EXPECT_EQ(QueuedType::ENTER, window->queue_response_type());
+ window->Respond(true);
+
+ DispatchDrag(window.get(), false, ui::EF_LEFT_MOUSE_BUTTON, gfx::Point(2, 2));
+ EXPECT_EQ(QueuedType::OVER, window->queue_response_type());
+ window->Respond(true);
+
+ DispatchDrag(window.get(), true, 0, gfx::Point(2, 2));
+ EXPECT_EQ(QueuedType::DROP, window->queue_response_type());
+
+ // Unlike SimpleDragDrop, respond with kDropEffectNone, which should make the
+ // drag fail.
+ window->Respond(false);
+
+ EXPECT_EQ(ui::mojom::kDropEffectNone,
+ drag_completed_action().value_or(ui::mojom::kDropEffectCopy));
+ EXPECT_FALSE(drag_completed_value().value_or(true));
+}
+
TEST_F(DragControllerTest, OnlyDeliverMimeDataOnce) {
std::unique_ptr<DragTestWindow> window1 = BuildWindow();
std::unique_ptr<DragTestWindow> window2 = BuildWindow();
« no previous file with comments | « services/ui/ws/drag_controller.cc ('k') | services/ui/ws/drag_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698