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

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

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

Powered by Google App Engine
This is Rietveld 408576698