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" |
11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/system/status_area_widget.h" | 14 #include "ash/system/status_area_widget.h" |
15 #include "ash/system/tray/system_tray_item.h" | 15 #include "ash/system/tray/system_tray_item.h" |
16 #include "ash/system/tray/tray_constants.h" | 16 #include "ash/system/tray/tray_constants.h" |
17 #include "ash/test/ash_test_base.h" | 17 #include "ash/test/ash_test_base.h" |
18 #include "ash/wm/window_util.h" | 18 #include "ash/wm/window_util.h" |
19 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "ui/aura/test/event_generator.h" | 21 #include "ui/aura/test/event_generator.h" |
22 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
23 #include "ui/base/ui_base_types.h" | 23 #include "ui/base/ui_base_types.h" |
| 24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
24 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
25 #include "ui/views/controls/label.h" | 26 #include "ui/views/controls/label.h" |
26 #include "ui/views/layout/fill_layout.h" | 27 #include "ui/views/layout/fill_layout.h" |
27 #include "ui/views/view.h" | 28 #include "ui/views/view.h" |
28 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
29 #include "ui/views/widget/widget_delegate.h" | 30 #include "ui/views/widget/widget_delegate.h" |
30 | 31 |
31 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
32 #include "base/win/windows_version.h" | 33 #include "base/win/windows_version.h" |
33 #endif | 34 #endif |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 ASSERT_TRUE(accessibility); | 477 ASSERT_TRUE(accessibility); |
477 EXPECT_TRUE(accessibility->visible()); | 478 EXPECT_TRUE(accessibility->visible()); |
478 | 479 |
479 const views::View* settings = | 480 const views::View* settings = |
480 tray->GetSystemBubble()->bubble_view()->GetViewByID( | 481 tray->GetSystemBubble()->bubble_view()->GetViewByID( |
481 test::kSettingsTrayItemViewId); | 482 test::kSettingsTrayItemViewId); |
482 ASSERT_TRUE(settings); | 483 ASSERT_TRUE(settings); |
483 EXPECT_TRUE(settings->visible()); | 484 EXPECT_TRUE(settings->visible()); |
484 } | 485 } |
485 | 486 |
| 487 // Tests that if SetVisible(true) is called while animating to hidden that the |
| 488 // tray becomes visible, and stops animating to hidden. |
| 489 TEST_F(SystemTrayTest, SetVisibleDuringHideAnimation) { |
| 490 SystemTray* tray = GetSystemTray(); |
| 491 ASSERT_TRUE(tray->visible()); |
| 492 |
| 493 scoped_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration; |
| 494 animation_duration.reset( |
| 495 new ui::ScopedAnimationDurationScaleMode( |
| 496 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); |
| 497 tray->SetVisible(false); |
| 498 EXPECT_TRUE(tray->visible()); |
| 499 EXPECT_EQ(0.0f, tray->layer()->GetTargetOpacity()); |
| 500 |
| 501 tray->SetVisible(true); |
| 502 animation_duration.reset(); |
| 503 tray->layer()->GetAnimator()->StopAnimating(); |
| 504 EXPECT_TRUE(tray->visible()); |
| 505 EXPECT_EQ(1.0f, tray->layer()->GetTargetOpacity()); |
| 506 } |
| 507 |
486 } // namespace test | 508 } // namespace test |
487 } // namespace ash | 509 } // namespace ash |
OLD | NEW |