OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/aura_shell/drag_drop_controller.h" | 5 #include "ui/aura_shell/drag_drop_controller.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/event.h" | 10 #include "ui/aura/event.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 gfx::Rect contents_view_bounds = contents_view->bounds(); | 165 gfx::Rect contents_view_bounds = contents_view->bounds(); |
166 contents_view_bounds = contents_view_bounds.Union(view->bounds()); | 166 contents_view_bounds = contents_view_bounds.Union(view->bounds()); |
167 contents_view->SetBoundsRect(contents_view_bounds); | 167 contents_view->SetBoundsRect(contents_view_bounds); |
168 widget->SetBounds(contents_view_bounds); | 168 widget->SetBounds(contents_view_bounds); |
169 } | 169 } |
170 | 170 |
171 } // namespace | 171 } // namespace |
172 | 172 |
173 class DragDropControllerTest : public AuraShellTestBase { | 173 class DragDropControllerTest : public AuraShellTestBase { |
174 public: | 174 public: |
175 DragDropControllerTest() : AuraShellTestBase() { | 175 DragDropControllerTest() : AuraShellTestBase() {} |
176 } | 176 virtual ~DragDropControllerTest() {} |
177 | |
178 virtual ~DragDropControllerTest() { | |
179 aura::RootWindow::GetInstance()->SetProperty( | |
180 aura::kRootWindowDragDropClientKey, | |
181 NULL); | |
182 } | |
183 | 177 |
184 void SetUp() OVERRIDE { | 178 void SetUp() OVERRIDE { |
185 AuraShellTestBase::SetUp(); | 179 AuraShellTestBase::SetUp(); |
186 drag_drop_controller_ = new TestDragDropController; | 180 drag_drop_controller_.reset(new TestDragDropController); |
187 drag_drop_controller_->set_should_block_during_drag_drop(false); | 181 drag_drop_controller_->set_should_block_during_drag_drop(false); |
188 aura::RootWindow::GetInstance()->SetProperty( | 182 aura::client::SetDragDropClient(drag_drop_controller_.get()); |
189 aura::kRootWindowDragDropClientKey, | |
190 drag_drop_controller_); | |
191 } | 183 } |
192 | 184 |
193 void TearDown() OVERRIDE { | 185 void TearDown() OVERRIDE { |
194 delete drag_drop_controller_; | 186 aura::client::SetDragDropClient(NULL); |
195 drag_drop_controller_ = NULL; | 187 drag_drop_controller_.reset(); |
196 AuraShellTestBase::TearDown(); | 188 AuraShellTestBase::TearDown(); |
197 } | 189 } |
198 | 190 |
199 void UpdateDragData(ui::OSExchangeData* data) { | 191 void UpdateDragData(ui::OSExchangeData* data) { |
200 drag_drop_controller_->drag_data_ = data; | 192 drag_drop_controller_->drag_data_ = data; |
201 } | 193 } |
202 | 194 |
203 protected: | 195 protected: |
204 TestDragDropController* drag_drop_controller_; | 196 scoped_ptr<TestDragDropController> drag_drop_controller_; |
205 | 197 |
206 private: | 198 private: |
207 DISALLOW_COPY_AND_ASSIGN(DragDropControllerTest); | 199 DISALLOW_COPY_AND_ASSIGN(DragDropControllerTest); |
208 }; | 200 }; |
209 | 201 |
210 TEST_F(DragDropControllerTest, DragDropInSingleViewTest) { | 202 TEST_F(DragDropControllerTest, DragDropInSingleViewTest) { |
211 views::Widget* widget = CreateNewWidget(); | 203 views::Widget* widget = CreateNewWidget(); |
212 DragTestView* drag_view = new DragTestView; | 204 DragTestView* drag_view = new DragTestView; |
213 AddViewToWidgetAndResize(widget, drag_view); | 205 AddViewToWidgetAndResize(widget, drag_view); |
214 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint(); | 206 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint(); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 EXPECT_EQ(num_drags_1 - 1 - drag_view->VerticalDragThreshold(), | 411 EXPECT_EQ(num_drags_1 - 1 - drag_view->VerticalDragThreshold(), |
420 drag_view->num_drag_updates_); | 412 drag_view->num_drag_updates_); |
421 EXPECT_EQ(0, drag_view->num_drops_); | 413 EXPECT_EQ(0, drag_view->num_drops_); |
422 EXPECT_EQ(0, drag_view->num_drag_exits_); | 414 EXPECT_EQ(0, drag_view->num_drag_exits_); |
423 EXPECT_TRUE(drag_view->drag_done_received_); | 415 EXPECT_TRUE(drag_view->drag_done_received_); |
424 delete widget; | 416 delete widget; |
425 } | 417 } |
426 | 418 |
427 } // namespace test | 419 } // namespace test |
428 } // namespace aura | 420 } // namespace aura |
OLD | NEW |