| 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/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "chrome/browser/ui/browser_commands.h" | 34 #include "chrome/browser/ui/browser_commands.h" |
| 35 #include "chrome/browser/ui/browser_finder.h" | 35 #include "chrome/browser/ui/browser_finder.h" |
| 36 #include "chrome/browser/ui/browser_list.h" | 36 #include "chrome/browser/ui/browser_list.h" |
| 37 #include "chrome/browser/ui/browser_list_observer.h" | 37 #include "chrome/browser/ui/browser_list_observer.h" |
| 38 #include "chrome/browser/ui/browser_navigator.h" | 38 #include "chrome/browser/ui/browser_navigator.h" |
| 39 #include "chrome/browser/ui/browser_navigator_params.h" | 39 #include "chrome/browser/ui/browser_navigator_params.h" |
| 40 #include "chrome/browser/ui/browser_tabstrip.h" | 40 #include "chrome/browser/ui/browser_tabstrip.h" |
| 41 #include "chrome/browser/ui/browser_window.h" | 41 #include "chrome/browser/ui/browser_window.h" |
| 42 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 42 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 43 #include "chrome/common/chrome_constants.h" | 43 #include "chrome/common/chrome_constants.h" |
| 44 #include "chrome/common/chrome_features.h" |
| 44 #include "chrome/common/chrome_paths.h" | 45 #include "chrome/common/chrome_paths.h" |
| 45 #include "chrome/common/chrome_switches.h" | 46 #include "chrome/common/chrome_switches.h" |
| 46 #include "chrome/common/features.h" | 47 #include "chrome/common/features.h" |
| 47 #include "chrome/common/logging_chrome.h" | 48 #include "chrome/common/logging_chrome.h" |
| 48 #include "chrome/common/url_constants.h" | 49 #include "chrome/common/url_constants.h" |
| 49 #include "chrome/renderer/chrome_content_renderer_client.h" | 50 #include "chrome/renderer/chrome_content_renderer_client.h" |
| 50 #include "chrome/test/base/chrome_test_suite.h" | 51 #include "chrome/test/base/chrome_test_suite.h" |
| 51 #include "chrome/test/base/test_launcher_utils.h" | 52 #include "chrome/test/base/test_launcher_utils.h" |
| 52 #include "chrome/test/base/testing_browser_process.h" | 53 #include "chrome/test/base/testing_browser_process.h" |
| 53 #include "components/google/core/browser/google_util.h" | 54 #include "components/google/core/browser/google_util.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 #endif | 186 #endif |
| 186 } | 187 } |
| 187 | 188 |
| 188 InProcessBrowserTest::~InProcessBrowserTest() { | 189 InProcessBrowserTest::~InProcessBrowserTest() { |
| 189 } | 190 } |
| 190 | 191 |
| 191 void InProcessBrowserTest::SetUp() { | 192 void InProcessBrowserTest::SetUp() { |
| 192 // Browser tests will create their own g_browser_process later. | 193 // Browser tests will create their own g_browser_process later. |
| 193 DCHECK(!g_browser_process); | 194 DCHECK(!g_browser_process); |
| 194 | 195 |
| 195 // Clear the FeatureList instance from base/test/test_suite.cc. Since this is | |
| 196 // a browser test, a FeatureList will be registered as part of normal browser | |
| 197 // start up in ChromeBrowserMainParts::SetupMetricsAndFieldTrials(). | |
| 198 base::FeatureList::ClearInstanceForTesting(); | |
| 199 | |
| 200 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 196 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 201 | 197 |
| 202 // Auto-reload breaks many browser tests, which assume error pages won't be | 198 // Auto-reload breaks many browser tests, which assume error pages won't be |
| 203 // reloaded out from under them. Tests that expect or desire this behavior can | 199 // reloaded out from under them. Tests that expect or desire this behavior can |
| 204 // append switches::kEnableOfflineAutoReload, which will override the disable | 200 // append switches::kEnableOfflineAutoReload, which will override the disable |
| 205 // here. | 201 // here. |
| 206 command_line->AppendSwitch(switches::kDisableOfflineAutoReload); | 202 command_line->AppendSwitch(switches::kDisableOfflineAutoReload); |
| 207 | 203 |
| 204 // Turn off preconnects because they break the brittle python webserver; |
| 205 // see http://crbug.com/60035. |
| 206 scoped_feature_list_.InitAndDisableFeature(features::kNetworkPrediction); |
| 207 |
| 208 // Allow subclasses to change the command line before running any tests. | 208 // Allow subclasses to change the command line before running any tests. |
| 209 SetUpCommandLine(command_line); | 209 SetUpCommandLine(command_line); |
| 210 // Add command line arguments that are used by all InProcessBrowserTests. | 210 // Add command line arguments that are used by all InProcessBrowserTests. |
| 211 SetUpDefaultCommandLine(command_line); | 211 SetUpDefaultCommandLine(command_line); |
| 212 | 212 |
| 213 // Create a temporary user data directory if required. | 213 // Create a temporary user data directory if required. |
| 214 ASSERT_TRUE(CreateUserDataDirectory()) | 214 ASSERT_TRUE(CreateUserDataDirectory()) |
| 215 << "Could not create user data directory."; | 215 << "Could not create user data directory."; |
| 216 | 216 |
| 217 // Allow subclasses the opportunity to make changes to the default user data | 217 // Allow subclasses the opportunity to make changes to the default user data |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 // On the Mac, this eventually reaches | 632 // On the Mac, this eventually reaches |
| 633 // -[BrowserWindowController windowWillClose:], which will post a deferred | 633 // -[BrowserWindowController windowWillClose:], which will post a deferred |
| 634 // -autorelease on itself to ultimately destroy the Browser object. The line | 634 // -autorelease on itself to ultimately destroy the Browser object. The line |
| 635 // below is necessary to pump these pending messages to ensure all Browsers | 635 // below is necessary to pump these pending messages to ensure all Browsers |
| 636 // get deleted. | 636 // get deleted. |
| 637 content::RunAllPendingInMessageLoop(); | 637 content::RunAllPendingInMessageLoop(); |
| 638 delete autorelease_pool_; | 638 delete autorelease_pool_; |
| 639 autorelease_pool_ = NULL; | 639 autorelease_pool_ = NULL; |
| 640 #endif | 640 #endif |
| 641 } | 641 } |
| OLD | NEW |