1 // Copyright (c) 2012 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 "content/test/content_test_suite.h"
7 #include "base/base_paths.h"
8 #include "base/logging.h"
9 #include "base/path_service.h"
10 #include "content/public/test/test_content_client_initializer.h"
11 #include "content/test/test_content_client.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/base/resource/resource_bundle.h"
15 #if defined(OS_MACOSX)
16 #include "base/mac/scoped_nsautorelease_pool.h"
21 class TestInitializationListener
: public testing::EmptyTestEventListener
{
23 TestInitializationListener() : test_content_client_initializer_(NULL
) {
26 virtual void OnTestStart(const testing::TestInfo
& test_info
) OVERRIDE
{
27 test_content_client_initializer_
=
28 new content::TestContentClientInitializer();
31 virtual void OnTestEnd(const testing::TestInfo
& test_info
) OVERRIDE
{
32 delete test_content_client_initializer_
;
36 content::TestContentClientInitializer
* test_content_client_initializer_
;
38 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener
);
45 ContentTestSuite::ContentTestSuite(int argc
, char** argv
)
46 : ContentTestSuiteBase(argc
, argv
) {
48 base::FilePath pak_file
;
49 PathService::Get(base::DIR_MODULE
, &pak_file
);
50 pak_file
= pak_file
.AppendASCII("ui_test.pak");
51 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file
);
55 ContentTestSuite::~ContentTestSuite() {
57 ui::ResourceBundle::CleanupSharedInstance();
61 void ContentTestSuite::Initialize() {
62 #if defined(OS_MACOSX)
63 base::mac::ScopedNSAutoreleasePool autorelease_pool
;
66 ContentTestSuiteBase::Initialize();
68 testing::TestEventListeners
& listeners
=
69 testing::UnitTest::GetInstance()->listeners();
70 listeners
.Append(new TestInitializationListener
);
73 ContentClient
* ContentTestSuite::CreateClientForInitialization() {
74 return new TestContentClient();
77 } // namespace content