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

Side by Side Diff: chrome/browser/chromeos/login/login_manager_test.h

Issue 296773002: Add a Key class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/browser/chromeos/login/mock_login_utils.h" 10 #include "chrome/browser/chromeos/login/mock_login_utils.h"
11 #include "chrome/browser/chromeos/login/test/js_checker.h" 11 #include "chrome/browser/chromeos/login/test/js_checker.h"
12 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
13 13
14 namespace content { 14 namespace content {
15 class WebContents; 15 class WebContents;
16 } // namespace content 16 } // namespace content
17 17
18 namespace chromeos { 18 namespace chromeos {
19 19
20 class UserContext;
21
20 // Base class for Chrome OS out-of-box/login WebUI tests. 22 // Base class for Chrome OS out-of-box/login WebUI tests.
21 // If no special configuration is done launches out-of-box WebUI. 23 // If no special configuration is done launches out-of-box WebUI.
22 // To launch login UI use PRE_* test that will register user(s) and mark 24 // To launch login UI use PRE_* test that will register user(s) and mark
23 // out-of-box as completed. 25 // out-of-box as completed.
24 // Guarantees that WebUI has been initialized by waiting for 26 // Guarantees that WebUI has been initialized by waiting for
25 // NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE notification. 27 // NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE notification.
26 class LoginManagerTest : public InProcessBrowserTest { 28 class LoginManagerTest : public InProcessBrowserTest {
27 public: 29 public:
28 explicit LoginManagerTest(bool should_launch_browser); 30 explicit LoginManagerTest(bool should_launch_browser);
29 31
30 // Overriden from InProcessBrowserTest. 32 // Overriden from InProcessBrowserTest.
31 virtual void CleanUpOnMainThread() OVERRIDE; 33 virtual void CleanUpOnMainThread() OVERRIDE;
32 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE; 34 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
33 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; 35 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE;
34 virtual void SetUpOnMainThread() OVERRIDE; 36 virtual void SetUpOnMainThread() OVERRIDE;
35 37
36 // Registers user with given |username| on device. 38 // Registers the user with the given |user_id| on the device.
37 // Should be called in PRE_* test. 39 // This method should be called in PRE_* test.
38 // TODO(dzhioev): add ability to register users without PRE_* test. 40 // TODO(dzhioev): Add the ability to register users without a PRE_* test.
39 void RegisterUser(const std::string& username); 41 void RegisterUser(const std::string& user_id);
40 42
41 // Set expected credentials for next login attempt. 43 // Set expected credentials for next login attempt.
42 void SetExpectedCredentials(const std::string& username, 44 void SetExpectedCredentials(const UserContext& user_context);
43 const std::string& password);
44 45
45 // Tries to login with |username| and |password|. Returns false if attempt 46 // Tries to login with the credentials in |user_context|. The return value
46 // has failed. 47 // indicates whether the login attempt succeeded.
47 bool TryToLogin(const std::string& username, const std::string& password); 48 bool TryToLogin(const UserContext& user_context);
48 49
49 // Tries to add user to session with |username| and |password|. Returns false 50 // Tries to add the user identified and authenticated by |user_context| to the
50 // if attempt has failed. this function does the same as TryToLogin but 51 // session. The return value indicates whether the attempt succeeded. This
51 // doesn't check that new user become active user. 52 // method does the same as TryToLogin() but doesn't verify that the new user
52 bool AddUserToSession(const std::string& username, 53 // has become the active user.
53 const std::string& password); 54 bool AddUserToSession(const UserContext& user_context);
54 55
55 // Login user with |username|. User should be registered using RegisterUser(). 56 // Log in user with |user_id|. User should be registered using RegisterUser().
56 void LoginUser(const std::string& username); 57 void LoginUser(const std::string& user_id);
57 58
58 // Add user with |username| to session. 59 // Add user with |user_id| to session.
59 void AddUser(const std::string& username); 60 void AddUser(const std::string& user_id);
60 61
61 // Executes given JS |expression| in |web_contents_| and checks 62 // Executes given JS |expression| in |web_contents_| and checks
62 // that it is true. 63 // that it is true.
63 void JSExpect(const std::string& expression); 64 void JSExpect(const std::string& expression);
64 65
65 MockLoginUtils& login_utils() { return *mock_login_utils_; } 66 MockLoginUtils& login_utils() { return *mock_login_utils_; }
66 67
67 content::WebContents* web_contents() { return web_contents_; } 68 content::WebContents* web_contents() { return web_contents_; }
68 69
69 private: 70 private:
70 void InitializeWebContents(); 71 void InitializeWebContents();
71 72
72 void set_web_contents(content::WebContents* web_contents) { 73 void set_web_contents(content::WebContents* web_contents) {
73 web_contents_ = web_contents; 74 web_contents_ = web_contents;
74 } 75 }
75 76
76 MockLoginUtils* mock_login_utils_; 77 MockLoginUtils* mock_login_utils_;
77 bool should_launch_browser_; 78 bool should_launch_browser_;
78 content::WebContents* web_contents_; 79 content::WebContents* web_contents_;
79 test::JSChecker js_checker_; 80 test::JSChecker js_checker_;
80 81
81 DISALLOW_COPY_AND_ASSIGN(LoginManagerTest); 82 DISALLOW_COPY_AND_ASSIGN(LoginManagerTest);
82 }; 83 };
83 84
84 } // namespace chromeos 85 } // namespace chromeos
85 86
86 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_H_ 87 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/lock/screen_locker_tester.cc ('k') | chrome/browser/chromeos/login/login_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698