| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/test/base/chrome_test_suite.h" | 5 #include "chrome/test/base/chrome_test_suite.h" |
| 6 | 6 |
| 7 #if defined(OS_CHROMEOS) | 7 #if defined(OS_CHROMEOS) |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 #endif | 10 #endif |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 public: | 124 public: |
| 125 ChromeTestSuiteInitializer() { | 125 ChromeTestSuiteInitializer() { |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { | 128 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { |
| 129 DCHECK(!g_browser_process); | 129 DCHECK(!g_browser_process); |
| 130 g_browser_process = new TestingBrowserProcess; | 130 g_browser_process = new TestingBrowserProcess; |
| 131 | 131 |
| 132 DCHECK(!content::GetContentClient()); | 132 DCHECK(!content::GetContentClient()); |
| 133 content_client_.reset(new chrome::ChromeContentClient); | 133 content_client_.reset(new chrome::ChromeContentClient); |
| 134 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. |
| 135 #if !defined(OS_IOS) |
| 134 browser_content_client_.reset(new chrome::ChromeContentBrowserClient()); | 136 browser_content_client_.reset(new chrome::ChromeContentBrowserClient()); |
| 135 content_client_->set_browser_for_testing(browser_content_client_.get()); | 137 content_client_->set_browser_for_testing(browser_content_client_.get()); |
| 138 #endif |
| 136 content::SetContentClient(content_client_.get()); | 139 content::SetContentClient(content_client_.get()); |
| 137 | 140 |
| 138 SetUpHostResolver(); | 141 SetUpHostResolver(); |
| 139 } | 142 } |
| 140 | 143 |
| 141 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { | 144 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { |
| 142 if (g_browser_process) { | 145 if (g_browser_process) { |
| 143 delete g_browser_process; | 146 delete g_browser_process; |
| 144 g_browser_process = NULL; | 147 g_browser_process = NULL; |
| 145 } | 148 } |
| 146 | 149 |
| 147 DCHECK_EQ(content_client_.get(), content::GetContentClient()); | 150 DCHECK_EQ(content_client_.get(), content::GetContentClient()); |
| 151 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. |
| 152 #if !defined(OS_IOS) |
| 148 browser_content_client_.reset(); | 153 browser_content_client_.reset(); |
| 154 #endif |
| 149 content_client_.reset(); | 155 content_client_.reset(); |
| 150 content::SetContentClient(NULL); | 156 content::SetContentClient(NULL); |
| 151 | 157 |
| 152 TearDownHostResolver(); | 158 TearDownHostResolver(); |
| 153 } | 159 } |
| 154 | 160 |
| 155 private: | 161 private: |
| 156 void SetUpHostResolver() { | 162 void SetUpHostResolver() { |
| 157 host_resolver_proc_ = new LocalHostResolverProc; | 163 host_resolver_proc_ = new LocalHostResolverProc; |
| 158 scoped_host_resolver_proc_.reset( | 164 scoped_host_resolver_proc_.reset( |
| 159 new net::ScopedDefaultHostResolverProc(host_resolver_proc_.get())); | 165 new net::ScopedDefaultHostResolverProc(host_resolver_proc_.get())); |
| 160 } | 166 } |
| 161 | 167 |
| 162 void TearDownHostResolver() { | 168 void TearDownHostResolver() { |
| 163 scoped_host_resolver_proc_.reset(); | 169 scoped_host_resolver_proc_.reset(); |
| 164 host_resolver_proc_ = NULL; | 170 host_resolver_proc_ = NULL; |
| 165 } | 171 } |
| 166 | 172 |
| 167 scoped_ptr<BrowserProcess> browser_process_; | 173 scoped_ptr<BrowserProcess> browser_process_; |
| 168 | 174 |
| 169 scoped_ptr<chrome::ChromeContentClient> content_client_; | 175 scoped_ptr<chrome::ChromeContentClient> content_client_; |
| 176 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. |
| 177 #if !defined(OS_IOS) |
| 170 scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_; | 178 scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_; |
| 179 #endif |
| 171 | 180 |
| 172 scoped_refptr<LocalHostResolverProc> host_resolver_proc_; | 181 scoped_refptr<LocalHostResolverProc> host_resolver_proc_; |
| 173 scoped_ptr<net::ScopedDefaultHostResolverProc> scoped_host_resolver_proc_; | 182 scoped_ptr<net::ScopedDefaultHostResolverProc> scoped_host_resolver_proc_; |
| 174 | 183 |
| 175 DISALLOW_COPY_AND_ASSIGN(ChromeTestSuiteInitializer); | 184 DISALLOW_COPY_AND_ASSIGN(ChromeTestSuiteInitializer); |
| 176 }; | 185 }; |
| 177 | 186 |
| 178 } // namespace | 187 } // namespace |
| 179 | 188 |
| 180 ChromeTestSuite::ChromeTestSuite(int argc, char** argv) | 189 ChromeTestSuite::ChromeTestSuite(int argc, char** argv) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 #if defined(OS_MACOSX) && !defined(OS_IOS) | 262 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 254 base::mac::SetOverrideFrameworkBundle(NULL); | 263 base::mac::SetOverrideFrameworkBundle(NULL); |
| 255 #endif | 264 #endif |
| 256 | 265 |
| 257 base::StatsTable::set_current(NULL); | 266 base::StatsTable::set_current(NULL); |
| 258 stats_table_.reset(); | 267 stats_table_.reset(); |
| 259 RemoveSharedMemoryFile(stats_filename_); | 268 RemoveSharedMemoryFile(stats_filename_); |
| 260 | 269 |
| 261 base::TestSuite::Shutdown(); | 270 base::TestSuite::Shutdown(); |
| 262 } | 271 } |
| OLD | NEW |