Commit d75f164b authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] Resetting the detail text color for SettingsImageDetailTextCell

The SettingsImageDetailTextItem needs to set the detail text color each
time the cell is configured.

Fixed: 1145527
Change-Id: I1607709f02ce6703b9b74c93854f0f267db78871
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2527044
Auto-Submit: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826712}
parent 8957c0f8
......@@ -61,7 +61,6 @@
_detailTextLabel.font =
[UIFont preferredFontForTextStyle:kTableViewSublabelFontStyle];
_detailTextLabel.adjustsFontForContentSizeCategory = YES;
_detailTextLabel.textColor = UIColor.cr_secondaryLabelColor;
}
// Sets constraints on subviews.
......
......@@ -4,10 +4,11 @@
#import "ios/chrome/browser/ui/settings/cells/settings_image_detail_text_item.h"
#include "base/check.h"
#import "base/check.h"
#import "ios/chrome/browser/ui/settings/cells/settings_image_detail_text_cell.h"
#include "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"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui/colors/UIColor+cr_semantic_colors.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -33,6 +34,8 @@
if (self.detailTextColor) {
cell.detailTextLabel.textColor = self.detailTextColor;
} else {
cell.detailTextLabel.textColor = UIColor.cr_secondaryLabelColor;
}
}
......
......@@ -68,3 +68,43 @@ TEST_F(SettingsImageDetailTextItemTest, setDetailTextColor) {
EXPECT_NSEQ(UIColor.blueColor, imageDetailCell.detailTextLabel.textColor);
}
// Tests that the text, detail text and image are honoured after a call to
// |configureCell:|, and then a second call.
TEST_F(SettingsImageDetailTextItemTest, ConfigureCellTwice) {
SettingsImageDetailTextItem* item =
[[SettingsImageDetailTextItem alloc] initWithType:0];
NSString* text = @"Test Text";
NSString* detailText = @"Test Detail Text";
UIColor* detailTextColor = UIColor.whiteColor;
UIImage* image = [[UIImage alloc] init];
item.image = image;
item.text = text;
item.detailText = detailText;
item.detailTextColor = detailTextColor;
id cell = [[[item cellClass] alloc] init];
SettingsImageDetailTextCell* imageDetailCell =
static_cast<SettingsImageDetailTextCell*>(cell);
EXPECT_FALSE(imageDetailCell.textLabel.text);
EXPECT_FALSE(imageDetailCell.detailTextLabel.text);
[item configureCell:cell withStyler:[[ChromeTableViewStyler alloc] init]];
EXPECT_NSEQ(text, imageDetailCell.textLabel.text);
EXPECT_NSEQ(detailText, imageDetailCell.detailTextLabel.text);
EXPECT_NSEQ(UIColor.whiteColor, imageDetailCell.detailTextLabel.textColor);
EXPECT_NSEQ(image, imageDetailCell.image);
// Change the text, the detail text, and the detail text color to new values.
text = @"Test Text2";
detailText = @"Test Detail Text2";
item.text = text;
item.detailText = detailText;
item.detailTextColor = nil;
[item configureCell:cell withStyler:[[ChromeTableViewStyler alloc] init]];
EXPECT_NSEQ(text, imageDetailCell.textLabel.text);
EXPECT_NSEQ(detailText, imageDetailCell.detailTextLabel.text);
EXPECT_NSEQ(UIColor.cr_secondaryLabelColor,
imageDetailCell.detailTextLabel.textColor);
}
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