15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "chrome/browser/sync/profile_sync_service_mock.h"
6f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/prefs/pref_service.h"
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/prefs/testing_pref_store.h"
968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/signin/signin_manager_factory.h"
115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "chrome/browser/sync/profile_sync_components_factory_mock.h"
12116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/pref_names.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/url_constants.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/test/base/testing_profile.h"
16effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "components/signin/core/browser/profile_oauth2_token_service.h"
17e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch#include "components/signin/core/browser/signin_manager.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)ProfileSyncServiceMock::ProfileSyncServiceMock(Profile* profile)
2068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)    : ProfileSyncService(
215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)          scoped_ptr<ProfileSyncComponentsFactory>(
225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)              new ProfileSyncComponentsFactoryMock()),
235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)          profile,
245f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)          make_scoped_ptr(new SupervisedUserSigninManagerWrapper(
255f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)              profile,
265f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)              SigninManagerFactory::GetForProfile(profile))),
275f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)          ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
285f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)          browser_sync::MANUAL_START) {
295f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}
305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
315f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)ProfileSyncServiceMock::ProfileSyncServiceMock(
325f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    scoped_ptr<ProfileSyncComponentsFactory> factory, Profile* profile)
335f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    : ProfileSyncService(
345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)          factory.Pass(),
3568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)          profile,
36116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch          make_scoped_ptr(new SupervisedUserSigninManagerWrapper(
37effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch              profile,
38f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)              SigninManagerFactory::GetForProfile(profile))),
3968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)          ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
40f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)          browser_sync::MANUAL_START) {
41f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)}
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ProfileSyncServiceMock::~ProfileSyncServiceMock() {
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TestingProfile* ProfileSyncServiceMock::MakeSignedInTestingProfile() {
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  TestingProfile* profile = new TestingProfile();
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "foo");
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return profile;
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static
54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)KeyedService* ProfileSyncServiceMock::BuildMockProfileSyncService(
55c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    content::BrowserContext* profile) {
56c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  return new ProfileSyncServiceMock(static_cast<Profile*>(profile));
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
58