Commit 1ed4cc1e authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Passwords] ReEnable PasswordSaveUpdateWithAccountStoreView unit test

After recent fixes to the underlying blocking bug crbug.com/968222,
it's worth giving those test another shot.

Bug: 1044038,1054629
Change-Id: Idd2317c028c1cc7bb2ebee0e312c19456be57482
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2249981Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779763}
parent e90cf11a
...@@ -9,13 +9,16 @@ ...@@ -9,13 +9,16 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "chrome/browser/password_manager/password_store_factory.h" #include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/views/passwords/password_bubble_view_test_base.h" #include "chrome/browser/ui/views/passwords/password_bubble_view_test_base.h"
#include "chrome/grit/generated_resources.h"
#include "components/password_manager/core/browser/mock_password_feature_manager.h" #include "components/password_manager/core/browser/mock_password_feature_manager.h"
#include "components/password_manager/core/browser/mock_password_store.h" #include "components/password_manager/core/browser/mock_password_store.h"
#include "components/password_manager/core/browser/password_manager_test_utils.h" #include "components/password_manager/core/browser/password_manager_test_utils.h"
#include "content/public/test/navigation_simulator.h" #include "content/public/test/navigation_simulator.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/combobox/combobox.h" #include "ui/views/controls/combobox/combobox.h"
using ::testing::Return; using ::testing::Return;
...@@ -28,6 +31,7 @@ class PasswordSaveUpdateWithAccountStoreViewTest ...@@ -28,6 +31,7 @@ class PasswordSaveUpdateWithAccountStoreViewTest
~PasswordSaveUpdateWithAccountStoreViewTest() override = default; ~PasswordSaveUpdateWithAccountStoreViewTest() override = default;
void CreateViewAndShow(); void CreateViewAndShow();
void SimulateSignIn();
void TearDown() override { void TearDown() override {
view_->GetWidget()->CloseWithReason( view_->GetWidget()->CloseWithReason(
...@@ -78,6 +82,13 @@ void PasswordSaveUpdateWithAccountStoreViewTest::CreateViewAndShow() { ...@@ -78,6 +82,13 @@ void PasswordSaveUpdateWithAccountStoreViewTest::CreateViewAndShow() {
views::BubbleDialogDelegateView::CreateBubble(view_)->Show(); views::BubbleDialogDelegateView::CreateBubble(view_)->Show();
} }
void PasswordSaveUpdateWithAccountStoreViewTest::SimulateSignIn() {
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile());
AccountInfo info =
signin::MakePrimaryAccountAvailable(identity_manager, "test@email.com");
}
TEST_F(PasswordSaveUpdateWithAccountStoreViewTest, HasTitleAndTwoButtons) { TEST_F(PasswordSaveUpdateWithAccountStoreViewTest, HasTitleAndTwoButtons) {
CreateViewAndShow(); CreateViewAndShow();
EXPECT_TRUE(view()->ShouldShowWindowTitle()); EXPECT_TRUE(view()->ShouldShowWindowTitle());
...@@ -85,58 +96,54 @@ TEST_F(PasswordSaveUpdateWithAccountStoreViewTest, HasTitleAndTwoButtons) { ...@@ -85,58 +96,54 @@ TEST_F(PasswordSaveUpdateWithAccountStoreViewTest, HasTitleAndTwoButtons) {
EXPECT_TRUE(view()->GetCancelButton()); EXPECT_TRUE(view()->GetCancelButton());
} }
// TODO(crbug.com/1054629): Flakily times out on all platforms. TEST_F(PasswordSaveUpdateWithAccountStoreViewTest, ShouldNotShowAccountPicker) {
TEST_F(PasswordSaveUpdateWithAccountStoreViewTest,
DISABLED_ShouldNotShowAccountPicker) {
ON_CALL(*feature_manager_mock(), ShouldShowPasswordStorePicker) ON_CALL(*feature_manager_mock(), ShouldShowPasswordStorePicker)
.WillByDefault(Return(false)); .WillByDefault(Return(false));
CreateViewAndShow(); CreateViewAndShow();
EXPECT_FALSE(account_picker()); EXPECT_FALSE(account_picker());
} }
// TODO(crbug.com/1054629): Flakily times out on all platforms. TEST_F(PasswordSaveUpdateWithAccountStoreViewTest, ShouldShowAccountPicker) {
TEST_F(PasswordSaveUpdateWithAccountStoreViewTest,
DISABLED_ShouldShowAccountPicker) {
ON_CALL(*feature_manager_mock(), ShouldShowPasswordStorePicker) ON_CALL(*feature_manager_mock(), ShouldShowPasswordStorePicker)
.WillByDefault(Return(true)); .WillByDefault(Return(true));
SimulateSignIn();
CreateViewAndShow(); CreateViewAndShow();
ASSERT_TRUE(account_picker()); ASSERT_TRUE(account_picker());
EXPECT_EQ(0, account_picker()->GetSelectedIndex()); EXPECT_EQ(0, account_picker()->GetSelectedIndex());
} }
// TODO(crbug.com/1054629): Flakily times out on all platforms.
TEST_F(PasswordSaveUpdateWithAccountStoreViewTest, TEST_F(PasswordSaveUpdateWithAccountStoreViewTest,
DISABLED_ShouldSelectAccountStoreByDefault) { ShouldSelectAccountStoreByDefault) {
ON_CALL(*feature_manager_mock(), ShouldShowPasswordStorePicker) ON_CALL(*feature_manager_mock(), ShouldShowPasswordStorePicker)
.WillByDefault(Return(true)); .WillByDefault(Return(true));
ON_CALL(*feature_manager_mock(), GetDefaultPasswordStore) ON_CALL(*feature_manager_mock(), GetDefaultPasswordStore)
.WillByDefault(Return(autofill::PasswordForm::Store::kAccountStore)); .WillByDefault(Return(autofill::PasswordForm::Store::kAccountStore));
CoreAccountInfo account_info = SimulateSignIn();
identity_test_env()->SetUnconsentedPrimaryAccount("test@email.com");
CreateViewAndShow(); CreateViewAndShow();
ASSERT_TRUE(account_picker()); ASSERT_TRUE(account_picker());
EXPECT_EQ(0, account_picker()->GetSelectedIndex()); EXPECT_EQ(0, account_picker()->GetSelectedIndex());
EXPECT_EQ( EXPECT_EQ(
base::ASCIIToUTF16(account_info.email), l10n_util::GetStringUTF16(
IDS_PASSWORD_MANAGER_DESTINATION_DROPDOWN_SAVE_TO_ACCOUNT),
account_picker()->GetTextForRow(account_picker()->GetSelectedIndex())); account_picker()->GetTextForRow(account_picker()->GetSelectedIndex()));
} }
// TODO(crbug.com/1054629): Flakily times out on all platforms.
TEST_F(PasswordSaveUpdateWithAccountStoreViewTest, TEST_F(PasswordSaveUpdateWithAccountStoreViewTest,
DISABLED_ShouldSelectProfileStoreByDefault) { ShouldSelectProfileStoreByDefault) {
ON_CALL(*feature_manager_mock(), ShouldShowPasswordStorePicker) ON_CALL(*feature_manager_mock(), ShouldShowPasswordStorePicker)
.WillByDefault(Return(true)); .WillByDefault(Return(true));
ON_CALL(*feature_manager_mock(), GetDefaultPasswordStore) ON_CALL(*feature_manager_mock(), GetDefaultPasswordStore)
.WillByDefault(Return(autofill::PasswordForm::Store::kProfileStore)); .WillByDefault(Return(autofill::PasswordForm::Store::kProfileStore));
SimulateSignIn();
CreateViewAndShow(); CreateViewAndShow();
ASSERT_TRUE(account_picker()); ASSERT_TRUE(account_picker());
EXPECT_EQ(1, account_picker()->GetSelectedIndex()); EXPECT_EQ(1, account_picker()->GetSelectedIndex());
// TODO(crbug.com/1044038): Use an internationalized string instead.
EXPECT_EQ( EXPECT_EQ(
base::ASCIIToUTF16("Local"), l10n_util::GetStringUTF16(
IDS_PASSWORD_MANAGER_DESTINATION_DROPDOWN_SAVE_TO_DEVICE),
account_picker()->GetTextForRow(account_picker()->GetSelectedIndex())); account_picker()->GetTextForRow(account_picker()->GetSelectedIndex()));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment