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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <map> 5 #include <map>
6 #include <memory>
6 #include <vector> 7 #include <vector>
7 8
8 // Include views_test_base.h first because the definition of None in X.h 9 // Include views_test_base.h first because the definition of None in X.h
9 // conflicts with the definition of None in gtest-type-util.h 10 // conflicts with the definition of None in gtest-type-util.h
10 #include "ui/views/test/views_test_base.h" 11 #include "ui/views/test/views_test_base.h"
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/ptr_util.h"
14 #include "base/run_loop.h" 15 #include "base/run_loop.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
17 #include "ui/aura/window_tree_host.h" 18 #include "ui/aura/window_tree_host.h"
18 #include "ui/base/dragdrop/os_exchange_data.h" 19 #include "ui/base/dragdrop/os_exchange_data.h"
19 #include "ui/base/x/x11_util.h" 20 #include "ui/base/x/x11_util.h"
20 #include "ui/events/event_utils.h" 21 #include "ui/events/event_utils.h"
21 #include "ui/gfx/x/x11_atom_cache.h" 22 #include "ui/gfx/x/x11_atom_cache.h"
22 #include "ui/gfx/x/x11_types.h" 23 #include "ui/gfx/x/x11_types.h"
23 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h" 24 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 ~SimpleTestDragDropClient() override; 113 ~SimpleTestDragDropClient() override;
113 114
114 // Sets |xid| as the topmost window for all mouse positions. 115 // Sets |xid| as the topmost window for all mouse positions.
115 void SetTopmostXWindow(XID xid); 116 void SetTopmostXWindow(XID xid);
116 117
117 // Returns true if the move loop is running. 118 // Returns true if the move loop is running.
118 bool IsMoveLoopRunning(); 119 bool IsMoveLoopRunning();
119 120
120 private: 121 private:
121 // DesktopDragDropClientAuraX11: 122 // DesktopDragDropClientAuraX11:
122 scoped_ptr<X11MoveLoop> CreateMoveLoop( 123 std::unique_ptr<X11MoveLoop> CreateMoveLoop(
123 X11MoveLoopDelegate* delegate) override; 124 X11MoveLoopDelegate* delegate) override;
124 XID FindWindowFor(const gfx::Point& screen_point) override; 125 XID FindWindowFor(const gfx::Point& screen_point) override;
125 126
126 // The XID of the window which is simulated to be the topmost window. 127 // The XID of the window which is simulated to be the topmost window.
127 XID target_xid_; 128 XID target_xid_;
128 129
129 // The move loop. Not owned. 130 // The move loop. Not owned.
130 TestMoveLoop* loop_; 131 TestMoveLoop* loop_;
131 132
132 DISALLOW_COPY_AND_ASSIGN(SimpleTestDragDropClient); 133 DISALLOW_COPY_AND_ASSIGN(SimpleTestDragDropClient);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 275 }
275 276
276 void SimpleTestDragDropClient::SetTopmostXWindow(XID xid) { 277 void SimpleTestDragDropClient::SetTopmostXWindow(XID xid) {
277 target_xid_ = xid; 278 target_xid_ = xid;
278 } 279 }
279 280
280 bool SimpleTestDragDropClient::IsMoveLoopRunning() { 281 bool SimpleTestDragDropClient::IsMoveLoopRunning() {
281 return loop_->IsRunning(); 282 return loop_->IsRunning();
282 } 283 }
283 284
284 scoped_ptr<X11MoveLoop> SimpleTestDragDropClient::CreateMoveLoop( 285 std::unique_ptr<X11MoveLoop> SimpleTestDragDropClient::CreateMoveLoop(
285 X11MoveLoopDelegate* delegate) { 286 X11MoveLoopDelegate* delegate) {
286 loop_ = new TestMoveLoop(delegate); 287 loop_ = new TestMoveLoop(delegate);
287 return make_scoped_ptr(loop_); 288 return base::WrapUnique(loop_);
288 } 289 }
289 290
290 XID SimpleTestDragDropClient::FindWindowFor(const gfx::Point& screen_point) { 291 XID SimpleTestDragDropClient::FindWindowFor(const gfx::Point& screen_point) {
291 return target_xid_; 292 return target_xid_;
292 } 293 }
293 294
294 /////////////////////////////////////////////////////////////////////////////// 295 ///////////////////////////////////////////////////////////////////////////////
295 // TestDragDropClient 296 // TestDragDropClient
296 297
297 // static 298 // static
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 cursor_manager_.reset(); 421 cursor_manager_.reset();
421 widget_.reset(); 422 widget_.reset();
422 ViewsTestBase::TearDown(); 423 ViewsTestBase::TearDown();
423 } 424 }
424 425
425 TestDragDropClient* client() { 426 TestDragDropClient* client() {
426 return client_.get(); 427 return client_.get();
427 } 428 }
428 429
429 private: 430 private:
430 scoped_ptr<TestDragDropClient> client_; 431 std::unique_ptr<TestDragDropClient> client_;
431 scoped_ptr<DesktopNativeCursorManager> cursor_manager_; 432 std::unique_ptr<DesktopNativeCursorManager> cursor_manager_;
432 433
433 // The widget used to initiate drags. 434 // The widget used to initiate drags.
434 scoped_ptr<Widget> widget_; 435 std::unique_ptr<Widget> widget_;
435 436
436 DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11Test); 437 DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11Test);
437 }; 438 };
438 439
439 namespace { 440 namespace {
440 441
441 void BasicStep2(TestDragDropClient* client, XID toplevel) { 442 void BasicStep2(TestDragDropClient* client, XID toplevel) {
442 EXPECT_TRUE(client->IsMoveLoopRunning()); 443 EXPECT_TRUE(client->IsMoveLoopRunning());
443 444
444 ClientMessageEventCollector collector(toplevel, client); 445 ClientMessageEventCollector collector(toplevel, client);
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 cursor_manager_.reset(); 863 cursor_manager_.reset();
863 widget_.reset(); 864 widget_.reset();
864 ViewsTestBase::TearDown(); 865 ViewsTestBase::TearDown();
865 } 866 }
866 867
867 SimpleTestDragDropClient* client() { 868 SimpleTestDragDropClient* client() {
868 return client_.get(); 869 return client_.get();
869 } 870 }
870 871
871 private: 872 private:
872 scoped_ptr<SimpleTestDragDropClient> client_; 873 std::unique_ptr<SimpleTestDragDropClient> client_;
873 scoped_ptr<DesktopNativeCursorManager> cursor_manager_; 874 std::unique_ptr<DesktopNativeCursorManager> cursor_manager_;
874 875
875 // The widget used to initiate drags. 876 // The widget used to initiate drags.
876 scoped_ptr<Widget> widget_; 877 std::unique_ptr<Widget> widget_;
877 878
878 DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11ChromeSourceTargetTest); 879 DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11ChromeSourceTargetTest);
879 }; 880 };
880 881
881 namespace { 882 namespace {
882 883
883 void ChromeSourceTargetStep2(SimpleTestDragDropClient* client, 884 void ChromeSourceTargetStep2(SimpleTestDragDropClient* client,
884 int modifier_flags) { 885 int modifier_flags) {
885 EXPECT_TRUE(client->IsMoveLoopRunning()); 886 EXPECT_TRUE(client->IsMoveLoopRunning());
886 887
887 scoped_ptr<Widget> target_widget(new Widget); 888 std::unique_ptr<Widget> target_widget(new Widget);
888 Widget::InitParams target_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); 889 Widget::InitParams target_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
889 target_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 890 target_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
890 target_params.native_widget = 891 target_params.native_widget =
891 new DesktopNativeWidgetAura(target_widget.get()); 892 new DesktopNativeWidgetAura(target_widget.get());
892 target_params.bounds = gfx::Rect(100, 100); 893 target_params.bounds = gfx::Rect(100, 100);
893 target_widget->Init(target_params); 894 target_widget->Init(target_params);
894 target_widget->Show(); 895 target_widget->Show();
895 896
896 TestDragDropDelegate* delegate = new TestDragDropDelegate; 897 TestDragDropDelegate* delegate = new TestDragDropDelegate;
897 aura::client::SetDragDropDelegate(target_widget->GetNativeWindow(), delegate); 898 aura::client::SetDragDropDelegate(target_widget->GetNativeWindow(), delegate);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 // the aura::client::DragDropDelegate is properly notified. 956 // the aura::client::DragDropDelegate is properly notified.
956 TEST_F(DesktopDragDropClientAuraX11ChromeSourceTargetTest, CtrlPressed) { 957 TEST_F(DesktopDragDropClientAuraX11ChromeSourceTargetTest, CtrlPressed) {
957 base::MessageLoop::current()->PostTask( 958 base::MessageLoop::current()->PostTask(
958 FROM_HERE, 959 FROM_HERE,
959 base::Bind(&ChromeSourceTargetStep2, client(), ui::EF_CONTROL_DOWN)); 960 base::Bind(&ChromeSourceTargetStep2, client(), ui::EF_CONTROL_DOWN));
960 int result = StartDragAndDrop(); 961 int result = StartDragAndDrop();
961 EXPECT_EQ(ui::DragDropTypes::DRAG_COPY, result); 962 EXPECT_EQ(ui::DragDropTypes::DRAG_COPY, result);
962 } 963 }
963 964
964 } // namespace views 965 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698