- add sources.
[platform/framework/web/crosswalk.git] / src / ash / test / test_system_tray_delegate.cc
1 // Copyright 2013 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.
4
5 #include "ash/test/test_system_tray_delegate.h"
6
7 #include <string>
8
9 #include "ash/session_state_delegate.h"
10 #include "ash/shell.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/time/time.h"
13
14 namespace ash {
15 namespace test {
16
17 namespace {
18
19 user::LoginStatus g_initial_status = user::LOGGED_IN_USER;
20
21 }  // namespace
22
23 TestSystemTrayDelegate::TestSystemTrayDelegate()
24     : should_show_display_notification_(false),
25       login_status_(g_initial_status) {
26 }
27
28 TestSystemTrayDelegate::~TestSystemTrayDelegate() {
29 }
30
31 // static
32 void TestSystemTrayDelegate::SetInitialLoginStatus(
33     user::LoginStatus login_status) {
34   g_initial_status = login_status;
35 }
36
37 void TestSystemTrayDelegate::SetLoginStatus(user::LoginStatus login_status) {
38   login_status_ = login_status;
39   Shell::GetInstance()->UpdateAfterLoginStatusChange(login_status);
40 }
41
42 user::LoginStatus TestSystemTrayDelegate::GetUserLoginStatus() const {
43   // Initial login status has been changed for testing.
44   if (g_initial_status != user::LOGGED_IN_USER &&
45       g_initial_status == login_status_) {
46     return login_status_;
47   }
48
49   // At new user image screen manager->IsUserLoggedIn() would return true
50   // but there's no browser session available yet so use SessionStarted().
51   SessionStateDelegate* delegate =
52       Shell::GetInstance()->session_state_delegate();
53
54   if (!delegate->IsActiveUserSessionStarted())
55     return ash::user::LOGGED_IN_NONE;
56   if (delegate->IsScreenLocked())
57     return user::LOGGED_IN_LOCKED;
58   return login_status_;
59 }
60
61 bool TestSystemTrayDelegate::ShouldShowDisplayNotification() {
62   return should_show_display_notification_;
63 }
64
65 void TestSystemTrayDelegate::ShutDown() {
66   base::MessageLoop::current()->Quit();
67 }
68
69 void TestSystemTrayDelegate::SignOut() {
70   base::MessageLoop::current()->Quit();
71 }
72
73 }  // namespace test
74 }  // namespace ash