1 // Copyright 2013 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.
5 #include "chrome/test/base/chrome_unit_test_suite.h"
7 #include "chrome/test/base/testing_browser_process.h"
8 #include "testing/gtest/include/gtest/gtest.h"
12 // Creates a TestingBrowserProcess for each test.
13 class ChromeUnitTestSuiteInitializer
: public testing::EmptyTestEventListener
{
15 ChromeUnitTestSuiteInitializer() {}
16 virtual ~ChromeUnitTestSuiteInitializer() {}
18 virtual void OnTestStart(const testing::TestInfo
& test_info
) OVERRIDE
{
19 TestingBrowserProcess::CreateInstance();
22 virtual void OnTestEnd(const testing::TestInfo
& test_info
) OVERRIDE
{
23 TestingBrowserProcess::DeleteInstance();
27 DISALLOW_COPY_AND_ASSIGN(ChromeUnitTestSuiteInitializer
);
32 ChromeUnitTestSuite::ChromeUnitTestSuite(int argc
, char** argv
)
33 : ChromeTestSuite(argc
, argv
) {}
35 ChromeUnitTestSuite::~ChromeUnitTestSuite() {}
37 void ChromeUnitTestSuite::Initialize() {
38 // Add an additional listener to do the extra initialization for unit tests.
39 // It will be started before the base class listeners and ended after the
40 // base class listeners.
41 testing::TestEventListeners
& listeners
=
42 testing::UnitTest::GetInstance()->listeners();
43 listeners
.Append(new ChromeUnitTestSuiteInitializer
);
45 ChromeTestSuite::Initialize();