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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/password_manager/auto_signin_infobar_delegate_unittest.cc
diff --git a/chrome/browser/password_manager/auto_signin_infobar_delegate_unittest.cc b/chrome/browser/password_manager/auto_signin_infobar_delegate_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..911c4aadfe51da22d81d701e3e30becc1b083537
--- /dev/null
+++ b/chrome/browser/password_manager/auto_signin_infobar_delegate_unittest.cc
@@ -0,0 +1,79 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/prefs/pref_service.h"
+#include "chrome/browser/password_manager/auto_signin_first_run_infobar_delegate.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "components/password_manager/core/common/password_manager_pref_names.h"
+#include "content/public/browser/web_contents.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class TestAutoSigninFirstRunInfoBarDelegate
+ : public AutoSigninFirstRunInfoBarDelegate {
+ public:
+ explicit TestAutoSigninFirstRunInfoBarDelegate(
+ content::WebContents* web_contents)
+ : AutoSigninFirstRunInfoBarDelegate(
+ web_contents,
+ true /* is_smartlock_branding_enabled */,
+ base::string16()) {}
+
+ ~TestAutoSigninFirstRunInfoBarDelegate() override {}
+};
+
+} // namespace
+
+class AutoSigninFirstRunInfoBarDelegateTest
+ : public ChromeRenderViewHostTestHarness {
+ public:
+ AutoSigninFirstRunInfoBarDelegateTest() {}
+ ~AutoSigninFirstRunInfoBarDelegateTest() override {}
+
+ PrefService* prefs();
+
+ protected:
+ scoped_ptr<ConfirmInfoBarDelegate> CreateDelegate();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AutoSigninFirstRunInfoBarDelegateTest);
+};
+
+scoped_ptr<ConfirmInfoBarDelegate>
+AutoSigninFirstRunInfoBarDelegateTest::CreateDelegate() {
+ scoped_ptr<ConfirmInfoBarDelegate> delegate(
+ new TestAutoSigninFirstRunInfoBarDelegate(web_contents()));
+ return delegate.Pass();
+}
+
+PrefService* AutoSigninFirstRunInfoBarDelegateTest::prefs() {
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents()->GetBrowserContext());
+ return profile->GetPrefs();
+}
+
+TEST_F(AutoSigninFirstRunInfoBarDelegateTest,
+ CheckResetOfPrefAfterFirstRunMessageWasShownOnCancel) {
+ prefs()->SetBoolean(
+ password_manager::prefs::kWasAutoSignInFirstRunExperienceShown, false);
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
+ EXPECT_TRUE(infobar->Cancel());
+ infobar.reset();
+ EXPECT_TRUE(prefs()->GetBoolean(
+ password_manager::prefs::kWasAutoSignInFirstRunExperienceShown));
+}
+
+TEST_F(AutoSigninFirstRunInfoBarDelegateTest,
+ CheckResetOfPrefAfterFirstRunMessageWasShownOnAccept) {
+ prefs()->SetBoolean(
+ password_manager::prefs::kWasAutoSignInFirstRunExperienceShown, false);
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate());
+ EXPECT_TRUE(infobar->Accept());
+ infobar.reset();
+ EXPECT_TRUE(prefs()->GetBoolean(
+ password_manager::prefs::kWasAutoSignInFirstRunExperienceShown));
+}

Powered by Google App Engine
This is Rietveld 408576698