| OLD | NEW |
| (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/basictypes.h" | |
| 6 #include "base/command_line.h" | |
| 7 #include "base/file_path.h" | |
| 8 #include "base/file_util.h" | |
| 9 #include "base/path_service.h" | |
| 10 #include "base/process_util.h" | |
| 11 #include "base/string_util.h" | |
| 12 #include "base/threading/platform_thread.h" | |
| 13 #include "chrome/browser/net/url_fixer_upper.h" | |
| 14 #include "chrome/common/chrome_constants.h" | |
| 15 #include "chrome/common/chrome_paths.h" | |
| 16 #include "chrome/common/chrome_switches.h" | |
| 17 #include "chrome/test/automation/automation_proxy.h" | |
| 18 #include "chrome/test/automation/browser_proxy.h" | |
| 19 #include "chrome/test/automation/tab_proxy.h" | |
| 20 #include "chrome/test/automation/window_proxy.h" | |
| 21 #include "chrome/test/base/chrome_process_util.h" | |
| 22 #include "chrome/test/ui/ui_perf_test.h" | |
| 23 #include "googleurl/src/gurl.h" | |
| 24 #include "net/base/net_util.h" | |
| 25 #include "testing/gtest/include/gtest/gtest.h" | |
| 26 | |
| 27 namespace { | |
| 28 | |
| 29 static const FilePath::CharType kTempDirName[] = | |
| 30 FILE_PATH_LITERAL("memory_test_profile"); | |
| 31 | |
| 32 class MemoryTest : public UIPerfTest { | |
| 33 public: | |
| 34 MemoryTest() : cleanup_temp_dir_on_exit_(false) {} | |
| 35 | |
| 36 ~MemoryTest() { | |
| 37 // Cleanup our temporary directory. | |
| 38 if (cleanup_temp_dir_on_exit_) | |
| 39 file_util::Delete(temp_dir_, true); | |
| 40 } | |
| 41 | |
| 42 // Called from SetUp() to determine the user data dir to copy. | |
| 43 virtual FilePath GetUserDataDirSource() const = 0; | |
| 44 | |
| 45 // Called from RunTest() to determine the set of URLs to retrieve. | |
| 46 // Returns the length of the list. | |
| 47 virtual size_t GetUrlList(std::string** list) = 0; | |
| 48 | |
| 49 virtual void SetUp() { | |
| 50 show_window_ = true; | |
| 51 | |
| 52 // For now, turn off plugins because they crash like crazy. | |
| 53 // TODO(mbelshe): Fix Chrome to not crash with plugins. | |
| 54 launch_arguments_.AppendSwitch(switches::kDisablePlugins); | |
| 55 | |
| 56 launch_arguments_.AppendSwitch(switches::kEnableLogging); | |
| 57 | |
| 58 // In order to record a dataset to cache for future playback, | |
| 59 // set the |playback| to false and run the test. The source user data dir | |
| 60 // will be populated with an appropriate cache set. If any of source | |
| 61 // urls are particularly slow, setting |kMaxWaitTime| higher while record | |
| 62 // may be useful. | |
| 63 bool playback = true; | |
| 64 if (playback) { | |
| 65 // Use the playback cache, but don't use playback events. | |
| 66 launch_arguments_.AppendSwitch(switches::kPlaybackMode); | |
| 67 launch_arguments_.AppendSwitch(switches::kNoEvents); | |
| 68 | |
| 69 // Get the specified user data dir (optional) | |
| 70 FilePath profile_dir = | |
| 71 CommandLine::ForCurrentProcess()->GetSwitchValuePath( | |
| 72 switches::kUserDataDir); | |
| 73 | |
| 74 if (profile_dir.empty()) { | |
| 75 if (!SetupTempDirectory(GetUserDataDirSource())) { | |
| 76 // There isn't really a way to fail gracefully here. | |
| 77 // Neither this constructor nor the SetUp() method return | |
| 78 // status to the caller. So, just fall through using the | |
| 79 // default profile and log this. The failure will be | |
| 80 // obvious. | |
| 81 LOG(ERROR) << "Error preparing temp directory for test"; | |
| 82 } | |
| 83 } | |
| 84 } else { // Record session. | |
| 85 launch_arguments_.AppendSwitch(switches::kRecordMode); | |
| 86 launch_arguments_.AppendSwitch(switches::kNoEvents); | |
| 87 | |
| 88 user_data_dir_ = GetUserDataDirSource(); | |
| 89 } | |
| 90 | |
| 91 launch_arguments_.AppendSwitchPath(switches::kUserDataDir, user_data_dir_); | |
| 92 UITest::SetUp(); | |
| 93 } | |
| 94 | |
| 95 // This memory test loads a set of URLs across a set of tabs, maintaining the | |
| 96 // number of concurrent open tabs at num_target_tabs. | |
| 97 // <NEWTAB> is a special URL which informs the loop when we should create a | |
| 98 // new tab. | |
| 99 // <PAUSE> is a special URL that informs the loop to pause before proceeding | |
| 100 // to the next URL. | |
| 101 void RunTest(const char* test_name, int num_target_tabs) { | |
| 102 std::string* urls; | |
| 103 size_t urls_length = GetUrlList(&urls); | |
| 104 | |
| 105 // Record the initial CommitCharge. This is a system-wide measurement, | |
| 106 // so if other applications are running, they can create variance in this | |
| 107 // test. | |
| 108 size_t start_size = base::GetSystemCommitCharge(); | |
| 109 | |
| 110 // Cycle through the URLs. | |
| 111 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | |
| 112 ASSERT_TRUE(window.get()); | |
| 113 int active_window = 0; // The index of the window we are currently using. | |
| 114 scoped_refptr<TabProxy> tab(window->GetActiveTab()); | |
| 115 ASSERT_TRUE(tab.get()); | |
| 116 int expected_tab_count = 1; | |
| 117 for (unsigned counter = 0; counter < urls_length; ++counter) { | |
| 118 std::string url = urls[counter]; | |
| 119 | |
| 120 SCOPED_TRACE(url); | |
| 121 | |
| 122 if (url == "<PAUSE>") { // Special command to delay on this page | |
| 123 base::PlatformThread::Sleep(2000); | |
| 124 continue; | |
| 125 } | |
| 126 | |
| 127 if (url == "<NEWTAB>") { // Special command to create a new tab | |
| 128 if (++counter >= urls_length) | |
| 129 continue; // Newtab was specified at end of list. ignore. | |
| 130 | |
| 131 url = urls[counter]; | |
| 132 if (GetTabCount() < num_target_tabs) { | |
| 133 EXPECT_TRUE(window->AppendTab(GURL(url))); | |
| 134 expected_tab_count++; | |
| 135 WaitUntilTabCount(expected_tab_count); | |
| 136 tab = window->GetActiveTab(); | |
| 137 ASSERT_TRUE(tab.get()); | |
| 138 continue; | |
| 139 } | |
| 140 | |
| 141 int tab_index = counter % num_target_tabs; // A pseudo-random tab. | |
| 142 tab = window->GetTab(tab_index); | |
| 143 ASSERT_TRUE(tab.get()); | |
| 144 } | |
| 145 | |
| 146 if (url == "<NEXTTAB>") { // Special command to select the next tab. | |
| 147 int tab_index, tab_count; | |
| 148 EXPECT_TRUE(window->GetActiveTabIndex(&tab_index)); | |
| 149 EXPECT_TRUE(window->GetTabCount(&tab_count)); | |
| 150 tab_index = (tab_index + 1) % tab_count; | |
| 151 tab = window->GetTab(tab_index); | |
| 152 ASSERT_TRUE(tab.get()); | |
| 153 continue; | |
| 154 } | |
| 155 | |
| 156 if (url == "<NEWWINDOW>") { // Special command to create a new window. | |
| 157 if (counter + 1 >= urls_length) | |
| 158 continue; // Newwindows was specified at end of list. ignore. | |
| 159 | |
| 160 int window_count; | |
| 161 EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | |
| 162 EXPECT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, | |
| 163 show_window_)); | |
| 164 int expected_window_count = window_count + 1; | |
| 165 EXPECT_TRUE(automation()->WaitForWindowCountToBecome( | |
| 166 expected_window_count)); | |
| 167 EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | |
| 168 EXPECT_EQ(expected_window_count, window_count); | |
| 169 | |
| 170 // A new window will not load a url if requested too soon. The window | |
| 171 // stays on the new tab page instead. | |
| 172 base::PlatformThread::Sleep(200); | |
| 173 | |
| 174 active_window = window_count - 1; | |
| 175 window = automation()->GetBrowserWindow(active_window); | |
| 176 ASSERT_TRUE(window.get()); | |
| 177 tab = window->GetActiveTab(); | |
| 178 ASSERT_TRUE(tab.get()); | |
| 179 continue; | |
| 180 } | |
| 181 | |
| 182 if (url == "<NEXTWINDOW>") { // Select the next window. | |
| 183 int window_count; | |
| 184 EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | |
| 185 active_window = (active_window + 1) % window_count; | |
| 186 window = automation()->GetBrowserWindow(active_window); | |
| 187 ASSERT_TRUE(window.get()); | |
| 188 tab = window->GetActiveTab(); | |
| 189 ASSERT_TRUE(tab.get()); | |
| 190 continue; | |
| 191 } | |
| 192 | |
| 193 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | |
| 194 tab->NavigateToURL(GURL(urls[counter]))); | |
| 195 | |
| 196 // TODO(mbelshe): Bug 2953 | |
| 197 // The automation crashes periodically if we cycle too quickly. | |
| 198 // To make these tests more reliable, slowing them down a bit. | |
| 199 base::PlatformThread::Sleep(100); | |
| 200 } | |
| 201 | |
| 202 size_t stop_size = base::GetSystemCommitCharge(); | |
| 203 PrintIOPerfInfo(test_name); | |
| 204 PrintMemoryUsageInfo(test_name); | |
| 205 PrintSystemCommitCharge(test_name, stop_size - start_size, | |
| 206 true /* important */); | |
| 207 } | |
| 208 | |
| 209 private: | |
| 210 // Setup a temporary directory to store the profile to use | |
| 211 // with these tests. | |
| 212 // Input: | |
| 213 // src_dir is set to the source directory | |
| 214 // Output: | |
| 215 // On success, modifies user_data_dir_ to be a new profile directory | |
| 216 // sets temp_dir_ to the containing temporary directory, | |
| 217 // and sets cleanup_temp_dir_on_exit_ to true. | |
| 218 bool SetupTempDirectory(const FilePath& src_dir) { | |
| 219 VLOG(1) << "Setting up temp directory in " << src_dir.value(); | |
| 220 // We create a copy of the test dir and use it so that each | |
| 221 // run of this test starts with the same data. Running this | |
| 222 // test has the side effect that it will change the profile. | |
| 223 if (!file_util::CreateNewTempDirectory(kTempDirName, &temp_dir_)) { | |
| 224 LOG(ERROR) << "Could not create temp directory:" << kTempDirName; | |
| 225 return false; | |
| 226 } | |
| 227 | |
| 228 if (!file_util::CopyDirectory(src_dir, temp_dir_, true)) { | |
| 229 LOG(ERROR) << "Could not copy temp directory"; | |
| 230 return false; | |
| 231 } | |
| 232 | |
| 233 // The profile directory was copied in to the containing temp | |
| 234 // directory as its base name, so point user_data_dir_ there. | |
| 235 user_data_dir_ = temp_dir_.Append(src_dir.BaseName()); | |
| 236 cleanup_temp_dir_on_exit_ = true; | |
| 237 VLOG(1) << "Finished temp directory setup."; | |
| 238 return true; | |
| 239 } | |
| 240 | |
| 241 bool cleanup_temp_dir_on_exit_; | |
| 242 FilePath temp_dir_; | |
| 243 FilePath user_data_dir_; | |
| 244 }; | |
| 245 | |
| 246 class GeneralMixMemoryTest : public MemoryTest { | |
| 247 public: | |
| 248 virtual FilePath GetUserDataDirSource() const { | |
| 249 FilePath profile_dir; | |
| 250 PathService::Get(base::DIR_SOURCE_ROOT, &profile_dir); | |
| 251 profile_dir = profile_dir.AppendASCII("data"); | |
| 252 profile_dir = profile_dir.AppendASCII("memory_test"); | |
| 253 profile_dir = profile_dir.AppendASCII("general_mix"); | |
| 254 return profile_dir; | |
| 255 } | |
| 256 | |
| 257 virtual size_t GetUrlList(std::string** list) { | |
| 258 *list = urls_; | |
| 259 return urls_length_; | |
| 260 } | |
| 261 | |
| 262 private: | |
| 263 static std::string urls_[]; | |
| 264 static size_t urls_length_; | |
| 265 }; | |
| 266 | |
| 267 // TODO(mbelshe): Separate this data to an external file. | |
| 268 std::string GeneralMixMemoryTest::urls_[] = { | |
| 269 "http://www.yahoo.com/", | |
| 270 "http://hotjobs.yahoo.com/career-articles-the_biggest_resume_mistake_you_can_m
ake-436", | |
| 271 "http://news.yahoo.com/s/ap/20080804/ap_on_re_mi_ea/odd_israel_home_alone", | |
| 272 "http://news.yahoo.com/s/nm/20080729/od_nm/subway_dc", | |
| 273 "http://search.yahoo.com/search?p=new+york+subway&ygmasrchbtn=web+search&fr=us
h-news", | |
| 274 "<NEWTAB>", | |
| 275 "http://www.cnn.com/", | |
| 276 "http://www.cnn.com/2008/SHOWBIZ/TV/08/03/applegate.cancer.ap/index.html", | |
| 277 "http://www.cnn.com/2008/HEALTH/conditions/07/29/black.aids.report/index.html"
, | |
| 278 "http://www.cnn.com/POLITICS/", | |
| 279 "http://search.cnn.com/search.jsp?query=obama&type=web&sortBy=date&intl=false"
, | |
| 280 "<NEWTAB>", | |
| 281 "http://mail.google.com/", | |
| 282 "http://mail.google.com/mail/?shva=1", | |
| 283 "http://mail.google.com/mail/?shva=1#search/ipsec", | |
| 284 "http://mail.google.com/mail/?shva=1#search/ipsec/ee29ae66165d417", | |
| 285 "http://mail.google.com/mail/?shva=1#compose", | |
| 286 "<NEWTAB>", | |
| 287 "http://docs.google.com/", | |
| 288 "<NEWTAB>", | |
| 289 "http://calendar.google.com/", | |
| 290 "<NEWTAB>", | |
| 291 "http://maps.google.com/", | |
| 292 "http://maps.google.com/maps/mpl?moduleurl=http://earthquake.usgs.gov/eqcenter
/mapplets/earthquakes.xml&ie=UTF8&ll=20,170&spn=140.625336,73.828125&t=k&z=2", | |
| 293 "http://maps.google.com/maps?f=q&hl=en&geocode=&q=1600+amphitheater+parkway,+m
ountain+view,+ca&ie=UTF8&z=13", | |
| 294 "<NEWTAB>", | |
| 295 "http://www.google.com/", | |
| 296 "http://www.google.com/search?hl=en&q=food&btnG=Google+Search", | |
| 297 "http://books.google.com/books?hl=en&q=food&um=1&ie=UTF-8&sa=N&tab=wp", | |
| 298 "http://images.google.com/images?hl=en&q=food&um=1&ie=UTF-8&sa=N&tab=pi", | |
| 299 "http://news.google.com/news?hl=en&q=food&um=1&ie=UTF-8&sa=N&tab=in", | |
| 300 "http://www.google.com/products?sa=N&tab=nf&q=food", | |
| 301 "<NEWTAB>", | |
| 302 "http://www.scoundrelspoint.com/polyhedra/shuttle/index.html", | |
| 303 "<PAUSE>", | |
| 304 "<NEWTAB>", | |
| 305 "http://ctho.ath.cx/toys/3d.html", | |
| 306 "<PAUSE>", | |
| 307 "<NEWTAB>", | |
| 308 "http://www.youtube.com/", | |
| 309 "http://www.youtube.com/results?search_query=funny&search_type=&aq=f", | |
| 310 "http://www.youtube.com/watch?v=GuMMfgWhm3g", | |
| 311 "<NEWTAB>", | |
| 312 "http://www.craigslist.com/", | |
| 313 "http://sfbay.craigslist.org/", | |
| 314 "http://sfbay.craigslist.org/apa/", | |
| 315 "http://sfbay.craigslist.org/sfc/apa/782398209.html", | |
| 316 "http://sfbay.craigslist.org/sfc/apa/782347795.html", | |
| 317 "http://sfbay.craigslist.org/sby/apa/782342791.html", | |
| 318 "http://sfbay.craigslist.org/sfc/apa/782344396.html", | |
| 319 "<NEWTAB>", | |
| 320 "http://www.whitehouse.gov/", | |
| 321 "http://www.whitehouse.gov/news/releases/2008/07/20080729.html", | |
| 322 "http://www.whitehouse.gov/infocus/afghanistan/", | |
| 323 "http://www.whitehouse.gov/infocus/africa/", | |
| 324 "<NEWTAB>", | |
| 325 "http://www.msn.com/", | |
| 326 "http://msn.foxsports.com/horseracing/story/8409670/Big-Brown-rebounds-in-Hask
ell-Invitational?MSNHPHMA", | |
| 327 "http://articles.moneycentral.msn.com/Investing/StockInvestingTrading/TheBigge
stRiskToYourRetirement_SeriesHome.aspx", | |
| 328 "http://articles.moneycentral.msn.com/Investing/StockInvestingTrading/TheSmart
WayToGetRich.aspx", | |
| 329 "http://articles.moneycentral.msn.com/Investing/ContrarianChronicles/TheFictio
nOfCorporateTransparency.aspx", | |
| 330 "<NEWTAB>", | |
| 331 "http://flickr.com/", | |
| 332 "http://flickr.com/explore/interesting/2008/03/18/", | |
| 333 "http://flickr.com/photos/chavals/2344906748/", | |
| 334 "http://flickr.com/photos/rosemary/2343058024/", | |
| 335 "http://flickr.com/photos/arbaa/2343235019/", | |
| 336 "<NEWTAB>", | |
| 337 "http://zh.wikipedia.org/wiki/%E6%B1%B6%E5%B7%9D%E5%A4%A7%E5%9C%B0%E9%9C%87", | |
| 338 "http://zh.wikipedia.org/wiki/5%E6%9C%8812%E6%97%A5", | |
| 339 "http://zh.wikipedia.org/wiki/5%E6%9C%8820%E6%97%A5", | |
| 340 "http://zh.wikipedia.org/wiki/%E9%A6%96%E9%A1%B5", | |
| 341 "<NEWTAB>", | |
| 342 "http://www.nytimes.com/pages/technology/index.html", | |
| 343 "http://pogue.blogs.nytimes.com/2008/07/17/a-candy-store-for-the-iphone/", | |
| 344 "http://www.nytimes.com/2008/07/21/technology/21pc.html?_r=1&ref=technology&or
ef=slogin", | |
| 345 "http://bits.blogs.nytimes.com/2008/07/19/a-wikipedian-challenge-convincing-ar
abic-speakers-to-write-in-arabic/", | |
| 346 "<NEWTAB>", | |
| 347 "http://www.amazon.com/exec/obidos/tg/browse/-/502394/ref=topnav_storetab_p", | |
| 348 "http://www.amazon.com/Panasonic-DMC-TZ5K-Digital-Optical-Stabilized/dp/B0011Z
8CCG/ref=pd_ts_p_17?ie=UTF8&s=photo", | |
| 349 "http://www.amazon.com/Nikon-Coolpix-Digital-Vibration-Reduction/dp/B0012OI6HW
/ref=pd_ts_p_24?ie=UTF8&s=photo", | |
| 350 "http://www.amazon.com/Digital-SLRs-Cameras-Photo/b/ref=sv_p_2?ie=UTF8&node=30
17941", | |
| 351 "<NEWTAB>", | |
| 352 "http://www.boston.com/bigpicture/2008/07/californias_continuing_fires.html", | |
| 353 "http://www.boston.com/business/", | |
| 354 "http://www.boston.com/business/articles/2008/07/29/staples_has_a_games_plan/"
, | |
| 355 "http://www.boston.com/business/personalfinance/articles/2008/08/04/a_grim_for
ecast_for_heating_costs/", | |
| 356 "<NEWTAB>", | |
| 357 "http://arstechnica.com/", | |
| 358 "http://arstechnica.com/news.ars/post/20080721-this-years-e3-substance-over-st
yleand-far-from-dead.html", | |
| 359 "http://arstechnica.com/news.ars/post/20080729-ifpi-italian-police-take-down-i
talian-bittorrent-tracker.html", | |
| 360 "http://arstechnica.com/news.ars/post/20080804-congress-wants-privacy-answers-
from-google-ms-aol.html", | |
| 361 "<NEWTAB>", | |
| 362 "http://finance.google.com/finance?q=NASDAQ:AAPL", | |
| 363 "http://finance.google.com/finance?q=GOOG&hl=en", | |
| 364 "<NEWTAB>", | |
| 365 "http://blog.wired.com/underwire/2008/07/futurama-gets-m.html", | |
| 366 "http://blog.wired.com/cars/2008/07/gas-prices-hit.html", | |
| 367 "<NEWTAB>", | |
| 368 "http://del.icio.us/popular/programming", | |
| 369 "http://del.icio.us/popular/", | |
| 370 "http://del.icio.us/tag/", | |
| 371 "<NEWTAB>", | |
| 372 "http://gadgets.boingboing.net/2008/07/21/boom-computing.html", | |
| 373 "http://3533.spreadshirt.com/us/US/Shop/", | |
| 374 "<NEWTAB>", | |
| 375 "http://www.autoblog.com/", | |
| 376 "http://www.autoblog.com/2008/07/21/audi-introduces-the-next-mmi/", | |
| 377 "http://www.autoblog.com/categories/auto-types/", | |
| 378 "http://www.autoblog.com/category/sports/", | |
| 379 "<NEWTAB>", | |
| 380 "http://www.wikipedia.org/", | |
| 381 "http://en.wikipedia.org/wiki/Main_Page", | |
| 382 "http://fr.wikipedia.org/wiki/Accueil", | |
| 383 "http://de.wikipedia.org/wiki/Hauptseite", | |
| 384 "http://ja.wikipedia.org/wiki/%E3%83%A1%E3%82%A4%E3%83%B3%E3%83%9A%E3%83%BC%E3
%82%B8", | |
| 385 "http://it.wikipedia.org/wiki/Pagina_principale", | |
| 386 "http://nl.wikipedia.org/wiki/Hoofdpagina", | |
| 387 "http://pt.wikipedia.org/wiki/P%C3%A1gina_principal", | |
| 388 "http://es.wikipedia.org/wiki/Portada", | |
| 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", | |
| 390 "<NEWTAB>", | |
| 391 "http://www.google.com/translate_t?hl=en&text=This%20Is%20A%20Test%20Of%20miss
spellingsdfdf&sl=en&tl=ja" | |
| 392 }; | |
| 393 | |
| 394 size_t GeneralMixMemoryTest::urls_length_ = | |
| 395 arraysize(GeneralMixMemoryTest::urls_); | |
| 396 | |
| 397 class GeneralMixReferenceMemoryTest : public GeneralMixMemoryTest { | |
| 398 public: | |
| 399 void SetUp() { | |
| 400 UseReferenceBuild(); | |
| 401 GeneralMixMemoryTest::SetUp(); | |
| 402 } | |
| 403 }; | |
| 404 | |
| 405 class MembusterMemoryTest : public MemoryTest { | |
| 406 public: | |
| 407 MembusterMemoryTest() : test_urls_(NULL) {} | |
| 408 | |
| 409 virtual ~MembusterMemoryTest() { | |
| 410 delete[] test_urls_; | |
| 411 } | |
| 412 | |
| 413 virtual FilePath GetUserDataDirSource() const { | |
| 414 FilePath profile_dir; | |
| 415 PathService::Get(base::DIR_SOURCE_ROOT, &profile_dir); | |
| 416 profile_dir = profile_dir.AppendASCII("data"); | |
| 417 profile_dir = profile_dir.AppendASCII("memory_test"); | |
| 418 profile_dir = profile_dir.AppendASCII("membuster"); | |
| 419 return profile_dir; | |
| 420 } | |
| 421 | |
| 422 virtual size_t GetUrlList(std::string** list) { | |
| 423 size_t total_url_entries = urls_length_ * kIterations_ * 2 - 1; | |
| 424 if (!test_urls_) { | |
| 425 test_urls_ = new std::string[total_url_entries]; | |
| 426 | |
| 427 // Open url_length_ + 1 windows as we access urls. We start with one | |
| 428 // open window. | |
| 429 test_urls_[0] = source_urls_[0]; | |
| 430 size_t fill_position = 1; | |
| 431 size_t source_url_index = 1; | |
| 432 for (; fill_position <= urls_length_ * 2; fill_position += 2) { | |
| 433 test_urls_[fill_position] = "<NEWWINDOW>"; | |
| 434 test_urls_[fill_position + 1] = source_urls_[source_url_index]; | |
| 435 source_url_index = (source_url_index + 1) % urls_length_; | |
| 436 } | |
| 437 | |
| 438 // Then cycle through all the urls to fill out the list. | |
| 439 for (; fill_position < total_url_entries; fill_position += 2) { | |
| 440 test_urls_[fill_position] = "<NEXTWINDOW>"; | |
| 441 test_urls_[fill_position + 1] = source_urls_[source_url_index]; | |
| 442 source_url_index = (source_url_index + 1) % urls_length_; | |
| 443 } | |
| 444 } | |
| 445 *list = test_urls_; | |
| 446 return total_url_entries; | |
| 447 } | |
| 448 | |
| 449 private: | |
| 450 static const int kIterations_ = 11; | |
| 451 | |
| 452 static std::string source_urls_[]; | |
| 453 static size_t urls_length_; | |
| 454 | |
| 455 std::string* test_urls_; | |
| 456 }; | |
| 457 | |
| 458 // membuster traverses the list in reverse order. We just list them that way. | |
| 459 std::string MembusterMemoryTest::source_urls_[] = { | |
| 460 "http://joi.ito.com/archives/email/", | |
| 461 "http://joi.ito.com/jp/", | |
| 462 "http://forums.studentdoctor.net/showthread.php?t=469342", | |
| 463 "http://forums.studentdoctor.net/forumdisplay.php?s=718b9d0e8692d7c3f4cc7c64fa
ffd17b&f=10", | |
| 464 "http://de.wikipedia.org/wiki/Hauptseite", | |
| 465 "http://zh.wikipedia.org/wiki/", | |
| 466 "http://ru.wikipedia.org/wiki/", | |
| 467 "http://ja.wikipedia.org/wiki/", | |
| 468 "http://en.wikipedia.org/wiki/Main_Page", | |
| 469 "http://wikitravel.org/ru/", | |
| 470 "http://wikitravel.org/hi/", | |
| 471 "http://wikitravel.org/he/", | |
| 472 "http://wikitravel.org/ja/", | |
| 473 "http://wikitravel.org/en/Main_Page", | |
| 474 "http://wikitravel.org/en/China", | |
| 475 "http://www.vodcars.com/", | |
| 476 "http://en.wikinews.org/wiki/Main_Page", | |
| 477 "http://creativecommons.org/", | |
| 478 "http://pushingdaisies.wikia.com/wiki/Pushing_Daisies", | |
| 479 "http://www.wowwiki.com/Main_Page", | |
| 480 "http://spademanns.wikia.com/wiki/Forside", | |
| 481 "http://ja.uncyclopedia.info/wiki/", | |
| 482 "http://uncyclopedia.org/wiki/Babel:Vi", | |
| 483 "http://uncyclopedia.org/wiki/Main_Page", | |
| 484 "http://en.marveldatabase.com/Main_Page", | |
| 485 "http://bioshock.wikia.com/wiki/Main_Page", | |
| 486 "http://www.armchairgm.com/Special:ImageRating", | |
| 487 "http://www.armchairgm.com/Anderson_Continues_to_Thrive_for_Cleveland", | |
| 488 "http://www.armchairgm.com/Main_Page" | |
| 489 }; | |
| 490 | |
| 491 size_t MembusterMemoryTest::urls_length_ = | |
| 492 arraysize(MembusterMemoryTest::source_urls_); | |
| 493 | |
| 494 #define QUOTE(x) #x | |
| 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); \ | |
| 501 } | |
| 502 | |
| 503 GENERAL_MIX_MEMORY_TESTS(SingleTabTest, 1); | |
| 504 GENERAL_MIX_MEMORY_TESTS(FiveTabTest, 5); | |
| 505 GENERAL_MIX_MEMORY_TESTS(TwelveTabTest, 12); | |
| 506 | |
| 507 // Commented out until the recorded cache data is added. | |
| 508 //TEST_F(MembusterMemoryTest, Windows) { | |
| 509 // RunTest("membuster", 0); | |
| 510 //} | |
| 511 | |
| 512 } // namespace | |
| OLD | NEW |