| 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/test_desktop_delegate.h" |
| 13 #include "ui/aura/window_delegate.h" | 14 #include "ui/aura/window_delegate.h" |
| 14 #include "ui/gfx/canvas_skia.h" | 15 #include "ui/gfx/canvas_skia.h" |
| 15 #include "ui/gfx/compositor/layer.h" | 16 #include "ui/gfx/compositor/layer.h" |
| 16 #include "ui/base/keycodes/keyboard_codes.h" | 17 #include "ui/base/keycodes/keyboard_codes.h" |
| 17 | 18 |
| 18 #if !defined(OS_WIN) | 19 #if !defined(OS_WIN) |
| 19 #include "ui/aura/hit_test.h" | 20 #include "ui/aura/hit_test.h" |
| 20 #endif | 21 #endif |
| 21 | 22 |
| 22 namespace aura { | 23 namespace aura { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 ui::KeyboardCode last_key_code_; | 171 ui::KeyboardCode last_key_code_; |
| 171 | 172 |
| 172 DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate); | 173 DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate); |
| 173 }; | 174 }; |
| 174 | 175 |
| 175 class WindowTest : public testing::Test { | 176 class WindowTest : public testing::Test { |
| 176 public: | 177 public: |
| 177 WindowTest() : main_message_loop(MessageLoop::TYPE_UI) { | 178 WindowTest() : main_message_loop(MessageLoop::TYPE_UI) { |
| 178 Desktop::GetInstance()->Show(); | 179 Desktop::GetInstance()->Show(); |
| 179 Desktop::GetInstance()->SetSize(gfx::Size(500, 500)); | 180 Desktop::GetInstance()->SetSize(gfx::Size(500, 500)); |
| 180 if (!Desktop::GetInstance()->default_parent()) | |
| 181 Desktop::GetInstance()->CreateDefaultParentForTesting(); | |
| 182 } | 181 } |
| 183 virtual ~WindowTest() {} | 182 virtual ~WindowTest() {} |
| 184 | 183 |
| 185 // Overridden from testing::Test: | 184 // Overridden from testing::Test: |
| 186 virtual void SetUp() OVERRIDE { | 185 virtual void SetUp() OVERRIDE { |
| 187 } | 186 } |
| 188 | 187 |
| 189 virtual void TearDown() OVERRIDE { | 188 virtual void TearDown() OVERRIDE { |
| 190 } | 189 } |
| 191 | 190 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 207 Window* parent) { | 206 Window* parent) { |
| 208 Window* window = new Window(delegate); | 207 Window* window = new Window(delegate); |
| 209 window->set_id(id); | 208 window->set_id(id); |
| 210 window->Init(); | 209 window->Init(); |
| 211 window->SetBounds(bounds); | 210 window->SetBounds(bounds); |
| 212 window->Show(); | 211 window->Show(); |
| 213 window->SetParent(parent); | 212 window->SetParent(parent); |
| 214 return window; | 213 return window; |
| 215 } | 214 } |
| 216 | 215 |
| 216 protected: |
| 217 Window* toplevel_container() { |
| 218 return desktop_delegate_.default_container(); |
| 219 } |
| 220 |
| 217 private: | 221 private: |
| 218 MessageLoop main_message_loop; | 222 MessageLoop main_message_loop; |
| 223 TestDesktopDelegate desktop_delegate_; |
| 219 | 224 |
| 220 DISALLOW_COPY_AND_ASSIGN(WindowTest); | 225 DISALLOW_COPY_AND_ASSIGN(WindowTest); |
| 221 }; | 226 }; |
| 222 | 227 |
| 223 } // namespace | 228 } // namespace |
| 224 | 229 |
| 225 TEST_F(WindowTest, GetChildById) { | 230 TEST_F(WindowTest, GetChildById) { |
| 226 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); | 231 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); |
| 227 scoped_ptr<Window> w11(CreateTestWindowWithId(11, w1.get())); | 232 scoped_ptr<Window> w11(CreateTestWindowWithId(11, w1.get())); |
| 228 scoped_ptr<Window> w111(CreateTestWindowWithId(111, w11.get())); | 233 scoped_ptr<Window> w111(CreateTestWindowWithId(111, w11.get())); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 259 CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); | 264 CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); |
| 260 scoped_ptr<Window> w12( | 265 scoped_ptr<Window> w12( |
| 261 CreateTestWindow(SK_ColorMAGENTA, 12, gfx::Rect(10, 420, 25, 25), | 266 CreateTestWindow(SK_ColorMAGENTA, 12, gfx::Rect(10, 420, 25, 25), |
| 262 w1.get())); | 267 w1.get())); |
| 263 scoped_ptr<Window> w121( | 268 scoped_ptr<Window> w121( |
| 264 CreateTestWindow(SK_ColorYELLOW, 121, gfx::Rect(5, 5, 5, 5), w12.get())); | 269 CreateTestWindow(SK_ColorYELLOW, 121, gfx::Rect(5, 5, 5, 5), w12.get())); |
| 265 scoped_ptr<Window> w13( | 270 scoped_ptr<Window> w13( |
| 266 CreateTestWindow(SK_ColorGRAY, 13, gfx::Rect(5, 470, 50, 50), w1.get())); | 271 CreateTestWindow(SK_ColorGRAY, 13, gfx::Rect(5, 470, 50, 50), w1.get())); |
| 267 | 272 |
| 268 Window* desktop = Desktop::GetInstance()->window(); | 273 Window* desktop = Desktop::GetInstance()->window(); |
| 269 Desktop::GetInstance()->default_parent()->SetBounds(gfx::Rect(500, 500)); | 274 toplevel_container()->SetBounds(gfx::Rect(500, 500)); |
| 270 EXPECT_EQ(NULL, desktop->GetEventHandlerForPoint(gfx::Point(5, 5))); | 275 EXPECT_EQ(NULL, desktop->GetEventHandlerForPoint(gfx::Point(5, 5))); |
| 271 EXPECT_EQ(w1.get(), desktop->GetEventHandlerForPoint(gfx::Point(11, 11))); | 276 EXPECT_EQ(w1.get(), desktop->GetEventHandlerForPoint(gfx::Point(11, 11))); |
| 272 EXPECT_EQ(w11.get(), desktop->GetEventHandlerForPoint(gfx::Point(16, 16))); | 277 EXPECT_EQ(w11.get(), desktop->GetEventHandlerForPoint(gfx::Point(16, 16))); |
| 273 EXPECT_EQ(w111.get(), desktop->GetEventHandlerForPoint(gfx::Point(21, 21))); | 278 EXPECT_EQ(w111.get(), desktop->GetEventHandlerForPoint(gfx::Point(21, 21))); |
| 274 EXPECT_EQ(w1111.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 26))); | 279 EXPECT_EQ(w1111.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 26))); |
| 275 EXPECT_EQ(w12.get(), desktop->GetEventHandlerForPoint(gfx::Point(21, 431))); | 280 EXPECT_EQ(w12.get(), desktop->GetEventHandlerForPoint(gfx::Point(21, 431))); |
| 276 EXPECT_EQ(w121.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 436))); | 281 EXPECT_EQ(w121.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 436))); |
| 277 EXPECT_EQ(w13.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 481))); | 282 EXPECT_EQ(w13.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 481))); |
| 278 } | 283 } |
| 279 | 284 |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 w->Maximize(); | 739 w->Maximize(); |
| 735 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, w->show_state()); | 740 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, w->show_state()); |
| 736 EXPECT_EQ(max_bounds, w->bounds()); | 741 EXPECT_EQ(max_bounds, w->bounds()); |
| 737 w->Restore(); | 742 w->Restore(); |
| 738 EXPECT_EQ(ui::SHOW_STATE_NORMAL, w->show_state()); | 743 EXPECT_EQ(ui::SHOW_STATE_NORMAL, w->show_state()); |
| 739 EXPECT_EQ(original_bounds, w->bounds()); | 744 EXPECT_EQ(original_bounds, w->bounds()); |
| 740 } | 745 } |
| 741 | 746 |
| 742 } // namespace internal | 747 } // namespace internal |
| 743 } // namespace aura | 748 } // namespace aura |
| OLD | NEW |