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

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

Issue 7185023: Support Chromium-branded builds and cleanup reference build usage. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: . Created 9 years, 6 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 23 matching lines...) Expand all
34 34
35 ~MemoryTest() { 35 ~MemoryTest() {
36 // Cleanup our temporary directory. 36 // Cleanup our temporary directory.
37 if (cleanup_temp_dir_on_exit_) 37 if (cleanup_temp_dir_on_exit_)
38 file_util::Delete(temp_dir_, true); 38 file_util::Delete(temp_dir_, true);
39 } 39 }
40 40
41 // Called from SetUp() to determine the user data dir to copy. 41 // Called from SetUp() to determine the user data dir to copy.
42 virtual FilePath GetUserDataDirSource() const = 0; 42 virtual FilePath GetUserDataDirSource() const = 0;
43 43
44 // Called from Setup() to find the path for the chrome executable.
45 // An empty FilePath results in the default being used.
46 virtual FilePath GetBrowserDirectory() const { return FilePath(); }
47
48 // Called from RunTest() to determine the set of URLs to retrieve. 44 // Called from RunTest() to determine the set of URLs to retrieve.
49 // Returns the length of the list. 45 // Returns the length of the list.
50 virtual size_t GetUrlList(std::string** list) = 0; 46 virtual size_t GetUrlList(std::string** list) = 0;
51 47
52 static FilePath GetReferenceBrowserDirectory() {
53 FilePath dir;
54 PathService::Get(chrome::DIR_TEST_TOOLS, &dir);
55 dir = dir.AppendASCII("reference_build");
56 #if defined(OS_WIN)
57 dir = dir.AppendASCII("chrome");
58 #elif defined(OS_LINUX)
59 dir = dir.AppendASCII("chrome_linux");
60 #elif defined(OS_MACOSX)
61 dir = dir.AppendASCII("chrome_mac");
62 #endif
63 return dir;
64 }
65
66 virtual void SetUp() { 48 virtual void SetUp() {
67 show_window_ = true; 49 show_window_ = true;
68 50
69 // For now, turn off plugins because they crash like crazy. 51 // For now, turn off plugins because they crash like crazy.
70 // TODO(mbelshe): Fix Chrome to not crash with plugins. 52 // TODO(mbelshe): Fix Chrome to not crash with plugins.
71 launch_arguments_.AppendSwitch(switches::kDisablePlugins); 53 launch_arguments_.AppendSwitch(switches::kDisablePlugins);
72 54
73 launch_arguments_.AppendSwitch(switches::kEnableLogging); 55 launch_arguments_.AppendSwitch(switches::kEnableLogging);
74 56
75 // In order to record a dataset to cache for future playback, 57 // In order to record a dataset to cache for future playback,
(...skipping 22 matching lines...) Expand all
98 LOG(ERROR) << "Error preparing temp directory for test"; 80 LOG(ERROR) << "Error preparing temp directory for test";
99 } 81 }
100 } 82 }
101 } else { // Record session. 83 } else { // Record session.
102 launch_arguments_.AppendSwitch(switches::kRecordMode); 84 launch_arguments_.AppendSwitch(switches::kRecordMode);
103 launch_arguments_.AppendSwitch(switches::kNoEvents); 85 launch_arguments_.AppendSwitch(switches::kNoEvents);
104 86
105 user_data_dir_ = GetUserDataDirSource(); 87 user_data_dir_ = GetUserDataDirSource();
106 } 88 }
107 89
108 FilePath browser_dir = GetBrowserDirectory();
109 if (!browser_dir.empty()) {
110 #if defined(OS_WIN)
111 browser_dir = browser_dir.AppendASCII("chrome");
112 #elif defined(OS_LINUX)
113 browser_dir = browser_dir.AppendASCII("chrome_linux");
114 #elif defined(OS_MACOSX)
115 browser_dir = browser_dir.AppendASCII("chrome_mac");
116 #endif
117 browser_directory_ = browser_dir;
118 }
119
120 launch_arguments_.AppendSwitchPath(switches::kUserDataDir, user_data_dir_); 90 launch_arguments_.AppendSwitchPath(switches::kUserDataDir, user_data_dir_);
121 UITest::SetUp(); 91 UITest::SetUp();
122 } 92 }
123 93
124 // This memory test loads a set of URLs across a set of tabs, maintaining the 94 // This memory test loads a set of URLs across a set of tabs, maintaining the
125 // number of concurrent open tabs at num_target_tabs. 95 // number of concurrent open tabs at num_target_tabs.
126 // <NEWTAB> is a special URL which informs the loop when we should create a 96 // <NEWTAB> is a special URL which informs the loop when we should create a
127 // new tab. 97 // new tab.
128 // <PAUSE> is a special URL that informs the loop to pause before proceeding 98 // <PAUSE> is a special URL that informs the loop to pause before proceeding
129 // to the next URL. 99 // to the next URL.
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 "http://pt.wikipedia.org/wiki/P%C3%A1gina_principal", 386 "http://pt.wikipedia.org/wiki/P%C3%A1gina_principal",
417 "http://es.wikipedia.org/wiki/Portada", 387 "http://es.wikipedia.org/wiki/Portada",
418 "http://ru.wikipedia.org/wiki/%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0 %D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0", 388 "http://ru.wikipedia.org/wiki/%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0 %D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0",
419 "<NEWTAB>", 389 "<NEWTAB>",
420 "http://www.google.com/translate_t?hl=en&text=This%20Is%20A%20Test%20Of%20miss spellingsdfdf&sl=en&tl=ja" 390 "http://www.google.com/translate_t?hl=en&text=This%20Is%20A%20Test%20Of%20miss spellingsdfdf&sl=en&tl=ja"
421 }; 391 };
422 392
423 size_t GeneralMixMemoryTest::urls_length_ = 393 size_t GeneralMixMemoryTest::urls_length_ =
424 arraysize(GeneralMixMemoryTest::urls_); 394 arraysize(GeneralMixMemoryTest::urls_);
425 395
426 class GenerlMixReferenceMemoryTest : public GeneralMixMemoryTest { 396 class GeneralMixReferenceMemoryTest : public GeneralMixMemoryTest {
427 public: 397 public:
428 virtual FilePath GetBrowserDirectory() const { 398 void SetUp() {
429 return GetReferenceBrowserDirectory(); 399 UseReferenceBuild();
400 GeneralMixMemoryTest::SetUp();
430 } 401 }
431 }; 402 };
432 403
433 class MembusterMemoryTest : public MemoryTest { 404 class MembusterMemoryTest : public MemoryTest {
434 public: 405 public:
435 MembusterMemoryTest() : test_urls_(NULL) {} 406 MembusterMemoryTest() : test_urls_(NULL) {}
436 407
437 virtual ~MembusterMemoryTest() { 408 virtual ~MembusterMemoryTest() {
438 delete[] test_urls_; 409 delete[] test_urls_;
439 } 410 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 "http://en.marveldatabase.com/Main_Page", 483 "http://en.marveldatabase.com/Main_Page",
513 "http://bioshock.wikia.com/wiki/Main_Page", 484 "http://bioshock.wikia.com/wiki/Main_Page",
514 "http://www.armchairgm.com/Special:ImageRating", 485 "http://www.armchairgm.com/Special:ImageRating",
515 "http://www.armchairgm.com/Anderson_Continues_to_Thrive_for_Cleveland", 486 "http://www.armchairgm.com/Anderson_Continues_to_Thrive_for_Cleveland",
516 "http://www.armchairgm.com/Main_Page" 487 "http://www.armchairgm.com/Main_Page"
517 }; 488 };
518 489
519 size_t MembusterMemoryTest::urls_length_ = 490 size_t MembusterMemoryTest::urls_length_ =
520 arraysize(MembusterMemoryTest::source_urls_); 491 arraysize(MembusterMemoryTest::source_urls_);
521 492
522 TEST_F(GeneralMixMemoryTest, SingleTabTest) { 493 #define QUOTE(x) #x
523 RunTest("_1t", 1); 494 #define GENERAL_MIX_MEMORY_TESTS(name, tabs) \
495 TEST_F(GeneralMixMemoryTest, name) { \
496 RunTest(QUOTE(_##tabs##t), tabs); \
497 } \
498 TEST_F(GeneralMixReferenceMemoryTest, name) { \
499 RunTest(QUOTE(_##tabs##t_ref), tabs); \
524 } 500 }
525 501
526 TEST_F(GeneralMixMemoryTest, FiveTabTest) { 502 GENERAL_MIX_MEMORY_TESTS(SingleTabTest, 1);
527 RunTest("_5t", 5); 503 GENERAL_MIX_MEMORY_TESTS(FiveTabTest, 5);
528 } 504 GENERAL_MIX_MEMORY_TESTS(TwelveTabTest, 12);
529
530 TEST_F(GeneralMixMemoryTest, TwelveTabTest) {
531 RunTest("_12t", 12);
532 }
533 505
534 // Commented out until the recorded cache data is added. 506 // Commented out until the recorded cache data is added.
535 //TEST_F(MembusterMemoryTest, Windows) { 507 //TEST_F(MembusterMemoryTest, Windows) {
536 // RunTest("membuster", 0); 508 // RunTest("membuster", 0);
537 //} 509 //}
538 510
539 } // namespace 511 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698