| Index: chrome/browser/chromeos/login/login_manager_test_helper.h
|
| diff --git a/chrome/browser/chromeos/login/login_manager_test_helper.h b/chrome/browser/chromeos/login/login_manager_test_helper.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..09abb3255f1ed610d5278fc15499ef921b92126c
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/login/login_manager_test_helper.h
|
| @@ -0,0 +1,76 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_HELPER_H_
|
| +#define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_HELPER_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/compiler_specific.h"
|
| +#include "base/macros.h"
|
| +#include "chrome/browser/chromeos/login/mock_login_utils.h"
|
| +
|
| +namespace chromeos {
|
| +
|
| +// Helper class for Chrome OS multi-user browser tests. Provides mock login
|
| +// utils. Tests may subclass LoginManagerTest or use this helper directly.
|
| +// If no special configuration is done launches out-of-box WebUI.
|
| +// To launch login UI use a PRE_* test that will register user(s) and mark
|
| +// out-of-box as completed.
|
| +// Guarantees that WebUI has been initialized by waiting for
|
| +// NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE notification.
|
| +class LoginManagerTestHelper {
|
| + public:
|
| + LoginManagerTestHelper();
|
| + ~LoginManagerTestHelper();
|
| +
|
| + // Adds flags for LoginManager and multi-profiles.
|
| + void SetUpCommandLine(base::CommandLine* command_line);
|
| +
|
| + // Creates the mock login utils.
|
| + void SetUpLoginUtils(bool should_launch_browser);
|
| +
|
| + // Waits for NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE.
|
| + void WaitForLoginWebUI();
|
| +
|
| + void CloseLoginWebUI();
|
| +
|
| + // Registers user with given |username| on device.
|
| + // Should be called in PRE_* test.
|
| + // TODO(dzhioev): add ability to register users without PRE_* test.
|
| + void RegisterUser(const std::string& username);
|
| +
|
| + // Sets expected credentials for next login attempt.
|
| + void SetExpectedCredentials(const std::string& username,
|
| + const std::string& password);
|
| +
|
| + // Tries to log in with |username| and |password|. Returns false if attempt
|
| + // has failed.
|
| + bool TryToLogIn(const std::string& username, const std::string& password);
|
| +
|
| + // Tries to add user to session with |username| and |password|. Returns false
|
| + // if attempt has failed. This function does the same as TryToLogIn but
|
| + // doesn't check that the new user became the active user.
|
| + bool AddUserToSession(const std::string& username,
|
| + const std::string& password);
|
| +
|
| + // Logs in user with |username|. User should be registered with
|
| + // RegisterUser().
|
| + void LogInUser(const std::string& username);
|
| +
|
| + // Adds user with |username| to session.
|
| + void AddUser(const std::string& username);
|
| +
|
| + MockLoginUtils& mock_login_utils() { return *mock_login_utils_; }
|
| +
|
| + private:
|
| + MockLoginUtils* mock_login_utils_;
|
| + bool web_ui_visible_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(LoginManagerTestHelper);
|
| +};
|
| +
|
| +} // namespace chromeos
|
| +
|
| +#endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_MANAGER_TEST_HELPER_H_
|
|
|