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

Side by Side Diff: chrome/browser/password_manager/auto_signin_infobar_delegate_unittest.cc

Issue 1379153003: [Smart Lock, UI] First run expience for Auto sign-in prompt. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: AutoSigninFirstRunInfoBar.java Created 5 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/prefs/pref_service.h"
6 #include "chrome/browser/password_manager/auto_signin_first_run_infobar_delegate .h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
9 #include "components/password_manager/core/common/password_manager_pref_names.h"
10 #include "content/public/browser/web_contents.h"
11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace {
15
16 class TestAutoSigninFirstRunInfoBarDelegate
17 : public AutoSigninFirstRunInfoBarDelegate {
18 public:
19 explicit TestAutoSigninFirstRunInfoBarDelegate(
20 content::WebContents* web_contents)
21 : AutoSigninFirstRunInfoBarDelegate(
22 web_contents,
23 true /* is_smartlock_branding_enabled */,
24 base::string16()) {}
25
26 ~TestAutoSigninFirstRunInfoBarDelegate() override {}
27 };
28
29 } // namespace
30
31 class AutoSigninFirstRunInfoBarDelegateTest
32 : public ChromeRenderViewHostTestHarness {
33 public:
34 AutoSigninFirstRunInfoBarDelegateTest() {}
35 ~AutoSigninFirstRunInfoBarDelegateTest() override {}
36
37 PrefService* prefs();
38
39 protected:
40 scoped_ptr<ConfirmInfoBarDelegate> CreateDelegate();
41
42 private:
43 DISALLOW_COPY_AND_ASSIGN(AutoSigninFirstRunInfoBarDelegateTest);
44 };
45
46 scoped_ptr<ConfirmInfoBarDelegate>
47 AutoSigninFirstRunInfoBarDelegateTest::CreateDelegate() {
48 scoped_ptr<ConfirmInfoBarDelegate> delegate(
49 new TestAutoSigninFirstRunInfoBarDelegate(web_contents()));
50 return delegate.Pass();
51 }
52
53 PrefService* AutoSigninFirstRunInfoBarDelegateTest::prefs() {
54 Profile* profile =
55 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
56 return profile->GetPrefs();
57 }
58
59 TEST_F(AutoSigninFirstRunInfoBarDelegateTest,
60 CheckResetOfPrefAfterFirstRunMessageWasShownOnCancel) {
61 prefs()->SetBoolean(
62 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown, false);
63 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
64 EXPECT_TRUE(infobar->Cancel());
65 infobar.reset();
66 EXPECT_TRUE(prefs()->GetBoolean(
67 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown));
68 }
69
70 TEST_F(AutoSigninFirstRunInfoBarDelegateTest,
71 CheckResetOfPrefAfterFirstRunMessageWasShownOnAccept) {
72 prefs()->SetBoolean(
73 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown, false);
74 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
75 EXPECT_TRUE(infobar->Accept());
76 infobar.reset();
77 EXPECT_TRUE(prefs()->GetBoolean(
78 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown));
79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698