test_signin_client.cc revision 4ad1aa43a48567659193a298fad74f55e00b3dd9
1// Copyright 2014 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. 4 5#include "base/logging.h" 6#include "components/signin/core/browser/test_signin_client.h" 7#include "components/signin/core/browser/webdata/token_service_table.h" 8#include "components/webdata/common/web_data_service_base.h" 9#include "components/webdata/common/web_database_service.h" 10#include "testing/gtest/include/gtest/gtest.h" 11 12TestSigninClient::TestSigninClient() 13 : request_context_(new net::TestURLRequestContextGetter( 14 base::MessageLoopProxy::current())) { 15 LoadDatabase(); 16} 17 18TestSigninClient::~TestSigninClient() {} 19 20PrefService* TestSigninClient::GetPrefs() { return NULL; } 21 22scoped_refptr<TokenWebData> TestSigninClient::GetDatabase() { 23 return database_; 24} 25 26bool TestSigninClient::CanRevokeCredentials() { return true; } 27 28net::URLRequestContextGetter* TestSigninClient::GetURLRequestContext() { 29 return request_context_; 30} 31 32void TestSigninClient::LoadDatabase() { 33 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 34 base::FilePath path = temp_dir_.path().AppendASCII("TestWebDB"); 35 scoped_refptr<WebDatabaseService> web_database = 36 new WebDatabaseService(path, 37 base::MessageLoopProxy::current(), 38 base::MessageLoopProxy::current()); 39 web_database->AddTable(scoped_ptr<WebDatabaseTable>(new TokenServiceTable())); 40 web_database->LoadDatabase(); 41 database_ = new TokenWebData(web_database, 42 base::MessageLoopProxy::current(), 43 base::MessageLoopProxy::current(), 44 WebDataServiceBase::ProfileErrorCallback()); 45 database_->Init(); 46} 47