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. 4 5 #include "content/test/content_test_suite.h" 6 7 #include "base/logging.h" 8 #include "content/public/test/test_content_client_initializer.h" 9 #include "content/test/test_content_client.h" 10 #include "testing/gtest/include/gtest/gtest.h" 11 12 #if defined(USE_AURA) 13 #include "ui/aura/test/test_aura_initializer.h" 14 #endif 15 16 #if defined(OS_MACOSX) 17 #include "base/mac/scoped_nsautorelease_pool.h" 18 #endif 19 20 namespace { 21 22 class TestInitializationListener : public testing::EmptyTestEventListener { 23 public: 24 TestInitializationListener() : test_content_client_initializer_(NULL) { 25 } 26 27 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { 28 test_content_client_initializer_ = 29 new content::TestContentClientInitializer(); 30 } 31 32 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { 33 delete test_content_client_initializer_; 34 } 35 36 private: 37 content::TestContentClientInitializer* test_content_client_initializer_; 38 39 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener); 40 }; 41 42 } // namespace 43 44 namespace content { 45 46 ContentTestSuite::ContentTestSuite(int argc, char** argv) 47 : ContentTestSuiteBase(argc, argv) { 48 #if defined(USE_AURA) 49 aura_initializer_.reset(new aura::test::TestAuraInitializer); 50 #endif 51 } 52 53 ContentTestSuite::~ContentTestSuite() { 54 } 55 56 void ContentTestSuite::Initialize() { 57 #if defined(OS_MACOSX) 58 base::mac::ScopedNSAutoreleasePool autorelease_pool; 59 #endif 60 61 ContentTestSuiteBase::Initialize(); 62 63 testing::TestEventListeners& listeners = 64 testing::UnitTest::GetInstance()->listeners(); 65 listeners.Append(new TestInitializationListener); 66 } 67 68 ContentClient* ContentTestSuite::CreateClientForInitialization() { 69 return new TestContentClient(); 70 } 71 72 } // namespace content 73