| 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/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
| 10 #include "ash/shelf/shelf_delegate.h" | 10 #include "ash/shelf/shelf_delegate.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 ShelfWidget* GetShelfWidget() { | 31 ShelfWidget* GetShelfWidget() { |
| 32 return Shelf::ForPrimaryDisplay()->shelf_widget(); | 32 return Shelf::ForPrimaryDisplay()->shelf_widget(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 ShelfLayoutManager* GetShelfLayoutManager() { | 35 ShelfLayoutManager* GetShelfLayoutManager() { |
| 36 return GetShelfWidget()->shelf_layout_manager(); | 36 return GetShelfWidget()->shelf_layout_manager(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 using ShelfWidgetTest = test::AshMDTestBase; | 41 using ShelfWidgetTest = test::AshMDTestBase; |
| 42 | 42 |
| 43 INSTANTIATE_TEST_CASE_P( | 43 INSTANTIATE_TEST_CASE_P( |
| 44 /* prefix intentionally left blank due to only one parameterization */, | 44 /* prefix intentionally left blank due to only one parameterization */, |
| 45 ShelfWidgetTest, | 45 ShelfWidgetTest, |
| 46 testing::Values(MaterialDesignController::NON_MATERIAL, | 46 testing::Values(MaterialDesignController::NON_MATERIAL, |
| 47 MaterialDesignController::MATERIAL_NORMAL, | 47 MaterialDesignController::MATERIAL_NORMAL, |
| 48 MaterialDesignController::MATERIAL_EXPERIMENTAL)); | 48 MaterialDesignController::MATERIAL_EXPERIMENTAL)); |
| 49 | 49 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 #endif // defined(OS_CHROMEOS) | 137 #endif // defined(OS_CHROMEOS) |
| 138 | 138 |
| 139 // Makes sure the shelf is initially sized correctly. | 139 // Makes sure the shelf is initially sized correctly. |
| 140 TEST_P(ShelfWidgetTest, LauncherInitiallySized) { | 140 TEST_P(ShelfWidgetTest, LauncherInitiallySized) { |
| 141 ShelfWidget* shelf_widget = GetShelfWidget(); | 141 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 142 Shelf* shelf = shelf_widget->shelf(); | 142 Shelf* shelf = shelf_widget->shelf(); |
| 143 ASSERT_TRUE(shelf); | 143 ASSERT_TRUE(shelf); |
| 144 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); | 144 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); |
| 145 ASSERT_TRUE(shelf_layout_manager); | 145 ASSERT_TRUE(shelf_layout_manager); |
| 146 ASSERT_TRUE(shelf_widget->status_area_widget()); | 146 ASSERT_TRUE(shelf_widget->status_area_widget()); |
| 147 int status_width = shelf_widget->status_area_widget()-> | 147 int status_width = |
| 148 GetWindowBoundsInScreen().width(); | 148 shelf_widget->status_area_widget()->GetWindowBoundsInScreen().width(); |
| 149 // Test only makes sense if the status is > 0, which it better be. | 149 // Test only makes sense if the status is > 0, which it better be. |
| 150 EXPECT_GT(status_width, 0); | 150 EXPECT_GT(status_width, 0); |
| 151 EXPECT_EQ(status_width, shelf_widget->GetContentsView()->width() - | 151 EXPECT_EQ(status_width, shelf_widget->GetContentsView()->width() - |
| 152 test::ShelfTestAPI(shelf).shelf_view()->width()); | 152 test::ShelfTestAPI(shelf).shelf_view()->width()); |
| 153 } | 153 } |
| 154 | 154 |
| 155 // Verifies when the shell is deleted with a full screen window we don't crash. | 155 // Verifies when the shell is deleted with a full screen window we don't crash. |
| 156 TEST_P(ShelfWidgetTest, DontReferenceShelfAfterDeletion) { | 156 TEST_P(ShelfWidgetTest, DontReferenceShelfAfterDeletion) { |
| 157 views::Widget* widget = new views::Widget; | 157 views::Widget* widget = new views::Widget; |
| 158 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 158 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 159 params.bounds = gfx::Rect(0, 0, 200, 200); | 159 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 160 params.context = CurrentContext(); | 160 params.context = CurrentContext(); |
| 161 // Widget is now owned by the parent window. | 161 // Widget is now owned by the parent window. |
| 162 widget->Init(params); | 162 widget->Init(params); |
| 163 widget->SetFullscreen(true); | 163 widget->SetFullscreen(true); |
| 164 } | 164 } |
| 165 | 165 |
| 166 #if defined(OS_CHROMEOS) | 166 #if defined(OS_CHROMEOS) |
| 167 // Verifies shelf is created with correct size after user login and when its | 167 // Verifies shelf is created with correct size after user login and when its |
| 168 // container and status widget has finished sizing. | 168 // container and status widget has finished sizing. |
| 169 // See http://crbug.com/252533 | 169 // See http://crbug.com/252533 |
| 170 TEST_P(ShelfWidgetTest, ShelfInitiallySizedAfterLogin) { | 170 TEST_P(ShelfWidgetTest, ShelfInitiallySizedAfterLogin) { |
| 171 SetUserLoggedIn(false); | 171 SetUserLoggedIn(false); |
| 172 UpdateDisplay("300x200,400x300"); | 172 UpdateDisplay("300x200,400x300"); |
| 173 | 173 |
| 174 ShelfWidget* shelf_widget = NULL; | 174 ShelfWidget* shelf_widget = NULL; |
| 175 Shell::RootWindowControllerList controllers( | 175 Shell::RootWindowControllerList controllers( |
| 176 Shell::GetAllRootWindowControllers()); | 176 Shell::GetAllRootWindowControllers()); |
| 177 for (Shell::RootWindowControllerList::const_iterator i = controllers.begin(); | 177 for (Shell::RootWindowControllerList::const_iterator i = controllers.begin(); |
| 178 i != controllers.end(); | 178 i != controllers.end(); ++i) { |
| 179 ++i) { | |
| 180 if (!(*i)->shelf_widget()->shelf()) { | 179 if (!(*i)->shelf_widget()->shelf()) { |
| 181 shelf_widget = (*i)->shelf_widget(); | 180 shelf_widget = (*i)->shelf_widget(); |
| 182 break; | 181 break; |
| 183 } | 182 } |
| 184 } | 183 } |
| 185 ASSERT_TRUE(shelf_widget != NULL); | 184 ASSERT_TRUE(shelf_widget != NULL); |
| 186 | 185 |
| 187 SetUserLoggedIn(true); | 186 SetUserLoggedIn(true); |
| 188 Shell::GetInstance()->CreateShelf(); | 187 Shell::GetInstance()->CreateShelf(); |
| 189 | 188 |
| 190 Shelf* shelf = shelf_widget->shelf(); | 189 Shelf* shelf = shelf_widget->shelf(); |
| 191 ASSERT_TRUE(shelf != NULL); | 190 ASSERT_TRUE(shelf != NULL); |
| 192 | 191 |
| 193 const int status_width = | 192 const int status_width = |
| 194 shelf_widget->status_area_widget()->GetWindowBoundsInScreen().width(); | 193 shelf_widget->status_area_widget()->GetWindowBoundsInScreen().width(); |
| 195 EXPECT_GT(status_width, 0); | 194 EXPECT_GT(status_width, 0); |
| 196 EXPECT_EQ(status_width, | 195 EXPECT_EQ(status_width, shelf_widget->GetContentsView()->width() - |
| 197 shelf_widget->GetContentsView()->width() - | 196 test::ShelfTestAPI(shelf).shelf_view()->width()); |
| 198 test::ShelfTestAPI(shelf).shelf_view()->width()); | |
| 199 } | 197 } |
| 200 #endif // defined(OS_CHROMEOS) | 198 #endif // defined(OS_CHROMEOS) |
| 201 | 199 |
| 202 // Tests that the shelf lets mouse-events close to the edge fall through to the | 200 // Tests that the shelf lets mouse-events close to the edge fall through to the |
| 203 // window underneath. | 201 // window underneath. |
| 204 TEST_P(ShelfWidgetTest, ShelfEdgeOverlappingWindowHitTestMouse) { | 202 TEST_P(ShelfWidgetTest, ShelfEdgeOverlappingWindowHitTestMouse) { |
| 205 if (!SupportsHostWindowResize()) | 203 if (!SupportsHostWindowResize()) |
| 206 return; | 204 return; |
| 207 | 205 |
| 208 UpdateDisplay("400x400"); | 206 UpdateDisplay("400x400"); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 } | 478 } |
| 481 | 479 |
| 482 TEST_P(ShelfWidgetTestWithDelegate, CreateLockedShelf) { | 480 TEST_P(ShelfWidgetTestWithDelegate, CreateLockedShelf) { |
| 483 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. | 481 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. |
| 484 TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_BOTTOM_LOCKED, | 482 TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_BOTTOM_LOCKED, |
| 485 SHELF_AUTO_HIDE_BEHAVIOR_NEVER, | 483 SHELF_AUTO_HIDE_BEHAVIOR_NEVER, |
| 486 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN); | 484 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN); |
| 487 } | 485 } |
| 488 | 486 |
| 489 } // namespace ash | 487 } // namespace ash |
| OLD | NEW |