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

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: Fixups. 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..1147f49fb9ca62978484d093a9b5c444832e8530 100644
--- a/chrome/browser/ui/passwords/manage_passwords_bubble_model_unittest.cc
+++ b/chrome/browser/ui/passwords/manage_passwords_bubble_model_unittest.cc
@@ -4,6 +4,7 @@
#include "base/metrics/histogram_samples.h"
#include "base/prefs/pref_service.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/test/statistics_delta_reader.h"
#include "chrome/browser/ui/passwords/manage_passwords_bubble.h"
#include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
@@ -45,6 +46,18 @@ 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);
+
vabr (Chromium) 2014/04/30 11:08:46 nit: Please reduce to a single blank line. (http:/
+
+ base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
+ autofill::PasswordFormMap map;
+ map[kTestUsername] = &test_form_;
+ controller()->SetPasswordFormMap(map);
+ }
+
ManagePasswordsBubbleUIControllerMock* controller() {
return reinterpret_cast<ManagePasswordsBubbleUIControllerMock*>(
ManagePasswordsBubbleUIController::FromWebContents(
@@ -53,11 +66,13 @@ class ManagePasswordsBubbleModelTest : public testing::Test {
protected:
scoped_ptr<ManagePasswordsBubbleModel> model_;
+ autofill::PasswordForm test_form_;
private:
content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
scoped_ptr<content::WebContents> test_web_contents_;
+
vabr (Chromium) 2014/04/30 11:08:46 nit: Please remove this blank line.
};
TEST_F(ManagePasswordsBubbleModelTest, DefaultValues) {
@@ -90,6 +105,7 @@ 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());
@@ -106,6 +122,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,6 +134,8 @@ 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());
@@ -131,6 +152,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,6 +164,8 @@ 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());
@@ -156,6 +182,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,6 +194,8 @@ 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());
@@ -181,6 +212,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,6 +224,8 @@ 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());
@@ -206,6 +242,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 +254,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 +272,51 @@ 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());
+
+ 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