Commit a59d659b authored by Eugene But's avatar Eugene But Committed by Commit Bot

Port ScopedSynchronizationDisabler to EG2.

GREYConfiguration API has changed for EG2, so this CL uses different
methods depending on compiler defines. Also added a separate EG2 target
for ScopedSynchronizationDisabler.

Bug: 987646
Change-Id: I4005a8c12a149492642aeaa61bf6c7c5eabb7a82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1726370
Commit-Queue: Eugene But <eugenebut@chromium.org>
Auto-Submit: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683351}
parent 2ee180e1
......@@ -67,6 +67,7 @@ source_set("test_support") {
}
source_set("eg_test_support") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
......@@ -74,12 +75,31 @@ source_set("eg_test_support") {
"scoped_eg_synchronization_disabler.mm",
]
deps = [
":test_support",
"//base:base",
"//base",
"//ios/testing/earl_grey:earl_grey_support",
"//ios/third_party/earl_grey:earl_grey+link",
]
}
source_set("eg_test_support+eg2") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"scoped_eg_synchronization_disabler.h",
"scoped_eg_synchronization_disabler.mm",
]
deps = [
"//base",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
]
libs = [ "XCTest.framework" ]
}
source_set("block_cleanup_test") {
# TODO(crbug.com/733237): Replace this comment with an explicit disable_arc config.
# The files in this target depend on non-ARC memory management.
......
......@@ -4,12 +4,26 @@
#import "ios/chrome/test/scoped_eg_synchronization_disabler.h"
#import <EarlGrey/EarlGrey.h>
#import "ios/testing/earl_grey/earl_grey_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
// EG1 and EG2 have different API to obtain shared GREYConfiguration object.
// This function abstracts the API access.
GREYConfiguration* GetSharedGREYConfiguration() {
#if defined(CHROME_EARL_GREY_1)
return [GREYConfiguration sharedInstance];
#elif defined(CHROME_EARL_GREY_2)
return [GREYConfiguration sharedConfiguration];
#else
#error Either CHROME_EARL_GREY_1 or CHROME_EARL_GREY_2 must be defined
#endif
}
} // namespace
ScopedSynchronizationDisabler::ScopedSynchronizationDisabler()
: saved_eg_synchronization_enabled_value_(GetEgSynchronizationEnabled()) {
SetEgSynchronizationEnabled(NO);
......@@ -20,12 +34,11 @@ ScopedSynchronizationDisabler::~ScopedSynchronizationDisabler() {
}
bool ScopedSynchronizationDisabler::GetEgSynchronizationEnabled() {
return [[GREYConfiguration sharedInstance]
return [GetSharedGREYConfiguration()
boolValueForConfigKey:kGREYConfigKeySynchronizationEnabled];
}
void ScopedSynchronizationDisabler::SetEgSynchronizationEnabled(BOOL flag) {
[[GREYConfiguration sharedInstance]
setValue:@(flag)
forConfigKey:kGREYConfigKeySynchronizationEnabled];
[GetSharedGREYConfiguration() setValue:@(flag)
forConfigKey:kGREYConfigKeySynchronizationEnabled];
}
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