| 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 = new Browser(Browser::CreateParams(browser()->profile())); | 88 Browser* browser2 = |
| 89 new Browser(Browser::CreateParams(browser()->profile(), true)); |
| 89 chrome::AddTabAt(browser2, GURL(), -1, true); | 90 chrome::AddTabAt(browser2, GURL(), -1, true); |
| 90 chrome::AddTabAt(browser2, GURL(), -1, true); | 91 chrome::AddTabAt(browser2, GURL(), -1, true); |
| 91 TestWebContentsObserver observer( | 92 TestWebContentsObserver observer( |
| 92 browser2->tab_strip_model()->GetWebContentsAt(0), | 93 browser2->tab_strip_model()->GetWebContentsAt(0), |
| 93 browser2->tab_strip_model()->GetWebContentsAt(1)); | 94 browser2->tab_strip_model()->GetWebContentsAt(1)); |
| 94 BrowserView::GetBrowserViewForBrowser(browser2)->GetWidget()->CloseNow(); | 95 BrowserView::GetBrowserViewForBrowser(browser2)->GetWidget()->CloseNow(); |
| 95 } | 96 } |
| 96 | 97 |
| 97 // Same as CloseWithTabs, but activates the first tab, which is the first tab | 98 // Same as CloseWithTabs, but activates the first tab, which is the first tab |
| 98 // BrowserView will destroy. | 99 // BrowserView will destroy. |
| 99 IN_PROC_BROWSER_TEST_F(BrowserViewTest, CloseWithTabsStartWithActive) { | 100 IN_PROC_BROWSER_TEST_F(BrowserViewTest, CloseWithTabsStartWithActive) { |
| 100 Browser* browser2 = new Browser(Browser::CreateParams(browser()->profile())); | 101 Browser* browser2 = |
| 102 new Browser(Browser::CreateParams(browser()->profile(), true)); |
| 101 chrome::AddTabAt(browser2, GURL(), -1, true); | 103 chrome::AddTabAt(browser2, GURL(), -1, true); |
| 102 chrome::AddTabAt(browser2, GURL(), -1, true); | 104 chrome::AddTabAt(browser2, GURL(), -1, true); |
| 103 browser2->tab_strip_model()->ActivateTabAt(0, true); | 105 browser2->tab_strip_model()->ActivateTabAt(0, true); |
| 104 TestWebContentsObserver observer( | 106 TestWebContentsObserver observer( |
| 105 browser2->tab_strip_model()->GetWebContentsAt(0), | 107 browser2->tab_strip_model()->GetWebContentsAt(0), |
| 106 browser2->tab_strip_model()->GetWebContentsAt(1)); | 108 browser2->tab_strip_model()->GetWebContentsAt(1)); |
| 107 BrowserView::GetBrowserViewForBrowser(browser2)->GetWidget()->CloseNow(); | 109 BrowserView::GetBrowserViewForBrowser(browser2)->GetWidget()->CloseNow(); |
| 108 } | 110 } |
| 109 | 111 |
| 110 // Verifies that page and devtools WebViews are being correctly layed out | 112 // Verifies that page and devtools WebViews are being correctly layed out |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 EXPECT_EQ(0, observer.change_count()); | 229 EXPECT_EQ(0, observer.change_count()); |
| 228 observer.clear_change_count(); | 230 observer.clear_change_count(); |
| 229 | 231 |
| 230 browser()->tab_strip_model()->ActivateTabAt(1, true); | 232 browser()->tab_strip_model()->ActivateTabAt(1, true); |
| 231 EXPECT_TRUE(bookmark_bar->visible()); | 233 EXPECT_TRUE(bookmark_bar->visible()); |
| 232 EXPECT_EQ(0, observer.change_count()); | 234 EXPECT_EQ(0, observer.change_count()); |
| 233 observer.clear_change_count(); | 235 observer.clear_change_count(); |
| 234 | 236 |
| 235 browser_view()->bookmark_bar()->RemoveObserver(&observer); | 237 browser_view()->bookmark_bar()->RemoveObserver(&observer); |
| 236 } | 238 } |
| OLD | NEW |