Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/ui/startup/session_crashed_infobar_delegate_unittest.cc

Issue 1198313003: Fix the browser match rules. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use scoped_ptr<Browser> instead. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/prefs/pref_registry_simple.h" 8 #include "base/prefs/pref_registry_simple.h"
9 #include "base/prefs/testing_pref_service.h" 9 #include "base/prefs/testing_pref_service.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 TEST_F(SessionCrashedInfoBarDelegateUnitTest, DetachingTabWithCrashedInfoBar) { 51 TEST_F(SessionCrashedInfoBarDelegateUnitTest, DetachingTabWithCrashedInfoBar) {
52 SessionServiceFactory::SetForTestProfile( 52 SessionServiceFactory::SetForTestProfile(
53 browser()->profile(), 53 browser()->profile(),
54 make_scoped_ptr(static_cast<SessionService*>( 54 make_scoped_ptr(static_cast<SessionService*>(
55 SessionServiceFactory::GetInstance()->BuildServiceInstanceFor( 55 SessionServiceFactory::GetInstance()->BuildServiceInstanceFor(
56 browser()->profile())))); 56 browser()->profile()))));
57 57
58 // Create a browser which we can close during the test. 58 // Create a browser which we can close during the test.
59 Browser::CreateParams params(browser()->profile(), 59 Browser::CreateParams params(browser()->profile(),
60 browser()->host_desktop_type()); 60 browser()->host_desktop_type());
61 scoped_ptr<Browser> first_browser( 61 scoped_ptr<Browser> first_browser =
62 chrome::CreateBrowserWithTestWindowForParams(&params)); 62 chrome::CreateBrowserWithTestWindowForParams(&params);
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);
71 InfoBarService* infobar_service = 71 InfoBarService* infobar_service =
72 InfoBarService::FromWebContents(web_contents); 72 InfoBarService::FromWebContents(web_contents);
73 EXPECT_EQ(1U, infobar_service->infobar_count()); 73 EXPECT_EQ(1U, infobar_service->infobar_count());
74 ConfirmInfoBarDelegate* infobar = 74 ConfirmInfoBarDelegate* infobar =
75 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); 75 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate();
76 ASSERT_TRUE(infobar); 76 ASSERT_TRUE(infobar);
77 77
78 // Open another browser. 78 // Open another browser.
79 scoped_ptr<Browser> opened_browser( 79 scoped_ptr<Browser> opened_browser =
80 chrome::CreateBrowserWithTestWindowForParams(&params)); 80 chrome::CreateBrowserWithTestWindowForParams(&params);
81 81
82 // Move the tab which is destroying the crash info bar to the new browser. 82 // Move the tab which is destroying the crash info bar to the new browser.
83 tab_strip->DetachWebContentsAt(0); 83 tab_strip->DetachWebContentsAt(0);
84 tab_strip = opened_browser->tab_strip_model(); 84 tab_strip = opened_browser->tab_strip_model();
85 tab_strip->AppendWebContents(web_contents, true); 85 tab_strip->AppendWebContents(web_contents, true);
86 86
87 // Close the original browser. 87 // Close the original browser.
88 first_browser->window()->Close(); 88 first_browser->window()->Close();
89 first_browser.reset(); 89 first_browser.reset();
90 90
91 ASSERT_EQ(1, tab_strip->count()); 91 ASSERT_EQ(1, tab_strip->count());
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698