Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / browser / chromeos / login / login_manager_test.h
blobadeb77138f1af1618e82c3d3759aa1fd84263dc9
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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_H_
8 #include <string>
10 #include "chrome/browser/chromeos/login/mixin_based_browser_test.h"
11 #include "chrome/browser/chromeos/login/test/js_checker.h"
13 namespace content {
14 class WebContents;
15 } // namespace content
17 namespace chromeos {
19 class UserContext;
21 // Base class for Chrome OS out-of-box/login WebUI tests.
22 // If no special configuration is done launches out-of-box WebUI.
23 // To launch login UI use PRE_* test that will register user(s) and mark
24 // out-of-box as completed.
25 // Guarantees that WebUI has been initialized by waiting for
26 // NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE notification.
27 class LoginManagerTest : public MixinBasedBrowserTest {
28 public:
29 explicit LoginManagerTest(bool should_launch_browser);
31 // Overridden from InProcessBrowserTest.
32 void TearDownOnMainThread() override;
33 void SetUpCommandLine(base::CommandLine* command_line) override;
34 void SetUpInProcessBrowserTestFixture() override;
35 void SetUpOnMainThread() override;
37 // Registers the user with the given |user_id| on the device.
38 // This method should be called in PRE_* test.
39 // TODO(dzhioev): Add the ability to register users without a PRE_* test.
40 void RegisterUser(const std::string& user_id);
42 // Set expected credentials for next login attempt.
43 void SetExpectedCredentials(const UserContext& user_context);
45 // Tries to login with the credentials in |user_context|. The return value
46 // indicates whether the login attempt succeeded.
47 bool TryToLogin(const UserContext& user_context);
49 // Tries to add the user identified and authenticated by |user_context| to the
50 // session. The return value indicates whether the attempt succeeded. This
51 // method does the same as TryToLogin() but doesn't verify that the new user
52 // has become the active user.
53 bool AddUserToSession(const UserContext& user_context);
55 // Log in user with |user_id|. User should be registered using RegisterUser().
56 void LoginUser(const std::string& user_id);
58 // Add user with |user_id| to session.
59 void AddUser(const std::string& user_id);
61 // Executes given JS |expression| in |web_contents_| and checks
62 // that it is true.
63 void JSExpect(const std::string& expression);
65 content::WebContents* web_contents() { return web_contents_; }
67 test::JSChecker& js_checker() { return js_checker_; }
69 static std::string GetGaiaIDForUserID(const std::string& user_id);
71 private:
72 void InitializeWebContents();
74 void set_web_contents(content::WebContents* web_contents) {
75 web_contents_ = web_contents;
78 bool should_launch_browser_;
79 content::WebContents* web_contents_;
80 test::JSChecker js_checker_;
82 DISALLOW_COPY_AND_ASSIGN(LoginManagerTest);
85 } // namespace chromeos
87 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_H_