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

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

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 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
« no previous file with comments | « ash/common/drag_drop/drag_image_view.cc ('k') | ash/common/focus_cycler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/common/drag_drop/drag_image_view.h"
6
7 #include "ash/common/test/ash_test.h"
8 #include "ui/base/dragdrop/drag_drop_types.h"
9
10 namespace ash {
11 namespace test {
12
13 using DragDropImageTest = AshTest;
14
15 TEST_F(DragDropImageTest, SetBoundsConsidersDragHintForTouch) {
16 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow());
17 DragImageView drag_image_view(
18 window_owner->window(),
19 ui::DragDropTypes::DragEventSource::DRAG_EVENT_SOURCE_TOUCH);
20
21 gfx::Size minimum_size = drag_image_view.GetMinimumSize();
22 gfx::Point new_pos(5, 5);
23
24 if (!minimum_size.IsEmpty()) {
25 // Expect that the view is at least the size of the drag hint image.
26 gfx::Rect small_bounds(0, 0, 1, 1);
27 drag_image_view.SetBoundsInScreen(small_bounds);
28 EXPECT_EQ(gfx::Rect(minimum_size), drag_image_view.GetBoundsInScreen());
29
30 // Expect that we can change the position without affecting the bounds.
31 drag_image_view.SetScreenPosition(new_pos);
32 EXPECT_EQ(gfx::Rect(new_pos, minimum_size),
33 drag_image_view.GetBoundsInScreen());
34 }
35
36 // Expect that we can resize the view normally.
37 gfx::Rect large_bounds(0, 0, minimum_size.width() + 1,
38 minimum_size.height() + 1);
39 drag_image_view.SetBoundsInScreen(large_bounds);
40 EXPECT_EQ(large_bounds, drag_image_view.GetBoundsInScreen());
41 // Expect that we can change the position without affecting the bounds.
42 drag_image_view.SetScreenPosition(new_pos);
43 EXPECT_EQ(gfx::Rect(new_pos, large_bounds.size()),
44 drag_image_view.GetBoundsInScreen());
45 }
46
47 TEST_F(DragDropImageTest, SetBoundsIgnoresDragHintForMouse) {
48 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow());
49 DragImageView drag_image_view(
50 window_owner->window(),
51 ui::DragDropTypes::DragEventSource::DRAG_EVENT_SOURCE_MOUSE);
52
53 // Expect no drag hint image.
54 gfx::Rect small_bounds(0, 0, 1, 1);
55 drag_image_view.SetBoundsInScreen(small_bounds);
56 EXPECT_EQ(small_bounds, drag_image_view.GetBoundsInScreen());
57 EXPECT_EQ(drag_image_view.GetMinimumSize(),
58 drag_image_view.GetBoundsInScreen().size());
59
60 gfx::Point new_pos(5, 5);
61 // Expect that we can change the position without affecting the bounds.
62 drag_image_view.SetScreenPosition(new_pos);
63 EXPECT_EQ(gfx::Rect(new_pos, small_bounds.size()),
64 drag_image_view.GetBoundsInScreen());
65
66 // Expect that we can resize the view.
67 gfx::Rect large_bounds(0, 0, 100, 100);
68 drag_image_view.SetBoundsInScreen(large_bounds);
69 EXPECT_EQ(large_bounds, drag_image_view.GetBoundsInScreen());
70 // Expect that we can change the position without affecting the bounds.
71 drag_image_view.SetScreenPosition(new_pos);
72 EXPECT_EQ(gfx::Rect(new_pos, large_bounds.size()),
73 drag_image_view.GetBoundsInScreen());
74 }
75
76 } // namespace test
77 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/drag_drop/drag_image_view.cc ('k') | ash/common/focus_cycler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698