Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: ios/chrome/browser/ui/collection_view/cells/collection_view_text_item_unittest.mm

Issue 2856113002: CollectionViewTextItem should copy accessibilityLabel to the cell (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/collection_view/cells/collection_view_text_item_unittest.mm
diff --git a/ios/chrome/browser/ui/collection_view/cells/collection_view_text_item_unittest.mm b/ios/chrome/browser/ui/collection_view/cells/collection_view_text_item_unittest.mm
index 1372fbc360f96115c11239e87df128e21d46b844..60d49c28fade8683643869f05cacffa1f559381c 100644
--- a/ios/chrome/browser/ui/collection_view/cells/collection_view_text_item_unittest.mm
+++ b/ios/chrome/browser/ui/collection_view/cells/collection_view_text_item_unittest.mm
@@ -18,6 +18,7 @@
namespace {
+// Test that accessory type is copied over to the cell from the item.
TEST(CollectionViewTextItemTest, ConfigureCellPortsAccessoryType) {
CollectionViewTextItem* item =
[[CollectionViewTextItem alloc] initWithType:0];
@@ -29,6 +30,7 @@ TEST(CollectionViewTextItemTest, ConfigureCellPortsAccessoryType) {
EXPECT_EQ(MDCCollectionViewCellAccessoryCheckmark, [cell accessoryType]);
}
+// Test that text properties are copied over to the cell from the item.
TEST(CollectionViewTextItemTest, ConfigureCellPortsTextCellProperties) {
CollectionViewTextItem* item =
[[CollectionViewTextItem alloc] initWithType:0];
@@ -43,4 +45,35 @@ TEST(CollectionViewTextItemTest, ConfigureCellPortsTextCellProperties) {
EXPECT_NSEQ(@"some detail text", [cell detailTextLabel].text);
}
+// Test that if the item has no accessibilityLabel, the cell gets one composed
+// of the text and detailText.
+TEST(CollectionViewTextItemTest, ConfigureCellDerivesAccessibilityLabel) {
+ CollectionViewTextItem* item =
+ [[CollectionViewTextItem alloc] initWithType:0];
+ item.text = @"some text";
+ item.detailText = @"some detail text";
+ CollectionViewTextCell* cell = [[[item cellClass] alloc] init];
+ EXPECT_TRUE([cell isMemberOfClass:[CollectionViewTextCell class]]);
+ EXPECT_FALSE([cell textLabel].accessibilityLabel);
+ [item configureCell:cell];
+ EXPECT_NSEQ(@"some text, some detail text", [cell accessibilityLabel]);
+}
+
+// Test that if the item has a non-empty accessibilityLabel, this is copied
+// over to the cell.
+TEST(CollectionViewTextItemTest, ConfigureCellPortsAccessibilityLabel) {
+ CollectionViewTextItem* item =
+ [[CollectionViewTextItem alloc] initWithType:0];
+ item.accessibilityLabel = @"completely different label";
+ // Also set text and detailText to verify that the derived
+ // accessibilityLabel is not composed of those.
+ item.text = @"some text";
+ item.detailText = @"some detail text";
+ CollectionViewTextCell* cell = [[[item cellClass] alloc] init];
+ EXPECT_TRUE([cell isMemberOfClass:[CollectionViewTextCell class]]);
+ EXPECT_FALSE([cell textLabel].accessibilityLabel);
+ [item configureCell:cell];
+ EXPECT_NSEQ(@"completely different label", [cell accessibilityLabel]);
+}
+
} // namespace
« no previous file with comments | « ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698