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

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

Issue 270563002: Componentize LoginManagerTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/login_manager_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/memory/scoped_ptr.h"
11 #include "chrome/browser/chromeos/login/login_manager_test_helper.h"
10 #include "chrome/browser/chromeos/login/mock_login_utils.h" 12 #include "chrome/browser/chromeos/login/mock_login_utils.h"
11 #include "chrome/browser/chromeos/login/test/js_checker.h" 13 #include "chrome/browser/chromeos/login/test/js_checker.h"
12 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
13 15
14 namespace content { 16 namespace content {
15 class WebContents; 17 class WebContents;
16 } // namespace content 18 } // namespace content
17 19
18 namespace chromeos { 20 namespace chromeos {
19 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 a 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 // Uses LoginManagerTestHelper to set up login utils and ensure WebUI has been
25 // NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE notification. 27 // initialized.
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);
31 virtual ~LoginManagerTest();
29 32
30 // Overriden from InProcessBrowserTest. 33 // Overriden from InProcessBrowserTest.
31 virtual void CleanUpOnMainThread() OVERRIDE; 34 virtual void CleanUpOnMainThread() OVERRIDE;
32 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE; 35 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
33 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; 36 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE;
34 virtual void SetUpOnMainThread() OVERRIDE; 37 virtual void SetUpOnMainThread() OVERRIDE;
35 38
36 // Registers user with given |username| on device. 39 // Registers user with given |username| on device.
37 // Should be called in PRE_* test. 40 // Should be called in PRE_* test.
38 // TODO(dzhioev): add ability to register users without PRE_* test. 41 // TODO(dzhioev): add ability to register users without PRE_* test.
39 void RegisterUser(const std::string& username); 42 void RegisterUser(const std::string& username);
40 43
41 // Set expected credentials for next login attempt. 44 // Sets expected credentials for next login attempt.
42 void SetExpectedCredentials(const std::string& username, 45 void SetExpectedCredentials(const std::string& username,
43 const std::string& password); 46 const std::string& password);
44 47
45 // Tries to login with |username| and |password|. Returns false if attempt 48 // Tries to log in with |username| and |password|. Returns false if attempt
46 // has failed. 49 // has failed.
47 bool TryToLogin(const std::string& username, const std::string& password); 50 bool TryToLogin(const std::string& username, const std::string& password);
48 51
49 // Tries to add user to session with |username| and |password|. Returns false 52 // Tries to add user to session with |username| and |password|. Returns false
50 // if attempt has failed. this function does the same as TryToLogin but 53 // if attempt has failed. This function does the same as TryToLogin but
51 // doesn't check that new user become active user. 54 // doesn't check that the new user became the active user.
52 bool AddUserToSession(const std::string& username, 55 bool AddUserToSession(const std::string& username,
53 const std::string& password); 56 const std::string& password);
54 57
55 // Login user with |username|. User should be registered using RegisterUser(). 58 // Logs in user with |username|. User should be registered using
59 // RegisterUser().
56 void LoginUser(const std::string& username); 60 void LoginUser(const std::string& username);
57 61
58 // Add user with |username| to session. 62 // Adds user with |username| to session.
59 void AddUser(const std::string& username); 63 void AddUser(const std::string& username);
60 64
61 // Executes given JS |expression| in |web_contents_| and checks 65 // Executes given JS |expression| in |web_contents_| and checks
62 // that it is true. 66 // that it is true.
63 void JSExpect(const std::string& expression); 67 void JSExpect(const std::string& expression);
64 68
65 MockLoginUtils& login_utils() { return *mock_login_utils_; } 69 MockLoginUtils& login_utils();
66 70
67 content::WebContents* web_contents() { return web_contents_; } 71 content::WebContents* web_contents() { return web_contents_; }
68 72
69 private: 73 private:
70 void InitializeWebContents(); 74 void InitializeWebContents();
71 75
72 void set_web_contents(content::WebContents* web_contents) { 76 void set_web_contents(content::WebContents* web_contents) {
73 web_contents_ = web_contents; 77 web_contents_ = web_contents;
74 } 78 }
75 79
76 MockLoginUtils* mock_login_utils_; 80 MockLoginUtils* mock_login_utils_;
81 scoped_ptr<LoginManagerTestHelper> login_manager_test_helper_;
77 bool should_launch_browser_; 82 bool should_launch_browser_;
78 content::WebContents* web_contents_; 83 content::WebContents* web_contents_;
79 test::JSChecker js_checker_; 84 test::JSChecker js_checker_;
80 85
81 DISALLOW_COPY_AND_ASSIGN(LoginManagerTest); 86 DISALLOW_COPY_AND_ASSIGN(LoginManagerTest);
82 }; 87 };
83 88
84 } // namespace chromeos 89 } // namespace chromeos
85 90
86 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_H_ 91 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/login_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698