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

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

Issue 228293004: InfoBarService inherits from InfoBarManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: whitespace Created 6 years, 8 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 | Annotate | Revision Log
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/prefs/pref_registry_simple.h" 7 #include "base/prefs/pref_registry_simple.h"
8 #include "base/prefs/testing_pref_service.h" 8 #include "base/prefs/testing_pref_service.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "chrome/browser/infobars/infobar.h" 10 #include "chrome/browser/infobars/infobar.h"
11 #include "chrome/browser/infobars/infobar_manager.h"
12 #include "chrome/browser/infobars/infobar_service.h" 11 #include "chrome/browser/infobars/infobar_service.h"
13 #include "chrome/browser/prefs/browser_prefs.h" 12 #include "chrome/browser/prefs/browser_prefs.h"
14 #include "chrome/browser/sessions/session_service_factory.h" 13 #include "chrome/browser/sessions/session_service_factory.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
17 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
18 #include "chrome/test/base/browser_with_test_window_test.h" 17 #include "chrome/test/base/browser_with_test_window_test.h"
19 #include "chrome/test/base/scoped_testing_local_state.h" 18 #include "chrome/test/base/scoped_testing_local_state.h"
20 #include "chrome/test/base/testing_browser_process.h" 19 #include "chrome/test/base/testing_browser_process.h"
21 20
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 scoped_ptr<Browser> first_browser( 74 scoped_ptr<Browser> first_browser(
76 chrome::CreateBrowserWithTestWindowForParams(&params)); 75 chrome::CreateBrowserWithTestWindowForParams(&params));
77 AddTab(first_browser.get(), GURL(chrome::kChromeUINewTabURL)); 76 AddTab(first_browser.get(), GURL(chrome::kChromeUINewTabURL));
78 77
79 // Attach the crashed infobar to it. 78 // Attach the crashed infobar to it.
80 SessionCrashedInfoBarDelegate::Create(first_browser.get()); 79 SessionCrashedInfoBarDelegate::Create(first_browser.get());
81 80
82 TabStripModel* tab_strip = first_browser->tab_strip_model(); 81 TabStripModel* tab_strip = first_browser->tab_strip_model();
83 ASSERT_EQ(1, tab_strip->count()); 82 ASSERT_EQ(1, tab_strip->count());
84 content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); 83 content::WebContents* web_contents = tab_strip->GetWebContentsAt(0);
85 InfoBarManager* infobar_manager = 84 InfoBarService* infobar_service =
86 InfoBarService::FromWebContents(web_contents)->infobar_manager(); 85 InfoBarService::FromWebContents(web_contents);
87 EXPECT_EQ(1U, infobar_manager->infobar_count()); 86 EXPECT_EQ(1U, infobar_service->infobar_count());
88 ConfirmInfoBarDelegate* infobar = 87 ConfirmInfoBarDelegate* infobar =
89 infobar_manager->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); 88 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate();
90 ASSERT_TRUE(infobar); 89 ASSERT_TRUE(infobar);
91 90
92 // Open another browser. 91 // Open another browser.
93 scoped_ptr<Browser> opened_browser( 92 scoped_ptr<Browser> opened_browser(
94 chrome::CreateBrowserWithTestWindowForParams(&params)); 93 chrome::CreateBrowserWithTestWindowForParams(&params));
95 94
96 // Move the tab which is destroying the crash info bar to the new browser. 95 // Move the tab which is destroying the crash info bar to the new browser.
97 tab_strip->DetachWebContentsAt(0); 96 tab_strip->DetachWebContentsAt(0);
98 tab_strip = opened_browser->tab_strip_model(); 97 tab_strip = opened_browser->tab_strip_model();
99 tab_strip->AppendWebContents(web_contents, true); 98 tab_strip->AppendWebContents(web_contents, true);
100 99
101 // Close the original browser. 100 // Close the original browser.
102 first_browser->window()->Close(); 101 first_browser->window()->Close();
103 first_browser.reset(); 102 first_browser.reset();
104 103
105 ASSERT_EQ(1, tab_strip->count()); 104 ASSERT_EQ(1, tab_strip->count());
106 InfoBarService* infobar_service = 105 infobar_service =
107 InfoBarService::FromWebContents(tab_strip->GetWebContentsAt(0)); 106 InfoBarService::FromWebContents(tab_strip->GetWebContentsAt(0));
108 EXPECT_EQ(1U, infobar_service->infobar_manager()->infobar_count()); 107 EXPECT_EQ(1U, infobar_service->infobar_count());
109 108
110 // This used to crash. 109 // This used to crash.
111 infobar->Accept(); 110 infobar->Accept();
112 111
113 // Ramp down the test. 112 // Ramp down the test.
114 tab_strip->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); 113 tab_strip->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE);
115 } 114 }
116 115
117 #if defined(OS_CHROMEOS) 116 #if defined(OS_CHROMEOS)
118 INSTANTIATE_TEST_CASE_P(SessionCrashedInfoBarDelegateUnitTestInstantiation, 117 INSTANTIATE_TEST_CASE_P(SessionCrashedInfoBarDelegateUnitTestInstantiation,
119 SessionCrashedInfoBarDelegateUnitTest, 118 SessionCrashedInfoBarDelegateUnitTest,
120 testing::Bool()); 119 testing::Bool());
121 #endif 120 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698