Commit a749c1d8 authored by edchin's avatar edchin Committed by Commit Bot

[ios] Add close cell egtest in tab grid

Bug: 804560
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I8a7f1779aff808edddc525110c8900cbd9fd8b8a
Reviewed-on: https://chromium-review.googlesource.com/955345Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541925}
parent fe81a901
......@@ -11,9 +11,6 @@
@class GridCell;
// The accessibility label for the close button for use in test automation.
extern NSString* const kGridCellCloseButtonAccessibilityID;
// Informs the receiver of actions on the cell.
@protocol GridCellDelegate
- (void)closeButtonTappedForCell:(GridCell*)cell;
......
......@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/tab_grid/grid_cell.h"
#import "base/logging.h"
#import "ios/chrome/browser/ui/tab_grid/grid_constants.h"
#import "ios/chrome/browser/ui/tab_grid/top_aligned_image_view.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -13,9 +14,6 @@
#error "This file requires ARC support."
#endif
NSString* const kGridCellCloseButtonAccessibilityID =
@"GridCellCloseButtonAccessibilityID";
namespace {
// Height of the top bar containing the icon, title, and close button.
const CGFloat kTopBarHeight = 28.0f;
......@@ -205,7 +203,7 @@ const CGFloat kBorderWidth = 6.0f;
[closeButton addTarget:self
action:@selector(closeButtonTapped:)
forControlEvents:UIControlEventTouchUpInside];
closeButton.accessibilityIdentifier = kGridCellCloseButtonAccessibilityID;
closeButton.accessibilityIdentifier = kGridCellCloseButtonIdentifier;
[topBar addSubview:iconView];
[topBar addSubview:titleLabel];
......
......@@ -13,4 +13,7 @@
// index].
extern NSString* const kGridCellIdentifierPrefix;
// Accessibility identifier for the close button in a grid cell.
extern NSString* const kGridCellCloseButtonIdentifier;
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_GRID_CONSTANTS_H_
......@@ -10,3 +10,7 @@
// Accessibility identifier prefix of a grid cell.
NSString* const kGridCellIdentifierPrefix = @"GridCellIdentifierPrefix";
// Accessibility identifier for the close button in a grid cell.
NSString* const kGridCellCloseButtonIdentifier =
@"GridCellCloseButtonIdentifier";
......@@ -15,15 +15,32 @@
#endif
namespace {
// Identifer for cell at given |index|.
NSString* IdentifierForCellAtIndex(unsigned int index) {
return [NSString stringWithFormat:@"%@%u", kGridCellIdentifierPrefix, index];
}
// Matcher for cell at |index|.
id<GREYMatcher> CellAtIndex(unsigned int index) {
return grey_allOf(grey_accessibilityID(IdentifierForCellAtIndex(index)),
grey_sufficientlyVisible(), nil);
}
// Matcher for close button for cell at |index|.
id<GREYMatcher> CloseButtonForCellAtIndex(unsigned int index) {
return grey_allOf(
grey_ancestor(grey_accessibilityID(IdentifierForCellAtIndex(index))),
grey_accessibilityID(kGridCellCloseButtonIdentifier),
grey_sufficientlyVisible(), nil);
}
// Matcher for done button in tab grid.
id<GREYMatcher> TabGridDoneButton() {
return grey_allOf(grey_accessibilityID(kTabGridDoneButtonAccessibilityID),
grey_sufficientlyVisible(), nil);
}
// Identifer for cell at given |index|.
NSString* IdentifierForCellAtIndex(unsigned int index) {
return [NSString stringWithFormat:@"%@%u", kGridCellIdentifierPrefix, index];
}
} // namespace
@interface TabGridTestCase : ChromeTestCase
......@@ -43,11 +60,19 @@ NSString* IdentifierForCellAtIndex(unsigned int index) {
- (void)testTappingOnFirstCell {
[[EarlGrey selectElementWithMatcher:chrome_test_util::ShowTabsButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
IdentifierForCellAtIndex(0))]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:CellAtIndex(0)] performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::ShowTabsButton()]
assertWithMatcher:grey_sufficientlyVisible()];
}
// Tests that closing the cell shows no tabs.
- (void)testClosingFirstCell {
[[EarlGrey selectElementWithMatcher:chrome_test_util::ShowTabsButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:CloseButtonForCellAtIndex(0)]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:CellAtIndex(0)]
assertWithMatcher:grey_nil()];
}
@end
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