OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/media_security/multi_profile_media_tray_item.h" | 5 #include "ash/system/tray/media_security/multi_profile_media_tray_item.h" |
6 | 6 |
7 #include "ash/ash_view_ids.h" | 7 #include "ash/ash_view_ids.h" |
8 #include "ash/common/system/tray/system_tray_bubble.h" | |
9 #include "ash/common/system/tray/tray_item_view.h" | 8 #include "ash/common/system/tray/tray_item_view.h" |
| 9 #include "ash/shell.h" |
10 #include "ash/system/status_area_widget.h" | 10 #include "ash/system/status_area_widget.h" |
11 #include "ash/system/tray/system_tray.h" | 11 #include "ash/system/tray/system_tray.h" |
| 12 #include "ash/system/tray/system_tray_bubble.h" |
12 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
13 #include "ash/test/ash_test_helper.h" | |
14 #include "ash/test/status_area_widget_test_helper.h" | |
15 #include "ash/test/test_session_state_delegate.h" | 14 #include "ash/test/test_session_state_delegate.h" |
16 #include "ash/test/test_shell_delegate.h" | 15 #include "ash/test/test_shell_delegate.h" |
17 #include "ui/views/bubble/tray_bubble_view.h" | 16 #include "ui/views/bubble/tray_bubble_view.h" |
18 | 17 |
19 namespace ash { | 18 namespace ash { |
20 | 19 |
21 typedef test::AshTestBase MultiProfileMediaTrayItemTest; | 20 typedef test::AshTestBase MultiProfileMediaTrayItemTest; |
22 | 21 |
23 TEST_F(MultiProfileMediaTrayItemTest, NotifyMediaCaptureChange) { | 22 TEST_F(MultiProfileMediaTrayItemTest, NotifyMediaCaptureChange) { |
24 TrayItemView::DisableAnimationsForTest(); | 23 TrayItemView::DisableAnimationsForTest(); |
25 test::TestShellDelegate* shell_delegate = | 24 test::TestShellDelegate* shell_delegate = |
26 ash_test_helper()->test_shell_delegate(); | 25 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate()); |
27 test::TestSessionStateDelegate* session_state_delegate = | 26 test::TestSessionStateDelegate* session_state_delegate = |
28 test::AshTestHelper::GetTestSessionStateDelegate(); | 27 static_cast<test::TestSessionStateDelegate*>( |
| 28 Shell::GetInstance()->session_state_delegate()); |
29 session_state_delegate->set_logged_in_users(2); | 29 session_state_delegate->set_logged_in_users(2); |
30 | 30 |
31 SystemTray* system_tray = GetPrimarySystemTray(); | 31 SystemTray* system_tray = Shell::GetInstance()->GetPrimarySystemTray(); |
32 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 32 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
33 views::View* in_user_view = | 33 views::View* in_user_view = |
34 system_tray->GetSystemBubble()->bubble_view()->GetViewByID( | 34 system_tray->GetSystemBubble()->bubble_view()->GetViewByID( |
35 VIEW_ID_USER_VIEW_MEDIA_INDICATOR); | 35 VIEW_ID_USER_VIEW_MEDIA_INDICATOR); |
36 | 36 |
37 StatusAreaWidget* widget = StatusAreaWidgetTestHelper::GetStatusAreaWidget(); | 37 StatusAreaWidget* widget = system_tray->status_area_widget(); |
38 EXPECT_TRUE(widget->GetRootView()->visible()); | 38 EXPECT_TRUE(widget->GetRootView()->visible()); |
39 views::View* tray_view = | 39 views::View* tray_view = |
40 widget->GetRootView()->GetViewByID(VIEW_ID_MEDIA_TRAY_VIEW); | 40 widget->GetRootView()->GetViewByID(VIEW_ID_MEDIA_TRAY_VIEW); |
41 | 41 |
42 EXPECT_FALSE(tray_view->visible()); | 42 EXPECT_FALSE(tray_view->visible()); |
43 EXPECT_FALSE(in_user_view->visible()); | 43 EXPECT_FALSE(in_user_view->visible()); |
44 | 44 |
45 shell_delegate->SetMediaCaptureState(MEDIA_CAPTURE_AUDIO); | 45 shell_delegate->SetMediaCaptureState(MEDIA_CAPTURE_AUDIO); |
46 EXPECT_TRUE(tray_view->visible()); | 46 EXPECT_TRUE(tray_view->visible()); |
47 EXPECT_TRUE(in_user_view->visible()); | 47 EXPECT_TRUE(in_user_view->visible()); |
48 | 48 |
49 shell_delegate->SetMediaCaptureState(MEDIA_CAPTURE_AUDIO_VIDEO); | 49 shell_delegate->SetMediaCaptureState(MEDIA_CAPTURE_AUDIO_VIDEO); |
50 EXPECT_TRUE(tray_view->visible()); | 50 EXPECT_TRUE(tray_view->visible()); |
51 EXPECT_TRUE(in_user_view->visible()); | 51 EXPECT_TRUE(in_user_view->visible()); |
52 | 52 |
53 shell_delegate->SetMediaCaptureState(MEDIA_CAPTURE_NONE); | 53 shell_delegate->SetMediaCaptureState(MEDIA_CAPTURE_NONE); |
54 EXPECT_FALSE(tray_view->visible()); | 54 EXPECT_FALSE(tray_view->visible()); |
55 EXPECT_FALSE(in_user_view->visible()); | 55 EXPECT_FALSE(in_user_view->visible()); |
56 } | 56 } |
57 | 57 |
58 } // namespace ash | 58 } // namespace ash |
OLD | NEW |