This source file includes following definitions.
- CreateTemplateURLService
- CreateAutocompleteClassifier
- SetUp
- TearDown
- CreateProfile
- CreateBrowserWindow
#include "chrome/browser/ui/views/frame/test_with_browser_view.h"
#include "chrome/browser/autocomplete/autocomplete_classifier.h"
#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
#include "chrome/browser/predictors/predictor_database.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_io_thread_state.h"
#include "content/public/test/test_utils.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/input_method/input_method_configuration.h"
#include "chrome/browser/chromeos/input_method/mock_input_method_manager.h"
#endif
namespace {
KeyedService* CreateTemplateURLService(content::BrowserContext* profile) {
return new TemplateURLService(static_cast<Profile*>(profile));
}
KeyedService* CreateAutocompleteClassifier(content::BrowserContext* profile) {
return new AutocompleteClassifier(static_cast<Profile*>(profile));
}
}
TestWithBrowserView::TestWithBrowserView() {
}
TestWithBrowserView::TestWithBrowserView(
Browser::Type browser_type,
chrome::HostDesktopType host_desktop_type,
bool hosted_app)
: BrowserWithTestWindowTest(browser_type,
host_desktop_type,
hosted_app) {
}
TestWithBrowserView::~TestWithBrowserView() {
}
void TestWithBrowserView::SetUp() {
local_state_.reset(
new ScopedTestingLocalState(TestingBrowserProcess::GetGlobal()));
#if defined(OS_CHROMEOS)
chromeos::input_method::InitializeForTesting(
new chromeos::input_method::MockInputMethodManager);
#endif
testing_io_thread_state_.reset(new chrome::TestingIOThreadState());
BrowserWithTestWindowTest::SetUp();
predictor_db_.reset(new predictors::PredictorDatabase(GetProfile()));
browser_view_ = static_cast<BrowserView*>(browser()->window());
}
void TestWithBrowserView::TearDown() {
ASSERT_TRUE(release_browser());
browser_view_->browser()->tab_strip_model()->CloseAllTabs();
browser_view_->GetWidget()->CloseNow();
browser_view_ = NULL;
content::RunAllPendingInMessageLoop(content::BrowserThread::DB);
BrowserWithTestWindowTest::TearDown();
testing_io_thread_state_.reset();
predictor_db_.reset();
#if defined(OS_CHROMEOS)
chromeos::input_method::Shutdown();
#endif
local_state_.reset(NULL);
}
TestingProfile* TestWithBrowserView::CreateProfile() {
TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile();
TemplateURLServiceFactory::GetInstance()->SetTestingFactory(
profile, &CreateTemplateURLService);
AutocompleteClassifierFactory::GetInstance()->SetTestingFactory(
profile, &CreateAutocompleteClassifier);
return profile;
}
BrowserWindow* TestWithBrowserView::CreateBrowserWindow() {
return NULL;
}