| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/startup/session_crashed_infobar_delegate.h" | 5 #include "chrome/browser/ui/startup/session_crashed_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 TEST_F(SessionCrashedInfoBarDelegateUnitTest, DetachingTabWithCrashedInfoBar) { | 52 TEST_F(SessionCrashedInfoBarDelegateUnitTest, DetachingTabWithCrashedInfoBar) { |
| 53 SessionServiceFactory::SetForTestProfile( | 53 SessionServiceFactory::SetForTestProfile( |
| 54 browser()->profile(), | 54 browser()->profile(), |
| 55 base::WrapUnique(static_cast<SessionService*>( | 55 base::WrapUnique(static_cast<SessionService*>( |
| 56 SessionServiceFactory::GetInstance()->BuildServiceInstanceFor( | 56 SessionServiceFactory::GetInstance()->BuildServiceInstanceFor( |
| 57 browser()->profile())))); | 57 browser()->profile())))); |
| 58 | 58 |
| 59 // Create a browser which we can close during the test. | 59 // Create a browser which we can close during the test. |
| 60 Browser::CreateParams params(browser()->profile()); | 60 Browser::CreateParams params(browser()->profile(), true); |
| 61 std::unique_ptr<Browser> first_browser( | 61 std::unique_ptr<Browser> first_browser( |
| 62 chrome::CreateBrowserWithTestWindowForParams(¶ms)); | 62 chrome::CreateBrowserWithTestWindowForParams(¶ms)); |
| 63 AddTab(first_browser.get(), GURL(chrome::kChromeUINewTabURL)); | 63 AddTab(first_browser.get(), GURL(chrome::kChromeUINewTabURL)); |
| 64 | 64 |
| 65 // Attach the crashed infobar to it. | 65 // Attach the crashed infobar to it. |
| 66 SessionCrashedInfoBarDelegate::Create(first_browser.get()); | 66 SessionCrashedInfoBarDelegate::Create(first_browser.get()); |
| 67 | 67 |
| 68 TabStripModel* tab_strip = first_browser->tab_strip_model(); | 68 TabStripModel* tab_strip = first_browser->tab_strip_model(); |
| 69 ASSERT_EQ(1, tab_strip->count()); | 69 ASSERT_EQ(1, tab_strip->count()); |
| 70 content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); | 70 content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 92 infobar_service = | 92 infobar_service = |
| 93 InfoBarService::FromWebContents(tab_strip->GetWebContentsAt(0)); | 93 InfoBarService::FromWebContents(tab_strip->GetWebContentsAt(0)); |
| 94 EXPECT_EQ(1U, infobar_service->infobar_count()); | 94 EXPECT_EQ(1U, infobar_service->infobar_count()); |
| 95 | 95 |
| 96 // This used to crash. | 96 // This used to crash. |
| 97 infobar->Accept(); | 97 infobar->Accept(); |
| 98 | 98 |
| 99 // Ramp down the test. | 99 // Ramp down the test. |
| 100 tab_strip->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); | 100 tab_strip->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); |
| 101 } | 101 } |
| OLD | NEW |