Chromium Code Reviews| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 scoped_ptr<FramePainter> painter(new FramePainter); | 116 scoped_ptr<FramePainter> painter(new FramePainter); |
| 117 ASSERT_TRUE(FramePainter::instances_); | 117 ASSERT_TRUE(FramePainter::instances_); |
| 118 EXPECT_EQ(1u, FramePainter::instances_->size()); | 118 EXPECT_EQ(1u, FramePainter::instances_->size()); |
| 119 | 119 |
| 120 // Destroying that painter leaves a valid pointer but no instances. | 120 // Destroying that painter leaves a valid pointer but no instances. |
| 121 painter.reset(); | 121 painter.reset(); |
| 122 ASSERT_TRUE(FramePainter::instances_); | 122 ASSERT_TRUE(FramePainter::instances_); |
| 123 EXPECT_EQ(0u, FramePainter::instances_->size()); | 123 EXPECT_EQ(0u, FramePainter::instances_->size()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 TEST_F(FramePainterTest, CreateAndDeleteSingleWindow) { | |
| 127 // Ensure that creating/deleting a window works well and doesn't cause | |
| 128 // crashes. See crbug.com/155634 | |
| 129 scoped_ptr<Widget> widget(CreateTestWidget()); | |
| 130 scoped_ptr<FramePainter> painter(new FramePainter); | |
| 131 ImageButton size(NULL); | |
| 132 ImageButton close(NULL); | |
| 133 painter->Init( | |
| 134 widget.get(), NULL, &size, &close, FramePainter::SIZE_BUTTON_MAXIMIZES); | |
| 135 widget->Show(); | |
| 136 | |
| 137 // We only have one window, so it should use a solo header. | |
| 138 EXPECT_TRUE(painter->UseSoloWindowHeader()); | |
| 139 | |
| 140 // Close the window. | |
| 141 widget.reset(); | |
|
James Cook
2012/10/16 20:51:46
Maybe after this line assert that the root window
Jun Mukai
2012/10/16 21:11:45
Done.
| |
| 142 | |
| 143 // Recreate another window again. | |
| 144 painter.reset(new FramePainter); | |
| 145 widget.reset(CreateTestWidget()); | |
| 146 | |
| 147 painter->Init( | |
| 148 widget.get(), NULL, &size, &close, FramePainter::SIZE_BUTTON_MAXIMIZES); | |
| 149 widget->Show(); | |
| 150 EXPECT_TRUE(painter->UseSoloWindowHeader()); | |
| 151 } | |
| 152 | |
| 126 TEST_F(FramePainterTest, UseSoloWindowHeader) { | 153 TEST_F(FramePainterTest, UseSoloWindowHeader) { |
| 127 // Create a widget and a painter for it. | 154 // Create a widget and a painter for it. |
| 128 scoped_ptr<Widget> w1(CreateTestWidget()); | 155 scoped_ptr<Widget> w1(CreateTestWidget()); |
| 129 FramePainter p1; | 156 FramePainter p1; |
| 130 ImageButton size1(NULL); | 157 ImageButton size1(NULL); |
| 131 ImageButton close1(NULL); | 158 ImageButton close1(NULL); |
| 132 p1.Init(w1.get(), NULL, &size1, &close1, FramePainter::SIZE_BUTTON_MAXIMIZES); | 159 p1.Init(w1.get(), NULL, &size1, &close1, FramePainter::SIZE_BUTTON_MAXIMIZES); |
| 133 w1->Show(); | 160 w1->Show(); |
| 134 | 161 |
| 135 // We only have one window, so it should use a solo header. | 162 // We only have one window, so it should use a solo header. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 EXPECT_EQ(HTRIGHT, | 381 EXPECT_EQ(HTRIGHT, |
| 355 p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2, | 382 p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2, |
| 356 screen.height() / 2))); | 383 screen.height() / 2))); |
| 357 // A hit into the middle lower area should generate right - not bottom&right. | 384 // A hit into the middle lower area should generate right - not bottom&right. |
| 358 EXPECT_EQ(HTRIGHT, | 385 EXPECT_EQ(HTRIGHT, |
| 359 p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2, | 386 p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2, |
| 360 screen.height() - 1))); | 387 screen.height() - 1))); |
| 361 } | 388 } |
| 362 | 389 |
| 363 } // namespace ash | 390 } // namespace ash |
| OLD | NEW |