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

Unified Diff: chrome/browser/ui/passwords/manage_passwords_bubble_model_unittest.cc

Issue 259153004: Password bubble: Give users the option of unblacklisting a site. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months 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/ui/passwords/manage_passwords_bubble_model_unittest.cc
diff --git a/chrome/browser/ui/passwords/manage_passwords_bubble_model_unittest.cc b/chrome/browser/ui/passwords/manage_passwords_bubble_model_unittest.cc
index 2ee54d68fec783cbc384e66a8637a4232d26c097..c4b35bcc78832ea278d71ac539db6dc75530ea21 100644
--- a/chrome/browser/ui/passwords/manage_passwords_bubble_model_unittest.cc
+++ b/chrome/browser/ui/passwords/manage_passwords_bubble_model_unittest.cc
@@ -45,6 +45,12 @@ class ManagePasswordsBubbleModelTest : public testing::Test {
model_->OnBubbleShown(ManagePasswordsBubble::USER_ACTION);
}
+ void PretendBlacklisted() {
+ model_->set_manage_passwords_bubble_state(
+ ManagePasswordsBubbleModel::NEVER_SAVE_PASSWORDS);
+ model_->OnBubbleShown(ManagePasswordsBubble::USER_ACTION);
+ }
+
ManagePasswordsBubbleUIControllerMock* controller() {
return reinterpret_cast<ManagePasswordsBubbleUIControllerMock*>(
ManagePasswordsBubbleUIController::FromWebContents(
@@ -67,6 +73,7 @@ TEST_F(ManagePasswordsBubbleModelTest, DefaultValues) {
password_manager::metrics_util::NOT_DISPLAYED);
EXPECT_FALSE(controller()->saved_password());
EXPECT_FALSE(controller()->never_saved_password());
+ EXPECT_FALSE(controller()->unblacklisted_site());
}
TEST_F(ManagePasswordsBubbleModelTest, CloseWithoutLogging) {
@@ -77,6 +84,7 @@ TEST_F(ManagePasswordsBubbleModelTest, CloseWithoutLogging) {
password_manager::metrics_util::NOT_DISPLAYED);
EXPECT_FALSE(controller()->saved_password());
EXPECT_FALSE(controller()->never_saved_password());
+ EXPECT_FALSE(controller()->unblacklisted_site());
scoped_ptr<base::HistogramSamples> samples(
statistics_delta_reader.GetHistogramSamplesSinceCreation(
@@ -90,8 +98,10 @@ TEST_F(ManagePasswordsBubbleModelTest, CloseWithoutInteraction) {
model_->OnBubbleHidden();
EXPECT_EQ(model_->dismissal_reason(),
password_manager::metrics_util::NO_DIRECT_INTERACTION);
+ EXPECT_TRUE(model_->WaitingToSavePassword());
EXPECT_FALSE(controller()->saved_password());
EXPECT_FALSE(controller()->never_saved_password());
+ EXPECT_FALSE(controller()->unblacklisted_site());
scoped_ptr<base::HistogramSamples> samples(
statistics_delta_reader.GetHistogramSamplesSinceCreation(
@@ -106,6 +116,9 @@ TEST_F(ManagePasswordsBubbleModelTest, CloseWithoutInteraction) {
EXPECT_EQ(0,
samples->GetCount(password_manager::metrics_util::CLICKED_MANAGE));
EXPECT_EQ(0, samples->GetCount(password_manager::metrics_util::CLICKED_DONE));
+ EXPECT_EQ(
+ 0,
+ samples->GetCount(password_manager::metrics_util::CLICKED_UNBLACKLIST));
}
TEST_F(ManagePasswordsBubbleModelTest, ClickSave) {
@@ -115,8 +128,11 @@ TEST_F(ManagePasswordsBubbleModelTest, ClickSave) {
model_->OnBubbleHidden();
EXPECT_EQ(model_->dismissal_reason(),
password_manager::metrics_util::CLICKED_SAVE);
+ EXPECT_FALSE(model_->WaitingToSavePassword());
+ EXPECT_FALSE(model_->NeverSavingPasswords());
EXPECT_TRUE(controller()->saved_password());
EXPECT_FALSE(controller()->never_saved_password());
+ EXPECT_FALSE(controller()->unblacklisted_site());
scoped_ptr<base::HistogramSamples> samples(
statistics_delta_reader.GetHistogramSamplesSinceCreation(
@@ -131,6 +147,9 @@ TEST_F(ManagePasswordsBubbleModelTest, ClickSave) {
EXPECT_EQ(0,
samples->GetCount(password_manager::metrics_util::CLICKED_MANAGE));
EXPECT_EQ(0, samples->GetCount(password_manager::metrics_util::CLICKED_DONE));
+ EXPECT_EQ(
+ 0,
+ samples->GetCount(password_manager::metrics_util::CLICKED_UNBLACKLIST));
}
TEST_F(ManagePasswordsBubbleModelTest, ClickNope) {
@@ -140,8 +159,11 @@ TEST_F(ManagePasswordsBubbleModelTest, ClickNope) {
model_->OnBubbleHidden();
EXPECT_EQ(model_->dismissal_reason(),
password_manager::metrics_util::CLICKED_NOPE);
+ EXPECT_TRUE(model_->WaitingToSavePassword());
+ EXPECT_FALSE(model_->NeverSavingPasswords());
EXPECT_FALSE(controller()->saved_password());
EXPECT_FALSE(controller()->never_saved_password());
+ EXPECT_FALSE(controller()->unblacklisted_site());
scoped_ptr<base::HistogramSamples> samples(
statistics_delta_reader.GetHistogramSamplesSinceCreation(
@@ -156,6 +178,9 @@ TEST_F(ManagePasswordsBubbleModelTest, ClickNope) {
EXPECT_EQ(0,
samples->GetCount(password_manager::metrics_util::CLICKED_MANAGE));
EXPECT_EQ(0, samples->GetCount(password_manager::metrics_util::CLICKED_DONE));
+ EXPECT_EQ(
+ 0,
+ samples->GetCount(password_manager::metrics_util::CLICKED_UNBLACKLIST));
}
TEST_F(ManagePasswordsBubbleModelTest, ClickNever) {
@@ -165,8 +190,11 @@ TEST_F(ManagePasswordsBubbleModelTest, ClickNever) {
model_->OnBubbleHidden();
EXPECT_EQ(model_->dismissal_reason(),
password_manager::metrics_util::CLICKED_NEVER);
+ EXPECT_FALSE(model_->WaitingToSavePassword());
+ EXPECT_TRUE(model_->NeverSavingPasswords());
EXPECT_FALSE(controller()->saved_password());
EXPECT_TRUE(controller()->never_saved_password());
+ EXPECT_FALSE(controller()->unblacklisted_site());
scoped_ptr<base::HistogramSamples> samples(
statistics_delta_reader.GetHistogramSamplesSinceCreation(
@@ -181,6 +209,9 @@ TEST_F(ManagePasswordsBubbleModelTest, ClickNever) {
EXPECT_EQ(0,
samples->GetCount(password_manager::metrics_util::CLICKED_MANAGE));
EXPECT_EQ(0, samples->GetCount(password_manager::metrics_util::CLICKED_DONE));
+ EXPECT_EQ(
+ 0,
+ samples->GetCount(password_manager::metrics_util::CLICKED_UNBLACKLIST));
}
TEST_F(ManagePasswordsBubbleModelTest, ClickManage) {
@@ -190,8 +221,11 @@ TEST_F(ManagePasswordsBubbleModelTest, ClickManage) {
model_->OnBubbleHidden();
EXPECT_EQ(model_->dismissal_reason(),
password_manager::metrics_util::CLICKED_MANAGE);
+ EXPECT_FALSE(model_->WaitingToSavePassword());
+ EXPECT_FALSE(model_->NeverSavingPasswords());
EXPECT_FALSE(controller()->saved_password());
EXPECT_FALSE(controller()->never_saved_password());
+ EXPECT_FALSE(controller()->unblacklisted_site());
scoped_ptr<base::HistogramSamples> samples(
statistics_delta_reader.GetHistogramSamplesSinceCreation(
@@ -206,6 +240,9 @@ TEST_F(ManagePasswordsBubbleModelTest, ClickManage) {
EXPECT_EQ(1,
samples->GetCount(password_manager::metrics_util::CLICKED_MANAGE));
EXPECT_EQ(0, samples->GetCount(password_manager::metrics_util::CLICKED_DONE));
+ EXPECT_EQ(
+ 0,
+ samples->GetCount(password_manager::metrics_util::CLICKED_UNBLACKLIST));
}
TEST_F(ManagePasswordsBubbleModelTest, ClickDone) {
@@ -215,6 +252,8 @@ TEST_F(ManagePasswordsBubbleModelTest, ClickDone) {
model_->OnBubbleHidden();
EXPECT_EQ(model_->dismissal_reason(),
password_manager::metrics_util::CLICKED_DONE);
+ EXPECT_FALSE(model_->WaitingToSavePassword());
+ EXPECT_FALSE(model_->NeverSavingPasswords());
EXPECT_FALSE(controller()->saved_password());
EXPECT_FALSE(controller()->never_saved_password());
@@ -231,12 +270,52 @@ TEST_F(ManagePasswordsBubbleModelTest, ClickDone) {
EXPECT_EQ(0,
samples->GetCount(password_manager::metrics_util::CLICKED_MANAGE));
EXPECT_EQ(1, samples->GetCount(password_manager::metrics_util::CLICKED_DONE));
+ EXPECT_EQ(
+ 0,
+ samples->GetCount(password_manager::metrics_util::CLICKED_UNBLACKLIST));
}
-TEST_F(ManagePasswordsBubbleModelTest, WaitingToSavePassword) {
+TEST_F(ManagePasswordsBubbleModelTest, ClickUnblacklist) {
+ base::StatisticsDeltaReader statistics_delta_reader;
+ PretendBlacklisted();
+ model_->OnUnblacklistClicked();
+ model_->OnBubbleHidden();
+ EXPECT_EQ(model_->dismissal_reason(),
+ password_manager::metrics_util::CLICKED_UNBLACKLIST);
EXPECT_FALSE(model_->WaitingToSavePassword());
+ EXPECT_FALSE(model_->NeverSavingPasswords());
+ EXPECT_FALSE(controller()->saved_password());
+ EXPECT_FALSE(controller()->never_saved_password());
+ EXPECT_TRUE(controller()->unblacklisted_site());
+ scoped_ptr<base::HistogramSamples> samples(
+ statistics_delta_reader.GetHistogramSamplesSinceCreation(
+ kUIDismissalReasonMetric));
+ EXPECT_EQ(
+ 0,
+ samples->GetCount(password_manager::metrics_util::NO_DIRECT_INTERACTION));
+ EXPECT_EQ(0, samples->GetCount(password_manager::metrics_util::CLICKED_SAVE));
+ EXPECT_EQ(0, samples->GetCount(password_manager::metrics_util::CLICKED_NOPE));
+ EXPECT_EQ(0,
+ samples->GetCount(password_manager::metrics_util::CLICKED_NEVER));
+ EXPECT_EQ(0,
+ samples->GetCount(password_manager::metrics_util::CLICKED_MANAGE));
+ EXPECT_EQ(0, samples->GetCount(password_manager::metrics_util::CLICKED_DONE));
+ EXPECT_EQ(
+ 1,
+ samples->GetCount(password_manager::metrics_util::CLICKED_UNBLACKLIST));
+}
+
+TEST_F(ManagePasswordsBubbleModelTest, WaitingToSavePassword) {
+ EXPECT_FALSE(model_->WaitingToSavePassword());
model_->set_manage_passwords_bubble_state(
ManagePasswordsBubbleModel::PASSWORD_TO_BE_SAVED);
EXPECT_TRUE(model_->WaitingToSavePassword());
}
+
+TEST_F(ManagePasswordsBubbleModelTest, NeverSavingPasswords) {
+ EXPECT_FALSE(model_->NeverSavingPasswords());
+ model_->set_manage_passwords_bubble_state(
+ ManagePasswordsBubbleModel::NEVER_SAVE_PASSWORDS);
+ EXPECT_TRUE(model_->NeverSavingPasswords());
+}

Powered by Google App Engine
This is Rietveld 408576698