Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: chrome/test/test_launcher_utils.cc

Issue 7541001: Move more files from chrome/test to chrome/test/base, part #3 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/test_launcher_utils.h ('k') | chrome/test/test_location_bar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "base/command_line.h"
6 #include "base/environment.h"
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/path_service.h"
10 #include "base/string_number_conversions.h"
11 #include "chrome/common/chrome_paths.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/test_launcher_utils.h"
14 #include "ui/gfx/gl/gl_switches.h"
15
16 namespace {
17
18 // A multiplier for slow tests. We generally avoid multiplying
19 // test timeouts by any constants. Here it is used as last resort
20 // to implement the SLOW_ test prefix.
21 static const int kSlowTestTimeoutMultiplier = 5;
22
23 } // namespace
24
25 namespace test_launcher_utils {
26
27 void PrepareBrowserCommandLineForTests(CommandLine* command_line) {
28 // Turn off tip loading for tests; see http://crbug.com/17725.
29 command_line->AppendSwitch(switches::kDisableWebResources);
30
31 // Turn off preconnects because they break the brittle python webserver;
32 // see http://crbug.com/60035.
33 command_line->AppendSwitch(switches::kDisablePreconnect);
34
35 // Don't show the first run ui.
36 command_line->AppendSwitch(switches::kNoFirstRun);
37
38 // No default browser check, it would create an info-bar (if we are not the
39 // default browser) that could conflicts with some tests expectations.
40 command_line->AppendSwitch(switches::kNoDefaultBrowserCheck);
41
42 // Enable warning level logging so that we can see when bad stuff happens.
43 command_line->AppendSwitch(switches::kEnableLogging);
44 command_line->AppendSwitchASCII(switches::kLoggingLevel, "1"); // warning
45
46 // Disable safebrowsing autoupdate.
47 command_line->AppendSwitch(switches::kSbDisableAutoUpdate);
48
49 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
50 // Don't use the native password stores on Linux since they may
51 // prompt for additional UI during tests and cause test failures or
52 // timeouts. Win, Mac and ChromeOS don't look at the kPasswordStore
53 // switch.
54 if (!command_line->HasSwitch(switches::kPasswordStore))
55 command_line->AppendSwitchASCII(switches::kPasswordStore, "basic");
56 #endif
57
58 #if defined(OS_MACOSX)
59 // Use mock keychain on mac to prevent blocking permissions dialogs.
60 // TODO(sync): Re-enable when mock keyring works with sync integration tests.
61 // See crbug.com/89808.
62 // command_line->AppendSwitch(switches::kUseMockKeychain);
63 #endif
64 }
65
66 bool OverrideUserDataDir(const FilePath& user_data_dir) {
67 bool success = true;
68
69 // PathService::Override() is the best way to change the user data directory.
70 // This matches what is done in ChromeMain().
71 success = PathService::Override(chrome::DIR_USER_DATA, user_data_dir);
72
73 #if defined(OS_POSIX) && !defined(OS_MACOSX)
74 // Make sure the cache directory is inside our clear profile. Otherwise
75 // the cache may contain data from earlier tests that could break the
76 // current test.
77 //
78 // Note: we use an environment variable here, because we have to pass the
79 // value to the child process. This is the simplest way to do it.
80 scoped_ptr<base::Environment> env(base::Environment::Create());
81 success = success && env->SetVar("XDG_CACHE_HOME", user_data_dir.value());
82 #endif
83
84 return success;
85 }
86
87 bool OverrideGLImplementation(CommandLine* command_line,
88 const std::string& implementation_name) {
89 if (command_line->HasSwitch(switches::kUseGL))
90 return false;
91
92 command_line->AppendSwitchASCII(switches::kUseGL, implementation_name);
93
94 return true;
95 }
96
97 int GetTestTerminationTimeout(const std::string& test_name,
98 int default_timeout_ms) {
99 int timeout_ms = default_timeout_ms;
100
101 // Make it possible for selected tests to request a longer timeout.
102 // Generally tests should really avoid doing too much, and splitting
103 // a test instead of using SLOW prefix is strongly preferred.
104 if (test_name.find("SLOW_") != std::string::npos)
105 timeout_ms *= kSlowTestTimeoutMultiplier;
106
107 return timeout_ms;
108 }
109
110 } // namespace test_launcher_utils
OLDNEW
« no previous file with comments | « chrome/test/test_launcher_utils.h ('k') | chrome/test/test_location_bar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698