| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/shelf/shelf_widget.h" | 5 #include "ash/shelf/shelf_widget.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/launcher/launcher_button.h" | 8 #include "ash/launcher/launcher_button.h" |
| 9 #include "ash/launcher/launcher_model.h" | 9 #include "ash/launcher/launcher_model.h" |
| 10 #include "ash/launcher/launcher_view.h" | 10 #include "ash/launcher/launcher_view.h" |
| 11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 12 #include "ash/shelf/shelf_layout_manager.h" | 12 #include "ash/shelf/shelf_layout_manager.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
| 15 #include "ash/test/launcher_test_api.h" |
| 15 #include "ash/test/launcher_view_test_api.h" | 16 #include "ash/test/launcher_view_test_api.h" |
| 16 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
| 17 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
| 18 #include "ui/gfx/display.h" | 19 #include "ui/gfx/display.h" |
| 19 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 20 #include "ui/views/corewm/corewm_switches.h" | 21 #include "ui/views/corewm/corewm_switches.h" |
| 21 #include "ui/views/view.h" | 22 #include "ui/views/view.h" |
| 22 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 23 | 24 |
| 24 namespace ash { | 25 namespace ash { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 Launcher* launcher = shelf_widget->launcher(); | 134 Launcher* launcher = shelf_widget->launcher(); |
| 134 ASSERT_TRUE(launcher); | 135 ASSERT_TRUE(launcher); |
| 135 internal::ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); | 136 internal::ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); |
| 136 ASSERT_TRUE(shelf_layout_manager); | 137 ASSERT_TRUE(shelf_layout_manager); |
| 137 ASSERT_TRUE(shelf_widget->status_area_widget()); | 138 ASSERT_TRUE(shelf_widget->status_area_widget()); |
| 138 int status_width = shelf_widget->status_area_widget()-> | 139 int status_width = shelf_widget->status_area_widget()-> |
| 139 GetWindowBoundsInScreen().width(); | 140 GetWindowBoundsInScreen().width(); |
| 140 // Test only makes sense if the status is > 0, which it better be. | 141 // Test only makes sense if the status is > 0, which it better be. |
| 141 EXPECT_GT(status_width, 0); | 142 EXPECT_GT(status_width, 0); |
| 142 EXPECT_EQ(status_width, shelf_widget->GetContentsView()->width() - | 143 EXPECT_EQ(status_width, shelf_widget->GetContentsView()->width() - |
| 143 launcher->GetLauncherViewForTest()->width()); | 144 test::LauncherTestAPI(launcher).launcher_view()->width()); |
| 144 } | 145 } |
| 145 | 146 |
| 146 // Verifies when the shell is deleted with a full screen window we don't crash. | 147 // Verifies when the shell is deleted with a full screen window we don't crash. |
| 147 TEST_F(ShelfWidgetTest, DontReferenceLauncherAfterDeletion) { | 148 TEST_F(ShelfWidgetTest, DontReferenceLauncherAfterDeletion) { |
| 148 views::Widget* widget = new views::Widget; | 149 views::Widget* widget = new views::Widget; |
| 149 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 150 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 150 params.bounds = gfx::Rect(0, 0, 200, 200); | 151 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 151 params.context = CurrentContext(); | 152 params.context = CurrentContext(); |
| 152 // Widget is now owned by the parent window. | 153 // Widget is now owned by the parent window. |
| 153 widget->Init(params); | 154 widget->Init(params); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 179 Shell::GetInstance()->CreateLauncher(); | 180 Shell::GetInstance()->CreateLauncher(); |
| 180 | 181 |
| 181 Launcher* launcher = shelf->launcher(); | 182 Launcher* launcher = shelf->launcher(); |
| 182 ASSERT_TRUE(launcher != NULL); | 183 ASSERT_TRUE(launcher != NULL); |
| 183 | 184 |
| 184 const int status_width = | 185 const int status_width = |
| 185 shelf->status_area_widget()->GetWindowBoundsInScreen().width(); | 186 shelf->status_area_widget()->GetWindowBoundsInScreen().width(); |
| 186 EXPECT_GT(status_width, 0); | 187 EXPECT_GT(status_width, 0); |
| 187 EXPECT_EQ(status_width, | 188 EXPECT_EQ(status_width, |
| 188 shelf->GetContentsView()->width() - | 189 shelf->GetContentsView()->width() - |
| 189 launcher->GetLauncherViewForTest()->width()); | 190 test::LauncherTestAPI(launcher).launcher_view()->width()); |
| 190 } | 191 } |
| 191 #endif | 192 #endif |
| 192 | 193 |
| 193 } // namespace ash | 194 } // namespace ash |
| OLD | NEW |