| 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/system/tray/system_tray.h" | 5 #include "ash/system/tray/system_tray.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/accessibility_delegate.h" | 9 #include "ash/accessibility_delegate.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 RunAllPendingInMessageLoop(); | 177 RunAllPendingInMessageLoop(); |
| 178 ASSERT_FALSE(tray->draw_background_as_active()); | 178 ASSERT_FALSE(tray->draw_background_as_active()); |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Closing the system bubble through an alignment change should change the | 181 // Closing the system bubble through an alignment change should change the |
| 182 // system tray coloring back to normal. | 182 // system tray coloring back to normal. |
| 183 TEST_F(SystemTrayTest, SystemTrayColoringAfterAlignmentChange) { | 183 TEST_F(SystemTrayTest, SystemTrayColoringAfterAlignmentChange) { |
| 184 SystemTray* tray = GetSystemTray(); | 184 SystemTray* tray = GetSystemTray(); |
| 185 ASSERT_TRUE(tray->GetWidget()); | 185 ASSERT_TRUE(tray->GetWidget()); |
| 186 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 186 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
| 187 shelf->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM); | 187 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 188 // At the beginning the tray coloring is not active. | 188 // At the beginning the tray coloring is not active. |
| 189 ASSERT_FALSE(tray->draw_background_as_active()); | 189 ASSERT_FALSE(tray->draw_background_as_active()); |
| 190 | 190 |
| 191 // Showing the system bubble should show the background as active. | 191 // Showing the system bubble should show the background as active. |
| 192 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 192 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 193 ASSERT_TRUE(tray->draw_background_as_active()); | 193 ASSERT_TRUE(tray->draw_background_as_active()); |
| 194 | 194 |
| 195 // Changing the alignment should close the system bubble and change the | 195 // Changing the alignment should close the system bubble and change the |
| 196 // background color. | 196 // background color. |
| 197 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); | 197 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 198 ASSERT_FALSE(tray->draw_background_as_active()); | 198 ASSERT_FALSE(tray->draw_background_as_active()); |
| 199 RunAllPendingInMessageLoop(); | 199 RunAllPendingInMessageLoop(); |
| 200 // The bubble should already be closed by now. | 200 // The bubble should already be closed by now. |
| 201 ASSERT_FALSE(tray->CloseSystemBubble()); | 201 ASSERT_FALSE(tray->CloseSystemBubble()); |
| 202 } | 202 } |
| 203 | 203 |
| 204 TEST_F(SystemTrayTest, SystemTrayTestItems) { | 204 TEST_F(SystemTrayTest, SystemTrayTestItems) { |
| 205 SystemTray* tray = GetSystemTray(); | 205 SystemTray* tray = GetSystemTray(); |
| 206 ASSERT_TRUE(tray->GetWidget()); | 206 ASSERT_TRUE(tray->GetWidget()); |
| 207 | 207 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 // Tests that the tray is laid out properly and is fully contained within | 352 // Tests that the tray is laid out properly and is fully contained within |
| 353 // the shelf. | 353 // the shelf. |
| 354 TEST_F(SystemTrayTest, TrayBoundsInWidget) { | 354 TEST_F(SystemTrayTest, TrayBoundsInWidget) { |
| 355 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 355 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
| 356 StatusAreaWidget* widget = Shell::GetPrimaryRootWindowController() | 356 StatusAreaWidget* widget = Shell::GetPrimaryRootWindowController() |
| 357 ->shelf_widget() | 357 ->shelf_widget() |
| 358 ->status_area_widget(); | 358 ->status_area_widget(); |
| 359 SystemTray* tray = widget->system_tray(); | 359 SystemTray* tray = widget->system_tray(); |
| 360 | 360 |
| 361 // Test in bottom alignment. | 361 // Test in bottom alignment. |
| 362 shelf->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM); | 362 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 363 gfx::Rect window_bounds = widget->GetWindowBoundsInScreen(); | 363 gfx::Rect window_bounds = widget->GetWindowBoundsInScreen(); |
| 364 gfx::Rect tray_bounds = tray->GetBoundsInScreen(); | 364 gfx::Rect tray_bounds = tray->GetBoundsInScreen(); |
| 365 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); | 365 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); |
| 366 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); | 366 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); |
| 367 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); | 367 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); |
| 368 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); | 368 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); |
| 369 | 369 |
| 370 // Test in locked alignment. | 370 // Test in locked alignment. |
| 371 shelf->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM_LOCKED); | 371 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM_LOCKED); |
| 372 window_bounds = widget->GetWindowBoundsInScreen(); | 372 window_bounds = widget->GetWindowBoundsInScreen(); |
| 373 tray_bounds = tray->GetBoundsInScreen(); | 373 tray_bounds = tray->GetBoundsInScreen(); |
| 374 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); | 374 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); |
| 375 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); | 375 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); |
| 376 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); | 376 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); |
| 377 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); | 377 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); |
| 378 | 378 |
| 379 // Test in the left alignment. | 379 // Test in the left alignment. |
| 380 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); | 380 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 381 window_bounds = widget->GetWindowBoundsInScreen(); | 381 window_bounds = widget->GetWindowBoundsInScreen(); |
| 382 tray_bounds = tray->GetBoundsInScreen(); | 382 tray_bounds = tray->GetBoundsInScreen(); |
| 383 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); | 383 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); |
| 384 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); | 384 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); |
| 385 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); | 385 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); |
| 386 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); | 386 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); |
| 387 | 387 |
| 388 // Test in the right alignment. | 388 // Test in the right alignment. |
| 389 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); | 389 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 390 window_bounds = widget->GetWindowBoundsInScreen(); | 390 window_bounds = widget->GetWindowBoundsInScreen(); |
| 391 tray_bounds = tray->GetBoundsInScreen(); | 391 tray_bounds = tray->GetBoundsInScreen(); |
| 392 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); | 392 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); |
| 393 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); | 393 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); |
| 394 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); | 394 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); |
| 395 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); | 395 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); |
| 396 } | 396 } |
| 397 | 397 |
| 398 TEST_F(SystemTrayTest, PersistentBubble) { | 398 TEST_F(SystemTrayTest, PersistentBubble) { |
| 399 SystemTray* tray = GetSystemTray(); | 399 SystemTray* tray = GetSystemTray(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 // Hide the default view, ensure the system tray height is back to zero. | 569 // Hide the default view, ensure the system tray height is back to zero. |
| 570 ASSERT_TRUE(tray->CloseSystemBubble()); | 570 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 571 RunAllPendingInMessageLoop(); | 571 RunAllPendingInMessageLoop(); |
| 572 | 572 |
| 573 EXPECT_EQ(0, notification_tray->system_tray_height_for_test()); | 573 EXPECT_EQ(0, notification_tray->system_tray_height_for_test()); |
| 574 } | 574 } |
| 575 #endif // OS_CHROMEOS | 575 #endif // OS_CHROMEOS |
| 576 | 576 |
| 577 } // namespace test | 577 } // namespace test |
| 578 } // namespace ash | 578 } // namespace ash |
| OLD | NEW |