Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ash / system / tray / media_security / multi_profile_media_tray_item_unittest.cc
blob1dcfeaa5129e4c1ce1915de2c811a0beeea9adc3
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
3 // found in the LICENSE file.
5 #include "ash/system/tray/media_security/multi_profile_media_tray_item.h"
7 #include "ash/ash_view_ids.h"
8 #include "ash/shell.h"
9 #include "ash/system/status_area_widget.h"
10 #include "ash/system/tray/system_tray.h"
11 #include "ash/system/tray/system_tray_bubble.h"
12 #include "ash/system/tray/tray_item_view.h"
13 #include "ash/test/ash_test_base.h"
14 #include "ash/test/test_session_state_delegate.h"
15 #include "ash/test/test_shell_delegate.h"
16 #include "ui/views/bubble/tray_bubble_view.h"
18 namespace ash {
20 typedef test::AshTestBase MultiProfileMediaTrayItemTest;
22 TEST_F(MultiProfileMediaTrayItemTest, NotifyMediaCaptureChange) {
23 TrayItemView::DisableAnimationsForTest();
24 test::TestShellDelegate* shell_delegate =
25 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate());
26 test::TestSessionStateDelegate* session_state_delegate =
27 static_cast<test::TestSessionStateDelegate*>(
28 Shell::GetInstance()->session_state_delegate());
29 session_state_delegate->set_logged_in_users(2);
31 SystemTray* system_tray = Shell::GetInstance()->GetPrimarySystemTray();
32 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
33 views::View* in_user_view =
34 system_tray->GetSystemBubble()->bubble_view()->GetViewByID(
35 VIEW_ID_USER_VIEW_MEDIA_INDICATOR);
37 StatusAreaWidget* widget = system_tray->status_area_widget();
38 EXPECT_TRUE(widget->GetRootView()->visible());
39 views::View* tray_view =
40 widget->GetRootView()->GetViewByID(VIEW_ID_MEDIA_TRAY_VIEW);
42 EXPECT_FALSE(tray_view->visible());
43 EXPECT_FALSE(in_user_view->visible());
45 shell_delegate->SetMediaCaptureState(MEDIA_CAPTURE_AUDIO);
46 EXPECT_TRUE(tray_view->visible());
47 EXPECT_TRUE(in_user_view->visible());
49 shell_delegate->SetMediaCaptureState(MEDIA_CAPTURE_AUDIO_VIDEO);
50 EXPECT_TRUE(tray_view->visible());
51 EXPECT_TRUE(in_user_view->visible());
53 shell_delegate->SetMediaCaptureState(MEDIA_CAPTURE_NONE);
54 EXPECT_FALSE(tray_view->visible());
55 EXPECT_FALSE(in_user_view->visible());
58 } // namespace ash