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

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

Issue 812823002: Remove dependency of infobars component on the embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests by instanciating a TestConfirmInfoBarDelegateFactory Created 6 years 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"
11 #include "chrome/browser/infobars/infobar_service.h" 11 #include "chrome/browser/infobars/infobar_service.h"
12 #include "chrome/browser/prefs/browser_prefs.h" 12 #include "chrome/browser/prefs/browser_prefs.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/sessions/session_service_factory.h" 14 #include "chrome/browser/sessions/session_service_factory.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "chrome/test/base/browser_with_test_window_test.h" 17 #include "chrome/test/base/browser_with_test_window_test.h"
18 #include "chrome/test/base/scoped_testing_local_state.h" 18 #include "chrome/test/base/scoped_testing_local_state.h"
19 #include "chrome/test/base/testing_browser_process.h" 19 #include "chrome/test/base/testing_browser_process.h"
20 #include "components/infobars/core/infobar.h" 20 #include "components/infobars/core/infobar.h"
21 #include "components/infobars/test/test_confirm_infobar_delegate_factory.h"
21 22
22 class SessionCrashedInfoBarDelegateUnitTest : public BrowserWithTestWindowTest { 23 class SessionCrashedInfoBarDelegateUnitTest : public BrowserWithTestWindowTest {
23 public: 24 public:
24 void SetUp() override { 25 void SetUp() override {
25 static_cast<TestingBrowserProcess*>(g_browser_process) 26 static_cast<TestingBrowserProcess*>(g_browser_process)
26 ->SetLocalState(&pref_service); 27 ->SetLocalState(&pref_service);
27 chrome::RegisterLocalState(pref_service.registry()); 28 chrome::RegisterLocalState(pref_service.registry());
28 29
29 // This needs to be called after the local state is set, because it will 30 // This needs to be called after the local state is set, because it will
30 // create a browser which will try to read from the local state. 31 // create a browser which will try to read from the local state.
31 BrowserWithTestWindowTest::SetUp(); 32 BrowserWithTestWindowTest::SetUp();
32 33
33 // Make sure we have a Profile Manager. 34 // Make sure we have a Profile Manager.
34 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 35 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
35 TestingBrowserProcess::GetGlobal()->SetProfileManager( 36 TestingBrowserProcess::GetGlobal()->SetProfileManager(
36 new ProfileManagerWithoutInit(temp_dir_.path())); 37 new ProfileManagerWithoutInit(temp_dir_.path()));
37 } 38 }
38 39
39 void TearDown() override { 40 void TearDown() override {
40 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState(NULL); 41 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState(NULL);
41 BrowserWithTestWindowTest::TearDown(); 42 BrowserWithTestWindowTest::TearDown();
42 43
43 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); 44 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL);
44 } 45 }
45 46
46 private: 47 private:
47 TestingPrefServiceSimple pref_service; 48 TestingPrefServiceSimple pref_service;
48 base::ScopedTempDir temp_dir_; 49 base::ScopedTempDir temp_dir_;
50 TestConfirmInfoBarDelegateFactory confirm_info_bar_delegate_factory_;
49 }; 51 };
50 52
51 TEST_F(SessionCrashedInfoBarDelegateUnitTest, DetachingTabWithCrashedInfoBar) { 53 TEST_F(SessionCrashedInfoBarDelegateUnitTest, DetachingTabWithCrashedInfoBar) {
52 SessionServiceFactory::SetForTestProfile( 54 SessionServiceFactory::SetForTestProfile(
53 browser()->profile(), 55 browser()->profile(),
54 static_cast<SessionService*>( 56 static_cast<SessionService*>(
55 SessionServiceFactory::GetInstance()->BuildServiceInstanceFor( 57 SessionServiceFactory::GetInstance()->BuildServiceInstanceFor(
56 browser()->profile()))); 58 browser()->profile())));
57 59
58 // Create a browser which we can close during the test. 60 // Create a browser which we can close during the test.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 infobar_service = 94 infobar_service =
93 InfoBarService::FromWebContents(tab_strip->GetWebContentsAt(0)); 95 InfoBarService::FromWebContents(tab_strip->GetWebContentsAt(0));
94 EXPECT_EQ(1U, infobar_service->infobar_count()); 96 EXPECT_EQ(1U, infobar_service->infobar_count());
95 97
96 // This used to crash. 98 // This used to crash.
97 infobar->Accept(); 99 infobar->Accept();
98 100
99 // Ramp down the test. 101 // Ramp down the test.
100 tab_strip->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); 102 tab_strip->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE);
101 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698