account_reconcilor_unittest.cc revision 8bcbed890bc3ce4d7a057a8f32cab53fa534672e
18bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 28bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 38bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// found in the LICENSE file. 48bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 58bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/memory/scoped_ptr.h" 68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/signin/account_reconcilor.h" 78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/signin/account_reconcilor_factory.h" 88bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/signin/fake_profile_oauth2_token_service.h" 98bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/signin/fake_signin_manager.h" 108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/signin/profile_oauth2_token_service.h" 118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/signin/signin_manager.h" 138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/signin/signin_manager_factory.h" 148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/test/base/testing_profile.h" 158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "testing/gmock/include/gmock/gmock.h" 168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h" 178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace { 198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class AccountReconcilorTest : public testing::Test { 218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SetUp() OVERRIDE; 238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void TearDown() OVERRIDE; 248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) TestingProfile* profile() { return profile_.get(); } 268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)private: 288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_ptr<TestingProfile> profile_; 298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)void AccountReconcilorTest::SetUp() { 328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) TestingProfile::Builder builder; 338bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), 348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) FakeProfileOAuth2TokenService::Build); 358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) builder.AddTestingFactory(SigninManagerFactory::GetInstance(), 368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) FakeSigninManagerBase::Build); 378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) profile_ = builder.Build(); 388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)void AccountReconcilorTest::TearDown() { 418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Destroy the profile before all threads are torn down. 428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) profile_.reset(); 438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} // namespace 468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)TEST_F(AccountReconcilorTest, Basic) { 488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) AccountReconcilor* reconcilor = 498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) AccountReconcilorFactory::GetForProfile(profile()); 508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) ASSERT_TRUE(NULL != reconcilor); 518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) ASSERT_EQ(profile(), reconcilor->profile()); 528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 53