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

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: 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..9f63335e74ef77e1fb985bb852791610ebcf6e6a
--- /dev/null
+++ b/chrome/browser/password_manager/auto_signin_infobar_delegate_unittest.cc
@@ -0,0 +1,90 @@
+// 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 {}
+
+ void SetUp() override;
+ void TearDown() 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();
+}
+
+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.
+ ChromeRenderViewHostTestHarness::SetUp();
+}
+
+void AutoSigninFirstRunInfobarDelegateTest::TearDown() {
+ ChromeRenderViewHostTestHarness::TearDown();
+}
+
+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