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

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

Issue 18248: CommandLine API rework (Closed)
Patch Set: fixes Created 11 years, 11 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 14 matching lines...) Expand all
25 25
26 static const wchar_t kTempDirName[] = L"memory_test_profile"; 26 static const wchar_t kTempDirName[] = L"memory_test_profile";
27 27
28 class MemoryTest : public UITest { 28 class MemoryTest : public UITest {
29 public: 29 public:
30 MemoryTest() : cleanup_temp_dir_on_exit_(false) { 30 MemoryTest() : cleanup_temp_dir_on_exit_(false) {
31 show_window_ = true; 31 show_window_ = true;
32 32
33 // For now, turn off plugins because they crash like crazy. 33 // For now, turn off plugins because they crash like crazy.
34 // TODO(mbelshe): Fix Chrome to not crash with plugins. 34 // TODO(mbelshe): Fix Chrome to not crash with plugins.
35 CommandLine::AppendSwitch(&launch_arguments_, switches::kDisablePlugins); 35 launch_arguments_.AppendSwitch(switches::kDisablePlugins);
36 36
37 CommandLine::AppendSwitch(&launch_arguments_, switches::kEnableLogging); 37 launch_arguments_.AppendSwitch(switches::kEnableLogging);
38 38
39 // Use the playback cache, but don't use playback events. 39 // Use the playback cache, but don't use playback events.
40 CommandLine::AppendSwitch(&launch_arguments_, switches::kPlaybackMode); 40 launch_arguments_.AppendSwitch(switches::kPlaybackMode);
41 CommandLine::AppendSwitch(&launch_arguments_, switches::kNoEvents); 41 launch_arguments_.AppendSwitch(switches::kNoEvents);
42 42
43 // Get the specified user data dir (optional) 43 // Get the specified user data dir (optional)
44 std::wstring profile_dir = 44 std::wstring profile_dir =
45 CommandLine().GetSwitchValue(switches::kUserDataDir); 45 CommandLine::ForCurrentProcess()->GetSwitchValue(switches::kUserDataDir);
46 46
47 if (profile_dir.length() == 0) { 47 if (profile_dir.length() == 0) {
48 // Compute the user-data-dir which contains our test cache. 48 // Compute the user-data-dir which contains our test cache.
49 PathService::Get(base::DIR_EXE, &profile_dir); 49 PathService::Get(base::DIR_EXE, &profile_dir);
50 file_util::UpOneDirectory(&profile_dir); 50 file_util::UpOneDirectory(&profile_dir);
51 file_util::UpOneDirectory(&profile_dir); 51 file_util::UpOneDirectory(&profile_dir);
52 file_util::AppendToPath(&profile_dir, L"data"); 52 file_util::AppendToPath(&profile_dir, L"data");
53 file_util::AppendToPath(&profile_dir, L"memory_test"); 53 file_util::AppendToPath(&profile_dir, L"memory_test");
54 file_util::AppendToPath(&profile_dir, L"general_mix"); 54 file_util::AppendToPath(&profile_dir, L"general_mix");
55 55
56 if (!SetupTempDirectory(profile_dir)) { 56 if (!SetupTempDirectory(profile_dir)) {
57 // There isn't really a way to fail gracefully here. 57 // There isn't really a way to fail gracefully here.
58 // Neither this constuctor nor the SetUp() method return 58 // Neither this constuctor nor the SetUp() method return
59 // status to the caller. So, just fall through using the 59 // status to the caller. So, just fall through using the
60 // default profile and log this. The failure will be 60 // default profile and log this. The failure will be
61 // obvious. 61 // obvious.
62 LOG(ERROR) << "Error preparing temp directory for test"; 62 LOG(ERROR) << "Error preparing temp directory for test";
63 } 63 }
64 } 64 }
65 65
66 CommandLine::AppendSwitchWithValue(&launch_arguments_, 66 launch_arguments_.AppendSwitchWithValue(switches::kUserDataDir,
67 switches::kUserDataDir, 67 user_data_dir_);
68 user_data_dir_);
69 } 68 }
70 69
71 ~MemoryTest() { 70 ~MemoryTest() {
72 // Cleanup our temporary directory. 71 // Cleanup our temporary directory.
73 if (cleanup_temp_dir_on_exit_) 72 if (cleanup_temp_dir_on_exit_)
74 file_util::Delete(user_data_dir_, true); 73 file_util::Delete(user_data_dir_, true);
75 } 74 }
76 75
77 // TODO(mbelshe): Separate this data to an external file. 76 // TODO(mbelshe): Separate this data to an external file.
78 // This memory test loads a set of URLs across a set of tabs, maintaining the 77 // This memory test loads a set of URLs across a set of tabs, maintaining the
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 430 }
432 431
433 TEST_F(MemoryTest, FiveTabTest) { 432 TEST_F(MemoryTest, FiveTabTest) {
434 RunTest(L"5t", 5); 433 RunTest(L"5t", 5);
435 } 434 }
436 435
437 TEST_F(MemoryTest, TwelveTabTest) { 436 TEST_F(MemoryTest, TwelveTabTest) {
438 RunTest(L"12t", 12); 437 RunTest(L"12t", 12);
439 } 438 }
440 439
OLDNEW
« no previous file with comments | « chrome/test/automation/automation_proxy_uitest.cc ('k') | chrome/test/page_cycler/page_cycler_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698