OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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. |
130 void RunTest(const char* test_name, int num_target_tabs) { | 100 void RunTest(const char* test_name, int num_target_tabs) { |
101 std::cout<<"\nRunning test: "<<test_name<<"\n"; | |
131 std::string* urls; | 102 std::string* urls; |
132 size_t urls_length = GetUrlList(&urls); | 103 size_t urls_length = GetUrlList(&urls); |
133 | 104 |
134 // Record the initial CommitCharge. This is a system-wide measurement, | 105 // Record the initial CommitCharge. This is a system-wide measurement, |
135 // so if other applications are running, they can create variance in this | 106 // so if other applications are running, they can create variance in this |
136 // test. | 107 // test. |
137 size_t start_size = base::GetSystemCommitCharge(); | 108 size_t start_size = base::GetSystemCommitCharge(); |
138 | 109 |
139 // Cycle through the URLs. | 110 // Cycle through the URLs. |
140 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 111 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 "http://pt.wikipedia.org/wiki/P%C3%A1gina_principal", | 387 "http://pt.wikipedia.org/wiki/P%C3%A1gina_principal", |
417 "http://es.wikipedia.org/wiki/Portada", | 388 "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", | 389 "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>", | 390 "<NEWTAB>", |
420 "http://www.google.com/translate_t?hl=en&text=This%20Is%20A%20Test%20Of%20miss spellingsdfdf&sl=en&tl=ja" | 391 "http://www.google.com/translate_t?hl=en&text=This%20Is%20A%20Test%20Of%20miss spellingsdfdf&sl=en&tl=ja" |
421 }; | 392 }; |
422 | 393 |
423 size_t GeneralMixMemoryTest::urls_length_ = | 394 size_t GeneralMixMemoryTest::urls_length_ = |
424 arraysize(GeneralMixMemoryTest::urls_); | 395 arraysize(GeneralMixMemoryTest::urls_); |
425 | 396 |
426 class GenerlMixReferenceMemoryTest : public GeneralMixMemoryTest { | 397 class GeneralMixReferenceMemoryTest : public GeneralMixMemoryTest { |
427 public: | 398 public: |
428 virtual FilePath GetBrowserDirectory() const { | 399 void SetUp() { |
429 return GetReferenceBrowserDirectory(); | 400 UseReferenceBuild(); |
401 GeneralMixMemoryTest::SetUp(); | |
430 } | 402 } |
431 }; | 403 }; |
432 | 404 |
433 class MembusterMemoryTest : public MemoryTest { | 405 class MembusterMemoryTest : public MemoryTest { |
434 public: | 406 public: |
435 MembusterMemoryTest() : test_urls_(NULL) {} | 407 MembusterMemoryTest() : test_urls_(NULL) {} |
436 | 408 |
437 virtual ~MembusterMemoryTest() { | 409 virtual ~MembusterMemoryTest() { |
438 delete[] test_urls_; | 410 delete[] test_urls_; |
439 } | 411 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 "http://en.marveldatabase.com/Main_Page", | 484 "http://en.marveldatabase.com/Main_Page", |
513 "http://bioshock.wikia.com/wiki/Main_Page", | 485 "http://bioshock.wikia.com/wiki/Main_Page", |
514 "http://www.armchairgm.com/Special:ImageRating", | 486 "http://www.armchairgm.com/Special:ImageRating", |
515 "http://www.armchairgm.com/Anderson_Continues_to_Thrive_for_Cleveland", | 487 "http://www.armchairgm.com/Anderson_Continues_to_Thrive_for_Cleveland", |
516 "http://www.armchairgm.com/Main_Page" | 488 "http://www.armchairgm.com/Main_Page" |
517 }; | 489 }; |
518 | 490 |
519 size_t MembusterMemoryTest::urls_length_ = | 491 size_t MembusterMemoryTest::urls_length_ = |
520 arraysize(MembusterMemoryTest::source_urls_); | 492 arraysize(MembusterMemoryTest::source_urls_); |
521 | 493 |
522 TEST_F(GeneralMixMemoryTest, SingleTabTest) { | 494 #define QUOTE(x) #x |
523 RunTest("_1t", 1); | 495 #define GENERAL_MIX_MEMORY_TESTS(name, tabs) \ |
496 TEST_F(GeneralMixMemoryTest, name) { \ | |
497 RunTest(QUOTE(_##tabs##t), tabs); \ | |
498 } \ | |
499 TEST_F(GeneralMixReferenceMemoryTest, name) { \ | |
500 RunTest(QUOTE(_##tabs##t_ref), tabs); \ | |
524 } | 501 } |
525 | 502 |
526 TEST_F(GeneralMixMemoryTest, FiveTabTest) { | 503 GENERAL_MIX_MEMORY_TESTS(SingleTabTest, 1); |
527 RunTest("_5t", 5); | 504 GENERAL_MIX_MEMORY_TESTS(FiveTabTest, 5); |
528 } | 505 GENERAL_MIX_MEMORY_TESTS(TwelveTabTest, 12); |
jrt
2011/06/17 19:50:46
This test did not previously use a reference build
| |
529 | |
530 TEST_F(GeneralMixMemoryTest, TwelveTabTest) { | |
531 RunTest("_12t", 12); | |
532 } | |
533 | 506 |
534 // Commented out until the recorded cache data is added. | 507 // Commented out until the recorded cache data is added. |
535 //TEST_F(MembusterMemoryTest, Windows) { | 508 //TEST_F(MembusterMemoryTest, Windows) { |
536 // RunTest("membuster", 0); | 509 // RunTest("membuster", 0); |
537 //} | 510 //} |
538 | 511 |
539 } // namespace | 512 } // namespace |
OLD | NEW |