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

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

Powered by Google App Engine
This is Rietveld 408576698