Commit 5d642a3d authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Fix FeatureEngagementTestCase for UI Refresh

This CL fixes the test suite, fixing the test that should pass and
disabling the one for the features not yet implemented.

Bug: 832638
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I2138a74a73b18c40ebdee6b22432541d7bc27a91
Reviewed-on: https://chromium-review.googlesource.com/1012104
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550628}
parent 44cc4dee
......@@ -41,7 +41,9 @@ source_set("eg_tests") {
"//ios/chrome/app/strings",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/ui:ui_util",
"//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/browser/ui/tab_switcher:egtest_support",
"//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/testing:ios_test_support",
......
......@@ -13,7 +13,9 @@
#include "components/feature_engagement/test/test_tracker.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/feature_engagement/tracker_factory.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_egtest_util.h"
#include "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.h"
#include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h"
......@@ -21,6 +23,7 @@
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/testing/earl_grey/disabled_test_macros.h"
#import "ios/testing/wait_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h"
......@@ -42,7 +45,11 @@ const int kMinChromeOpensRequiredForNewTabTip = 3;
// Matcher for the Reading List Text Badge.
id<GREYMatcher> ReadingListTextBadge() {
return grey_accessibilityID(@"kReadingListTextBadgeAccessibilityIdentifier");
return grey_allOf(
grey_accessibilityID(@"kToolsMenuTextBadgeAccessibilityIdentifier"),
grey_ancestor(grey_allOf(grey_accessibilityID(kToolsMenuReadingListId),
grey_sufficientlyVisible(), nil)),
nil);
}
// Matcher for the New Tab Tip Bubble.
......@@ -153,15 +160,28 @@ void EnableNewTabTipTriggering(base::test::ScopedFeatureList& feature_list) {
[ChromeEarlGreyUI openToolsMenu];
[[EarlGrey selectElementWithMatcher:ReadingListTextBadge()]
assertWithMatcher:grey_sufficientlyVisible()];
[[[EarlGrey selectElementWithMatcher:ReadingListTextBadge()]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 150)
onElementWithMatcher:grey_accessibilityID(kPopupMenuToolsMenuTableViewId)]
assertWithMatcher:grey_notNil()];
// Close tools menu by tapping reload.
[[EarlGrey selectElementWithMatcher:chrome_test_util::ReloadButton()]
[[[EarlGrey selectElementWithMatcher:chrome_test_util::ReloadButton()]
usingSearchAction:grey_scrollInDirection(kGREYDirectionUp, 150)
onElementWithMatcher:grey_accessibilityID(kPopupMenuToolsMenuTableViewId)]
performAction:grey_tap()];
// Reopen tools menu to verify that the badge does not appear again.
[ChromeEarlGreyUI openToolsMenu];
// Make sure the ReadingList entry is visible.
[[[EarlGrey
selectElementWithMatcher:grey_allOf(grey_accessibilityID(
kToolsMenuReadingListId),
grey_sufficientlyVisible(), nil)]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 150)
onElementWithMatcher:grey_accessibilityID(kPopupMenuToolsMenuTableViewId)]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:ReadingListTextBadge()]
assertWithMatcher:grey_notVisible()];
}
......@@ -215,6 +235,11 @@ void EnableNewTabTipTriggering(base::test::ScopedFeatureList& feature_list) {
// Verifies that the New Tab Tip appears when all conditions are met.
- (void)testNewTabTipPromoShouldShow {
if (IsUIRefreshPhase1Enabled()) {
// TODO(crbug.com/832661): Re-enable those tests.
EARL_GREY_TEST_SKIPPED(@"Not yet implemented.");
}
base::test::ScopedFeatureList scoped_feature_list;
EnableNewTabTipTriggering(scoped_feature_list);
......@@ -244,6 +269,11 @@ void EnableNewTabTipTriggering(base::test::ScopedFeatureList& feature_list) {
// Verifies that the New Tab Tip does not appear if all conditions are met,
// but the NTP is open.
- (void)testNewTabTipPromoDoesNotAppearOnNTP {
if (IsUIRefreshPhase1Enabled()) {
// TODO(crbug.com/832661): Re-enable those tests.
EARL_GREY_TEST_SKIPPED(@"Not yet implemented.");
}
base::test::ScopedFeatureList scoped_feature_list;
EnableNewTabTipTriggering(scoped_feature_list);
......
......@@ -27,6 +27,8 @@ const CGFloat kMargin = 15;
const CGFloat kTopMargin = 8;
const CGFloat kTopMarginBadge = 14;
const CGFloat kMaxHeight = 100;
NSString* const kToolsMenuTextBadgeAccessibilityIdentifier =
@"kToolsMenuTextBadgeAccessibilityIdentifier";
} // namespace
@implementation PopupMenuToolsItem
......@@ -124,6 +126,8 @@ const CGFloat kMaxHeight = 100;
_textBadgeView = [[TextBadgeView alloc] initWithText:nil];
_textBadgeView.translatesAutoresizingMaskIntoConstraints = NO;
_textBadgeView.accessibilityIdentifier =
kToolsMenuTextBadgeAccessibilityIdentifier;
_textBadgeView.hidden = YES;
[self.contentView addSubview:_titleLabel];
......
......@@ -18,8 +18,8 @@
#endif
// Accessibility identifier for the text badge on the reading list cell.
NSString* const kReadingListTextBadgeAccessibilityIdentifier =
@"kReadingListTextBadgeAccessibilityIdentifier";
NSString* const kToolsMenuTextBadgeAccessibilityIdentifier =
@"kToolsMenuTextBadgeAccessibilityIdentifier";
namespace {
// ID for cell reuse
......@@ -81,7 +81,7 @@ const NSTimeInterval kTextBadgeAnimationDuration = ios::material::kDuration3;
self.textBadge = [[TextBadgeView alloc] initWithText:uppercaseText];
self.textBadge.hidden = YES;
self.textBadge.accessibilityIdentifier =
kReadingListTextBadgeAccessibilityIdentifier;
kToolsMenuTextBadgeAccessibilityIdentifier;
self.textBadge.accessibilityLabel = text;
[self.contentView addSubview:self.textBadge];
......
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