OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/message_loop.h" |
| 6 #include "chrome/browser/automation/ui_controls.h" |
| 7 #include "chrome/browser/browser.h" |
| 8 #include "chrome/browser/browser_window.h" |
| 9 #include "chrome/browser/view_ids.h" |
| 10 #include "chrome/browser/views/tabs/base_tab.h" |
| 11 #include "chrome/browser/views/tabs/tab_strip.h" |
| 12 #include "chrome/common/url_constants.h" |
| 13 #include "chrome/test/in_process_browser_test.h" |
| 14 #include "chrome/test/ui_test_utils.h" |
| 15 #include "views/widget/root_view.h" |
| 16 #include "views/widget/widget.h" |
| 17 |
| 18 typedef InProcessBrowserTest TabStripTest; |
| 19 |
| 20 // Creates a tab, middle clicks to close the first, then clicks back on the |
| 21 // first. This test exercises a crasher in the mouse near code path. |
| 22 IN_PROC_BROWSER_TEST_F(TabStripTest, Close) { |
| 23 int initial_tab_count = browser()->tab_count(); |
| 24 |
| 25 browser()->AddTabWithURL( |
| 26 GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1, |
| 27 Browser::ADD_SELECTED, NULL, std::string()); |
| 28 views::RootView* root = |
| 29 views::Widget::FindRootView(browser()->window()->GetNativeHandle()); |
| 30 ASSERT_TRUE(root); |
| 31 TabStrip* tab_strip = |
| 32 static_cast<TabStrip*>(root->GetViewByID(VIEW_ID_TAB_STRIP)); |
| 33 ASSERT_TRUE(tab_strip); |
| 34 |
| 35 // Force a layout to ensure no animations are active. |
| 36 tab_strip->Layout(); |
| 37 |
| 38 // Close the first tab by way of am middle click. |
| 39 BaseTab* tab1 = tab_strip->base_tab_at_tab_index(1); |
| 40 ui_controls::MoveMouseToCenterAndPress( |
| 41 tab1, ui_controls::MIDDLE, ui_controls::DOWN | ui_controls::UP, |
| 42 new MessageLoop::QuitTask()); |
| 43 |
| 44 // Force a layout to ensure no animations are active. |
| 45 ui_test_utils::RunMessageLoop(); |
| 46 |
| 47 EXPECT_EQ(initial_tab_count, browser()->tab_count()); |
| 48 |
| 49 // Force a layout to ensure no animations are active. |
| 50 tab_strip->Layout(); |
| 51 |
| 52 // Click on the first tab. |
| 53 BaseTab* tab0 = tab_strip->base_tab_at_tab_index(0); |
| 54 ui_controls::MoveMouseToCenterAndPress( |
| 55 tab0, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, |
| 56 new MessageLoop::QuitTask()); |
| 57 |
| 58 ui_test_utils::RunMessageLoop(); |
| 59 } |
OLD | NEW |