| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/threading/platform_thread.h" |
| 12 #include "chrome/browser/net/url_fixer_upper.h" | 13 #include "chrome/browser/net/url_fixer_upper.h" |
| 13 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
| 14 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/test/automation/browser_proxy.h" | 17 #include "chrome/test/automation/browser_proxy.h" |
| 17 #include "chrome/test/automation/tab_proxy.h" | 18 #include "chrome/test/automation/tab_proxy.h" |
| 18 #include "chrome/test/automation/window_proxy.h" | 19 #include "chrome/test/automation/window_proxy.h" |
| 19 #include "chrome/test/chrome_process_util.h" | 20 #include "chrome/test/chrome_process_util.h" |
| 20 #include "chrome/test/ui/ui_perf_test.h" | 21 #include "chrome/test/ui/ui_perf_test.h" |
| 21 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 int active_window = 0; // The index of the window we are currently using. | 142 int active_window = 0; // The index of the window we are currently using. |
| 142 scoped_refptr<TabProxy> tab(window->GetActiveTab()); | 143 scoped_refptr<TabProxy> tab(window->GetActiveTab()); |
| 143 ASSERT_TRUE(tab.get()); | 144 ASSERT_TRUE(tab.get()); |
| 144 int expected_tab_count = 1; | 145 int expected_tab_count = 1; |
| 145 for (unsigned counter = 0; counter < urls_length; ++counter) { | 146 for (unsigned counter = 0; counter < urls_length; ++counter) { |
| 146 std::string url = urls[counter]; | 147 std::string url = urls[counter]; |
| 147 | 148 |
| 148 SCOPED_TRACE(url); | 149 SCOPED_TRACE(url); |
| 149 | 150 |
| 150 if (url == "<PAUSE>") { // Special command to delay on this page | 151 if (url == "<PAUSE>") { // Special command to delay on this page |
| 151 PlatformThread::Sleep(2000); | 152 base::PlatformThread::Sleep(2000); |
| 152 continue; | 153 continue; |
| 153 } | 154 } |
| 154 | 155 |
| 155 if (url == "<NEWTAB>") { // Special command to create a new tab | 156 if (url == "<NEWTAB>") { // Special command to create a new tab |
| 156 if (++counter >= urls_length) | 157 if (++counter >= urls_length) |
| 157 continue; // Newtab was specified at end of list. ignore. | 158 continue; // Newtab was specified at end of list. ignore. |
| 158 | 159 |
| 159 url = urls[counter]; | 160 url = urls[counter]; |
| 160 if (GetTabCount() < num_target_tabs) { | 161 if (GetTabCount() < num_target_tabs) { |
| 161 EXPECT_TRUE(window->AppendTab(GURL(url))); | 162 EXPECT_TRUE(window->AppendTab(GURL(url))); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 190 EXPECT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, | 191 EXPECT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, |
| 191 show_window_)); | 192 show_window_)); |
| 192 int expected_window_count = window_count + 1; | 193 int expected_window_count = window_count + 1; |
| 193 EXPECT_TRUE(automation()->WaitForWindowCountToBecome( | 194 EXPECT_TRUE(automation()->WaitForWindowCountToBecome( |
| 194 expected_window_count)); | 195 expected_window_count)); |
| 195 EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 196 EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 196 EXPECT_EQ(expected_window_count, window_count); | 197 EXPECT_EQ(expected_window_count, window_count); |
| 197 | 198 |
| 198 // A new window will not load a url if requested too soon. The window | 199 // A new window will not load a url if requested too soon. The window |
| 199 // stays on the new tab page instead. | 200 // stays on the new tab page instead. |
| 200 PlatformThread::Sleep(200); | 201 base::PlatformThread::Sleep(200); |
| 201 | 202 |
| 202 active_window = window_count - 1; | 203 active_window = window_count - 1; |
| 203 window = automation()->GetBrowserWindow(active_window); | 204 window = automation()->GetBrowserWindow(active_window); |
| 204 ASSERT_TRUE(window.get()); | 205 ASSERT_TRUE(window.get()); |
| 205 tab = window->GetActiveTab(); | 206 tab = window->GetActiveTab(); |
| 206 ASSERT_TRUE(tab.get()); | 207 ASSERT_TRUE(tab.get()); |
| 207 continue; | 208 continue; |
| 208 } | 209 } |
| 209 | 210 |
| 210 if (url == "<NEXTWINDOW>") { // Select the next window. | 211 if (url == "<NEXTWINDOW>") { // Select the next window. |
| 211 int window_count; | 212 int window_count; |
| 212 EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 213 EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 213 active_window = (active_window + 1) % window_count; | 214 active_window = (active_window + 1) % window_count; |
| 214 window = automation()->GetBrowserWindow(active_window); | 215 window = automation()->GetBrowserWindow(active_window); |
| 215 ASSERT_TRUE(window.get()); | 216 ASSERT_TRUE(window.get()); |
| 216 tab = window->GetActiveTab(); | 217 tab = window->GetActiveTab(); |
| 217 ASSERT_TRUE(tab.get()); | 218 ASSERT_TRUE(tab.get()); |
| 218 continue; | 219 continue; |
| 219 } | 220 } |
| 220 | 221 |
| 221 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 222 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
| 222 tab->NavigateToURL(GURL(urls[counter]))); | 223 tab->NavigateToURL(GURL(urls[counter]))); |
| 223 | 224 |
| 224 // TODO(mbelshe): Bug 2953 | 225 // TODO(mbelshe): Bug 2953 |
| 225 // The automation crashes periodically if we cycle too quickly. | 226 // The automation crashes periodically if we cycle too quickly. |
| 226 // To make these tests more reliable, slowing them down a bit. | 227 // To make these tests more reliable, slowing them down a bit. |
| 227 PlatformThread::Sleep(100); | 228 base::PlatformThread::Sleep(100); |
| 228 } | 229 } |
| 229 | 230 |
| 230 size_t stop_size = base::GetSystemCommitCharge(); | 231 size_t stop_size = base::GetSystemCommitCharge(); |
| 231 PrintIOPerfInfo(test_name); | 232 PrintIOPerfInfo(test_name); |
| 232 PrintMemoryUsageInfo(test_name); | 233 PrintMemoryUsageInfo(test_name); |
| 233 PrintSystemCommitCharge(test_name, stop_size - start_size, | 234 PrintSystemCommitCharge(test_name, stop_size - start_size, |
| 234 true /* important */); | 235 true /* important */); |
| 235 } | 236 } |
| 236 | 237 |
| 237 private: | 238 private: |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 TEST_F(GeneralMixMemoryTest, TwelveTabTest) { | 530 TEST_F(GeneralMixMemoryTest, TwelveTabTest) { |
| 530 RunTest("_12t", 12); | 531 RunTest("_12t", 12); |
| 531 } | 532 } |
| 532 | 533 |
| 533 // Commented out until the recorded cache data is added. | 534 // Commented out until the recorded cache data is added. |
| 534 //TEST_F(MembusterMemoryTest, Windows) { | 535 //TEST_F(MembusterMemoryTest, Windows) { |
| 535 // RunTest("membuster", 0); | 536 // RunTest("membuster", 0); |
| 536 //} | 537 //} |
| 537 | 538 |
| 538 } // namespace | 539 } // namespace |
| OLD | NEW |