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" |
11 #include "ui/views/controls/webview/webview.h" | 11 #include "ui/views/controls/webview/webview.h" |
12 #include "ui/wm/core/easy_resize_window_targeter.h" | 12 #include "ui/wm/core/easy_resize_window_targeter.h" |
13 | 13 |
14 #if defined(OS_WIN) | |
15 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views_win.h" | |
16 #endif | |
17 | |
18 class ShapedAppWindowTargeterTest : public aura::test::AuraTestBase { | 14 class ShapedAppWindowTargeterTest : public aura::test::AuraTestBase { |
19 public: | 15 public: |
20 ShapedAppWindowTargeterTest() | 16 ShapedAppWindowTargeterTest() |
21 : web_view_(NULL) { | 17 : web_view_(NULL) { |
22 } | 18 } |
23 | 19 |
24 virtual ~ShapedAppWindowTargeterTest() {} | 20 virtual ~ShapedAppWindowTargeterTest() {} |
25 | 21 |
26 views::Widget* widget() { return widget_.get(); } | 22 views::Widget* widget() { return widget_.get(); } |
27 | 23 |
(...skipping 18 matching lines...) Expand all Loading... |
46 } | 42 } |
47 | 43 |
48 virtual void TearDown() OVERRIDE { | 44 virtual void TearDown() OVERRIDE { |
49 widget_.reset(); | 45 widget_.reset(); |
50 aura::test::AuraTestBase::TearDown(); | 46 aura::test::AuraTestBase::TearDown(); |
51 } | 47 } |
52 | 48 |
53 private: | 49 private: |
54 views::WebView web_view_; | 50 views::WebView web_view_; |
55 scoped_ptr<views::Widget> widget_; | 51 scoped_ptr<views::Widget> widget_; |
56 #if defined(OS_WIN) | |
57 ChromeNativeAppWindowViewsWin app_window_; | |
58 #else | |
59 ChromeNativeAppWindowViews app_window_; | 52 ChromeNativeAppWindowViews app_window_; |
60 #endif | |
61 | 53 |
62 DISALLOW_COPY_AND_ASSIGN(ShapedAppWindowTargeterTest); | 54 DISALLOW_COPY_AND_ASSIGN(ShapedAppWindowTargeterTest); |
63 }; | 55 }; |
64 | 56 |
65 TEST_F(ShapedAppWindowTargeterTest, HitTestBasic) { | 57 TEST_F(ShapedAppWindowTargeterTest, HitTestBasic) { |
66 aura::Window* window = widget()->GetNativeWindow(); | 58 aura::Window* window = widget()->GetNativeWindow(); |
67 { | 59 { |
68 // Without any custom shapes, the event should be targeted correctly to the | 60 // Without any custom shapes, the event should be targeted correctly to the |
69 // window. | 61 // window. |
70 ui::MouseEvent move(ui::ET_MOUSE_MOVED, | 62 ui::MouseEvent move(ui::ET_MOUSE_MOVED, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // |window| as its target. | 177 // |window| as its target. |
186 ui::MouseEvent move(ui::ET_MOUSE_MOVED, | 178 ui::MouseEvent move(ui::ET_MOUSE_MOVED, |
187 gfx::Point(32, 37), gfx::Point(32, 37), | 179 gfx::Point(32, 37), gfx::Point(32, 37), |
188 ui::EF_NONE, ui::EF_NONE); | 180 ui::EF_NONE, ui::EF_NONE); |
189 ui::EventDispatchDetails details = | 181 ui::EventDispatchDetails details = |
190 event_processor()->OnEventFromSource(&move); | 182 event_processor()->OnEventFromSource(&move); |
191 ASSERT_FALSE(details.dispatcher_destroyed); | 183 ASSERT_FALSE(details.dispatcher_destroyed); |
192 EXPECT_EQ(window, move.target()); | 184 EXPECT_EQ(window, move.target()); |
193 } | 185 } |
194 | 186 |
195 #if defined(OS_WIN) | 187 // The EasyResizeTargeter specifies an inset of 5px within the window. |
196 // On Windows the non standard app frame has a easy resize targetter | 188 app_window_views()->InstallEasyResizeTargeterOnContainer(); |
197 // installed. | 189 |
198 app_window_views()->CreateNonStandardAppFrame(); | |
199 { | 190 { |
200 // An event in the center of the window should always have | 191 // An event in the center of the window should always have |
201 // |window| as its target. | 192 // |window| as its target. |
202 ui::MouseEvent move(ui::ET_MOUSE_MOVED, | 193 ui::MouseEvent move(ui::ET_MOUSE_MOVED, |
203 gfx::Point(80, 80), gfx::Point(80, 80), | 194 gfx::Point(80, 80), gfx::Point(80, 80), |
204 ui::EF_NONE, ui::EF_NONE); | 195 ui::EF_NONE, ui::EF_NONE); |
205 ui::EventDispatchDetails details = | 196 ui::EventDispatchDetails details = |
206 event_processor()->OnEventFromSource(&move); | 197 event_processor()->OnEventFromSource(&move); |
207 ASSERT_FALSE(details.dispatcher_destroyed); | 198 ASSERT_FALSE(details.dispatcher_destroyed); |
208 EXPECT_EQ(window, move.target()); | 199 EXPECT_EQ(window, move.target()); |
209 } | 200 } |
210 { | 201 { |
211 // With an EasyResizeTargeter on the container, an event | 202 // With an EasyResizeTargeter on the container, an event |
212 // inside the window and within 5px of an edge should have | 203 // inside the window and within 5px of an edge should have |
213 // root_window() as its target. | 204 // root_window() as its target. |
214 ui::MouseEvent move(ui::ET_MOUSE_MOVED, | 205 ui::MouseEvent move(ui::ET_MOUSE_MOVED, |
215 gfx::Point(32, 37), gfx::Point(32, 37), | 206 gfx::Point(32, 37), gfx::Point(32, 37), |
216 ui::EF_NONE, ui::EF_NONE); | 207 ui::EF_NONE, ui::EF_NONE); |
217 ui::EventDispatchDetails details = | 208 ui::EventDispatchDetails details = |
218 event_processor()->OnEventFromSource(&move); | 209 event_processor()->OnEventFromSource(&move); |
219 ASSERT_FALSE(details.dispatcher_destroyed); | 210 ASSERT_FALSE(details.dispatcher_destroyed); |
220 EXPECT_EQ(root_window(), move.target()); | 211 EXPECT_EQ(root_window(), move.target()); |
221 } | 212 } |
222 #endif // defined (OS_WIN) | |
223 } | 213 } |
OLD | NEW |