| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/frame_painter.h" | 5 #include "ash/wm/frame_painter.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/wm/property_util.h" | 10 #include "ash/wm/property_util.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { | 72 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { |
| 73 window->RemoveObserver(this); | 73 window->RemoveObserver(this); |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool is_paint_scheduled_; | 76 bool is_paint_scheduled_; |
| 77 | 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(WindowRepaintChecker); | 78 DISALLOW_COPY_AND_ASSIGN(WindowRepaintChecker); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 // Creates a test widget that owns its native widget. | |
| 82 Widget* CreateTestWidget() { | |
| 83 Widget* widget = new Widget; | |
| 84 Widget::InitParams params; | |
| 85 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
| 86 widget->Init(params); | |
| 87 return widget; | |
| 88 } | |
| 89 | |
| 90 Widget* CreateAlwaysOnTopWidget() { | |
| 91 Widget* widget = new Widget; | |
| 92 Widget::InitParams params; | |
| 93 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
| 94 params.keep_on_top = true; | |
| 95 widget->Init(params); | |
| 96 return widget; | |
| 97 } | |
| 98 | |
| 99 Widget* CreateResizableWidget() { | |
| 100 Widget* widget = new Widget; | |
| 101 Widget::InitParams params; | |
| 102 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
| 103 params.keep_on_top = true; | |
| 104 params.delegate = new ResizableWidgetDelegate(widget); | |
| 105 params.type = Widget::InitParams::TYPE_WINDOW; | |
| 106 widget->Init(params); | |
| 107 return widget; | |
| 108 } | |
| 109 | |
| 110 } // namespace | 81 } // namespace |
| 111 | 82 |
| 112 namespace ash { | 83 namespace ash { |
| 113 | 84 |
| 114 typedef ash::test::AshTestBase FramePainterTest; | 85 class FramePainterTest : public ash::test::AshTestBase { |
| 86 public: |
| 87 // Creates a test widget that owns its native widget. |
| 88 Widget* CreateTestWidget() { |
| 89 Widget* widget = new Widget; |
| 90 Widget::InitParams params; |
| 91 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 92 params.context = CurrentContext(); |
| 93 widget->Init(params); |
| 94 return widget; |
| 95 } |
| 96 |
| 97 Widget* CreateAlwaysOnTopWidget() { |
| 98 Widget* widget = new Widget; |
| 99 Widget::InitParams params; |
| 100 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 101 params.context = CurrentContext(); |
| 102 params.keep_on_top = true; |
| 103 widget->Init(params); |
| 104 return widget; |
| 105 } |
| 106 |
| 107 Widget* CreateResizableWidget() { |
| 108 Widget* widget = new Widget; |
| 109 Widget::InitParams params; |
| 110 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 111 params.context = CurrentContext(); |
| 112 params.keep_on_top = true; |
| 113 params.delegate = new ResizableWidgetDelegate(widget); |
| 114 params.type = Widget::InitParams::TYPE_WINDOW; |
| 115 widget->Init(params); |
| 116 return widget; |
| 117 } |
| 118 }; |
| 115 | 119 |
| 116 TEST_F(FramePainterTest, Basics) { | 120 TEST_F(FramePainterTest, Basics) { |
| 117 // Other tests might have created a FramePainter, so we cannot assert that | 121 // Other tests might have created a FramePainter, so we cannot assert that |
| 118 // FramePainter::instances_ is NULL here. | 122 // FramePainter::instances_ is NULL here. |
| 119 | 123 |
| 120 // Creating a painter bumps the instance count. | 124 // Creating a painter bumps the instance count. |
| 121 scoped_ptr<FramePainter> painter(new FramePainter); | 125 scoped_ptr<FramePainter> painter(new FramePainter); |
| 122 ASSERT_TRUE(FramePainter::instances_); | 126 ASSERT_TRUE(FramePainter::instances_); |
| 123 EXPECT_EQ(1u, FramePainter::instances_->size()); | 127 EXPECT_EQ(1u, FramePainter::instances_->size()); |
| 124 | 128 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 EXPECT_EQ(HTRIGHT, | 441 EXPECT_EQ(HTRIGHT, |
| 438 p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2, | 442 p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2, |
| 439 screen.height() / 2))); | 443 screen.height() / 2))); |
| 440 // A hit into the middle lower area should generate right - not bottom&right. | 444 // A hit into the middle lower area should generate right - not bottom&right. |
| 441 EXPECT_EQ(HTRIGHT, | 445 EXPECT_EQ(HTRIGHT, |
| 442 p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2, | 446 p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2, |
| 443 screen.height() - 1))); | 447 screen.height() - 1))); |
| 444 } | 448 } |
| 445 | 449 |
| 446 } // namespace ash | 450 } // namespace ash |
| OLD | NEW |