Commit f214555c authored by stkhapugin@chromium.org's avatar stkhapugin@chromium.org Committed by Commit Bot

Reenable tests using openShareMenu.

 - Reenable tests that rely on the share menu.
 - Fix -openShareMenu test helper
 - Fix location bar's trailing button accessibility:
now it's correctly updated when it's switched between
voice search and share.

Bug: 849932, 835871
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I01101fb34ce57464e2722a753e5e3ad9c71bbd3f
Reviewed-on: https://chromium-review.googlesource.com/1140161
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576032}
parent 296da10c
......@@ -85,13 +85,14 @@ id<GREYMatcher> ShareMenuCollectionView() {
EARL_GREY_TEST_DISABLED(@"Test disabled on device.");
#endif
// TODO(crbug.com/849932): re-enable this test on iOS 10 once the share button
// is implemented.
// TODO(crbug.com/864597): Reenable this test.
EARL_GREY_TEST_DISABLED(@"Test disabled due to changes in error pages.");
// TODO(crbug.com/747622): re-enable this test on iOS 11 once earl grey can
// interact with the share menu.
EARL_GREY_TEST_DISABLED(
@"Disabled until share button is implemented and "
"EG interaction is fixed on iOS 11");
if (base::ios::IsRunningOnIOS11OrLater()) {
EARL_GREY_TEST_DISABLED(@"Disabled on iOS 11.");
}
std::map<GURL, std::string> responses;
const GURL regularPageURL = web::test::HttpServer::MakeUrl("http://choux");
......@@ -123,13 +124,14 @@ id<GREYMatcher> ShareMenuCollectionView() {
}
- (void)testActivityServiceControllerCantPrintUnprintablePages {
// TODO(crbug.com/849932): re-enable this test on iOS 10 once the share button
// is implemented.
// TODO(crbug.com/747622): re-enable this test on iOS 11 once earl grey can
// interact with the share menu.
EARL_GREY_TEST_DISABLED(
@"Disabled until share button is implemented and "
"EG interaction is fixed on iOS 11");
if (base::ios::IsRunningOnIOS11OrLater()) {
EARL_GREY_TEST_DISABLED(@"Disabled on iOS 11.");
}
// TODO(crbug.com/864597): Reenable this test.
EARL_GREY_TEST_DISABLED(@"Test disabled due to changes in error pages.");
std::unique_ptr<web::DataResponseProvider> provider(
new ErrorPageResponseProvider());
......@@ -158,19 +160,11 @@ id<GREYMatcher> ShareMenuCollectionView() {
}
- (void)testActivityServiceControllerIsDisabled {
// TODO(crbug.com/849932): re-enable this test on iOS 10 once the share button
// is implemented.
// TODO(crbug.com/747622): re-enable this test on iOS 11 once earl grey can
// interact with the share menu.
EARL_GREY_TEST_DISABLED(
@"Disabled until share button is implemented and "
"EG interaction is fixed on iOS 11");
// Open an un-shareable page.
GURL kURL("chrome://version");
[ChromeEarlGrey loadURL:kURL];
// Verify that the share button is disabled.
if (IsCompactWidth()) {
if (IsCompactWidth() && !IsUIRefreshPhase1Enabled()) {
[ChromeEarlGreyUI openToolsMenu];
}
id<GREYMatcher> share_button = chrome_test_util::ShareButton();
......@@ -180,13 +174,11 @@ id<GREYMatcher> ShareMenuCollectionView() {
}
- (void)testOpenActivityServiceControllerAndCopy {
// TODO(crbug.com/849932): re-enable this test on iOS 10 once the share button
// is implemented.
// TODO(crbug.com/747622): re-enable this test on iOS 11 once earl grey can
// interact with the share menu.
EARL_GREY_TEST_DISABLED(
@"Disabled until share button is implemented and "
"EG interaction is fixed on iOS 11");
if (base::ios::IsRunningOnIOS11OrLater()) {
EARL_GREY_TEST_DISABLED(@"Disabled on iOS 11.");
}
// Set up mock http server.
std::map<GURL, std::string> responses;
......
......@@ -484,13 +484,11 @@ void TapSuppressDialogsButton() {
// Tests that an alert is presented after displaying the share menu.
- (void)testShowJavaScriptAfterShareMenu {
// TODO(crbug.com/849932): re-enable this test on iOS 10 once the share button
// is implemented.
// TODO(crbug.com/747622): re-enable this test on iOS 11 once earl grey can
// interact with the share menu.
EARL_GREY_TEST_DISABLED(
@"Disabled until share button is implemented and "
"EG interaction is fixed on iOS 11");
if (base::ios::IsRunningOnIOS11OrLater()) {
EARL_GREY_TEST_DISABLED(@"Disabled on iOS 11.");
}
// Load the blank test page.
[self loadBlankTestPage];
......
......@@ -14,6 +14,11 @@
- (void)updateLocationIcon:(UIImage*)icon
securityStatusText:(NSString*)statusText;
// Notifies the consumer about shareability of the current web page. Some web
// pages are not considered shareable (e.g. chrome://flags), and the share
// button for such pages should not be enabled.
- (void)updateLocationShareable:(BOOL)shareable;
// Notifies consumer to defocus the omnibox (for example on tab change).
- (void)defocusOmnibox;
......
......@@ -297,6 +297,10 @@ const int kLocationAuthorizationStatusCount = 4;
[self.viewController updateForNTP:YES];
}
- (void)updateLocationShareable:(BOOL)shareable {
[self.viewController setShareButtonEnabled:shareable];
}
#pragma mark - private
// Returns a dictionary with variation headers for qualified URLs. Can be empty.
......
......@@ -188,6 +188,7 @@
if (isNTP) {
[self.consumer updateAfterNavigatingToNTP];
}
[self.consumer updateLocationShareable:[self isCurrentPageShareable]];
}
- (void)notifyConsumerOfChangedSecurityIcon {
......@@ -228,4 +229,11 @@
return [UIImage imageNamed:@"location_bar_offline"];
}
#pragma mark Shareability helpers
- (BOOL)isCurrentPageShareable {
const GURL& URL = self.webState->GetLastCommittedURL();
return URL.is_valid() && !web::GetWebClient()->IsAppSpecificURL(URL);
}
@end
......@@ -213,8 +213,6 @@ const CGFloat kButtonTrailingSpacing = 10;
// Setup accessibility.
_trailingButton.isAccessibilityElement = YES;
_trailingButton.accessibilityLabel =
l10n_util::GetNSString(IDS_IOS_TOOLS_MENU_SHARE);
_locationButton.isAccessibilityElement = YES;
_locationButton.accessibilityLabel =
l10n_util::GetNSString(IDS_ACCNAME_LOCATION);
......
......@@ -69,6 +69,8 @@
// view and hides the trailing button if |isNTP|. Otherwise, shows the
// location text and the button as normal.
- (void)updateForNTP:(BOOL)isNTP;
// Sets |enabled| of the share button.
- (void)setShareButtonEnabled:(BOOL)enabled;
// Displays the voice search button instead of the share button in steady state,
// and adds the voice search button to the empty textfield.
......
......@@ -45,6 +45,11 @@ typedef NS_ENUM(int, TrailingButtonState) {
// visibility.
@property(nonatomic, assign) BOOL hideShareButtonWhileOnIncognitoNTP;
// Keeps the share button enabled status. This is necessary to preserve the
// state of the share button if it's temporarily replaced by the voice search
// icon (in iPad multitasking).
@property(nonatomic, assign) BOOL shareButtonEnabled;
// Starts voice search, updating the NamedGuide to be constrained to the
// trailing button.
- (void)startVoiceSearch;
......@@ -64,6 +69,7 @@ typedef NS_ENUM(int, TrailingButtonState) {
@synthesize trailingButtonState = _trailingButtonState;
@synthesize hideShareButtonWhileOnIncognitoNTP =
_hideShareButtonWhileOnIncognitoNTP;
@synthesize shareButtonEnabled = _shareButtonEnabled;
@synthesize offsetProvider = _offsetProvider;
#pragma mark - public
......@@ -233,6 +239,13 @@ typedef NS_ENUM(int, TrailingButtonState) {
self.hideShareButtonWhileOnIncognitoNTP = isNTP;
}
- (void)setShareButtonEnabled:(BOOL)enabled {
_shareButtonEnabled = enabled;
if (self.trailingButtonState == kShareButton) {
self.locationBarSteadyView.trailingButton.enabled = enabled;
}
}
#pragma mark - LocationBarAnimatee
- (void)offsetEditViewToMatchSteadyView {
......@@ -340,6 +353,10 @@ typedef NS_ENUM(int, TrailingButtonState) {
[[UIImage imageNamed:@"location_bar_share"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
forState:UIControlStateNormal];
self.locationBarSteadyView.trailingButton.accessibilityLabel =
l10n_util::GetNSString(IDS_IOS_TOOLS_MENU_SHARE);
self.locationBarSteadyView.trailingButton.enabled =
self.shareButtonEnabled;
break;
};
case kVoiceSearchButton: {
......@@ -356,6 +373,9 @@ typedef NS_ENUM(int, TrailingButtonState) {
[[UIImage imageNamed:@"location_bar_voice"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
forState:UIControlStateNormal];
self.locationBarSteadyView.trailingButton.accessibilityLabel =
l10n_util::GetNSString(IDS_IOS_TOOLS_MENU_VOICE_SEARCH);
self.locationBarSteadyView.trailingButton.enabled = YES;
}
}
}
......
......@@ -64,14 +64,6 @@ id<GREYMatcher> ShareMenuCollectionView() {
// loaded.
// TODO(crbug.com/683280): Does this test serve any purpose on iOS11?
- (void)testPrintNormalPage {
// TODO(crbug.com/849932): re-enable this test on iOS 10 once the share button
// is implemented.
// TODO(crbug.com/747622): re-enable this test on iOS 11 once earl grey can
// interact with the share menu.
EARL_GREY_TEST_DISABLED(
@"Disabled until share button is implemented and "
"EG interaction is fixed on iOS 11");
if (base::ios::IsRunningOnIOS11OrLater() && IsUIRefreshPhase1Enabled()) {
EARL_GREY_TEST_SKIPPED(
@"Dispatcher-based printing does not work on iOS11 when the "
......@@ -93,14 +85,6 @@ id<GREYMatcher> ShareMenuCollectionView() {
// Tests that the AirPrint menu successfully loads when a PDF is loaded.
// TODO(crbug.com/683280): Does this test serve any purpose on iOS11?
- (void)testPrintPDF {
// TODO(crbug.com/849932): re-enable this test on iOS 10 once the share button
// is implemented.
// TODO(crbug.com/747622): re-enable this test on iOS 11 once earl grey can
// interact with the share menu.
EARL_GREY_TEST_DISABLED(
@"Disabled until share button is implemented and "
"EG interaction is fixed on iOS 11");
if (base::ios::IsRunningOnIOS11OrLater() && IsUIRefreshPhase1Enabled()) {
EARL_GREY_TEST_SKIPPED(
@"Dispatcher-based printing does not work on iOS11 when the "
......
......@@ -6,7 +6,6 @@
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#include "base/ios/ios_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#import "base/test/ios/wait_util.h"
......@@ -261,11 +260,6 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
// Tests exiting the switcher by tapping the new tab button or selecting new tab
// from the menu (on phone only).
- (void)testLeaveSwitcherByOpeningNewNormalTab {
// TODO(crbug.com/849937): re-enable this test on iOS 10.
if (!base::ios::IsRunningOnIOS11OrLater()) {
EARL_GREY_TEST_DISABLED(@"Disabled on iOS10");
}
NSString* tab1_title = @"NormalTab1";
NSString* tab2_title = @"NormalTab2";
[self setUpTestServer];
......
......@@ -260,7 +260,7 @@
}
}
// Uodates the Share Menu button of the consumer.
// Updates the Share Menu button of the consumer.
- (void)updateShareMenuForWebState:(web::WebState*)webState {
const GURL& URL = webState->GetLastCommittedURL();
BOOL shareMenuEnabled =
......
......@@ -288,11 +288,6 @@ using chrome_test_util::SystemSelectionCalloutCopyButton;
// location bar is supported.
EARL_GREY_TEST_SKIPPED(@"Test not supported yet in UI Refresh.");
}
// TODO(crbug.com/849932): re-enable this test on iOS 10 once the share button
// is implemented.
if (!base::ios::IsRunningOnIOS11OrLater()) {
EARL_GREY_TEST_DISABLED(@"Disabled until share button is implemented.");
}
// Clear generalPasteboard before and after the test.
[UIPasteboard generalPasteboard].string = @"";
......
......@@ -144,7 +144,7 @@ id<GREYAction> ScrollDown() {
}
+ (void)openShareMenu {
if (IsCompactWidth()) {
if (IsCompactWidth() && !IsRefreshLocationBarEnabled()) {
[ChromeEarlGreyUI openToolsMenu];
}
[[EarlGrey selectElementWithMatcher:chrome_test_util::ShareButton()]
......
......@@ -242,7 +242,8 @@ id<GREYMatcher> ToolsMenuButton() {
}
id<GREYMatcher> ShareButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_TOOLS_MENU_SHARE);
return grey_allOf(ButtonWithAccessibilityLabelId(IDS_IOS_TOOLS_MENU_SHARE),
grey_sufficientlyVisible(), nil);
}
id<GREYMatcher> ShowTabsButton() {
......
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