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

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: 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 void SetUp() override;
38 void TearDown() override;
39
40 PrefService* prefs();
41
42 protected:
43 scoped_ptr<ConfirmInfoBarDelegate> CreateDelegate();
44
45 private:
46 DISALLOW_COPY_AND_ASSIGN(AutoSigninFirstRunInfobarDelegateTest);
47 };
48
49 scoped_ptr<ConfirmInfoBarDelegate>
50 AutoSigninFirstRunInfobarDelegateTest::CreateDelegate() {
51 scoped_ptr<ConfirmInfoBarDelegate> delegate(
52 new TestAutoSigninFirstRunInfobarDelegate(web_contents()));
53 return delegate.Pass();
54 }
55
56 void AutoSigninFirstRunInfobarDelegateTest::SetUp() {
vabr (Chromium) 2015/11/03 15:28:57 You don't have to define your own SetUp and TearDo
melandory 2015/11/03 16:32:35 Done.
57 ChromeRenderViewHostTestHarness::SetUp();
58 }
59
60 void AutoSigninFirstRunInfobarDelegateTest::TearDown() {
61 ChromeRenderViewHostTestHarness::TearDown();
62 }
63
64 PrefService* AutoSigninFirstRunInfobarDelegateTest::prefs() {
65 Profile* profile =
66 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
67 return profile->GetPrefs();
68 }
69
70 TEST_F(AutoSigninFirstRunInfobarDelegateTest,
71 CheckResetOfPrefAfterFirstRunMessageWasShownOnCancel) {
72 prefs()->SetBoolean(
73 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown, false);
74 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
75 EXPECT_TRUE(infobar->Cancel());
76 infobar.reset();
77 EXPECT_TRUE(prefs()->GetBoolean(
78 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown));
79 }
80
81 TEST_F(AutoSigninFirstRunInfobarDelegateTest,
82 CheckResetOfPrefAfterFirstRunMessageWasShownOnAccept) {
83 prefs()->SetBoolean(
84 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown, false);
85 scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
86 EXPECT_TRUE(infobar->Accept());
87 infobar.reset();
88 EXPECT_TRUE(prefs()->GetBoolean(
89 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown));
90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698