OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/aura/desktop.h" | 9 #include "ui/aura/desktop.h" |
10 #include "ui/aura/event.h" | 10 #include "ui/aura/event.h" |
11 #include "ui/aura/focus_manager.h" | 11 #include "ui/aura/focus_manager.h" |
12 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
13 #include "ui/aura/window_delegate.h" | 13 #include "ui/aura/window_delegate.h" |
14 #include "ui/gfx/canvas_skia.h" | 14 #include "ui/gfx/canvas_skia.h" |
| 15 #include "ui/gfx/compositor/layer.h" |
15 #include "ui/base/keycodes/keyboard_codes.h" | 16 #include "ui/base/keycodes/keyboard_codes.h" |
16 | 17 |
17 #if !defined(OS_WIN) | 18 #if !defined(OS_WIN) |
18 #include "ui/aura/hit_test.h" | 19 #include "ui/aura/hit_test.h" |
19 #endif | 20 #endif |
20 | 21 |
21 namespace aura { | 22 namespace aura { |
22 namespace internal { | 23 namespace internal { |
23 | 24 |
24 namespace { | 25 namespace { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); | 212 CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); |
212 scoped_ptr<Window> w12( | 213 scoped_ptr<Window> w12( |
213 CreateTestWindow(SK_ColorMAGENTA, 12, gfx::Rect(10, 420, 25, 25), | 214 CreateTestWindow(SK_ColorMAGENTA, 12, gfx::Rect(10, 420, 25, 25), |
214 w1.get())); | 215 w1.get())); |
215 scoped_ptr<Window> w121( | 216 scoped_ptr<Window> w121( |
216 CreateTestWindow(SK_ColorYELLOW, 121, gfx::Rect(5, 5, 5, 5), w12.get())); | 217 CreateTestWindow(SK_ColorYELLOW, 121, gfx::Rect(5, 5, 5, 5), w12.get())); |
217 scoped_ptr<Window> w13( | 218 scoped_ptr<Window> w13( |
218 CreateTestWindow(SK_ColorGRAY, 13, gfx::Rect(5, 470, 50, 50), w1.get())); | 219 CreateTestWindow(SK_ColorGRAY, 13, gfx::Rect(5, 470, 50, 50), w1.get())); |
219 | 220 |
220 Window* desktop = Desktop::GetInstance()->window(); | 221 Window* desktop = Desktop::GetInstance()->window(); |
221 EXPECT_EQ(desktop, desktop->GetEventHandlerForPoint(gfx::Point(5, 5))); | 222 EXPECT_EQ(NULL, desktop->GetEventHandlerForPoint(gfx::Point(5, 5))); |
222 EXPECT_EQ(w1.get(), desktop->GetEventHandlerForPoint(gfx::Point(11, 11))); | 223 EXPECT_EQ(w1.get(), desktop->GetEventHandlerForPoint(gfx::Point(11, 11))); |
223 EXPECT_EQ(w11.get(), desktop->GetEventHandlerForPoint(gfx::Point(16, 16))); | 224 EXPECT_EQ(w11.get(), desktop->GetEventHandlerForPoint(gfx::Point(16, 16))); |
224 EXPECT_EQ(w111.get(), desktop->GetEventHandlerForPoint(gfx::Point(21, 21))); | 225 EXPECT_EQ(w111.get(), desktop->GetEventHandlerForPoint(gfx::Point(21, 21))); |
225 EXPECT_EQ(w1111.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 26))); | 226 EXPECT_EQ(w1111.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 26))); |
226 EXPECT_EQ(w12.get(), desktop->GetEventHandlerForPoint(gfx::Point(21, 431))); | 227 EXPECT_EQ(w12.get(), desktop->GetEventHandlerForPoint(gfx::Point(21, 431))); |
227 EXPECT_EQ(w121.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 436))); | 228 EXPECT_EQ(w121.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 436))); |
228 EXPECT_EQ(w13.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 481))); | 229 EXPECT_EQ(w13.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 481))); |
229 } | 230 } |
230 | 231 |
231 TEST_F(WindowTest, Focus) { | 232 TEST_F(WindowTest, Focus) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 CreateTestWindowWithDelegate(&parent_delegate, 0, gfx::Rect(), NULL)); | 271 CreateTestWindowWithDelegate(&parent_delegate, 0, gfx::Rect(), NULL)); |
271 CreateTestWindowWithDelegate(&child_delegate, 0, gfx::Rect(), parent.get()); | 272 CreateTestWindowWithDelegate(&child_delegate, 0, gfx::Rect(), parent.get()); |
272 } | 273 } |
273 // Both the parent and child should have been destroyed. | 274 // Both the parent and child should have been destroyed. |
274 EXPECT_EQ(1, parent_delegate.destroying_count()); | 275 EXPECT_EQ(1, parent_delegate.destroying_count()); |
275 EXPECT_EQ(1, parent_delegate.destroyed_count()); | 276 EXPECT_EQ(1, parent_delegate.destroyed_count()); |
276 EXPECT_EQ(1, child_delegate.destroying_count()); | 277 EXPECT_EQ(1, child_delegate.destroying_count()); |
277 EXPECT_EQ(1, child_delegate.destroyed_count()); | 278 EXPECT_EQ(1, child_delegate.destroyed_count()); |
278 } | 279 } |
279 | 280 |
| 281 // Make sure MoveChildToFront moves both the window and layer to the front. |
| 282 TEST_F(WindowTest, MoveChildToFront) { |
| 283 Window parent(NULL); |
| 284 parent.Init(); |
| 285 Window child1(NULL); |
| 286 child1.Init(); |
| 287 Window child2(NULL); |
| 288 child2.Init(); |
| 289 |
| 290 child1.SetParent(&parent); |
| 291 child2.SetParent(&parent); |
| 292 ASSERT_EQ(2u, parent.children().size()); |
| 293 EXPECT_EQ(&child1, parent.children()[0]); |
| 294 EXPECT_EQ(&child2, parent.children()[1]); |
| 295 ASSERT_EQ(2u, parent.layer()->children().size()); |
| 296 EXPECT_EQ(child1.layer(), parent.layer()->children()[0]); |
| 297 EXPECT_EQ(child2.layer(), parent.layer()->children()[1]); |
| 298 |
| 299 parent.MoveChildToFront(&child1); |
| 300 ASSERT_EQ(2u, parent.children().size()); |
| 301 EXPECT_EQ(&child1, parent.children()[1]); |
| 302 EXPECT_EQ(&child2, parent.children()[0]); |
| 303 ASSERT_EQ(2u, parent.layer()->children().size()); |
| 304 EXPECT_EQ(child1.layer(), parent.layer()->children()[1]); |
| 305 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]); |
| 306 } |
| 307 |
280 } // namespace internal | 308 } // namespace internal |
281 } // namespace aura | 309 } // namespace aura |
282 | 310 |
OLD | NEW |