Commit 46c6817b authored by Tina Wang's avatar Tina Wang Committed by Commit Bot

[ios] Add EG test to chrome://management page

Added EG test to chrome://management page.

Updated omniboxContainingText: matcher to avoid crash when the
element is not an UITextField.

Bug: 1131052
Change-Id: Ia68ad5a6071867e8ae3cf4751ce1ef792cd741dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2424546Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: Tina Wang <tinazwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810645}
parent f01dc638
......@@ -31,7 +31,7 @@
<div id="managed-info" class="hidden">
<div id="main-message">$i18n{managementMessage}</div>
<div id="secondary-message">$i18n{managedInfo}
<a target="_blank" href=$i18n{learnMoreURL}>$i18n{learnMore}</a>
<a id="learn-more-link" target="_blank" href=$i18n{learnMoreURL}>$i18n{learnMore}</a>
</div>
</div>
<div id="unmanaged-info" class="hidden">$i18n{unmanagedInfo}</div>
......
......@@ -249,4 +249,34 @@ id<GREYMatcher> ToolsMenuTranslateButton() {
assertWithMatcher:grey_notNil()];
}
// Test the chrome://management page when no machine level policy is set.
- (void)testManagementPageUnmanaged {
// Open the management page and check if the content is expected.
[ChromeEarlGrey loadURL:GURL("chrome://management")];
[ChromeEarlGrey
waitForWebStateContainingText:l10n_util::GetStringUTF8(
IDS_IOS_MANAGEMENT_UI_UNMANAGED_DESC)];
}
// Test the chrome://management page when one or more machine level policies are
// set.
- (void)testManagementPageManaged {
// Setup a machine level policy.
SetPolicy(false, policy::key::kTranslateEnabled);
// Open the management page and check if the content is expected.
[ChromeEarlGrey loadURL:GURL("chrome://management")];
[ChromeEarlGrey
waitForWebStateContainingText:l10n_util::GetStringUTF8(
IDS_IOS_MANAGEMENT_UI_MESSAGE)];
// Open the "learn more" link in the web content.
[ChromeEarlGrey tapWebStateElementWithID:@"learn-more-link"];
[ChromeEarlGrey waitForPageToFinishLoading];
// Check the navigation.
[[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxContainingText(
"support.google.com")]
assertWithMatcher:grey_notNil()];
}
@end
......@@ -309,8 +309,10 @@ UIView* SubviewWithAccessibilityIdentifier(NSString* accessibility_id,
+ (id<GREYMatcher>)omniboxContainingText:(NSString*)text {
GREYElementMatcherBlock* matcher = [GREYElementMatcherBlock
matcherWithMatchesBlock:^BOOL(UITextField* element) {
return [element.text containsString:text];
matcherWithMatchesBlock:^BOOL(id element) {
OmniboxTextFieldIOS* omnibox =
base::mac::ObjCCast<OmniboxTextFieldIOS>(element);
return [omnibox.text containsString:text];
}
descriptionBlock:^void(id<GREYDescription> description) {
[description
......
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