Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / login_manager_test.h
blobcaa2a1494d523f5f065f850a700a022f7e4874cc
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;
36 bool SetUpUserDataDirectory() override;
38 // Registers the user with the given |user_id| on the device.
39 // This method should be called in PRE_* test.
40 // TODO(dzhioev): Add the ability to register users without a PRE_* test.
41 void RegisterUser(const std::string& user_id);
43 // Set expected credentials for next login attempt.
44 void SetExpectedCredentials(const UserContext& user_context);
46 // Tries to login with the credentials in |user_context|. The return value
47 // indicates whether the login attempt succeeded.
48 bool TryToLogin(const UserContext& user_context);
50 // Tries to add the user identified and authenticated by |user_context| to the
51 // session. The return value indicates whether the attempt succeeded. This
52 // method does the same as TryToLogin() but doesn't verify that the new user
53 // has become the active user.
54 bool AddUserToSession(const UserContext& user_context);
56 // Log in user with |user_id|. User should be registered using RegisterUser().
57 void LoginUser(const std::string& user_id);
59 // Add user with |user_id| to session.
60 void AddUser(const std::string& user_id);
62 // Executes given JS |expression| in |web_contents_| and checks
63 // that it is true.
64 void JSExpect(const std::string& expression);
66 content::WebContents* web_contents() { return web_contents_; }
68 test::JSChecker& js_checker() { return js_checker_; }
70 static std::string GetGaiaIDForUserID(const std::string& user_id);
72 protected:
73 bool use_webview() { return use_webview_; }
74 void set_use_webview(bool use_webview) { use_webview_ = use_webview; }
76 bool use_webview_;
78 private:
79 void InitializeWebContents();
81 void set_web_contents(content::WebContents* web_contents) {
82 web_contents_ = web_contents;
85 bool should_launch_browser_;
86 content::WebContents* web_contents_;
87 test::JSChecker js_checker_;
89 DISALLOW_COPY_AND_ASSIGN(LoginManagerTest);
92 } // namespace chromeos
94 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_H_