| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
| 7 #include "chrome/browser/password_manager/auto_signin_first_run_infobar_delegate
.h" | 7 #include "chrome/browser/password_manager/auto_signin_first_run_infobar_delegate
.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 10 #include "components/password_manager/core/common/password_manager_pref_names.h" | 10 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 scoped_ptr<ConfirmInfoBarDelegate> CreateDelegate(); | 41 scoped_ptr<ConfirmInfoBarDelegate> CreateDelegate(); |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 DISALLOW_COPY_AND_ASSIGN(AutoSigninFirstRunInfoBarDelegateTest); | 44 DISALLOW_COPY_AND_ASSIGN(AutoSigninFirstRunInfoBarDelegateTest); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 scoped_ptr<ConfirmInfoBarDelegate> | 47 scoped_ptr<ConfirmInfoBarDelegate> |
| 48 AutoSigninFirstRunInfoBarDelegateTest::CreateDelegate() { | 48 AutoSigninFirstRunInfoBarDelegateTest::CreateDelegate() { |
| 49 scoped_ptr<ConfirmInfoBarDelegate> delegate( | 49 scoped_ptr<ConfirmInfoBarDelegate> delegate( |
| 50 new TestAutoSigninFirstRunInfoBarDelegate(web_contents())); | 50 new TestAutoSigninFirstRunInfoBarDelegate(web_contents())); |
| 51 return delegate.Pass(); | 51 return delegate; |
| 52 } | 52 } |
| 53 | 53 |
| 54 PrefService* AutoSigninFirstRunInfoBarDelegateTest::prefs() { | 54 PrefService* AutoSigninFirstRunInfoBarDelegateTest::prefs() { |
| 55 Profile* profile = | 55 Profile* profile = |
| 56 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 56 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 57 return profile->GetPrefs(); | 57 return profile->GetPrefs(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 TEST_F(AutoSigninFirstRunInfoBarDelegateTest, | 60 TEST_F(AutoSigninFirstRunInfoBarDelegateTest, |
| 61 CheckResetOfPrefAfterFirstRunMessageWasShownOnCancel) { | 61 CheckResetOfPrefAfterFirstRunMessageWasShownOnCancel) { |
| 62 prefs()->SetBoolean( | 62 prefs()->SetBoolean( |
| 63 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown, false); | 63 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown, false); |
| 64 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate()); | 64 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate()); |
| 65 EXPECT_TRUE(infobar->Cancel()); | 65 EXPECT_TRUE(infobar->Cancel()); |
| 66 infobar.reset(); | 66 infobar.reset(); |
| 67 EXPECT_TRUE(prefs()->GetBoolean( | 67 EXPECT_TRUE(prefs()->GetBoolean( |
| 68 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown)); | 68 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 TEST_F(AutoSigninFirstRunInfoBarDelegateTest, | 71 TEST_F(AutoSigninFirstRunInfoBarDelegateTest, |
| 72 CheckResetOfPrefAfterFirstRunMessageWasShownOnAccept) { | 72 CheckResetOfPrefAfterFirstRunMessageWasShownOnAccept) { |
| 73 prefs()->SetBoolean( | 73 prefs()->SetBoolean( |
| 74 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown, false); | 74 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown, false); |
| 75 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate()); | 75 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate()); |
| 76 EXPECT_TRUE(infobar->Accept()); | 76 EXPECT_TRUE(infobar->Accept()); |
| 77 infobar.reset(); | 77 infobar.reset(); |
| 78 EXPECT_TRUE(prefs()->GetBoolean( | 78 EXPECT_TRUE(prefs()->GetBoolean( |
| 79 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown)); | 79 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown)); |
| 80 } | 80 } |
| OLD | NEW |