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

Side by Side Diff: ash/drag_drop/drag_image_view_unittest.cc

Issue 2828543003: chromeos: converts DragImageViewTest to AshTestBase (Closed)
Patch Set: cleanup Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_image_view.h" 5 #include "ash/drag_drop/drag_image_view.h"
6 6
7 #include "ash/test/ash_test.h" 7 #include "ash/test/ash_test_base.h"
8 #include "ui/aura/window.h"
8 #include "ui/base/dragdrop/drag_drop_types.h" 9 #include "ui/base/dragdrop/drag_drop_types.h"
9 10
10 namespace ash { 11 namespace ash {
11 namespace test { 12 namespace test {
12 13
13 using DragDropImageTest = AshTest; 14 using DragDropImageTest = AshTestBase;
14 15
15 TEST_F(DragDropImageTest, SetBoundsConsidersDragHintForTouch) { 16 TEST_F(DragDropImageTest, SetBoundsConsidersDragHintForTouch) {
16 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow()); 17 std::unique_ptr<aura::Window> window(CreateTestWindow());
17 DragImageView drag_image_view( 18 DragImageView drag_image_view(
18 window_owner->window(), 19 window.get(),
19 ui::DragDropTypes::DragEventSource::DRAG_EVENT_SOURCE_TOUCH); 20 ui::DragDropTypes::DragEventSource::DRAG_EVENT_SOURCE_TOUCH);
20 21
21 gfx::Size minimum_size = drag_image_view.GetMinimumSize(); 22 gfx::Size minimum_size = drag_image_view.GetMinimumSize();
22 gfx::Point new_pos(5, 5); 23 gfx::Point new_pos(5, 5);
23 24
24 if (!minimum_size.IsEmpty()) { 25 if (!minimum_size.IsEmpty()) {
25 // Expect that the view is at least the size of the drag hint image. 26 // Expect that the view is at least the size of the drag hint image.
26 gfx::Rect small_bounds(0, 0, 1, 1); 27 gfx::Rect small_bounds(0, 0, 1, 1);
27 drag_image_view.SetBoundsInScreen(small_bounds); 28 drag_image_view.SetBoundsInScreen(small_bounds);
28 EXPECT_EQ(gfx::Rect(minimum_size), drag_image_view.GetBoundsInScreen()); 29 EXPECT_EQ(gfx::Rect(minimum_size), drag_image_view.GetBoundsInScreen());
29 30
30 // Expect that we can change the position without affecting the bounds. 31 // Expect that we can change the position without affecting the bounds.
31 drag_image_view.SetScreenPosition(new_pos); 32 drag_image_view.SetScreenPosition(new_pos);
32 EXPECT_EQ(gfx::Rect(new_pos, minimum_size), 33 EXPECT_EQ(gfx::Rect(new_pos, minimum_size),
33 drag_image_view.GetBoundsInScreen()); 34 drag_image_view.GetBoundsInScreen());
34 } 35 }
35 36
36 // Expect that we can resize the view normally. 37 // Expect that we can resize the view normally.
37 gfx::Rect large_bounds(0, 0, minimum_size.width() + 1, 38 gfx::Rect large_bounds(0, 0, minimum_size.width() + 1,
38 minimum_size.height() + 1); 39 minimum_size.height() + 1);
39 drag_image_view.SetBoundsInScreen(large_bounds); 40 drag_image_view.SetBoundsInScreen(large_bounds);
40 EXPECT_EQ(large_bounds, drag_image_view.GetBoundsInScreen()); 41 EXPECT_EQ(large_bounds, drag_image_view.GetBoundsInScreen());
41 // Expect that we can change the position without affecting the bounds. 42 // Expect that we can change the position without affecting the bounds.
42 drag_image_view.SetScreenPosition(new_pos); 43 drag_image_view.SetScreenPosition(new_pos);
43 EXPECT_EQ(gfx::Rect(new_pos, large_bounds.size()), 44 EXPECT_EQ(gfx::Rect(new_pos, large_bounds.size()),
44 drag_image_view.GetBoundsInScreen()); 45 drag_image_view.GetBoundsInScreen());
45 } 46 }
46 47
47 TEST_F(DragDropImageTest, SetBoundsIgnoresDragHintForMouse) { 48 TEST_F(DragDropImageTest, SetBoundsIgnoresDragHintForMouse) {
48 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow()); 49 std::unique_ptr<aura::Window> window(CreateTestWindow());
49 DragImageView drag_image_view( 50 DragImageView drag_image_view(
50 window_owner->window(), 51 window.get(),
51 ui::DragDropTypes::DragEventSource::DRAG_EVENT_SOURCE_MOUSE); 52 ui::DragDropTypes::DragEventSource::DRAG_EVENT_SOURCE_MOUSE);
52 53
53 // Expect no drag hint image. 54 // Expect no drag hint image.
54 gfx::Rect small_bounds(0, 0, 1, 1); 55 gfx::Rect small_bounds(0, 0, 1, 1);
55 drag_image_view.SetBoundsInScreen(small_bounds); 56 drag_image_view.SetBoundsInScreen(small_bounds);
56 EXPECT_EQ(small_bounds, drag_image_view.GetBoundsInScreen()); 57 EXPECT_EQ(small_bounds, drag_image_view.GetBoundsInScreen());
57 EXPECT_EQ(drag_image_view.GetMinimumSize(), 58 EXPECT_EQ(drag_image_view.GetMinimumSize(),
58 drag_image_view.GetBoundsInScreen().size()); 59 drag_image_view.GetBoundsInScreen().size());
59 60
60 gfx::Point new_pos(5, 5); 61 gfx::Point new_pos(5, 5);
61 // Expect that we can change the position without affecting the bounds. 62 // Expect that we can change the position without affecting the bounds.
62 drag_image_view.SetScreenPosition(new_pos); 63 drag_image_view.SetScreenPosition(new_pos);
63 EXPECT_EQ(gfx::Rect(new_pos, small_bounds.size()), 64 EXPECT_EQ(gfx::Rect(new_pos, small_bounds.size()),
64 drag_image_view.GetBoundsInScreen()); 65 drag_image_view.GetBoundsInScreen());
65 66
66 // Expect that we can resize the view. 67 // Expect that we can resize the view.
67 gfx::Rect large_bounds(0, 0, 100, 100); 68 gfx::Rect large_bounds(0, 0, 100, 100);
68 drag_image_view.SetBoundsInScreen(large_bounds); 69 drag_image_view.SetBoundsInScreen(large_bounds);
69 EXPECT_EQ(large_bounds, drag_image_view.GetBoundsInScreen()); 70 EXPECT_EQ(large_bounds, drag_image_view.GetBoundsInScreen());
70 // Expect that we can change the position without affecting the bounds. 71 // Expect that we can change the position without affecting the bounds.
71 drag_image_view.SetScreenPosition(new_pos); 72 drag_image_view.SetScreenPosition(new_pos);
72 EXPECT_EQ(gfx::Rect(new_pos, large_bounds.size()), 73 EXPECT_EQ(gfx::Rect(new_pos, large_bounds.size()),
73 drag_image_view.GetBoundsInScreen()); 74 drag_image_view.GetBoundsInScreen());
74 } 75 }
75 76
76 } // namespace test 77 } // namespace test
77 } // namespace ash 78 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698