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/in_process_browser_test.h" | 5 #include "chrome/test/base/in_process_browser_test.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 #include "content/public/browser/notification_service.h" | 47 #include "content/public/browser/notification_service.h" |
48 #include "content/public/browser/notification_types.h" | 48 #include "content/public/browser/notification_types.h" |
49 #include "content/public/test/browser_test_utils.h" | 49 #include "content/public/test/browser_test_utils.h" |
50 #include "content/public/test/test_launcher.h" | 50 #include "content/public/test/test_launcher.h" |
51 #include "content/public/test/test_navigation_observer.h" | 51 #include "content/public/test/test_navigation_observer.h" |
52 #include "net/test/embedded_test_server/embedded_test_server.h" | 52 #include "net/test/embedded_test_server/embedded_test_server.h" |
53 #include "net/test/spawned_test_server/spawned_test_server.h" | 53 #include "net/test/spawned_test_server/spawned_test_server.h" |
54 | 54 |
55 #if defined(OS_MACOSX) | 55 #if defined(OS_MACOSX) |
56 #include "base/mac/scoped_nsautorelease_pool.h" | 56 #include "base/mac/scoped_nsautorelease_pool.h" |
57 #include "chrome/test/base/scoped_bundle_swizzler_mac.h" | |
57 #endif | 58 #endif |
58 | 59 |
59 #if defined(OS_WIN) | 60 #if defined(OS_WIN) |
60 #include "base/win/scoped_com_initializer.h" | 61 #include "base/win/scoped_com_initializer.h" |
61 #include "base/win/windows_version.h" | 62 #include "base/win/windows_version.h" |
62 #include "ui/base/win/atl_module.h" | 63 #include "ui/base/win/atl_module.h" |
63 #include "win8/test/metro_registration_helper.h" | 64 #include "win8/test/metro_registration_helper.h" |
64 #include "win8/test/test_registrar_constants.h" | 65 #include "win8/test/test_registrar_constants.h" |
65 #endif | 66 #endif |
66 | 67 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 CreateTestServer(base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 180 CreateTestServer(base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
180 base::FilePath src_dir; | 181 base::FilePath src_dir; |
181 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)); | 182 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)); |
182 base::FilePath test_data_dir = src_dir.AppendASCII("chrome/test/data"); | 183 base::FilePath test_data_dir = src_dir.AppendASCII("chrome/test/data"); |
183 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); | 184 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); |
184 | 185 |
185 // chrome::DIR_TEST_DATA isn't going to be setup until after we call | 186 // chrome::DIR_TEST_DATA isn't going to be setup until after we call |
186 // ContentMain. However that is after tests' constructors or SetUp methods, | 187 // ContentMain. However that is after tests' constructors or SetUp methods, |
187 // which sometimes need it. So just override it. | 188 // which sometimes need it. So just override it. |
188 CHECK(PathService::Override(chrome::DIR_TEST_DATA, test_data_dir)); | 189 CHECK(PathService::Override(chrome::DIR_TEST_DATA, test_data_dir)); |
190 | |
191 #if defined(OS_MACOSX) | |
192 bundle_swizzler_.reset(new ScopedBundleSwizzlerMac); | |
193 #endif | |
189 } | 194 } |
190 | 195 |
191 InProcessBrowserTest::~InProcessBrowserTest() { | 196 InProcessBrowserTest::~InProcessBrowserTest() { |
192 } | 197 } |
193 | 198 |
194 void InProcessBrowserTest::SetUp() { | 199 void InProcessBrowserTest::SetUp() { |
195 // Browser tests will create their own g_browser_process later. | 200 // Browser tests will create their own g_browser_process later. |
196 DCHECK(!g_browser_process); | 201 DCHECK(!g_browser_process); |
197 | 202 |
198 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 203 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 } | 372 } |
368 } | 373 } |
369 return test_launcher_utils::OverrideUserDataDir(user_data_dir); | 374 return test_launcher_utils::OverrideUserDataDir(user_data_dir); |
370 } | 375 } |
371 | 376 |
372 void InProcessBrowserTest::TearDown() { | 377 void InProcessBrowserTest::TearDown() { |
373 DCHECK(!g_browser_process); | 378 DCHECK(!g_browser_process); |
374 #if defined(OS_WIN) | 379 #if defined(OS_WIN) |
375 com_initializer_.reset(); | 380 com_initializer_.reset(); |
376 #endif | 381 #endif |
382 | |
Robert Sesek
2015/07/07 15:45:07
nit: remove extra blank line now?
erikchen
2015/07/07 18:28:14
Done.
| |
377 BrowserTestBase::TearDown(); | 383 BrowserTestBase::TearDown(); |
378 } | 384 } |
379 | 385 |
380 // TODO(alexmos): This function should expose success of the underlying | 386 // TODO(alexmos): This function should expose success of the underlying |
381 // navigation to tests, which should make sure navigations succeed when | 387 // navigation to tests, which should make sure navigations succeed when |
382 // appropriate. See https://crbug.com/425335 | 388 // appropriate. See https://crbug.com/425335 |
383 void InProcessBrowserTest::AddTabAtIndexToBrowser( | 389 void InProcessBrowserTest::AddTabAtIndexToBrowser( |
384 Browser* browser, | 390 Browser* browser, |
385 int index, | 391 int index, |
386 const GURL& url, | 392 const GURL& url, |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 // On the Mac, this eventually reaches | 597 // On the Mac, this eventually reaches |
592 // -[BrowserWindowController windowWillClose:], which will post a deferred | 598 // -[BrowserWindowController windowWillClose:], which will post a deferred |
593 // -autorelease on itself to ultimately destroy the Browser object. The line | 599 // -autorelease on itself to ultimately destroy the Browser object. The line |
594 // below is necessary to pump these pending messages to ensure all Browsers | 600 // below is necessary to pump these pending messages to ensure all Browsers |
595 // get deleted. | 601 // get deleted. |
596 content::RunAllPendingInMessageLoop(); | 602 content::RunAllPendingInMessageLoop(); |
597 delete autorelease_pool_; | 603 delete autorelease_pool_; |
598 autorelease_pool_ = NULL; | 604 autorelease_pool_ = NULL; |
599 #endif | 605 #endif |
600 } | 606 } |
OLD | NEW |