Commit f7768058 authored by harrisonsean's avatar harrisonsean Committed by Commit Bot

Safety Check iOS: Modify settings_password_check_cell for safety check

The custom cell for password check is similar to the one needed for
safety check.  It is being renamed to settings_check_cell for more
general use.

The main difference is the whether or not an image is used on the
leading side of the cell. This CL adds an optional image to the leading
side of the cell for compatibility with both checks.

Bug: 1078782
Change-Id: I825bdcb53f624ce2e567a68dc900bddc310dc270
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2273162
Commit-Queue: Sean Harrison <harrisonsean@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#785836}
parent a7d2baf4
...@@ -14,16 +14,16 @@ source_set("cells") { ...@@ -14,16 +14,16 @@ source_set("cells") {
"passphrase_error_item.mm", "passphrase_error_item.mm",
"search_engine_item.h", "search_engine_item.h",
"search_engine_item.mm", "search_engine_item.mm",
"settings_check_cell.h",
"settings_check_cell.mm",
"settings_check_item.h",
"settings_check_item.mm",
"settings_image_detail_text_cell.h", "settings_image_detail_text_cell.h",
"settings_image_detail_text_cell.mm", "settings_image_detail_text_cell.mm",
"settings_image_detail_text_item.h", "settings_image_detail_text_item.h",
"settings_image_detail_text_item.mm", "settings_image_detail_text_item.mm",
"settings_multiline_detail_item.h", "settings_multiline_detail_item.h",
"settings_multiline_detail_item.mm", "settings_multiline_detail_item.mm",
"settings_password_check_cell.h",
"settings_password_check_cell.mm",
"settings_password_check_item.h",
"settings_password_check_item.mm",
"settings_switch_cell.h", "settings_switch_cell.h",
"settings_switch_cell.mm", "settings_switch_cell.mm",
"settings_switch_item.h", "settings_switch_item.h",
...@@ -85,8 +85,8 @@ source_set("unit_tests") { ...@@ -85,8 +85,8 @@ source_set("unit_tests") {
"copied_to_chrome_item_unittest.mm", "copied_to_chrome_item_unittest.mm",
"passphrase_error_item_unittest.mm", "passphrase_error_item_unittest.mm",
"search_engine_item_unittest.mm", "search_engine_item_unittest.mm",
"settings_check_item_unittest.mm",
"settings_multiline_detail_item_unittest.mm", "settings_multiline_detail_item_unittest.mm",
"settings_password_check_item_unittest.mm",
"version_item_unittest.mm", "version_item_unittest.mm",
] ]
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_CHECK_CELL_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_CHECK_CELL_H_
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/table_view/cells/table_view_cell.h"
// Cell representation for SettingsCheckItem.
// +---------------------------------------------------------+
// | +--------+ |
// | +--------+ |trailing| |
// | | leading| One line title |image or| |
// | | image | Multiline detail text |spinner | |
// | +--------+ +--------+ |
// +---------------------------------------------------------+
@interface SettingsCheckCell : TableViewCell
// Shows |activityIndicator| and starts animation. It will hide |imageView| if
// it was shown.
- (void)showActivityIndicator;
// Hides |activityIndicator| and stops animation.
- (void)hideActivityIndicator;
// Sets the |trailingImage| and tint |trailingColor| for it that should be
// displayed at the trailing edge of the cell. If set to nil, |trailingImage|
// will be hidden, otherwise |imageView| will be shown and |activityIndicator|
// will be hidden.
- (void)setTrailingImage:(UIImage*)trailingImage
withTintColor:(UIColor*)tintColor;
// Sets the [leadingImage] and tint [leadingColor] for it that should be
// displayed at the leading edge of the cell. If set to nil, the image is
// hidden.
- (void)setLeadingImage:(UIImage*)leadingImage
withTintColor:(UIColor*)tintColor;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_CHECK_CELL_H_
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_PASSWORD_CHECK_ITEM_H_ #ifndef IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_CHECK_ITEM_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_PASSWORD_CHECK_ITEM_H_ #define IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_CHECK_ITEM_H_
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/table_view/cells/table_view_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_item.h"
// SettingsSwitchItem is a model class that uses SettingsSwitchCell. // SettingsSwitchItem is a model class that uses SettingsSwitchCell.
@interface SettingsPasswordCheckItem : TableViewItem @interface SettingsCheckItem : TableViewItem
// The text to display. // The text to display.
@property(nonatomic, copy) NSString* text; @property(nonatomic, copy) NSString* text;
...@@ -18,14 +18,23 @@ ...@@ -18,14 +18,23 @@
// The detail text string. // The detail text string.
@property(nonatomic, copy) NSString* detailText; @property(nonatomic, copy) NSString* detailText;
// The image to display (required). If this image should be tinted to match the // The image to display on the leading side of |text| (optional). If this image
// text color (e.g. in dark mode), the provided image should have rendering mode // should be tinted to match the text color (e.g. in dark mode), the provided
// UIImageRenderingModeAlwaysTemplate. Don't set image with |isIndicatorHidden| // image should have rendering mode UIImageRenderingModeAlwaysTemplate.
// as only either image or |activityIndicator| will be shown. @property(nonatomic, strong) UIImage* leadingImage;
@property(nonatomic, strong) UIImage* image;
// Tint color for an image. // Tint color for |leadingImage|.
@property(nonatomic, copy) UIColor* tintColor; @property(nonatomic, copy) UIColor* leadingImageTintColor;
// The image to display on the trailing side of |text| (required). If this image
// should be tinted to match the text color (e.g. in dark mode), the provided
// image should have rendering mode UIImageRenderingModeAlwaysTemplate. Don't
// set image with |isIndicatorHidden| as only either image or
// |activityIndicator| will be shown.
@property(nonatomic, strong) UIImage* trailingImage;
// Tint color for |trailingImage|.
@property(nonatomic, copy) UIColor* trailingImageTintColor;
// Controls visibility of |activityIndicator|, if set true |imageView| will be // Controls visibility of |activityIndicator|, if set true |imageView| will be
// hidden and activity indicator will be shown. In case both image is provided // hidden and activity indicator will be shown. In case both image is provided
...@@ -33,9 +42,9 @@ ...@@ -33,9 +42,9 @@
@property(nonatomic, assign, getter=isIndicatorHidden) BOOL indicatorHidden; @property(nonatomic, assign, getter=isIndicatorHidden) BOOL indicatorHidden;
// Disabled cell are automatically drawn with dimmed text and without // Disabled cell are automatically drawn with dimmed text and without
// |imageView| or |activityIndicator|. // |trailingImage| or |activityIndicator|.
@property(nonatomic, assign, getter=isEnabled) BOOL enabled; @property(nonatomic, assign, getter=isEnabled) BOOL enabled;
@end @end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_PASSWORD_CHECK_ITEM_H_ #endif // IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_CHECK_ITEM_H_
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/cells/settings_password_check_item.h" #import "ios/chrome/browser/ui/settings/cells/settings_check_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_password_check_cell.h" #import "ios/chrome/browser/ui/settings/cells/settings_check_cell.h"
#import "ios/chrome/common/ui/colors/UIColor+cr_semantic_colors.h" #import "ios/chrome/common/ui/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h"
...@@ -12,32 +12,37 @@ ...@@ -12,32 +12,37 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
@implementation SettingsPasswordCheckItem @implementation SettingsCheckItem
- (instancetype)initWithType:(NSInteger)type { - (instancetype)initWithType:(NSInteger)type {
self = [super initWithType:type]; self = [super initWithType:type];
if (self) { if (self) {
self.cellClass = [SettingsPasswordCheckCell class]; self.cellClass = [SettingsCheckCell class];
} }
return self; return self;
} }
#pragma mark TableViewItem #pragma mark TableViewItem
- (void)configureCell:(SettingsPasswordCheckCell*)cell - (void)configureCell:(SettingsCheckCell*)cell
withStyler:(ChromeTableViewStyler*)styler { withStyler:(ChromeTableViewStyler*)styler {
[super configureCell:cell withStyler:styler]; [super configureCell:cell withStyler:styler];
cell.textLabel.text = self.text; cell.textLabel.text = self.text;
cell.detailTextLabel.text = self.detailText; cell.detailTextLabel.text = self.detailText;
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (self.enabled) { if (self.enabled) {
[cell setIconImage:self.image withTintColor:self.tintColor]; [cell setLeadingImage:self.leadingImage
withTintColor:self.leadingImageTintColor];
[cell setTrailingImage:self.trailingImage
withTintColor:self.trailingImageTintColor];
self.indicatorHidden ? [cell hideActivityIndicator] self.indicatorHidden ? [cell hideActivityIndicator]
: [cell showActivityIndicator]; : [cell showActivityIndicator];
cell.textLabel.textColor = UIColor.cr_labelColor; cell.textLabel.textColor = UIColor.cr_labelColor;
cell.accessibilityTraits &= ~UIAccessibilityTraitNotEnabled; cell.accessibilityTraits &= ~UIAccessibilityTraitNotEnabled;
} else { } else {
[cell setIconImage:nil withTintColor:nil]; [cell setLeadingImage:self.leadingImage
withTintColor:UIColor.cr_secondaryLabelColor];
[cell setTrailingImage:nil withTintColor:nil];
[cell hideActivityIndicator]; [cell hideActivityIndicator];
cell.textLabel.textColor = UIColor.cr_secondaryLabelColor; cell.textLabel.textColor = UIColor.cr_secondaryLabelColor;
cell.accessibilityTraits |= UIAccessibilityTraitNotEnabled; cell.accessibilityTraits |= UIAccessibilityTraitNotEnabled;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/cells/settings_password_check_item.h" #import "ios/chrome/browser/ui/settings/cells/settings_check_item.h"
#import "base/mac/foundation_util.h" #import "base/mac/foundation_util.h"
#import "ios/chrome/browser/ui/settings/cells/settings_password_check_cell.h" #import "ios/chrome/browser/ui/settings/cells/settings_check_cell.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h" #import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h" #import "testing/gtest_mac.h"
...@@ -17,13 +17,12 @@ ...@@ -17,13 +17,12 @@
namespace { namespace {
using SettingsPasswordCheckItemTest = PlatformTest; using SettingsCheckItemTest = PlatformTest;
// Tests that the text and detail text are honoured after a call to // Tests that the text and detail text are honoured after a call to
// |configureCell:|. // |configureCell:|.
TEST_F(SettingsPasswordCheckItemTest, ConfigureCell) { TEST_F(SettingsCheckItemTest, ConfigureCell) {
SettingsPasswordCheckItem* item = SettingsCheckItem* item = [[SettingsCheckItem alloc] initWithType:0];
[[SettingsPasswordCheckItem alloc] initWithType:0];
NSString* text = @"Test Text"; NSString* text = @"Test Text";
NSString* detailText = @"Test Detail Text that can span multiple lines. For " NSString* detailText = @"Test Detail Text that can span multiple lines. For "
@"example, this line probably fits on three or four " @"example, this line probably fits on three or four "
...@@ -33,16 +32,16 @@ TEST_F(SettingsPasswordCheckItemTest, ConfigureCell) { ...@@ -33,16 +32,16 @@ TEST_F(SettingsPasswordCheckItemTest, ConfigureCell) {
item.detailText = detailText; item.detailText = detailText;
id cell = [[[item cellClass] alloc] init]; id cell = [[[item cellClass] alloc] init];
ASSERT_TRUE([cell isMemberOfClass:[SettingsPasswordCheckCell class]]); ASSERT_TRUE([cell isMemberOfClass:[SettingsCheckCell class]]);
SettingsPasswordCheckCell* passwordCheckCell = SettingsCheckCell* CheckCell =
base::mac::ObjCCastStrict<SettingsPasswordCheckCell>(cell); base::mac::ObjCCastStrict<SettingsCheckCell>(cell);
EXPECT_FALSE(passwordCheckCell.textLabel.text); EXPECT_FALSE(CheckCell.textLabel.text);
EXPECT_FALSE(passwordCheckCell.detailTextLabel.text); EXPECT_FALSE(CheckCell.detailTextLabel.text);
[item configureCell:cell withStyler:[[ChromeTableViewStyler alloc] init]]; [item configureCell:cell withStyler:[[ChromeTableViewStyler alloc] init]];
EXPECT_NSEQ(text, passwordCheckCell.textLabel.text); EXPECT_NSEQ(text, CheckCell.textLabel.text);
EXPECT_NSEQ(detailText, passwordCheckCell.detailTextLabel.text); EXPECT_NSEQ(detailText, CheckCell.detailTextLabel.text);
} }
} // namespace } // namespace
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_PASSWORD_CHECK_CELL_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_PASSWORD_CHECK_CELL_H_
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/table_view/cells/table_view_cell.h"
// Cell representation for SettingsPasswordCheckItem.
// +----------------------------------------------+
// | +-------+ |
// | One line title |icon or| |
// | Multiline detail text |spinner| |
// | +-------+ |
// +----------------------------------------------+
@interface SettingsPasswordCheckCell : TableViewCell
// Shows |activityIndicator| and starts animation. It will hide |imageView| if
// it was shown.
- (void)showActivityIndicator;
// Hides |activityIndicator| and stops animation.
- (void)hideActivityIndicator;
// Sets the icon |image| and tint |color| for it that should be displayed at the
// trailing edge of the cell. If set to nil, the icon will be hidden, otherwise
// |imageView| will be shown and |activityIndicator| will be hidden.
- (void)setIconImage:(UIImage*)image withTintColor:(UIColor*)color;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SETTINGS_PASSWORD_CHECK_CELL_H_
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
#import "ios/chrome/browser/signin/chrome_identity_service_observer_bridge.h" #import "ios/chrome/browser/signin/chrome_identity_service_observer_bridge.h"
#include "ios/chrome/browser/system_flags.h" #include "ios/chrome/browser/system_flags.h"
#import "ios/chrome/browser/ui/settings/cells/settings_cells_constants.h" #import "ios/chrome/browser/ui/settings/cells/settings_cells_constants.h"
#import "ios/chrome/browser/ui/settings/cells/settings_password_check_cell.h" #import "ios/chrome/browser/ui/settings/cells/settings_check_cell.h"
#import "ios/chrome/browser/ui/settings/cells/settings_password_check_item.h" #import "ios/chrome/browser/ui/settings/cells/settings_check_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_switch_cell.h" #import "ios/chrome/browser/ui/settings/cells/settings_switch_cell.h"
#import "ios/chrome/browser/ui/settings/cells/settings_switch_item.h" #import "ios/chrome/browser/ui/settings/cells/settings_switch_item.h"
#import "ios/chrome/browser/ui/settings/elements/enterprise_info_popover_view_controller.h" #import "ios/chrome/browser/ui/settings/elements/enterprise_info_popover_view_controller.h"
...@@ -190,7 +190,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -190,7 +190,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
// The item related to the enterprise managed save password setting. // The item related to the enterprise managed save password setting.
TableViewInfoButtonItem* _managedSavePasswordItem; TableViewInfoButtonItem* _managedSavePasswordItem;
// The item related to the password check status. // The item related to the password check status.
SettingsPasswordCheckItem* _passwordProblemsItem; SettingsCheckItem* _passwordProblemsItem;
// The button to start password check. // The button to start password check.
TableViewTextItem* _checkForProblemsItem; TableViewTextItem* _checkForProblemsItem;
// The item related to the button for exporting passwords. // The item related to the button for exporting passwords.
...@@ -521,10 +521,9 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -521,10 +521,9 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
return managedSavePasswordItem; return managedSavePasswordItem;
} }
- (SettingsPasswordCheckItem*)passwordProblemsItem { - (SettingsCheckItem*)passwordProblemsItem {
SettingsPasswordCheckItem* passwordProblemsItem = SettingsCheckItem* passwordProblemsItem =
[[SettingsPasswordCheckItem alloc] [[SettingsCheckItem alloc] initWithType:ItemTypePasswordCheckStatus];
initWithType:ItemTypePasswordCheckStatus];
passwordProblemsItem.enabled = NO; passwordProblemsItem.enabled = NO;
passwordProblemsItem.text = l10n_util::GetNSString(IDS_IOS_CHECK_PASSWORDS); passwordProblemsItem.text = l10n_util::GetNSString(IDS_IOS_CHECK_PASSWORDS);
passwordProblemsItem.detailText = passwordProblemsItem.detailText =
...@@ -914,7 +913,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -914,7 +913,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
if (!_passwordProblemsItem) if (!_passwordProblemsItem)
return; return;
_passwordProblemsItem.image = nil; _passwordProblemsItem.trailingImage = nil;
_passwordProblemsItem.enabled = YES; _passwordProblemsItem.enabled = YES;
_passwordProblemsItem.indicatorHidden = YES; _passwordProblemsItem.indicatorHidden = YES;
_passwordProblemsItem.accessoryType = UITableViewCellAccessoryNone; _passwordProblemsItem.accessoryType = UITableViewCellAccessoryNone;
...@@ -923,7 +922,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -923,7 +922,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
switch (state) { switch (state) {
case PasswordCheckStateRunning: { case PasswordCheckStateRunning: {
_passwordProblemsItem.image = nil; _passwordProblemsItem.trailingImage = nil;
_passwordProblemsItem.indicatorHidden = NO; _passwordProblemsItem.indicatorHidden = NO;
break; break;
} }
...@@ -936,8 +935,9 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -936,8 +935,9 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
l10n_util::GetNSString(IDS_IOS_CHECK_PASSWORDS_UNSAFE_STATE); l10n_util::GetNSString(IDS_IOS_CHECK_PASSWORDS_UNSAFE_STATE);
UIImage* unSafeIconImage = [[UIImage imageNamed:@"settings_unsafe_state"] UIImage* unSafeIconImage = [[UIImage imageNamed:@"settings_unsafe_state"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
_passwordProblemsItem.image = unSafeIconImage; _passwordProblemsItem.trailingImage = unSafeIconImage;
_passwordProblemsItem.tintColor = [UIColor colorNamed:kRedColor]; _passwordProblemsItem.trailingImageTintColor =
[UIColor colorNamed:kRedColor];
_passwordProblemsItem.accessoryType = _passwordProblemsItem.accessoryType =
UITableViewCellAccessoryDisclosureIndicator; UITableViewCellAccessoryDisclosureIndicator;
break; break;
...@@ -947,8 +947,9 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -947,8 +947,9 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
_passwordProblemsItem.detailText = _passwordProblemsItem.detailText =
l10n_util::GetNSString(IDS_IOS_CHECK_PASSWORDS_SAFE_STATE); l10n_util::GetNSString(IDS_IOS_CHECK_PASSWORDS_SAFE_STATE);
_passwordProblemsItem.image = safeIconImage; _passwordProblemsItem.trailingImage = safeIconImage;
_passwordProblemsItem.tintColor = [UIColor colorNamed:kGreenColor]; _passwordProblemsItem.trailingImageTintColor =
[UIColor colorNamed:kGreenColor];
break; break;
} }
case PasswordCheckStateDefault: { case PasswordCheckStateDefault: {
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h" #include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h"
#include "ios/chrome/browser/passwords/password_check_observer_bridge.h" #include "ios/chrome/browser/passwords/password_check_observer_bridge.h"
#include "ios/chrome/browser/passwords/save_passwords_consumer.h" #include "ios/chrome/browser/passwords/save_passwords_consumer.h"
#import "ios/chrome/browser/ui/settings/cells/settings_password_check_item.h" #import "ios/chrome/browser/ui/settings/cells/settings_check_item.h"
#import "ios/chrome/browser/ui/settings/password/password_details_table_view_controller.h" #import "ios/chrome/browser/ui/settings/password/password_details_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/password/passwords_consumer.h" #import "ios/chrome/browser/ui/settings/password/passwords_consumer.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
...@@ -545,11 +545,11 @@ TEST_P(PasswordsTableViewControllerTest, PasswordCheckStateDisabled) { ...@@ -545,11 +545,11 @@ TEST_P(PasswordsTableViewControllerTest, PasswordCheckStateDisabled) {
CheckDetailItemTextWithIds(IDS_IOS_CHECK_PASSWORDS, CheckDetailItemTextWithIds(IDS_IOS_CHECK_PASSWORDS,
IDS_IOS_CHECK_PASSWORDS_DESCRIPTION, IDS_IOS_CHECK_PASSWORDS_DESCRIPTION,
GetSectionIndex(PasswordCheck), 0); GetSectionIndex(PasswordCheck), 0);
SettingsPasswordCheckItem* checkPassword = SettingsCheckItem* checkPassword =
GetTableViewItem(GetSectionIndex(PasswordCheck), 0); GetTableViewItem(GetSectionIndex(PasswordCheck), 0);
EXPECT_FALSE(checkPassword.enabled); EXPECT_FALSE(checkPassword.enabled);
EXPECT_TRUE(checkPassword.indicatorHidden); EXPECT_TRUE(checkPassword.indicatorHidden);
EXPECT_FALSE(checkPassword.image); EXPECT_FALSE(checkPassword.trailingImage);
} }
// Test verifies default state of password check cell. // Test verifies default state of password check cell.
...@@ -564,11 +564,11 @@ TEST_P(PasswordsTableViewControllerTest, PasswordCheckStateDefault) { ...@@ -564,11 +564,11 @@ TEST_P(PasswordsTableViewControllerTest, PasswordCheckStateDefault) {
CheckDetailItemTextWithIds(IDS_IOS_CHECK_PASSWORDS, CheckDetailItemTextWithIds(IDS_IOS_CHECK_PASSWORDS,
IDS_IOS_CHECK_PASSWORDS_DESCRIPTION, IDS_IOS_CHECK_PASSWORDS_DESCRIPTION,
GetSectionIndex(PasswordCheck), 0); GetSectionIndex(PasswordCheck), 0);
SettingsPasswordCheckItem* checkPassword = SettingsCheckItem* checkPassword =
GetTableViewItem(GetSectionIndex(PasswordCheck), 0); GetTableViewItem(GetSectionIndex(PasswordCheck), 0);
EXPECT_TRUE(checkPassword.enabled); EXPECT_TRUE(checkPassword.enabled);
EXPECT_TRUE(checkPassword.indicatorHidden); EXPECT_TRUE(checkPassword.indicatorHidden);
EXPECT_FALSE(checkPassword.image); EXPECT_FALSE(checkPassword.trailingImage);
} }
// Test verifies running state of password check cell. // Test verifies running state of password check cell.
...@@ -583,11 +583,11 @@ TEST_P(PasswordsTableViewControllerTest, PasswordCheckStateRunning) { ...@@ -583,11 +583,11 @@ TEST_P(PasswordsTableViewControllerTest, PasswordCheckStateRunning) {
CheckDetailItemTextWithIds(IDS_IOS_CHECK_PASSWORDS, CheckDetailItemTextWithIds(IDS_IOS_CHECK_PASSWORDS,
IDS_IOS_CHECK_PASSWORDS_DESCRIPTION, IDS_IOS_CHECK_PASSWORDS_DESCRIPTION,
GetSectionIndex(PasswordCheck), 0); GetSectionIndex(PasswordCheck), 0);
SettingsPasswordCheckItem* checkPassword = SettingsCheckItem* checkPassword =
GetTableViewItem(GetSectionIndex(PasswordCheck), 0); GetTableViewItem(GetSectionIndex(PasswordCheck), 0);
EXPECT_TRUE(checkPassword.enabled); EXPECT_TRUE(checkPassword.enabled);
EXPECT_FALSE(checkPassword.indicatorHidden); EXPECT_FALSE(checkPassword.indicatorHidden);
EXPECT_FALSE(checkPassword.image); EXPECT_FALSE(checkPassword.trailingImage);
} }
// Test verifies tapping start with no saved passwords has no effect. // Test verifies tapping start with no saved passwords has no effect.
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#import "ios/chrome/browser/ui/icons/chrome_icon.h" #import "ios/chrome/browser/ui/icons/chrome_icon.h"
#import "ios/chrome/browser/ui/settings/cells/account_sign_in_item.h" #import "ios/chrome/browser/ui/settings/cells/account_sign_in_item.h"
#import "ios/chrome/browser/ui/settings/cells/copied_to_chrome_item.h" #import "ios/chrome/browser/ui/settings/cells/copied_to_chrome_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_check_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_image_detail_text_item.h" #import "ios/chrome/browser/ui/settings/cells/settings_image_detail_text_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_password_check_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_switch_item.h" #import "ios/chrome/browser/ui/settings/cells/settings_switch_item.h"
#import "ios/chrome/browser/ui/settings/cells/sync_switch_item.h" #import "ios/chrome/browser/ui/settings/cells/sync_switch_item.h"
#import "ios/chrome/browser/ui/settings/elements/enterprise_info_popover_view_controller.h" #import "ios/chrome/browser/ui/settings/elements/enterprise_info_popover_view_controller.h"
...@@ -79,9 +79,11 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -79,9 +79,11 @@ typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeSettingsSyncError, ItemTypeSettingsSyncError,
ItemTypeAutofillData, ItemTypeAutofillData,
ItemTypeAccount, ItemTypeAccount,
ItemTypePasswordCheck1, ItemTypeCheck1,
ItemTypePasswordCheck2, ItemTypeCheck2,
ItemTypePasswordCheck3, ItemTypeCheck3,
ItemTypeCheck4,
ItemTypeCheck5,
}; };
} }
...@@ -391,38 +393,65 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -391,38 +393,65 @@ typedef NS_ENUM(NSInteger, ItemType) {
[model addItem:imageDetailTextItem [model addItem:imageDetailTextItem
toSectionWithIdentifier:SectionIdentifierSettings]; toSectionWithIdentifier:SectionIdentifierSettings];
SettingsPasswordCheckItem* checkPasswordsInProcess = SettingsCheckItem* checkInProcess =
[[SettingsPasswordCheckItem alloc] initWithType:ItemTypePasswordCheck1]; [[SettingsCheckItem alloc] initWithType:ItemTypeCheck1];
checkPasswordsInProcess.text = @"This is running password check item"; checkInProcess.text = @"This is running check item";
checkPasswordsInProcess.detailText = checkInProcess.detailText =
@"This is very long description of password check item. Another line of " @"This is very long description of check item. Another line of "
@"description."; @"description.";
checkPasswordsInProcess.enabled = YES; checkInProcess.enabled = YES;
checkPasswordsInProcess.indicatorHidden = NO; checkInProcess.indicatorHidden = NO;
[model addItem:checkPasswordsInProcess [model addItem:checkInProcess
toSectionWithIdentifier:SectionIdentifierSettings]; toSectionWithIdentifier:SectionIdentifierSettings];
SettingsPasswordCheckItem* checkPasswordsFinished = SettingsCheckItem* checkFinished =
[[SettingsPasswordCheckItem alloc] initWithType:ItemTypePasswordCheck2]; [[SettingsCheckItem alloc] initWithType:ItemTypeCheck2];
checkPasswordsFinished.text = @"This is finished password check item"; checkFinished.text = @"This is finished check item";
checkPasswordsFinished.detailText = checkFinished.detailText =
@"This is very long description of password check item. Another line of " @"This is very long description of check item. Another line of "
@"description."; @"description.";
checkPasswordsFinished.enabled = YES; checkFinished.enabled = YES;
checkPasswordsFinished.indicatorHidden = YES; checkFinished.indicatorHidden = YES;
checkPasswordsFinished.image = [[ChromeIcon infoIcon] checkFinished.trailingImage = [[ChromeIcon infoIcon]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[model addItem:checkPasswordsFinished [model addItem:checkFinished
toSectionWithIdentifier:SectionIdentifierSettings]; toSectionWithIdentifier:SectionIdentifierSettings];
SettingsPasswordCheckItem* checkPasswordsDisabled = SettingsCheckItem* checkFinishedWithLeadingImage =
[[SettingsPasswordCheckItem alloc] initWithType:ItemTypePasswordCheck3]; [[SettingsCheckItem alloc] initWithType:ItemTypeCheck3];
checkPasswordsDisabled.text = @"This is disabled password check item"; checkFinishedWithLeadingImage.text = @"Check item leading image";
checkPasswordsDisabled.detailText = checkFinishedWithLeadingImage.detailText =
@"This is very long description of password check item. Another line of " @"This is very long description of check item. Another line of "
@"description."; @"description.";
checkPasswordsDisabled.enabled = NO; checkFinishedWithLeadingImage.leadingImage = [[ChromeIcon infoIcon]
[model addItem:checkPasswordsDisabled imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
checkFinishedWithLeadingImage.enabled = YES;
checkFinishedWithLeadingImage.indicatorHidden = NO;
checkFinishedWithLeadingImage.trailingImage = [[ChromeIcon infoIcon]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[model addItem:checkFinishedWithLeadingImage
toSectionWithIdentifier:SectionIdentifierSettings];
SettingsCheckItem* checkDisabled =
[[SettingsCheckItem alloc] initWithType:ItemTypeCheck4];
checkDisabled.text = @"This is disabled check item";
checkDisabled.detailText =
@"This is very long description of check item. Another line of "
@"description.";
checkDisabled.enabled = NO;
[model addItem:checkDisabled
toSectionWithIdentifier:SectionIdentifierSettings];
SettingsCheckItem* checkDisabledWithLeadingImage =
[[SettingsCheckItem alloc] initWithType:ItemTypeCheck5];
checkDisabledWithLeadingImage.text = @"Disabled check item leading image";
checkDisabledWithLeadingImage.detailText =
@"This is very long description of check item. Another line of "
@"description.";
checkDisabledWithLeadingImage.leadingImage = [[ChromeIcon infoIcon]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
checkDisabledWithLeadingImage.enabled = NO;
[model addItem:checkDisabledWithLeadingImage
toSectionWithIdentifier:SectionIdentifierSettings]; toSectionWithIdentifier:SectionIdentifierSettings];
TableViewLinkHeaderFooterItem* linkFooter = TableViewLinkHeaderFooterItem* linkFooter =
......
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