| 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/common/accessibility_delegate.h" | 9 #include "ash/common/accessibility_delegate.h" |
| 10 #include "ash/common/shelf/wm_shelf.h" |
| 10 #include "ash/common/system/tray/system_tray_bubble.h" | 11 #include "ash/common/system/tray/system_tray_bubble.h" |
| 11 #include "ash/common/system/tray/system_tray_item.h" | 12 #include "ash/common/system/tray/system_tray_item.h" |
| 12 #include "ash/common/system/tray/tray_constants.h" | 13 #include "ash/common/system/tray/tray_constants.h" |
| 13 #include "ash/common/system/tray/tray_popup_item_container.h" | 14 #include "ash/common/system/tray/tray_popup_item_container.h" |
| 14 #include "ash/shelf/shelf.h" | |
| 15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 16 #include "ash/system/status_area_widget.h" | 16 #include "ash/system/status_area_widget.h" |
| 17 #include "ash/system/web_notification/web_notification_tray.h" | 17 #include "ash/system/web_notification/web_notification_tray.h" |
| 18 #include "ash/test/ash_test_base.h" | 18 #include "ash/test/ash_test_base.h" |
| 19 #include "ash/test/status_area_widget_test_helper.h" | 19 #include "ash/test/status_area_widget_test_helper.h" |
| 20 #include "ash/wm/window_util.h" | 20 #include "ash/wm/window_util.h" |
| 21 #include "base/run_loop.h" | 21 #include "base/run_loop.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 23 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 24 #include "ui/base/ui_base_types.h" | 24 #include "ui/base/ui_base_types.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 ASSERT_TRUE(tray->CloseSystemBubble()); | 171 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 172 RunAllPendingInMessageLoop(); | 172 RunAllPendingInMessageLoop(); |
| 173 ASSERT_FALSE(tray->draw_background_as_active()); | 173 ASSERT_FALSE(tray->draw_background_as_active()); |
| 174 } | 174 } |
| 175 | 175 |
| 176 // Closing the system bubble through an alignment change should change the | 176 // Closing the system bubble through an alignment change should change the |
| 177 // system tray coloring back to normal. | 177 // system tray coloring back to normal. |
| 178 TEST_F(SystemTrayTest, SystemTrayColoringAfterAlignmentChange) { | 178 TEST_F(SystemTrayTest, SystemTrayColoringAfterAlignmentChange) { |
| 179 SystemTray* tray = GetPrimarySystemTray(); | 179 SystemTray* tray = GetPrimarySystemTray(); |
| 180 ASSERT_TRUE(tray->GetWidget()); | 180 ASSERT_TRUE(tray->GetWidget()); |
| 181 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 181 WmShelf* shelf = GetPrimaryShelf(); |
| 182 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 182 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 183 // At the beginning the tray coloring is not active. | 183 // At the beginning the tray coloring is not active. |
| 184 ASSERT_FALSE(tray->draw_background_as_active()); | 184 ASSERT_FALSE(tray->draw_background_as_active()); |
| 185 | 185 |
| 186 // Showing the system bubble should show the background as active. | 186 // Showing the system bubble should show the background as active. |
| 187 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 187 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 188 ASSERT_TRUE(tray->draw_background_as_active()); | 188 ASSERT_TRUE(tray->draw_background_as_active()); |
| 189 | 189 |
| 190 // Changing the alignment should close the system bubble and change the | 190 // Changing the alignment should close the system bubble and change the |
| 191 // background color. | 191 // background color. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view() | 343 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view() |
| 344 ->GetWidget() | 344 ->GetWidget() |
| 345 ->GetWindowBoundsInScreen() | 345 ->GetWindowBoundsInScreen() |
| 346 .ToString()); | 346 .ToString()); |
| 347 EXPECT_EQ(widget, test_item->default_view()->GetWidget()); | 347 EXPECT_EQ(widget, test_item->default_view()->GetWidget()); |
| 348 } | 348 } |
| 349 | 349 |
| 350 // Tests that the tray view is laid out properly and is fully contained within | 350 // Tests that the tray view is laid out properly and is fully contained within |
| 351 // the shelf widget. | 351 // the shelf widget. |
| 352 TEST_F(SystemTrayTest, TrayBoundsInWidget) { | 352 TEST_F(SystemTrayTest, TrayBoundsInWidget) { |
| 353 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 353 WmShelf* shelf = GetPrimaryShelf(); |
| 354 StatusAreaWidget* widget = StatusAreaWidgetTestHelper::GetStatusAreaWidget(); | 354 StatusAreaWidget* widget = StatusAreaWidgetTestHelper::GetStatusAreaWidget(); |
| 355 SystemTray* tray = GetPrimarySystemTray(); | 355 SystemTray* tray = GetPrimarySystemTray(); |
| 356 | 356 |
| 357 // Test in bottom alignment. | 357 // Test in bottom alignment. |
| 358 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 358 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 359 gfx::Rect window_bounds = widget->GetWindowBoundsInScreen(); | 359 gfx::Rect window_bounds = widget->GetWindowBoundsInScreen(); |
| 360 gfx::Rect tray_bounds = tray->GetBoundsInScreen(); | 360 gfx::Rect tray_bounds = tray->GetBoundsInScreen(); |
| 361 EXPECT_TRUE(window_bounds.Contains(tray_bounds)); | 361 EXPECT_TRUE(window_bounds.Contains(tray_bounds)); |
| 362 | 362 |
| 363 // Test in locked alignment. | 363 // Test in locked alignment. |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 // Hide the default view, ensure the system tray height is back to zero. | 547 // Hide the default view, ensure the system tray height is back to zero. |
| 548 ASSERT_TRUE(tray->CloseSystemBubble()); | 548 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 549 RunAllPendingInMessageLoop(); | 549 RunAllPendingInMessageLoop(); |
| 550 | 550 |
| 551 EXPECT_EQ(0, notification_tray->system_tray_height_for_test()); | 551 EXPECT_EQ(0, notification_tray->system_tray_height_for_test()); |
| 552 } | 552 } |
| 553 #endif // OS_CHROMEOS | 553 #endif // OS_CHROMEOS |
| 554 | 554 |
| 555 } // namespace test | 555 } // namespace test |
| 556 } // namespace ash | 556 } // namespace ash |
| OLD | NEW |