| Index: chrome/test/device_management_test_util.cc
|
| diff --git a/chrome/test/device_management_test_util.cc b/chrome/test/device_management_test_util.cc
|
| index 2bcff7fb6399da5cc81456f9587e4b3adba5cb5a..161ab2ff8a2c4d83e99acc40bb661bc0572c0aa1 100644
|
| --- a/chrome/test/device_management_test_util.cc
|
| +++ b/chrome/test/device_management_test_util.cc
|
| @@ -7,20 +7,29 @@
|
| #include <string>
|
|
|
| #include "chrome/browser/net/gaia/token_service.h"
|
| +#include "chrome/browser/policy/device_token_fetcher.h"
|
| #include "chrome/common/net/gaia/gaia_constants.h"
|
| #include "chrome/common/notification_service.h"
|
| #include "chrome/common/notification_source.h"
|
| #include "chrome/common/notification_type.h"
|
|
|
| +#if defined(OS_CHROMEOS)
|
| +#include "chrome/browser/chromeos/login/user_manager.h"
|
| +#else
|
| +#include "chrome/browser/sync/signin_manager.h"
|
| +#endif
|
| +
|
| namespace policy {
|
|
|
| +const char* kTestDasherDomainUsername = "___@example.com";
|
| +
|
| namespace {
|
|
|
| static const char kFakeGaiaAuthToken[] = "FakeGAIAToken";
|
|
|
| } // namespace
|
|
|
| -void SimulateSuccessfulLogin() {
|
| +void SimulateTokenAvailable() {
|
| const std::string service(GaiaConstants::kDeviceManagementService);
|
| const std::string auth_token(kFakeGaiaAuthToken);
|
| TokenService::TokenAvailableDetails details(service, auth_token);
|
| @@ -30,4 +39,29 @@ void SimulateSuccessfulLogin() {
|
| Details<const TokenService::TokenAvailableDetails>(&details));
|
| }
|
|
|
| +void SimulateUsernameAvailable(DeviceTokenFetcher* fetcher,
|
| + const std::string& username) {
|
| + fetcher->injected_username.reset(new std::string(username));
|
| +#if defined(OS_CHROMEOS)
|
| + chromeos::UserManager::User user;
|
| + user.set_email(username);
|
| + NotificationService::current()->Notify(
|
| + NotificationType::LOGIN_USER_CHANGED,
|
| + Source<chromeos::UserManager>(NULL),
|
| + Details<const chromeos::UserManager::User>(&user));
|
| +#else
|
| + GoogleServiceSigninSuccessDetails details(username, "");
|
| + NotificationService::current()->Notify(
|
| + NotificationType::GOOGLE_SIGNIN_SUCCESSFUL,
|
| + Source<SigninManager>(NULL),
|
| + Details<const GoogleServiceSigninSuccessDetails>(&details));
|
| +#endif
|
| +}
|
| +
|
| +void SimulateSuccessfulLogin(DeviceTokenFetcher* fetcher,
|
| + const std::string& username) {
|
| + SimulateTokenAvailable();
|
| + SimulateUsernameAvailable(fetcher, username);
|
| +}
|
| +
|
| } // namespace policy
|
|
|