| 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 "chrome/browser/ui/views/apps/chrome_native_app_window_views.h" | 7 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views.h" |
| 8 #include "ui/aura/test/aura_test_base.h" | 8 #include "ui/aura/test/aura_test_base.h" |
| 9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 10 #include "ui/aura/window_event_dispatcher.h" | 10 #include "ui/aura/window_event_dispatcher.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 ui::EventDispatchDetails details = | 181 ui::EventDispatchDetails details = |
| 182 event_processor()->OnEventFromSource(&move); | 182 event_processor()->OnEventFromSource(&move); |
| 183 ASSERT_FALSE(details.dispatcher_destroyed); | 183 ASSERT_FALSE(details.dispatcher_destroyed); |
| 184 EXPECT_EQ(window, move.target()); | 184 EXPECT_EQ(window, move.target()); |
| 185 } | 185 } |
| 186 | 186 |
| 187 // The EasyResizeTargeter specifies an inset of 5px within the window. | 187 // The EasyResizeTargeter specifies an inset of 5px within the window. |
| 188 app_window_views()->InstallEasyResizeTargeterOnContainer(); | 188 app_window_views()->InstallEasyResizeTargeterOnContainer(); |
| 189 | 189 |
| 190 { | 190 { |
| 191 // Ensure that the window has an event targeter (there should be an |
| 192 // EasyResizeWindowTargeter installed). |
| 193 EXPECT_TRUE(static_cast<ui::EventTarget*>(window)->GetEventTargeter()); |
| 194 } |
| 195 { |
| 191 // An event in the center of the window should always have | 196 // An event in the center of the window should always have |
| 192 // |window| as its target. | 197 // |window| as its target. |
| 198 // TODO(mgiuca): This isn't really testing anything (note that it has the |
| 199 // same expectation as the border case below). In the real environment, the |
| 200 // target will actually be the RenderWidgetHostViewAura's window that is the |
| 201 // child of the child of |window|, whereas in the border case it *will* be |
| 202 // |window|. However, since this test environment does not have a |
| 203 // RenderWidgetHostViewAura, we cannot differentiate the two cases. Fix |
| 204 // the test environment so that the test can assert that non-border events |
| 205 // bubble down to a child of |window|. |
| 193 ui::MouseEvent move(ui::ET_MOUSE_MOVED, | 206 ui::MouseEvent move(ui::ET_MOUSE_MOVED, |
| 194 gfx::Point(80, 80), gfx::Point(80, 80), | 207 gfx::Point(80, 80), gfx::Point(80, 80), |
| 195 ui::EF_NONE, ui::EF_NONE); | 208 ui::EF_NONE, ui::EF_NONE); |
| 196 ui::EventDispatchDetails details = | 209 ui::EventDispatchDetails details = |
| 197 event_processor()->OnEventFromSource(&move); | 210 event_processor()->OnEventFromSource(&move); |
| 198 ASSERT_FALSE(details.dispatcher_destroyed); | 211 ASSERT_FALSE(details.dispatcher_destroyed); |
| 199 EXPECT_EQ(window, move.target()); | 212 EXPECT_EQ(window, move.target()); |
| 200 } | 213 } |
| 201 { | 214 { |
| 202 // With an EasyResizeTargeter on the container, an event | 215 // With an EasyResizeTargeter on the container, an event |
| 203 // inside the window and within 5px of an edge should have | 216 // inside the window and within 5px of an edge should have |
| 204 // root_window() as its target. | 217 // |window| as its target. |
| 205 ui::MouseEvent move(ui::ET_MOUSE_MOVED, | 218 ui::MouseEvent move(ui::ET_MOUSE_MOVED, |
| 206 gfx::Point(32, 37), gfx::Point(32, 37), | 219 gfx::Point(32, 37), gfx::Point(32, 37), |
| 207 ui::EF_NONE, ui::EF_NONE); | 220 ui::EF_NONE, ui::EF_NONE); |
| 208 ui::EventDispatchDetails details = | 221 ui::EventDispatchDetails details = |
| 209 event_processor()->OnEventFromSource(&move); | 222 event_processor()->OnEventFromSource(&move); |
| 210 ASSERT_FALSE(details.dispatcher_destroyed); | 223 ASSERT_FALSE(details.dispatcher_destroyed); |
| 211 EXPECT_EQ(root_window(), move.target()); | 224 EXPECT_EQ(window, move.target()); |
| 212 } | 225 } |
| 213 } | 226 } |
| OLD | NEW |