Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: ash/common/test/test_session_controller_client.h

Issue 2734933004: ash: Use SessionController instead of SessionStateDelegate (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 #ifndef ASH_COMMON_TEST_TEST_SESSION_CONTROLLER_CLIENT_H_
6 #define ASH_COMMON_TEST_TEST_SESSION_CONTROLLER_CLIENT_H_
7
8 #include <stdint.h>
9
10 #include <string>
11
12 #include "ash/public/interfaces/session_controller.mojom.h"
13 #include "base/macros.h"
14 #include "mojo/public/cpp/bindings/binding.h"
15
16 class AccountId;
17
18 namespace ash {
19
20 class SessionController;
21
22 namespace test {
23
24 // Helper class to mock user sessions in unit tests.
25 // Note that tests that have an instance of SessionControllerClient should
26 // NOT use this.
James Cook 2017/03/17 17:14:36 nit: Maybe add to comment an example of that kind
xiyuan 2017/03/17 22:52:02 Done.
27 class TestSessionControllerClient : public ash::mojom::SessionControllerClient {
28 public:
29 explicit TestSessionControllerClient(SessionController* controller);
30 ~TestSessionControllerClient() override;
31
32 // Initialize using existing info in |controller| and bind as its client.
33 void InitializeAndBind();
34
35 // Sets up the default state of SessionController.
36 void Reset();
37
38 // Helpers to set SessionController state.
39 void SetCanLockScreen(bool can_lock);
40 void SetShouldLockScreenAutomatically(bool should_lock);
41 void SetSessionState(session_manager::SessionState state);
42
43 // Sets the |count| pre-defined user sessions. The first four user session
James Cook 2017/03/17 17:14:36 super nit: "Creates |count| pre-defined user sessi
xiyuan 2017/03/17 22:52:02 Done.
44 // have special names that are used in a few tests. After that, the users
45 // are named by numbers using "user%d@tray" template.
46 // Note that existing user sessions prior this call will be removed without
47 // sending out notifications.
48 void SetPredefinedUserSessions(int count);
James Cook 2017/03/17 17:14:36 optional: Maybe CreatePredefinedUserSessions()?
xiyuan 2017/03/17 22:52:02 Done.
49
50 // Adds a user session from a given display email. The display email will be
51 // canonicalized and used to construct an AccountId.
52 void AddUserSession(const std::string& display_email);
53
54 // Simulates screen unlocking. It is virtual so that test cases can override
55 // it. The default implementation sets the session state of SessionController
56 // to be ACTIVE.
57 virtual void UnlockScreen();
58
59 // ash::mojom::SessionControllerClient:
60 void RequestLockScreen() override;
61 void SwitchActiveUser(const AccountId& account_id) override;
62 void CycleActiveUser(CycleUserDirection direction) override;
63
64 private:
65 SessionController* const controller_;
66
67 // Binds to the client interface.
68 mojo::Binding<ash::mojom::SessionControllerClient> binding_;
69
70 int fake_session_id_ = 0;
71 mojom::SessionInfoPtr session_info_;
72
73 DISALLOW_COPY_AND_ASSIGN(TestSessionControllerClient);
74 };
75
76 } // namespace test
77 } // namespace ash
78
79 #endif // ASH_COMMON_TEST_TEST_SESSION_CONTROLLER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698