#include "ui/base/x/x11_drag_drop_client.h"
#include <map>
#include <memory>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkPath.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-shared.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/dragdrop/os_exchange_data_provider_factory_ozone.h"
#include "ui/base/x/x11_cursor.h"
#include "ui/base/x/x11_move_loop.h"
#include "ui/base/x/x11_move_loop_delegate.h"
#include "ui/base/x/x11_os_exchange_data_provider.h"
#include "ui/base/x/x11_util.h"
#include "ui/events/event_utils.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/atom_cache.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/xproto.h"
#include "ui/ozone/platform/x11/os_exchange_data_provider_x11.h"
#include "ui/ozone/platform/x11/x11_window.h"
#include "ui/platform_window/platform_window_init_properties.h"
namespace ui {
namespace {
DragOperation;
class TestDragDropClient;
class ClientMessageEventCollector { … };
class TestMoveLoop : public X11MoveLoop { … };
class SimpleTestDragDropClient : public XDragDropClient,
public XDragDropClient::Delegate,
public X11MoveLoopDelegate { … };
class TestDragDropClient : public SimpleTestDragDropClient { … };
ClientMessageEventCollector::ClientMessageEventCollector(
x11::Window window,
TestDragDropClient* client)
: … { … }
ClientMessageEventCollector::~ClientMessageEventCollector() { … }
std::vector<x11::ClientMessageEvent>
ClientMessageEventCollector::PopAllEvents() { … }
void ClientMessageEventCollector::RecordEvent(
const x11::ClientMessageEvent& event) { … }
TestMoveLoop::TestMoveLoop(X11MoveLoopDelegate* delegate)
: … { … }
TestMoveLoop::~TestMoveLoop() = default;
bool TestMoveLoop::IsRunning() const { … }
bool TestMoveLoop::RunMoveLoop(bool can_grab_pointer,
scoped_refptr<X11Cursor> old_cursor,
scoped_refptr<X11Cursor> new_cursor,
base::OnceClosure started_callback) { … }
void TestMoveLoop::UpdateCursor(scoped_refptr<X11Cursor> cursor) { … }
void TestMoveLoop::EndMoveLoop() { … }
SimpleTestDragDropClient::SimpleTestDragDropClient(X11Window* window)
: … { … }
SimpleTestDragDropClient::~SimpleTestDragDropClient() = default;
void SimpleTestDragDropClient::SetTopmostXWindow(x11::Window window) { … }
bool SimpleTestDragDropClient::IsMoveLoopRunning() { … }
DragOperation SimpleTestDragDropClient::StartDragAndDrop(
std::unique_ptr<OSExchangeData> data,
X11Window* source_window,
int allowed_operations,
mojom::DragEventSource source) { … }
std::optional<gfx::AcceleratedWidget>
SimpleTestDragDropClient::GetDragWidget() { … }
int SimpleTestDragDropClient::UpdateDrag(const gfx::Point& screen_point) { … }
void SimpleTestDragDropClient::UpdateCursor(
DragOperation negotiated_operation) { … }
void SimpleTestDragDropClient::OnBeginForeignDrag(x11::Window window) { … }
void SimpleTestDragDropClient::OnEndForeignDrag() { … }
void SimpleTestDragDropClient::OnBeforeDragLeave() { … }
DragOperation SimpleTestDragDropClient::PerformDrop() { … }
void SimpleTestDragDropClient::EndDragLoop() { … }
x11::Window SimpleTestDragDropClient::FindWindowFor(
const gfx::Point& screen_point) { … }
void SimpleTestDragDropClient::OnMouseMovement(const gfx::Point& screen_point,
int flags,
base::TimeTicks event_time) { … }
void SimpleTestDragDropClient::OnMouseReleased() { … }
void SimpleTestDragDropClient::OnMoveLoopEnded() { … }
TestDragDropClient::TestDragDropClient(X11Window* window)
: … { … }
TestDragDropClient::~TestDragDropClient() = default;
x11::Atom TestDragDropClient::GetAtom(const char* name) { … }
bool TestDragDropClient::MessageHasType(const x11::ClientMessageEvent& event,
const char* type) { … }
void TestDragDropClient::SetEventCollectorFor(
x11::Window window,
ClientMessageEventCollector* collector) { … }
void TestDragDropClient::OnStatus(x11::Window target_window,
bool will_accept_drop,
x11::Atom accepted_action) { … }
void TestDragDropClient::OnFinished(x11::Window target_window,
bool accepted_drop,
x11::Atom performed_action) { … }
void TestDragDropClient::SetTopmostXWindowAndMoveMouse(x11::Window window) { … }
void TestDragDropClient::SendXClientEvent(
x11::Window window,
const x11::ClientMessageEvent& event) { … }
class TestPlatformWindowDelegate : public PlatformWindowDelegate { … };
class TestOSExchangeDataProvideFactory
: public OSExchangeDataProviderFactoryOzone { … };
}
class X11DragDropClientTest : public testing::Test { … };
namespace {
void BasicStep2(TestDragDropClient* client, x11::Window toplevel) { … }
void BasicStep3(TestDragDropClient* client, x11::Window toplevel) { … }
}
TEST_F(X11DragDropClientTest, Basic) { … }
namespace {
void TargetDoesNotRespondStep2(TestDragDropClient* client) { … }
}
TEST_F(X11DragDropClientTest, TargetDoesNotRespond) { … }
namespace {
void QueuePositionStep2(TestDragDropClient* client) { … }
}
TEST_F(X11DragDropClientTest, QueuePosition) { … }
namespace {
void TargetChangesStep2(TestDragDropClient* client) { … }
}
TEST_F(X11DragDropClientTest, TargetChanges) { … }
namespace {
void RejectAfterMouseReleaseStep2(TestDragDropClient* client) { … }
void RejectAfterMouseReleaseStep3(TestDragDropClient* client) { … }
}
TEST_F(X11DragDropClientTest, RejectAfterMouseRelease) { … }
}