Commit e43e4863 authored by vabr's avatar vabr Committed by Commit bot

Separate deletion button in password settings

The "Delete this password" button gets a separate section. Before this CL it
shares the section with the password value (separate from username and site),
but the deletion affects the whole credential, so it should be separate.

Design doc: go/jgdrc, screenshots https://crbug.com/159166#c40

BUG=159166

Review-Url: https://codereview.chromium.org/2722783003
Cr-Commit-Position: refs/heads/master@{#468931}
parent b65a25e5
...@@ -35,6 +35,7 @@ typedef NS_ENUM(NSInteger, SectionIdentifier) { ...@@ -35,6 +35,7 @@ typedef NS_ENUM(NSInteger, SectionIdentifier) {
SectionIdentifierSite = kSectionIdentifierEnumZero, SectionIdentifierSite = kSectionIdentifierEnumZero,
SectionIdentifierUsername, SectionIdentifierUsername,
SectionIdentifierPassword, SectionIdentifierPassword,
SectionIdentifierDelete,
}; };
typedef NS_ENUM(NSInteger, ItemType) { typedef NS_ENUM(NSInteger, ItemType) {
...@@ -175,8 +176,10 @@ reauthenticationModule:(id<ReauthenticationProtocol>)reauthenticationModule ...@@ -175,8 +176,10 @@ reauthenticationModule:(id<ReauthenticationProtocol>)reauthenticationModule
toSectionWithIdentifier:SectionIdentifierPassword]; toSectionWithIdentifier:SectionIdentifierPassword];
[model addItem:[self passwordCopyButtonItem] [model addItem:[self passwordCopyButtonItem]
toSectionWithIdentifier:SectionIdentifierPassword]; toSectionWithIdentifier:SectionIdentifierPassword];
[model addSectionWithIdentifier:SectionIdentifierDelete];
[model addItem:[self deletePasswordButtonItem] [model addItem:[self deletePasswordButtonItem]
toSectionWithIdentifier:SectionIdentifierPassword]; toSectionWithIdentifier:SectionIdentifierDelete];
} }
- (void)dealloc { - (void)dealloc {
......
...@@ -82,7 +82,9 @@ const int kPasswordSection = 2; ...@@ -82,7 +82,9 @@ const int kPasswordSection = 2;
const int kPasswordItem = 0; const int kPasswordItem = 0;
const int kShowHideButtonItem = 1; const int kShowHideButtonItem = 1;
const int kCopyPasswordButtonItem = 2; const int kCopyPasswordButtonItem = 2;
const int kDeleteButtonItem = 3;
const int kDeleteSection = 3;
const int kDeleteButtonItem = 0;
class PasswordDetailsCollectionViewControllerTest class PasswordDetailsCollectionViewControllerTest
: public CollectionViewControllerTest { : public CollectionViewControllerTest {
...@@ -125,7 +127,7 @@ class PasswordDetailsCollectionViewControllerTest ...@@ -125,7 +127,7 @@ class PasswordDetailsCollectionViewControllerTest
TEST_F(PasswordDetailsCollectionViewControllerTest, TestInitialization) { TEST_F(PasswordDetailsCollectionViewControllerTest, TestInitialization) {
CreateController(); CreateController();
CheckController(); CheckController();
EXPECT_EQ(3, NumberOfSections()); EXPECT_EQ(4, NumberOfSections());
// Site section // Site section
EXPECT_EQ(2, NumberOfItemsInSection(kUsernameSection)); EXPECT_EQ(2, NumberOfItemsInSection(kUsernameSection));
CheckSectionHeaderWithId(IDS_IOS_SHOW_PASSWORD_VIEW_SITE, kSiteSection); CheckSectionHeaderWithId(IDS_IOS_SHOW_PASSWORD_VIEW_SITE, kSiteSection);
...@@ -146,7 +148,7 @@ TEST_F(PasswordDetailsCollectionViewControllerTest, TestInitialization) { ...@@ -146,7 +148,7 @@ TEST_F(PasswordDetailsCollectionViewControllerTest, TestInitialization) {
CheckTextCellTitleWithId(IDS_IOS_SETTINGS_USERNAME_COPY_BUTTON, CheckTextCellTitleWithId(IDS_IOS_SETTINGS_USERNAME_COPY_BUTTON,
kUsernameSection, kCopyUsernameButtonItem); kUsernameSection, kCopyUsernameButtonItem);
// Password section // Password section
EXPECT_EQ(4, NumberOfItemsInSection(kPasswordSection)); EXPECT_EQ(3, NumberOfItemsInSection(kPasswordSection));
CheckSectionHeaderWithId(IDS_IOS_SHOW_PASSWORD_VIEW_PASSWORD, CheckSectionHeaderWithId(IDS_IOS_SHOW_PASSWORD_VIEW_PASSWORD,
kPasswordSection); kPasswordSection);
PasswordDetailsItem* passwordItem = PasswordDetailsItem* passwordItem =
...@@ -157,8 +159,10 @@ TEST_F(PasswordDetailsCollectionViewControllerTest, TestInitialization) { ...@@ -157,8 +159,10 @@ TEST_F(PasswordDetailsCollectionViewControllerTest, TestInitialization) {
kPasswordSection, kShowHideButtonItem); kPasswordSection, kShowHideButtonItem);
CheckTextCellTitleWithId(IDS_IOS_SETTINGS_PASSWORD_COPY_BUTTON, CheckTextCellTitleWithId(IDS_IOS_SETTINGS_PASSWORD_COPY_BUTTON,
kPasswordSection, kCopyPasswordButtonItem); kPasswordSection, kCopyPasswordButtonItem);
// Delete section
EXPECT_EQ(1, NumberOfItemsInSection(kDeleteSection));
CheckTextCellTitleWithId(IDS_IOS_SETTINGS_PASSWORD_DELETE_BUTTON, CheckTextCellTitleWithId(IDS_IOS_SETTINGS_PASSWORD_DELETE_BUTTON,
kPasswordSection, kDeleteButtonItem); kDeleteSection, kDeleteButtonItem);
} }
struct SimplifyOriginTestData { struct SimplifyOriginTestData {
...@@ -251,7 +255,7 @@ TEST_F(PasswordDetailsCollectionViewControllerTest, DeletePassword) { ...@@ -251,7 +255,7 @@ TEST_F(PasswordDetailsCollectionViewControllerTest, DeletePassword) {
CreateController(); CreateController();
[controller() collectionView:[controller() collectionView] [controller() collectionView:[controller() collectionView]
didSelectItemAtIndexPath:[NSIndexPath indexPathForRow:kDeleteButtonItem didSelectItemAtIndexPath:[NSIndexPath indexPathForRow:kDeleteButtonItem
inSection:kPasswordSection]]; inSection:kDeleteSection]];
EXPECT_EQ(1, delegate_.numberOfCallsToDeletePassword); EXPECT_EQ(1, delegate_.numberOfCallsToDeletePassword);
} }
......
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