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..675d2c475ba2b38183e355959aab713a03a00828 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,17 @@ 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); |
+ |
+ 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,6 +65,7 @@ class ManagePasswordsBubbleModelTest : public testing::Test { |
protected: |
scoped_ptr<ManagePasswordsBubbleModel> model_; |
+ autofill::PasswordForm test_form_; |
private: |
content::TestBrowserThreadBundle thread_bundle_; |
@@ -90,6 +103,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 +120,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 +132,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 +150,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 +162,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 +180,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 +192,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 +210,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 +222,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 +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,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()); |
+} |