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

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

Issue 287083003: Multi-profile flag cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: Created 6 years, 7 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_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
11 #include "chrome/browser/prefs/browser_prefs.h" 11 #include "chrome/browser/prefs/browser_prefs.h"
12 #include "chrome/browser/sessions/session_service_factory.h" 12 #include "chrome/browser/sessions/session_service_factory.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
16 #include "chrome/test/base/browser_with_test_window_test.h" 16 #include "chrome/test/base/browser_with_test_window_test.h"
17 #include "chrome/test/base/scoped_testing_local_state.h" 17 #include "chrome/test/base/scoped_testing_local_state.h"
18 #include "chrome/test/base/testing_browser_process.h" 18 #include "chrome/test/base/testing_browser_process.h"
19 #include "components/infobars/core/infobar.h" 19 #include "components/infobars/core/infobar.h"
20 20
21 #if defined(OS_CHROMEOS) 21 #if defined(OS_CHROMEOS)
Nikita (slow) 2014/05/19 14:27:15 nit: can safely remove this block (both includes).
22 #include "base/command_line.h" 22 #include "base/command_line.h"
23 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
24 #endif 24 #endif
25 25
26 #if defined(OS_CHROMEOS)
27 // TODO(nkostylev): Cleanup this code once multi-profiles are enabled by
28 // default on CrOS. http://crbug.com/351655
29 class SessionCrashedInfoBarDelegateUnitTest :
30 public BrowserWithTestWindowTest,
31 public testing::WithParamInterface<bool> {
32 #else
33 class SessionCrashedInfoBarDelegateUnitTest : public BrowserWithTestWindowTest { 26 class SessionCrashedInfoBarDelegateUnitTest : public BrowserWithTestWindowTest {
34 #endif
35 public: 27 public:
36 virtual void SetUp() OVERRIDE { 28 virtual void SetUp() OVERRIDE {
37 static_cast<TestingBrowserProcess*>(g_browser_process) 29 static_cast<TestingBrowserProcess*>(g_browser_process)
38 ->SetLocalState(&pref_service); 30 ->SetLocalState(&pref_service);
39 chrome::RegisterLocalState(pref_service.registry()); 31 chrome::RegisterLocalState(pref_service.registry());
40 32
41 #if defined(OS_CHROMEOS)
42 if (GetParam())
43 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles);
44 #endif
45
46 // This needs to be called after the local state is set, because it will 33 // This needs to be called after the local state is set, because it will
47 // create a browser which will try to read from the local state. 34 // create a browser which will try to read from the local state.
48 BrowserWithTestWindowTest::SetUp(); 35 BrowserWithTestWindowTest::SetUp();
49 } 36 }
50 37
51 virtual void TearDown() OVERRIDE { 38 virtual void TearDown() OVERRIDE {
52 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState(NULL); 39 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState(NULL);
53 BrowserWithTestWindowTest::TearDown(); 40 BrowserWithTestWindowTest::TearDown();
54 } 41 }
55 42
56 private: 43 private:
57 TestingPrefServiceSimple pref_service; 44 TestingPrefServiceSimple pref_service;
58 }; 45 };
59 46
60 #if defined(OS_CHROMEOS)
61 TEST_P(SessionCrashedInfoBarDelegateUnitTest, DetachingTabWithCrashedInfoBar) {
62 #else
63 TEST_F(SessionCrashedInfoBarDelegateUnitTest, DetachingTabWithCrashedInfoBar) { 47 TEST_F(SessionCrashedInfoBarDelegateUnitTest, DetachingTabWithCrashedInfoBar) {
64 #endif
65 SessionServiceFactory::SetForTestProfile( 48 SessionServiceFactory::SetForTestProfile(
66 browser()->profile(), 49 browser()->profile(),
67 static_cast<SessionService*>( 50 static_cast<SessionService*>(
68 SessionServiceFactory::GetInstance()->BuildServiceInstanceFor( 51 SessionServiceFactory::GetInstance()->BuildServiceInstanceFor(
69 browser()->profile()))); 52 browser()->profile())));
70 53
71 // Create a browser which we can close during the test. 54 // Create a browser which we can close during the test.
72 Browser::CreateParams params(browser()->profile(), 55 Browser::CreateParams params(browser()->profile(),
73 browser()->host_desktop_type()); 56 browser()->host_desktop_type());
74 scoped_ptr<Browser> first_browser( 57 scoped_ptr<Browser> first_browser(
(...skipping 30 matching lines...) Expand all
105 infobar_service = 88 infobar_service =
106 InfoBarService::FromWebContents(tab_strip->GetWebContentsAt(0)); 89 InfoBarService::FromWebContents(tab_strip->GetWebContentsAt(0));
107 EXPECT_EQ(1U, infobar_service->infobar_count()); 90 EXPECT_EQ(1U, infobar_service->infobar_count());
108 91
109 // This used to crash. 92 // This used to crash.
110 infobar->Accept(); 93 infobar->Accept();
111 94
112 // Ramp down the test. 95 // Ramp down the test.
113 tab_strip->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); 96 tab_strip->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE);
114 } 97 }
115
116 #if defined(OS_CHROMEOS)
117 INSTANTIATE_TEST_CASE_P(SessionCrashedInfoBarDelegateUnitTestInstantiation,
118 SessionCrashedInfoBarDelegateUnitTest,
119 testing::Bool());
120 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698