Commit 16af8671 authored by Eric Aleshire's avatar Eric Aleshire Committed by Commit Bot

Convert verifySyncServerURLs to build under EG2.

The signature for the function is changed for simplicity, as there is
only one callsite for this helper. Confirmed test works on EG1.

Bug: 922813
Change-Id: I2684bd847e072da5f060eb8766f8e27101081c66
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636279
Commit-Queue: ericale <ericale@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665692}
parent e0b037c2
...@@ -392,9 +392,11 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) { ...@@ -392,9 +392,11 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
syncTimeout:kSyncOperationTimeout]); syncTimeout:kSyncOperationTimeout]);
AssertNumberOfEntities(3, syncer::SESSIONS); AssertNumberOfEntities(3, syncer::SESSIONS);
CHROME_EG_ASSERT_NO_ERROR( NSArray<NSString*>* specs = @[
[ChromeEarlGrey verifySyncServerURLs:(std::multiset<std::string>{ base::SysUTF8ToNSString(URL1.spec()),
URL1.spec(), URL2.spec()})]); base::SysUTF8ToNSString(URL2.spec()),
];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey verifySyncServerURLs:specs]);
} }
// Tests that a typed URL (after Sync is enabled) is uploaded to the Sync // Tests that a typed URL (after Sync is enabled) is uploaded to the Sync
......
...@@ -146,6 +146,14 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error); ...@@ -146,6 +146,14 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// the real one. // the real one.
- (void)tearDownFakeSyncServer; - (void)tearDownFakeSyncServer;
// Verifies the sessions hierarchy on the Sync FakeServer. |URLs| is
// the collection of URLs that are to be expected for a single window. A
// GREYAssert is induced on failure. See the SessionsHierarchy class for
// documentation regarding the verification.
// TODO(crbug.com/963613): Change return type to void when
// CHROME_EG_ASSERT_NO_ERROR is removed.
- (NSError*)verifySyncServerURLs:(NSArray<NSString*>*)URLs;
#pragma mark - Tab Utilities (EG2) #pragma mark - Tab Utilities (EG2)
// Opens a new tab and waits for the new tab animation to complete within a // Opens a new tab and waits for the new tab animation to complete within a
...@@ -377,13 +385,6 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error); ...@@ -377,13 +385,6 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// exists. If it doesn't exist, nothing is done. // exists. If it doesn't exist, nothing is done.
- (void)deleteAutofillProfileOnFakeSyncServerWithGUID:(const std::string&)GUID; - (void)deleteAutofillProfileOnFakeSyncServerWithGUID:(const std::string&)GUID;
// Verifies the sessions hierarchy on the Sync FakeServer. |expected_urls| is
// the collection of URLs that are to be expected for a single window. Returns
// nil on success, or else an NSError indicating why the operation failed. See
// the SessionsHierarchy class for documentation regarding the verification.
- (NSError*)verifySyncServerURLs:(const std::multiset<std::string>&)URLs
WARN_UNUSED_RESULT;
@end @end
#endif // IOS_CHROME_TEST_EARL_GREY_CHROME_EARL_GREY_H_ #endif // IOS_CHROME_TEST_EARL_GREY_CHROME_EARL_GREY_H_
...@@ -390,6 +390,13 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface) ...@@ -390,6 +390,13 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
return base::SysNSStringToUTF8(cacheGUID); return base::SysNSStringToUTF8(cacheGUID);
} }
- (NSError*)verifySyncServerURLs:(NSArray<NSString*>*)URLs {
EG_TEST_HELPER_ASSERT_NO_ERROR(
[ChromeEarlGreyAppInterface verifySessionsOnSyncServerWithSpecs:URLs]);
return nil;
}
#pragma mark - SignIn Utilities #pragma mark - SignIn Utilities
- (NSError*)signOutAndClearAccounts { - (NSError*)signOutAndClearAccounts {
...@@ -630,21 +637,6 @@ id ExecuteJavaScript(NSString* javascript, ...@@ -630,21 +637,6 @@ id ExecuteJavaScript(NSString* javascript,
chrome_test_util::DeleteAutofillProfileOnFakeSyncServer(GUID); chrome_test_util::DeleteAutofillProfileOnFakeSyncServer(GUID);
} }
- (NSError*)verifySyncServerURLs:(const std::multiset<std::string>&)URLs {
NSError* error = nil;
NSError* __autoreleasing tempError = error;
BOOL success = chrome_test_util::VerifySessionsOnSyncServer(URLs, &tempError);
error = tempError;
if (error != nil) {
return error;
}
if (!success) {
return testing::NSErrorWithLocalizedDescription(
@"Error occurred during verification sessions.");
}
return nil;
}
@end @end
#endif // defined(CHROME_EARL_GREY_1) #endif // defined(CHROME_EARL_GREY_1)
...@@ -187,6 +187,12 @@ ...@@ -187,6 +187,12 @@
// the real one. // the real one.
+ (void)tearDownFakeSyncServer; + (void)tearDownFakeSyncServer;
// Verifies the sessions hierarchy on the Sync FakeServer. |specs| is
// the collection of URLs that are to be expected for a single window. On
// failure, returns a NSError describing the failure. See the
// SessionsHierarchy class for documentation regarding the verification.
+ (NSError*)verifySessionsOnSyncServerWithSpecs:(NSArray<NSString*>*)specs;
#pragma mark - JavaScript Utilities (EG2) #pragma mark - JavaScript Utilities (EG2)
// Executes JavaScript on current WebState, and waits for either the completion // Executes JavaScript on current WebState, and waits for either the completion
......
...@@ -297,6 +297,23 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC; ...@@ -297,6 +297,23 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC;
chrome_test_util::TearDownFakeSyncServer(); chrome_test_util::TearDownFakeSyncServer();
} }
+ (NSError*)verifySessionsOnSyncServerWithSpecs:(NSArray<NSString*>*)specs {
std::multiset<std::string> multisetSpecs;
for (NSString* spec in specs) {
multisetSpecs.insert(base::SysNSStringToUTF8(spec));
}
NSError* __autoreleasing tempError = nil;
bool success =
chrome_test_util::VerifySessionsOnSyncServer(multisetSpecs, &tempError);
NSError* error = tempError;
if (!success && !error) {
error = testing::NSErrorWithLocalizedDescription(
@"Error occurred during verification sessions.");
}
return error;
}
+ (id)executeJavaScript:(NSString*)javaScript error:(NSError**)outError { + (id)executeJavaScript:(NSString*)javaScript error:(NSError**)outError {
__block bool handlerCalled = false; __block bool handlerCalled = false;
__block id blockResult = nil; __block id blockResult = nil;
......
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