| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "chrome/app/chrome_dll_resource.h" | 6 #include "chrome/app/chrome_dll_resource.h" |
| 7 #include "chrome/browser/worker_host/worker_service.h" | 7 #include "chrome/browser/worker_host/worker_service.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/test/automation/browser_proxy.h" | 9 #include "chrome/test/automation/browser_proxy.h" |
| 10 #include "chrome/test/automation/tab_proxy.h" | 10 #include "chrome/test/automation/tab_proxy.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 ASSERT_TRUE(tab.get()); | 329 ASSERT_TRUE(tab.get()); |
| 330 ASSERT_TRUE(tab->NavigateToURL(url)); | 330 ASSERT_TRUE(tab->NavigateToURL(url)); |
| 331 | 331 |
| 332 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); | 332 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); |
| 333 } | 333 } |
| 334 #endif | 334 #endif |
| 335 | 335 |
| 336 #if defined(OS_LINUX) | 336 #if defined(OS_LINUX) |
| 337 // Fails (crashes) on Linux Tests: http://crbug.com/28445 | 337 // Fails (crashes) on Linux Tests: http://crbug.com/28445 |
| 338 #define LimitTotal DISABLED_LimitTotal | 338 #define LimitTotal DISABLED_LimitTotal |
| 339 #elif defined(OS_MACOSX) |
| 340 // Doesn't crash, but on Mac it sometimes fails for a few runs in a row, |
| 341 // http://crbug.com/28445 |
| 342 #define LimitTotal FLAKY_LimitTotal |
| 339 #endif | 343 #endif |
| 340 | 344 |
| 341 TEST_F(WorkerTest, LimitTotal) { | 345 TEST_F(WorkerTest, LimitTotal) { |
| 342 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; | 346 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; |
| 343 int total_workers = WorkerService::kMaxWorkersWhenSeparate; | 347 int total_workers = WorkerService::kMaxWorkersWhenSeparate; |
| 344 | 348 |
| 345 int tab_count = (total_workers / max_workers_per_tab) + 1; | 349 int tab_count = (total_workers / max_workers_per_tab) + 1; |
| 346 GURL url = GetTestUrl(L"workers", L"many_workers.html"); | 350 GURL url = GetTestUrl(L"workers", L"many_workers.html"); |
| 347 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab)); | 351 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab)); |
| 348 | 352 |
| 349 scoped_refptr<TabProxy> tab(GetActiveTab()); | 353 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 350 ASSERT_TRUE(tab.get()); | 354 ASSERT_TRUE(tab.get()); |
| 351 ASSERT_TRUE(tab->NavigateToURL(url)); | 355 ASSERT_TRUE(tab->NavigateToURL(url)); |
| 352 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 356 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 353 for (int i = 1; i < tab_count; ++i) | 357 for (int i = 1; i < tab_count; ++i) |
| 354 window->AppendTab(url); | 358 window->AppendTab(url); |
| 355 | 359 |
| 356 // Check that we didn't create more than the max number of workers. | 360 // Check that we didn't create more than the max number of workers. |
| 357 ASSERT_TRUE(WaitForProcessCountToBe(tab_count, total_workers)); | 361 ASSERT_TRUE(WaitForProcessCountToBe(tab_count, total_workers)); |
| 358 | 362 |
| 359 // Now close a page and check that the queued workers were started. | 363 // Now close a page and check that the queued workers were started. |
| 360 tab->NavigateToURL(GetTestUrl(L"google", L"google.html")); | 364 tab->NavigateToURL(GetTestUrl(L"google", L"google.html")); |
| 361 | 365 |
| 362 ASSERT_TRUE(WaitForProcessCountToBe(tab_count, total_workers)); | 366 ASSERT_TRUE(WaitForProcessCountToBe(tab_count, total_workers)); |
| 363 } | 367 } |
| OLD | NEW |