| 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/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/shelf/shelf_widget.h" |
| 10 #include "ash/system/status_area_widget.h" | 11 #include "ash/system/status_area_widget.h" |
| 11 #include "ash/system/tray/system_tray_item.h" | 12 #include "ash/system/tray/system_tray_item.h" |
| 12 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
| 13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 14 #include "ui/views/controls/label.h" | 15 #include "ui/views/controls/label.h" |
| 15 #include "ui/views/layout/fill_layout.h" | 16 #include "ui/views/layout/fill_layout.h" |
| 16 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
| 17 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 18 | 19 |
| 19 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 20 #include "base/win/windows_version.h" | 21 #include "base/win/windows_version.h" |
| 21 #endif | 22 #endif |
| 22 | 23 |
| 23 namespace ash { | 24 namespace ash { |
| 24 namespace test { | 25 namespace test { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 SystemTray* GetSystemTray() { | 29 SystemTray* GetSystemTray() { |
| 29 return Shell::GetPrimaryRootWindowController()->status_area_widget()-> | 30 return Shell::GetPrimaryRootWindowController()->shelf()-> |
| 30 system_tray(); | 31 status_area_widget()->system_tray(); |
| 31 } | 32 } |
| 32 | 33 |
| 33 // Trivial item implementation that tracks its views for testing. | 34 // Trivial item implementation that tracks its views for testing. |
| 34 class TestItem : public SystemTrayItem { | 35 class TestItem : public SystemTrayItem { |
| 35 public: | 36 public: |
| 36 TestItem() : SystemTrayItem(GetSystemTray()), tray_view_(NULL) {} | 37 TestItem() : SystemTrayItem(GetSystemTray()), tray_view_(NULL) {} |
| 37 | 38 |
| 38 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE { | 39 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE { |
| 39 tray_view_ = new views::View; | 40 tray_view_ = new views::View; |
| 40 // Add a label so it has non-zero width. | 41 // Add a label so it has non-zero width. |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 282 |
| 282 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()-> | 283 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()-> |
| 283 GetWindowBoundsInScreen().ToString()); | 284 GetWindowBoundsInScreen().ToString()); |
| 284 EXPECT_EQ(widget, test_item->default_view()->GetWidget()); | 285 EXPECT_EQ(widget, test_item->default_view()->GetWidget()); |
| 285 } | 286 } |
| 286 | 287 |
| 287 // Tests that the tray is laid out properly in the widget to make sure that the | 288 // Tests that the tray is laid out properly in the widget to make sure that the |
| 288 // tray extends to the correct edge of the screen. | 289 // tray extends to the correct edge of the screen. |
| 289 TEST_F(SystemTrayTest, TrayBoundsInWidget) { | 290 TEST_F(SystemTrayTest, TrayBoundsInWidget) { |
| 290 internal::StatusAreaWidget* widget = | 291 internal::StatusAreaWidget* widget = |
| 291 Shell::GetPrimaryRootWindowController()->status_area_widget(); | 292 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); |
| 292 SystemTray* tray = widget->system_tray(); | 293 SystemTray* tray = widget->system_tray(); |
| 293 | 294 |
| 294 // Test in bottom alignment. Bottom and right edges of the view should be | 295 // Test in bottom alignment. Bottom and right edges of the view should be |
| 295 // aligned with the widget. | 296 // aligned with the widget. |
| 296 widget->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM); | 297 widget->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 297 gfx::Rect window_bounds = widget->GetWindowBoundsInScreen(); | 298 gfx::Rect window_bounds = widget->GetWindowBoundsInScreen(); |
| 298 gfx::Rect tray_bounds = tray->GetBoundsInScreen(); | 299 gfx::Rect tray_bounds = tray->GetBoundsInScreen(); |
| 299 EXPECT_EQ(window_bounds.bottom(), tray_bounds.bottom()); | 300 EXPECT_EQ(window_bounds.bottom(), tray_bounds.bottom()); |
| 300 EXPECT_EQ(window_bounds.right(), tray_bounds.right()); | 301 EXPECT_EQ(window_bounds.right(), tray_bounds.right()); |
| 301 | 302 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 316 // Test in the right alignment. Right and bottom edges should match. | 317 // Test in the right alignment. Right and bottom edges should match. |
| 317 widget->SetShelfAlignment(SHELF_ALIGNMENT_LEFT); | 318 widget->SetShelfAlignment(SHELF_ALIGNMENT_LEFT); |
| 318 window_bounds = widget->GetWindowBoundsInScreen(); | 319 window_bounds = widget->GetWindowBoundsInScreen(); |
| 319 tray_bounds = tray->GetBoundsInScreen(); | 320 tray_bounds = tray->GetBoundsInScreen(); |
| 320 EXPECT_EQ(window_bounds.bottom(), tray_bounds.bottom()); | 321 EXPECT_EQ(window_bounds.bottom(), tray_bounds.bottom()); |
| 321 EXPECT_EQ(window_bounds.right(), tray_bounds.right()); | 322 EXPECT_EQ(window_bounds.right(), tray_bounds.right()); |
| 322 } | 323 } |
| 323 | 324 |
| 324 } // namespace test | 325 } // namespace test |
| 325 } // namespace ash | 326 } // namespace ash |
| OLD | NEW |