Commit 780c37b8 authored by Yi Su's avatar Yi Su Committed by Commit Bot

Revert "[ios] Fix BadgeViewController interpretation of badgeState"

This reverts commit 4fcce6d7.

Reason for revert: SCBadgeTestCase.testBadgesVisible is failing consistently after this CL:
https://ci.chromium.org/p/chrome/builders/ci/iphone-simulator/5469

Original change's description:
> [ios] Fix BadgeViewController interpretation of badgeState
> 
> Since BadgeState is a mask, a direct equality comparison to
> BadgeState values for the BadgeItem properties is not the correct
> way to assess if a badge is accepted.
> 
> To add testing support for this case, accepted a11y identifiers
> for BadgeButtons are created, and they will be properly set
> in setAccepted: in BadgeButton.
> 
> Bug: 976901, 1016793
> Change-Id: Id17eb82e0764fbbf80b871df0b974fe148c2339f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872938
> Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
> Reviewed-by: Peter Lee <pkl@chromium.org>
> Reviewed-by: Sergio Collazos <sczs@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#709037}

TBR=pkl@chromium.org,sczs@chromium.org,thegreenfrog@chromium.org

Change-Id: I7cc7f67cbb24a962388c2079a71e9e168c32fdfb
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 976901, 1016793
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880029Reviewed-by: default avatarYi Su <mrsuyi@chromium.org>
Commit-Queue: Yi Su <mrsuyi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709406}
parent dcbbe562
......@@ -4,8 +4,6 @@
#import "ios/chrome/browser/ui/badges/badge_button.h"
#import "base/logging.h"
#import "ios/chrome/browser/ui/badges/badge_constants.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/colors/semantic_color_names.h"
......@@ -47,7 +45,6 @@ const CGFloat kButtonCircularCornerRadiusDivisor = 2.0;
self.accepted = accepted;
void (^changeTintColor)() = ^{
self.tintColor = accepted ? nil : [UIColor colorNamed:kToolbarButtonColor];
self.accessibilityIdentifier = [self getAccessibilityIdentifier:accepted];
};
if (animated) {
[UIView animateWithDuration:kButtonAnimationDuration
......@@ -76,31 +73,6 @@ const CGFloat kButtonCircularCornerRadiusDivisor = 2.0;
#pragma mark - Private
- (NSString*)getAccessibilityIdentifier:(BOOL)accepted {
switch (self.badgeType) {
case BadgeType::kBadgeTypeNone:
NOTREACHED() << "A badge should not have kBadgeTypeNone";
return nil;
case BadgeType::kBadgeTypePasswordSave:
return accepted ? kBadgeButtonSavePasswordAcceptedAccessibilityIdentifier
: kBadgeButtonSavePasswordAccessibilityIdentifier;
case BadgeType::kBadgeTypePasswordUpdate:
return accepted
? kBadgeButtonUpdatePasswordAccpetedAccessibilityIdentifier
: kBadgeButtonUpdatePasswordAccessibilityIdentifier;
case BadgeType::kBadgeTypeIncognito:
return kBadgeButtonIncognitoAccessibilityIdentifier;
case BadgeType::kBadgeTypeOverflow:
return kBadgeButtonOverflowAccessibilityIdentifier;
case BadgeType::kBadgeTypeSaveCard:
return accepted ? kBadgeButtonSaveCardAcceptedAccessibilityIdentifier
: kBadgeButtonSaveCardAccessibilityIdentifier;
case BadgeType::kBadgeTypeTranslate:
return accepted ? kBadgeButtonTranslateAcceptedAccessibilityIdentifier
: kBadgeButtonTranslateAccessibilityIdentifier;
}
}
- (void)configureImage {
if (self.fullScreenOn && self.fullScreenImage) {
[self setImage:self.fullScreenImage forState:UIControlStateNormal];
......
......@@ -9,16 +9,11 @@
// A11y identifiers so that automation can tap on BadgeButtons
extern NSString* const kBadgeButtonSavePasswordAccessibilityIdentifier;
extern NSString* const kBadgeButtonSavePasswordAcceptedAccessibilityIdentifier;
extern NSString* const kBadgeButtonUpdatePasswordAccessibilityIdentifier;
extern NSString* const
kBadgeButtonUpdatePasswordAccpetedAccessibilityIdentifier;
extern NSString* const kBadgeButtonIncognitoAccessibilityIdentifier;
extern NSString* const kBadgeButtonOverflowAccessibilityIdentifier;
extern NSString* const kBadgeButtonSaveCardAccessibilityIdentifier;
extern NSString* const kBadgeButtonSaveCardAcceptedAccessibilityIdentifier;
extern NSString* const kBadgeButtonTranslateAccessibilityIdentifier;
extern NSString* const kBadgeButtonTranslateAcceptedAccessibilityIdentifier;
// A11y identifier for the Badge Popup Menu Table View.
extern NSString* const kBadgePopupMenuTableViewAccessibilityIdentifier;
......
......@@ -11,15 +11,9 @@
NSString* const kBadgeButtonSavePasswordAccessibilityIdentifier =
@"badgeButtonSavePasswordAXID";
NSString* const kBadgeButtonSavePasswordAcceptedAccessibilityIdentifier =
@"badgeButtonSavePasswordAcceptedAXID";
NSString* const kBadgeButtonUpdatePasswordAccessibilityIdentifier =
@"badgeButtonUpdatePasswordAXID";
NSString* const kBadgeButtonUpdatePasswordAccpetedAccessibilityIdentifier =
@"badgeButtonUpdatePasswordAcceptedAXID";
NSString* const kBadgeButtonIncognitoAccessibilityIdentifier =
@"badgeButtonIncognitoAXID";
......@@ -29,15 +23,9 @@ NSString* const kBadgeButtonOverflowAccessibilityIdentifier =
NSString* const kBadgeButtonSaveCardAccessibilityIdentifier =
@"badgeButtonSaveCardAXID";
NSString* const kBadgeButtonSaveCardAcceptedAccessibilityIdentifier =
@"badgeButtonSaveCardAcceptedAXID";
NSString* const kBadgeButtonTranslateAccessibilityIdentifier =
@"badgeButtonTranslateAXID";
NSString* const kBadgeButtonTranslateAcceptedAccessibilityIdentifier =
@"badgeButtonTranslateAcceptedAXID";
NSString* const kBadgePopupMenuTableViewAccessibilityIdentifier =
@"badgePopupMenuOverflowAXID";
......
......@@ -89,7 +89,7 @@ const CGFloat kUnreadIndicatorViewHeight = 6.0;
if (displayedBadgeItem) {
BadgeButton* newButton = [self.buttonFactory
getBadgeButtonForBadgeType:displayedBadgeItem.badgeType];
[newButton setAccepted:displayedBadgeItem.badgeState & BadgeStateAccepted
[newButton setAccepted:displayedBadgeItem.badgeState == BadgeStateAccepted
animated:NO];
self.displayedBadge = newButton;
}
......@@ -116,12 +116,12 @@ const CGFloat kUnreadIndicatorViewHeight = 6.0;
if (self.displayedBadge &&
self.displayedBadge.badgeType == displayedBadgeItem.badgeType) {
[self.displayedBadge
setAccepted:displayedBadgeItem.badgeState & BadgeStateAccepted
setAccepted:displayedBadgeItem.badgeState == BadgeStateAccepted
animated:YES];
} else {
BadgeButton* newButton = [self.buttonFactory
getBadgeButtonForBadgeType:displayedBadgeItem.badgeType];
[newButton setAccepted:displayedBadgeItem.badgeState & BadgeStateAccepted
[newButton setAccepted:displayedBadgeItem.badgeState == BadgeStateAccepted
animated:NO];
self.displayedBadge = newButton;
}
......
......@@ -17,7 +17,9 @@
// successfully. If it returns NO no Modal should be presented.
- (BOOL)configureModalViewController;
// Returns YES if the Infobar Accept action was completed successfully.
// Returns YES if the Infobar action was completed successfully. Useful for
// Infobar actions that finish asynchronously to delay marking the Infobar as
// accepted.
- (BOOL)isInfobarAccepted;
// Performs any actions related to an Infobar Banner presentation.
......
......@@ -65,7 +65,8 @@
- (void)translateInfoBarDelegate:(translate::TranslateInfoBarDelegate*)delegate
didChangeTranslateStep:(translate::TranslateStep)step
withErrorType:(translate::TranslateErrors::Type)errorType {
// TODO(crbug.com/1014959): implement
// TODO(crbug.com/1014959): Update currentStep and call
// infobarWasAccepted:forWebState: if translate finished.
}
- (BOOL)translateInfoBarDelegateDidDismissWithoutInteraction:
......
......@@ -9,10 +9,7 @@
// A11y identifier for button that will replace the displayed badge with the
// overflow badge button.
extern NSString* const kSCShowOverflowDisplayedBadgeButton;
// A11y identifier for button that will show an accepted displayed button.
extern NSString* const kSCShowAcceptedDisplayedBadgeButton;
extern NSString* const kSCDisplayedBadgeToggleButton;
@interface SCBadgeCoordinator : NSObject <NavigationCoordinator>
......
......@@ -20,11 +20,8 @@
#error "This file requires ARC support."
#endif
NSString* const kSCShowOverflowDisplayedBadgeButton =
@"kSCShowOverflowDisplayedBadgeButtonAXID";
NSString* const kSCShowAcceptedDisplayedBadgeButton =
@"kSCShowAcceptedDisplayedBadgeButtonAXID";
NSString* const kSCDisplayedBadgeToggleButton =
@"kSCDisplayedBadgeToggleButtonAXID";
@interface BadgeContainerViewController : UIViewController
@property(nonatomic, strong) BadgeViewController* centeredChildViewController;
......@@ -57,27 +54,13 @@ NSString* const kSCShowAcceptedDisplayedBadgeButton =
constraintEqualToConstant:100]
]];
UIButton* showAcceptedBadgeButton =
[UIButton buttonWithType:UIButtonTypeSystem];
showAcceptedBadgeButton.accessibilityIdentifier =
kSCShowAcceptedDisplayedBadgeButton;
[showAcceptedBadgeButton setTitle:@"Show Accepted Badge"
forState:UIControlStateNormal];
[showAcceptedBadgeButton addTarget:self
action:@selector(showAcceptedDisplayedBadge)
forControlEvents:UIControlEventTouchUpInside];
[stackView addArrangedSubview:showAcceptedBadgeButton];
UIButton* showOverflowBadgeButton =
[UIButton buttonWithType:UIButtonTypeSystem];
showOverflowBadgeButton.accessibilityIdentifier =
kSCShowOverflowDisplayedBadgeButton;
[showOverflowBadgeButton setTitle:@"Show Overflow badge"
forState:UIControlStateNormal];
[showOverflowBadgeButton addTarget:self
UIButton* button = [UIButton buttonWithType:UIButtonTypeSystem];
button.accessibilityIdentifier = kSCDisplayedBadgeToggleButton;
[button setTitle:@"Show Overflow badge" forState:UIControlStateNormal];
[button addTarget:self
action:@selector(addSecondBadge:)
forControlEvents:UIControlEventTouchUpInside];
[stackView addArrangedSubview:showOverflowBadgeButton];
[stackView addArrangedSubview:button];
UIView* containerView = self.view;
containerView.backgroundColor = [UIColor whiteColor];
......@@ -87,17 +70,6 @@ NSString* const kSCShowAcceptedDisplayedBadgeButton =
initWithBadgeType:BadgeType::kBadgeTypeIncognito];
InfobarBadgeModel* passwordBadgeItem = [[InfobarBadgeModel alloc]
initWithInfobarType:InfobarType::kInfobarTypePasswordSave];
passwordBadgeItem.badgeState = BadgeStateRead;
[self.consumer setupWithDisplayedBadge:passwordBadgeItem
fullScreenBadge:incognitoItem];
}
- (void)showAcceptedDisplayedBadge {
BadgeStaticItem* incognitoItem = [[BadgeStaticItem alloc]
initWithBadgeType:BadgeType::kBadgeTypeIncognito];
InfobarBadgeModel* passwordBadgeItem = [[InfobarBadgeModel alloc]
initWithInfobarType:InfobarType::kInfobarTypePasswordSave];
passwordBadgeItem.badgeState = BadgeStateRead | BadgeStateAccepted;
[self.consumer setupWithDisplayedBadge:passwordBadgeItem
fullScreenBadge:incognitoItem];
}
......
......@@ -43,22 +43,10 @@ using ::showcase_utils::Close;
kBadgeButtonSavePasswordAccessibilityIdentifier),
grey_sufficientlyVisible(), nil)]
assertWithMatcher:grey_sufficientlyVisible()];
// Tap on button to show the accepted badge.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kSCShowAcceptedDisplayedBadgeButton)]
performAction:grey_tap()];
[[EarlGrey
selectElementWithMatcher:
grey_allOf(
grey_accessibilityID(
kBadgeButtonSavePasswordAcceptedAccessibilityIdentifier),
grey_sufficientlyVisible(), nil)]
assertWithMatcher:grey_sufficientlyVisible()];
[[EarlGrey selectElementWithMatcher:
grey_allOf(grey_accessibilityID(
kBadgeButtonIncognitoAccessibilityIdentifier),
kBadgeButtonSavePasswordAccessibilityIdentifier),
grey_sufficientlyVisible(), nil)]
assertWithMatcher:grey_sufficientlyVisible()];
}
......@@ -68,7 +56,7 @@ using ::showcase_utils::Close;
- (void)testOverflowbadge {
// Tap on button to show the overflow badge.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kSCShowOverflowDisplayedBadgeButton)]
kSCDisplayedBadgeToggleButton)]
performAction:grey_tap()];
// Assert that overflow badge and the unread indicator is shown and tap on it.
......@@ -99,7 +87,7 @@ using ::showcase_utils::Close;
// badge is sufficient here. Assert that the unread indicator is not there
// anymore.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kSCShowOverflowDisplayedBadgeButton)]
kSCDisplayedBadgeToggleButton)]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:
grey_allOf(grey_accessibilityID(
......
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