Commit e30dc321 authored by Maksym Onufriienko's avatar Maksym Onufriienko Committed by Commit Bot

Replace [GREYConfiguration sharedInstance] with ScopedSynchronizationDisabler.

This is part of EG1 to EG2 migration, which involves moving
EarlGrey code from app-side helpers into test code.
EarlGrey2 has multiprocess architecture,
where Chrome Test and Chrome App are separate processes

Change-Id: Ib41116bb8df8c8383ad8a76460d5643560983716
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1732157
Commit-Queue: Maksym Onufriienko <monufriienko@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683767}
parent 529c3c87
......@@ -514,6 +514,7 @@ source_set("eg_tests") {
"//ios/chrome/app/strings",
"//ios/chrome/browser/autofill:autofill_shared",
"//ios/chrome/browser/ui/util",
"//ios/chrome/test:eg_test_support",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/testing/earl_grey:earl_grey_support",
......
......@@ -16,6 +16,7 @@
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/chrome/test/scoped_eg_synchronization_disabler.h"
#import "ios/web/public/deprecated/crw_js_injection_receiver.h"
#import "ios/web/public/test/earl_grey/web_view_actions.h"
#import "ios/web/public/test/earl_grey/web_view_matchers.h"
......@@ -27,6 +28,9 @@
#error "This file requires ARC support."
#endif
using base::test::ios::kWaitForUIElementTimeout;
using base::test::ios::WaitUntilConditionOrTimeout;
using chrome_test_util::WebViewMatcher;
namespace {
......@@ -55,8 +59,7 @@ void AssertElementIsFocused(const std::string& element_id) {
ConditionBlock condition = ^{
return base::SysNSStringToUTF8(GetFocusedElementId()) == element_id;
};
GREYAssert(base::test::ios::WaitUntilConditionOrTimeout(10, condition),
description);
GREYAssert(WaitUntilConditionOrTimeout(10, condition), description);
}
} // namespace
......@@ -68,12 +71,6 @@ void AssertElementIsFocused(const std::string& element_id) {
@implementation FormInputTestCase
- (void)tearDown {
// |testFindDefaultFormAssistControls| disables synchronization.
// This makes sure it is enabled if that test has failed and did not enable it
// back.
[[GREYConfiguration sharedInstance]
setValue:@YES
forConfigKey:kGREYConfigKeySynchronizationEnabled];
[super tearDown];
}
......@@ -96,9 +93,8 @@ void AssertElementIsFocused(const std::string& element_id) {
[ChromeEarlGrey waitForWebStateContainingText:"hello!"];
// Opening the keyboard from a webview blocks EarlGrey's synchronization.
[[GREYConfiguration sharedInstance]
setValue:@NO
forConfigKey:kGREYConfigKeySynchronizationEnabled];
{
ScopedSynchronizationDisabler disabler;
// Brings up the keyboard by tapping on one of the form's field.
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
......@@ -118,7 +114,8 @@ void AssertElementIsFocused(const std::string& element_id) {
IDS_IOS_AUTOFILL_ACCNAME_HIDE_KEYBOARD);
// Wait until the keyboard's "Next" button appeared.
NSString* description = @"Wait for the keyboard's \"Next\" button to appear.";
NSString* description =
@"Wait for the keyboard's \"Next\" button to appear.";
ConditionBlock condition = ^{
NSError* error = nil;
[[EarlGrey selectElementWithMatcher:nextButtonMatcher]
......@@ -126,8 +123,7 @@ void AssertElementIsFocused(const std::string& element_id) {
error:&error];
return (error == nil);
};
GREYAssert(base::test::ios::WaitUntilConditionOrTimeout(
base::test::ios::kWaitForUIElementTimeout, condition),
GREYAssert(WaitUntilConditionOrTimeout(kWaitForUIElementTimeout, condition),
description);
base::test::ios::SpinRunLoopWithMinDelay(base::TimeDelta::FromSeconds(1));
......@@ -147,10 +143,7 @@ void AssertElementIsFocused(const std::string& element_id) {
// Tap the "Close" button.
[[EarlGrey selectElementWithMatcher:closeButtonMatcher]
performAction:grey_tap()];
[[GREYConfiguration sharedInstance]
setValue:@YES
forConfigKey:kGREYConfigKeySynchronizationEnabled];
}
}
// Tests that trying to programmatically dismiss the keyboard when it isn't
......
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