OLD | NEW |
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 "chrome/browser/ui/views/apps/shaped_app_window_targeter.h" | 5 #include "chrome/browser/ui/views/apps/shaped_app_window_targeter.h" |
6 | 6 |
7 #include "apps/ui/views/app_window_frame_view.h" | 7 #include "apps/ui/views/app_window_frame_view.h" |
8 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views.h" | 8 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views.h" |
9 #include "ui/aura/test/aura_test_base.h" | 9 #include "ui/aura/test/aura_test_base.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 ui::MouseEvent move(ui::ET_MOUSE_MOVED, | 65 ui::MouseEvent move(ui::ET_MOUSE_MOVED, |
66 gfx::Point(40, 40), gfx::Point(40, 40), | 66 gfx::Point(40, 40), gfx::Point(40, 40), |
67 ui::EF_NONE, ui::EF_NONE); | 67 ui::EF_NONE, ui::EF_NONE); |
68 ui::EventDispatchDetails details = | 68 ui::EventDispatchDetails details = |
69 event_processor()->OnEventFromSource(&move); | 69 event_processor()->OnEventFromSource(&move); |
70 ASSERT_FALSE(details.dispatcher_destroyed); | 70 ASSERT_FALSE(details.dispatcher_destroyed); |
71 EXPECT_EQ(window, move.target()); | 71 EXPECT_EQ(window, move.target()); |
72 } | 72 } |
73 | 73 |
74 scoped_ptr<SkRegion> region(new SkRegion); | 74 scoped_ptr<SkRegion> region(new SkRegion); |
| 75 region->op(SkIRect::MakeXYWH(0, 0, 0, 0), SkRegion::kUnion_Op); |
| 76 app_window()->UpdateShape(region.Pass()); |
| 77 { |
| 78 // With an empty custom shape, all events within the window should fall |
| 79 // through to the root window. |
| 80 ui::MouseEvent move(ui::ET_MOUSE_MOVED, |
| 81 gfx::Point(40, 40), gfx::Point(40, 40), |
| 82 ui::EF_NONE, ui::EF_NONE); |
| 83 ui::EventDispatchDetails details = |
| 84 event_processor()->OnEventFromSource(&move); |
| 85 ASSERT_FALSE(details.dispatcher_destroyed); |
| 86 EXPECT_EQ(root_window(), move.target()); |
| 87 } |
| 88 |
| 89 // Window shape (global coordinates) |
| 90 // 30 70 90 130 |
| 91 // 30 + +-----+ |
| 92 // . | | <- mouse move (40,40) |
| 93 // 70 +--------+ +---------+ |
| 94 // | . | <- mouse move (80,80) |
| 95 // 90 +--------+ +---------+ |
| 96 // | | |
| 97 // 130 +-----+ |
| 98 region.reset(new SkRegion); |
75 region->op(SkIRect::MakeXYWH(40, 0, 20, 100), SkRegion::kUnion_Op); | 99 region->op(SkIRect::MakeXYWH(40, 0, 20, 100), SkRegion::kUnion_Op); |
76 region->op(SkIRect::MakeXYWH(0, 40, 100, 20), SkRegion::kUnion_Op); | 100 region->op(SkIRect::MakeXYWH(0, 40, 100, 20), SkRegion::kUnion_Op); |
77 app_window()->UpdateShape(region.Pass()); | 101 app_window()->UpdateShape(region.Pass()); |
78 { | 102 { |
79 // With the custom shape, the events that don't fall within the custom shape | 103 // With the custom shape, the events that don't fall within the custom shape |
80 // will go through to the root window. | 104 // will go through to the root window. |
81 ui::MouseEvent move(ui::ET_MOUSE_MOVED, | 105 ui::MouseEvent move(ui::ET_MOUSE_MOVED, |
82 gfx::Point(40, 40), gfx::Point(40, 40), | 106 gfx::Point(40, 40), gfx::Point(40, 40), |
83 ui::EF_NONE, ui::EF_NONE); | 107 ui::EF_NONE, ui::EF_NONE); |
84 ui::EventDispatchDetails details = | 108 ui::EventDispatchDetails details = |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 ui::MouseEvent move(ui::ET_MOUSE_MOVED, | 246 ui::MouseEvent move(ui::ET_MOUSE_MOVED, |
223 gfx::Point(32, 37), gfx::Point(32, 37), | 247 gfx::Point(32, 37), gfx::Point(32, 37), |
224 ui::EF_NONE, ui::EF_NONE); | 248 ui::EF_NONE, ui::EF_NONE); |
225 ui::EventDispatchDetails details = | 249 ui::EventDispatchDetails details = |
226 event_processor()->OnEventFromSource(&move); | 250 event_processor()->OnEventFromSource(&move); |
227 ASSERT_FALSE(details.dispatcher_destroyed); | 251 ASSERT_FALSE(details.dispatcher_destroyed); |
228 EXPECT_EQ(window, move.target()); | 252 EXPECT_EQ(window, move.target()); |
229 } | 253 } |
230 #endif // defined (OS_CHROMEOS) | 254 #endif // defined (OS_CHROMEOS) |
231 } | 255 } |
OLD | NEW |