Chromium Code Reviews| 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/test/test_timeouts.h" | 6 #include "base/test/test_timeouts.h" |
| 7 #include "chrome/browser/net/url_request_mock_http_job.h" | 7 #include "chrome/browser/net/url_request_mock_http_job.h" |
| 8 #include "chrome/browser/ui/view_ids.h" | 8 #include "chrome/browser/ui/view_ids.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/test/automation/browser_proxy.h" | 10 #include "chrome/test/automation/browser_proxy.h" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 | 407 |
| 408 #if defined(OS_MACOSX) | 408 #if defined(OS_MACOSX) |
| 409 // http://crbug.com/45162 | 409 // http://crbug.com/45162 |
| 410 #define MAYBE_BrowserCloseTabWhenOtherTabHasListener \ | 410 #define MAYBE_BrowserCloseTabWhenOtherTabHasListener \ |
| 411 DISABLED_BrowserCloseTabWhenOtherTabHasListener | 411 DISABLED_BrowserCloseTabWhenOtherTabHasListener |
| 412 #elif defined(OS_WIN) | 412 #elif defined(OS_WIN) |
| 413 // http://crbug.com/45281 | 413 // http://crbug.com/45281 |
| 414 #define MAYBE_BrowserCloseTabWhenOtherTabHasListener \ | 414 #define MAYBE_BrowserCloseTabWhenOtherTabHasListener \ |
| 415 DISABLED_BrowserCloseTabWhenOtherTabHasListener | 415 DISABLED_BrowserCloseTabWhenOtherTabHasListener |
| 416 #else | 416 #else |
| 417 // Flaky on Linux under valgrind. http://crbug.com/46781 | 417 // Flaky on Linux under valgrind. http://crbug.com/46781 |
|
Paweł Hajdan Jr.
2011/02/18 12:12:24
nit: This comment is now outdated.
Johnny(Jianning) Ding
2011/02/18 13:23:17
Done.
| |
| 418 // TODO(stuartmorgan): Switch to just disabling for valgrind. | 418 // TODO(stuartmorgan): Switch to just disabling for valgrind. |
| 419 #define MAYBE_BrowserCloseTabWhenOtherTabHasListener \ | 419 #define MAYBE_BrowserCloseTabWhenOtherTabHasListener \ |
| 420 FLAKY_BrowserCloseTabWhenOtherTabHasListener | 420 BrowserCloseTabWhenOtherTabHasListener |
| 421 #endif | 421 #endif |
| 422 | 422 |
| 423 // Tests that if there's a renderer process with two tabs, one of which has an | 423 // Tests that if there's a renderer process with two tabs, one of which has an |
| 424 // unload handler, and the other doesn't, the tab that doesn't have an unload | 424 // unload handler, and the other doesn't, the tab that doesn't have an unload |
| 425 // handler can be closed. | 425 // handler can be closed. |
| 426 TEST_F(UnloadTest, MAYBE_BrowserCloseTabWhenOtherTabHasListener) { | 426 TEST_F(UnloadTest, MAYBE_BrowserCloseTabWhenOtherTabHasListener) { |
| 427 NavigateToDataURL(CLOSE_TAB_WHEN_OTHER_TAB_HAS_LISTENER, L"only_one_unload"); | 427 NavigateToDataURL(CLOSE_TAB_WHEN_OTHER_TAB_HAS_LISTENER, L"only_one_unload"); |
| 428 | 428 |
| 429 scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(0); | 429 scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(0); |
| 430 ASSERT_TRUE(browser.get()); | 430 ASSERT_TRUE(browser.get()); |
| 431 scoped_refptr<WindowProxy> window = browser->GetWindow(); | 431 scoped_refptr<WindowProxy> window = browser->GetWindow(); |
| 432 ASSERT_TRUE(window.get()); | 432 ASSERT_TRUE(window.get()); |
| 433 | 433 |
| 434 gfx::Rect tab_view_bounds; | 434 gfx::Rect tab_view_bounds; |
| 435 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, | 435 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, |
| 436 &tab_view_bounds, true)); | 436 &tab_view_bounds, true)); |
| 437 // Simulate a click to force user_gesture to true; if we don't, the resulting | 437 // Simulate a click to force user_gesture to true; if we don't, the resulting |
| 438 // popup will be constrained, which isn't what we want to test. | 438 // popup will be constrained, which isn't what we want to test. |
| 439 ASSERT_TRUE(window->SimulateOSClick(tab_view_bounds.CenterPoint(), | 439 ASSERT_TRUE(window->SimulateOSClick(tab_view_bounds.CenterPoint(), |
| 440 ui::EF_LEFT_BUTTON_DOWN)); | 440 ui::EF_LEFT_BUTTON_DOWN)); |
| 441 ASSERT_TRUE(browser->WaitForTabCountToBecome(2)); | 441 ASSERT_TRUE(browser->WaitForTabCountToBecome(2)); |
| 442 | 442 |
| 443 CheckTitle(L"popup"); | |
| 443 scoped_refptr<TabProxy> popup_tab(browser->GetActiveTab()); | 444 scoped_refptr<TabProxy> popup_tab(browser->GetActiveTab()); |
| 444 ASSERT_TRUE(popup_tab.get()); | 445 ASSERT_TRUE(popup_tab.get()); |
| 445 std::wstring popup_title; | |
| 446 EXPECT_TRUE(popup_tab->GetTabTitle(&popup_title)); | |
| 447 EXPECT_EQ(std::wstring(L"popup"), popup_title); | |
| 448 EXPECT_TRUE(popup_tab->Close(true)); | 446 EXPECT_TRUE(popup_tab->Close(true)); |
| 449 | 447 |
| 450 ASSERT_TRUE(browser->WaitForTabCountToBecome(1)); | 448 ASSERT_TRUE(browser->WaitForTabCountToBecome(1)); |
| 451 scoped_refptr<TabProxy> main_tab(browser->GetActiveTab()); | 449 scoped_refptr<TabProxy> main_tab(browser->GetActiveTab()); |
| 452 ASSERT_TRUE(main_tab.get()); | 450 ASSERT_TRUE(main_tab.get()); |
| 453 std::wstring main_title; | 451 std::wstring main_title; |
| 454 EXPECT_TRUE(main_tab->GetTabTitle(&main_title)); | 452 EXPECT_TRUE(main_tab->GetTabTitle(&main_title)); |
| 455 EXPECT_EQ(std::wstring(L"only_one_unload"), main_title); | 453 EXPECT_EQ(std::wstring(L"only_one_unload"), main_title); |
| 456 } | 454 } |
| 457 | 455 |
| 458 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs | 456 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs |
| 459 // and multiple windows. | 457 // and multiple windows. |
| OLD | NEW |