| 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 "chrome/browser/worker_host/worker_service.h" | 5 #include "chrome/browser/worker_host/worker_service.h" |
| 6 #include "chrome/test/automation/browser_proxy.h" | 6 #include "chrome/test/automation/browser_proxy.h" |
| 7 #include "chrome/test/automation/tab_proxy.h" | 7 #include "chrome/test/automation/tab_proxy.h" |
| 8 #include "chrome/test/ui/ui_layout_test.h" | 8 #include "chrome/test/ui/ui_layout_test.h" |
| 9 | 9 |
| 10 static const char kTestCompleteCookie[] = "status"; | 10 static const char kTestCompleteCookie[] = "status"; |
| 11 static const char kTestCompleteSuccess[] = "OK"; | 11 static const char kTestCompleteSuccess[] = "OK"; |
| 12 | 12 |
| 13 #if defined(OS_WIN) |
| 14 #define MAYBE_LimitTotal FLAKY_LimitTotal |
| 15 #else |
| 16 #define MAYBE_LimitTotal LimitTotal |
| 17 #endif |
| 18 |
| 13 class WorkerTest : public UILayoutTest { | 19 class WorkerTest : public UILayoutTest { |
| 14 protected: | 20 protected: |
| 15 virtual ~WorkerTest() { } | 21 virtual ~WorkerTest() { } |
| 16 | 22 |
| 17 void RunTest(const std::wstring& test_case) { | 23 void RunTest(const std::wstring& test_case) { |
| 18 scoped_refptr<TabProxy> tab(GetActiveTab()); | 24 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 19 ASSERT_TRUE(tab.get()); | 25 ASSERT_TRUE(tab.get()); |
| 20 | 26 |
| 21 GURL url = GetTestUrl(L"workers", test_case); | 27 GURL url = GetTestUrl(L"workers", test_case); |
| 22 ASSERT_TRUE(tab->NavigateToURL(url)); | 28 ASSERT_TRUE(tab->NavigateToURL(url)); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 206 |
| 201 scoped_refptr<TabProxy> tab(GetActiveTab()); | 207 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 202 ASSERT_TRUE(tab.get()); | 208 ASSERT_TRUE(tab.get()); |
| 203 ASSERT_TRUE(tab->NavigateToURL(url)); | 209 ASSERT_TRUE(tab->NavigateToURL(url)); |
| 204 | 210 |
| 205 EXPECT_EQ(max_workers_per_tab + 1 + (UITest::in_process_renderer() ? 0 : 1), | 211 EXPECT_EQ(max_workers_per_tab + 1 + (UITest::in_process_renderer() ? 0 : 1), |
| 206 UITest::GetBrowserProcessCount()); | 212 UITest::GetBrowserProcessCount()); |
| 207 } | 213 } |
| 208 #endif | 214 #endif |
| 209 | 215 |
| 210 TEST_F(WorkerTest, LimitTotal) { | 216 TEST_F(WorkerTest, MAYBE_LimitTotal) { |
| 211 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; | 217 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; |
| 212 int total_workers = WorkerService::kMaxWorkersWhenSeparate; | 218 int total_workers = WorkerService::kMaxWorkersWhenSeparate; |
| 213 | 219 |
| 214 int tab_count = (total_workers / max_workers_per_tab) + 1; | 220 int tab_count = (total_workers / max_workers_per_tab) + 1; |
| 215 GURL url = GetTestUrl(L"workers", L"many_workers.html"); | 221 GURL url = GetTestUrl(L"workers", L"many_workers.html"); |
| 216 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab)); | 222 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab)); |
| 217 | 223 |
| 218 scoped_refptr<TabProxy> tab(GetActiveTab()); | 224 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 219 ASSERT_TRUE(tab.get()); | 225 ASSERT_TRUE(tab.get()); |
| 220 ASSERT_TRUE(tab->NavigateToURL(url)); | 226 ASSERT_TRUE(tab->NavigateToURL(url)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 233 // Check that we didn't create more than the max number of workers. | 239 // Check that we didn't create more than the max number of workers. |
| 234 EXPECT_EQ(total_workers + number_of_processes, | 240 EXPECT_EQ(total_workers + number_of_processes, |
| 235 UITest::GetBrowserProcessCount()); | 241 UITest::GetBrowserProcessCount()); |
| 236 | 242 |
| 237 // Now close a page and check that the queued workers were started. | 243 // Now close a page and check that the queued workers were started. |
| 238 tab->NavigateToURL(GetTestUrl(L"google", L"google.html")); | 244 tab->NavigateToURL(GetTestUrl(L"google", L"google.html")); |
| 239 | 245 |
| 240 EXPECT_EQ(total_workers + number_of_processes, | 246 EXPECT_EQ(total_workers + number_of_processes, |
| 241 UITest::GetBrowserProcessCount()); | 247 UITest::GetBrowserProcessCount()); |
| 242 } | 248 } |
| OLD | NEW |