| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/views/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "chrome/browser/devtools/devtools_window_testing.h" | 8 #include "chrome/browser/devtools/devtools_window_testing.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_tabstrip.h" | 10 #include "chrome/browser/ui/browser_tabstrip.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver); | 79 DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 } // namespace | 82 } // namespace |
| 83 | 83 |
| 84 // Verifies don't crash when CloseNow() is invoked with two tabs in a browser. | 84 // Verifies don't crash when CloseNow() is invoked with two tabs in a browser. |
| 85 // Additionally when one of the tabs is destroyed NotifyNavigationStateChanged() | 85 // Additionally when one of the tabs is destroyed NotifyNavigationStateChanged() |
| 86 // is invoked on the other. | 86 // is invoked on the other. |
| 87 IN_PROC_BROWSER_TEST_F(BrowserViewTest, CloseWithTabs) { | 87 IN_PROC_BROWSER_TEST_F(BrowserViewTest, CloseWithTabs) { |
| 88 Browser* browser2 = | 88 Browser* browser2 = new Browser(Browser::CreateParams(browser()->profile())); |
| 89 new Browser(Browser::CreateParams(browser()->profile(), | |
| 90 browser()->host_desktop_type())); | |
| 91 chrome::AddTabAt(browser2, GURL(), -1, true); | 89 chrome::AddTabAt(browser2, GURL(), -1, true); |
| 92 chrome::AddTabAt(browser2, GURL(), -1, true); | 90 chrome::AddTabAt(browser2, GURL(), -1, true); |
| 93 TestWebContentsObserver observer( | 91 TestWebContentsObserver observer( |
| 94 browser2->tab_strip_model()->GetWebContentsAt(0), | 92 browser2->tab_strip_model()->GetWebContentsAt(0), |
| 95 browser2->tab_strip_model()->GetWebContentsAt(1)); | 93 browser2->tab_strip_model()->GetWebContentsAt(1)); |
| 96 BrowserView::GetBrowserViewForBrowser(browser2)->GetWidget()->CloseNow(); | 94 BrowserView::GetBrowserViewForBrowser(browser2)->GetWidget()->CloseNow(); |
| 97 } | 95 } |
| 98 | 96 |
| 99 // Same as CloseWithTabs, but activates the first tab, which is the first tab | 97 // Same as CloseWithTabs, but activates the first tab, which is the first tab |
| 100 // BrowserView will destroy. | 98 // BrowserView will destroy. |
| 101 IN_PROC_BROWSER_TEST_F(BrowserViewTest, CloseWithTabsStartWithActive) { | 99 IN_PROC_BROWSER_TEST_F(BrowserViewTest, CloseWithTabsStartWithActive) { |
| 102 Browser* browser2 = | 100 Browser* browser2 = new Browser(Browser::CreateParams(browser()->profile())); |
| 103 new Browser(Browser::CreateParams(browser()->profile(), | |
| 104 browser()->host_desktop_type())); | |
| 105 chrome::AddTabAt(browser2, GURL(), -1, true); | 101 chrome::AddTabAt(browser2, GURL(), -1, true); |
| 106 chrome::AddTabAt(browser2, GURL(), -1, true); | 102 chrome::AddTabAt(browser2, GURL(), -1, true); |
| 107 browser2->tab_strip_model()->ActivateTabAt(0, true); | 103 browser2->tab_strip_model()->ActivateTabAt(0, true); |
| 108 TestWebContentsObserver observer( | 104 TestWebContentsObserver observer( |
| 109 browser2->tab_strip_model()->GetWebContentsAt(0), | 105 browser2->tab_strip_model()->GetWebContentsAt(0), |
| 110 browser2->tab_strip_model()->GetWebContentsAt(1)); | 106 browser2->tab_strip_model()->GetWebContentsAt(1)); |
| 111 BrowserView::GetBrowserViewForBrowser(browser2)->GetWidget()->CloseNow(); | 107 BrowserView::GetBrowserViewForBrowser(browser2)->GetWidget()->CloseNow(); |
| 112 } | 108 } |
| 113 | 109 |
| 114 // Verifies that page and devtools WebViews are being correctly layed out | 110 // Verifies that page and devtools WebViews are being correctly layed out |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 EXPECT_EQ(0, observer.change_count()); | 227 EXPECT_EQ(0, observer.change_count()); |
| 232 observer.clear_change_count(); | 228 observer.clear_change_count(); |
| 233 | 229 |
| 234 browser()->tab_strip_model()->ActivateTabAt(1, true); | 230 browser()->tab_strip_model()->ActivateTabAt(1, true); |
| 235 EXPECT_TRUE(bookmark_bar->visible()); | 231 EXPECT_TRUE(bookmark_bar->visible()); |
| 236 EXPECT_EQ(0, observer.change_count()); | 232 EXPECT_EQ(0, observer.change_count()); |
| 237 observer.clear_change_count(); | 233 observer.clear_change_count(); |
| 238 | 234 |
| 239 browser_view()->bookmark_bar()->RemoveObserver(&observer); | 235 browser_view()->bookmark_bar()->RemoveObserver(&observer); |
| 240 } | 236 } |
| OLD | NEW |