| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ash/drag_drop/drag_drop_controller.h" | 5 #include "ash/drag_drop/drag_drop_controller.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace ash { | 22 namespace ash { |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 class DraggableView : public views::View { | 25 class DraggableView : public views::View { |
| 26 public: | 26 public: |
| 27 DraggableView() {} | 27 DraggableView() {} |
| 28 virtual ~DraggableView() {} | 28 virtual ~DraggableView() {} |
| 29 | 29 |
| 30 // views::View overrides: | 30 // views::View overrides: |
| 31 virtual int GetDragOperations(const gfx::Point& press_pt) OVERRIDE { | 31 virtual int GetDragOperations(const gfx::Point& press_pt) override { |
| 32 return ui::DragDropTypes::DRAG_MOVE; | 32 return ui::DragDropTypes::DRAG_MOVE; |
| 33 } | 33 } |
| 34 virtual void WriteDragData(const gfx::Point& press_pt, | 34 virtual void WriteDragData(const gfx::Point& press_pt, |
| 35 OSExchangeData* data)OVERRIDE { | 35 OSExchangeData* data)override { |
| 36 data->SetString(base::UTF8ToUTF16("test")); | 36 data->SetString(base::UTF8ToUTF16("test")); |
| 37 } | 37 } |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 DISALLOW_COPY_AND_ASSIGN(DraggableView); | 40 DISALLOW_COPY_AND_ASSIGN(DraggableView); |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 class TargetView : public views::View { | 43 class TargetView : public views::View { |
| 44 public: | 44 public: |
| 45 TargetView() : dropped_(false) {} | 45 TargetView() : dropped_(false) {} |
| 46 virtual ~TargetView() {} | 46 virtual ~TargetView() {} |
| 47 | 47 |
| 48 // views::View overrides: | 48 // views::View overrides: |
| 49 virtual bool GetDropFormats( | 49 virtual bool GetDropFormats( |
| 50 int* formats, | 50 int* formats, |
| 51 std::set<OSExchangeData::CustomFormat>* custom_formats) OVERRIDE { | 51 std::set<OSExchangeData::CustomFormat>* custom_formats) override { |
| 52 *formats = ui::OSExchangeData::STRING; | 52 *formats = ui::OSExchangeData::STRING; |
| 53 return true; | 53 return true; |
| 54 } | 54 } |
| 55 virtual bool AreDropTypesRequired() OVERRIDE { | 55 virtual bool AreDropTypesRequired() override { |
| 56 return false; | 56 return false; |
| 57 } | 57 } |
| 58 virtual bool CanDrop(const OSExchangeData& data) OVERRIDE { | 58 virtual bool CanDrop(const OSExchangeData& data) override { |
| 59 return true; | 59 return true; |
| 60 } | 60 } |
| 61 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE { | 61 virtual int OnDragUpdated(const ui::DropTargetEvent& event) override { |
| 62 return ui::DragDropTypes::DRAG_MOVE; | 62 return ui::DragDropTypes::DRAG_MOVE; |
| 63 } | 63 } |
| 64 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE { | 64 virtual int OnPerformDrop(const ui::DropTargetEvent& event) override { |
| 65 dropped_ = true; | 65 dropped_ = true; |
| 66 return ui::DragDropTypes::DRAG_MOVE; | 66 return ui::DragDropTypes::DRAG_MOVE; |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool dropped() const { return dropped_; } | 69 bool dropped() const { return dropped_; } |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 bool dropped_; | 72 bool dropped_; |
| 73 | 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(TargetView); | 74 DISALLOW_COPY_AND_ASSIGN(TargetView); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 base::Bind(&DragDropAcrossMultiDisplay_Step2)); | 119 base::Bind(&DragDropAcrossMultiDisplay_Step2)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace | 122 } // namespace |
| 123 | 123 |
| 124 class DragDropTest : public test::AshTestBase { | 124 class DragDropTest : public test::AshTestBase { |
| 125 public: | 125 public: |
| 126 DragDropTest() {} | 126 DragDropTest() {} |
| 127 virtual ~DragDropTest() {} | 127 virtual ~DragDropTest() {} |
| 128 | 128 |
| 129 virtual void SetUp() OVERRIDE { | 129 virtual void SetUp() override { |
| 130 gfx::GLSurface::InitializeOneOffForTests(); | 130 gfx::GLSurface::InitializeOneOffForTests(); |
| 131 | 131 |
| 132 ui::RegisterPathProvider(); | 132 ui::RegisterPathProvider(); |
| 133 ui::ResourceBundle::InitSharedInstanceWithLocale( | 133 ui::ResourceBundle::InitSharedInstanceWithLocale( |
| 134 "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); | 134 "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); |
| 135 base::FilePath resources_pack_path; | 135 base::FilePath resources_pack_path; |
| 136 PathService::Get(base::DIR_MODULE, &resources_pack_path); | 136 PathService::Get(base::DIR_MODULE, &resources_pack_path); |
| 137 resources_pack_path = | 137 resources_pack_path = |
| 138 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); | 138 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); |
| 139 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 139 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 base::MessageLoop::current()->Run(); | 179 base::MessageLoop::current()->Run(); |
| 180 | 180 |
| 181 EXPECT_TRUE(target_view->dropped()); | 181 EXPECT_TRUE(target_view->dropped()); |
| 182 | 182 |
| 183 source->Close(); | 183 source->Close(); |
| 184 target->Close(); | 184 target->Close(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 } // namespace ash | 187 } // namespace ash |
| OLD | NEW |