Commit ad7e8b93 authored by zhaoyangli's avatar zhaoyangli Committed by Commit Bot

Make automation_action.mm fully EG2 compatible.

"automation_action.mm" implements autofill automation actions for iOS
through earlgrey framework. This change makes it fully EG2 compatible.
This is part of autofill automation framework EG2 migration.

- Removed unused headers and changed headers for EG2.
- Changed web view test util method calls to methods in chrome_matchers
and chrome_actions which are EG2 compatible.

Bug: 987646, 1003605
Change-Id: Idad2a2fbe68436cccd623c92044b46f0137f32d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1847904Reviewed-by: default avatarEric Noyau <noyau@chromium.org>
Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Commit-Queue: Zhaoyang Li <zhaoyangli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704236}
parent b1be0f0c
......@@ -4,25 +4,18 @@
#import "ios/chrome/browser/autofill/automation/automation_action.h"
#import <EarlGrey/EarlGrey.h>
#include "base/guid.h"
#include "base/mac/foundation_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#import "base/test/ios/wait_util.h"
#include "components/autofill/core/browser/autofill_manager.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/ios/browser/autofill_driver_ios.h"
#include "base/values.h"
#import "ios/chrome/browser/autofill/form_suggestion_constants.h"
#import "ios/chrome/browser/ui/infobars/infobar_constants.h"
#import "ios/chrome/test/app/tab_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_actions.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/web/public/js_messaging/web_frames_manager.h"
#import "ios/web/public/test/earl_grey/web_view_actions.h"
#import "ios/web/public/test/earl_grey/web_view_matchers.h"
#include "ios/web/public/test/element_selector.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#import "ios/web/public/test/element_selector.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -198,27 +191,26 @@
// A shared flow across many actions, this waits for the target element to be
// visible, scrolls it into view, then taps on it.
- (void)tapOnTarget:(ElementSelector*)selector {
web::WebState* web_state = chrome_test_util::GetCurrentWebState();
// Wait for the element to be visible on the page.
[ChromeEarlGrey waitForWebStateContainingElement:selector];
// Potentially scroll into view if below the fold.
[[EarlGrey selectElementWithMatcher:web::WebViewInWebState(web_state)]
performAction:WebViewScrollElementToVisible(web_state, selector)];
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
performAction:chrome_test_util::ScrollElementToVisible(selector)];
// Calling WebViewTapElement right after WebViewScrollElement caused flaky
// issues with the wrong location being provided for the tap target,
// seemingly caused by the screen not redrawing in-between these two actions.
// We force a brief wait here to avoid this issue.
[[GREYCondition conditionWithName:@"forced wait to allow for redraw"
// We force a brief wait here to avoid this issue. |waitWithTimeout| requires
// its result to be used. Void the result as it's always false.
(void)[[GREYCondition conditionWithName:@"forced wait to allow for redraw"
block:^BOOL {
return false;
}] waitWithTimeout:0.1];
// Tap on the element.
[[EarlGrey selectElementWithMatcher:web::WebViewInWebState(web_state)]
performAction:web::WebViewTapElement(web_state, selector)];
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
performAction:chrome_test_util::TapWebElement(selector)];
}
// Creates a selector targeting the element specified in the action.
......
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