Commit 5ed48053 authored by mrefaat's avatar mrefaat Committed by Commit Bot

Add EG test for Javascript paste and go

Bug: 877984
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: Idcecd7ba8d49fa8045483f7b2309c3e3eecb3b92
Reviewed-on: https://chromium-review.googlesource.com/1211670
Commit-Queue: Mohammad Refaat <mrefaat@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589718}
parent 7bd9d693
...@@ -113,10 +113,7 @@ id<GREYMatcher> DialogCancelButton() { ...@@ -113,10 +113,7 @@ id<GREYMatcher> DialogCancelButton() {
// Opens the QR Scanner view. // Opens the QR Scanner view.
void ShowQRScanner() { void ShowQRScanner() {
// Tap the omnibox to get the keyboard accessory view to show up. // Tap the omnibox to get the keyboard accessory view to show up.
id<GREYMatcher> locationbarButton = grey_allOf( [[EarlGrey selectElementWithMatcher:chrome_test_util::NewTabPageOmnibox()]
grey_accessibilityLabel(l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT)),
grey_minimumVisiblePercent(0.2), nil);
[[EarlGrey selectElementWithMatcher:locationbarButton]
performAction:grey_tap()]; performAction:grey_tap()];
[ChromeEarlGrey [ChromeEarlGrey
waitForElementWithMatcherSufficientlyVisible:chrome_test_util::Omnibox()]; waitForElementWithMatcherSufficientlyVisible:chrome_test_util::Omnibox()];
......
...@@ -36,6 +36,17 @@ using chrome_test_util::OmniboxText; ...@@ -36,6 +36,17 @@ using chrome_test_util::OmniboxText;
using chrome_test_util::SystemSelectionCallout; using chrome_test_util::SystemSelectionCallout;
using chrome_test_util::SystemSelectionCalloutCopyButton; using chrome_test_util::SystemSelectionCalloutCopyButton;
namespace {
// Returns matcher for the Paste and Go button on the system callout.
id<GREYMatcher> PasteAndGoCalloutButton() {
return grey_allOf(
grey_accessibilityLabel(@"Paste and Go"),
grey_not(grey_accessibilityTrait(UIAccessibilityTraitButton)),
grey_not(grey_accessibilityTrait(UIAccessibilityTraitStaticText)), nil);
}
} // namespace
// Toolbar integration tests for Chrome. // Toolbar integration tests for Chrome.
@interface ToolbarTestCase : ChromeTestCase @interface ToolbarTestCase : ChromeTestCase
@end @end
...@@ -361,6 +372,28 @@ using chrome_test_util::SystemSelectionCalloutCopyButton; ...@@ -361,6 +372,28 @@ using chrome_test_util::SystemSelectionCalloutCopyButton;
assertWithMatcher:chrome_test_util::OmniboxText(URL.spec().c_str())]; assertWithMatcher:chrome_test_util::OmniboxText(URL.spec().c_str())];
} }
// Verifies that PasteAndGo removes javascript scheme from the URL before
// navigation.
- (void)testJavascriptPasteAndGo {
if (!IsUIRefreshPhase1Enabled()) {
EARL_GREY_TEST_SKIPPED(@"Paste and Go is only availble for UI Refresh.");
}
// Clear generalPasteboard after the test.
[self setTearDownHandler:^{
[UIPasteboard generalPasteboard].string = @"";
}];
[UIPasteboard generalPasteboard].string = @"javascript:notavalidurl";
[[EarlGrey selectElementWithMatcher:chrome_test_util::NewTabPageOmnibox()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
performAction:grey_longPress()];
[[EarlGrey selectElementWithMatcher:PasteAndGoCalloutButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
assertWithMatcher:chrome_test_util::OmniboxContainingText(
"www.google.com/search?q=notavalidurl")];
}
// Verifies that the clear text button clears any text in the omnibox. // Verifies that the clear text button clears any text in the omnibox.
- (void)testOmniboxClearTextButton { - (void)testOmniboxClearTextButton {
// TODO(crbug.com/753098): Re-enable this test on iOS 11 iPad once // TODO(crbug.com/753098): Re-enable this test on iOS 11 iPad once
...@@ -433,11 +466,7 @@ using chrome_test_util::SystemSelectionCalloutCopyButton; ...@@ -433,11 +466,7 @@ using chrome_test_util::SystemSelectionCalloutCopyButton;
EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to a simulator bug."); EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to a simulator bug.");
} }
id<GREYMatcher> locationbarButton = grey_allOf( [[EarlGrey selectElementWithMatcher:chrome_test_util::NewTabPageOmnibox()]
grey_accessibilityLabel(l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT)),
grey_minimumVisiblePercent(0.2), nil);
[[EarlGrey selectElementWithMatcher:locationbarButton]
performAction:grey_typeText(@"a")]; performAction:grey_typeText(@"a")];
[[EarlGrey selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"a"), [[EarlGrey selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"a"),
grey_kindOfClass( grey_kindOfClass(
...@@ -531,10 +560,7 @@ using chrome_test_util::SystemSelectionCalloutCopyButton; ...@@ -531,10 +560,7 @@ using chrome_test_util::SystemSelectionCalloutCopyButton;
// Tests typing in the omnibox using the keyboard accessory view. // Tests typing in the omnibox using the keyboard accessory view.
- (void)testToolbarOmniboxKeyboardAccessoryView { - (void)testToolbarOmniboxKeyboardAccessoryView {
// Select the omnibox to get the keyboard up. // Select the omnibox to get the keyboard up.
id<GREYMatcher> locationbarButton = grey_allOf( [[EarlGrey selectElementWithMatcher:chrome_test_util::NewTabPageOmnibox()]
grey_accessibilityLabel(l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT)),
grey_minimumVisiblePercent(0.2), nil);
[[EarlGrey selectElementWithMatcher:locationbarButton]
performAction:grey_tap()]; performAction:grey_tap()];
[ChromeEarlGrey [ChromeEarlGrey
waitForElementWithMatcherSufficientlyVisible:chrome_test_util::Omnibox()]; waitForElementWithMatcherSufficientlyVisible:chrome_test_util::Omnibox()];
......
...@@ -235,6 +235,10 @@ id<GREYMatcher> SystemSelectionCalloutCopyButton(); ...@@ -235,6 +235,10 @@ id<GREYMatcher> SystemSelectionCalloutCopyButton();
// Returns matcher for the Copy item on the context menu. // Returns matcher for the Copy item on the context menu.
id<GREYMatcher> ContextMenuCopyButton(); id<GREYMatcher> ContextMenuCopyButton();
// Returns matcher for defoucesed omnibox on a new tab.
// This matcher will only work when kUIRefreshPhase1 flag is enabled.
id<GREYMatcher> NewTabPageOmnibox();
} // namespace chrome_test_util } // namespace chrome_test_util
#endif // IOS_CHROME_TEST_EARL_GREY_CHROME_MATCHERS_H_ #endif // IOS_CHROME_TEST_EARL_GREY_CHROME_MATCHERS_H_
...@@ -461,4 +461,10 @@ id<GREYMatcher> ContextMenuCopyButton() { ...@@ -461,4 +461,10 @@ id<GREYMatcher> ContextMenuCopyButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_CONTENT_CONTEXT_COPY); return ButtonWithAccessibilityLabelId(IDS_IOS_CONTENT_CONTEXT_COPY);
} }
id<GREYMatcher> NewTabPageOmnibox() {
return grey_allOf(
grey_accessibilityLabel(l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT)),
grey_minimumVisiblePercent(0.2), nil);
}
} // namespace chrome_test_util } // namespace chrome_test_util
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