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

Convert sync-methods to compile under EG2.

Convert sync-methods to compile under EG2:
-numberOfSyncEntitiesWithType
-injectBookmarkOnFakeSyncServerWithURL
-triggerSyncCycleForType
-injectTypedURLOnFakeSyncServer
-deleteAutofillProfileOnFakeSyncServerWithGUID

Bug: 922813
Change-Id: I0b74ecf5061915c9424721845be830128956aea6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1628605
Commit-Queue: Maksym Onufriienko <monufriienko@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665812}
parent 1ff49c20
......@@ -121,8 +121,8 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
// client.
- (void)testSyncDownloadBookmark {
[[self class] assertBookmarksWithTitle:@"hoo" expectedCount:0];
[ChromeEarlGrey injectBookmarkOnFakeSyncServerWithURL:"http://www.hoo.com"
bookmarkTitle:"hoo"];
const GURL URL = web::test::HttpServer::MakeUrl("http://www.hoo.com");
[ChromeEarlGrey addFakeSyncServerBookmarkWithURL:URL title:"hoo"];
// Sign in to sync, after a bookmark has been injected in the sync server.
ChromeIdentity* identity = [SigninEarlGreyUtils fakeIdentity1];
......@@ -408,7 +408,7 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
[self setTearDownHandler:^{
[ChromeEarlGrey clearBrowsingHistory];
}];
[ChromeEarlGrey addTypedURL:mockURL];
[ChromeEarlGrey addHistoryServiceTypedURL:mockURL];
// Sign in to sync.
ChromeIdentity* identity = [SigninEarlGreyUtils fakeIdentity1];
......@@ -439,7 +439,7 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
}];
// Inject typed url on server.
[ChromeEarlGrey injectTypedURLOnFakeSyncServer:mockURL.spec()];
[ChromeEarlGrey addFakeSyncServerTypedURL:mockURL];
// Sign in to sync.
ChromeIdentity* identity = [SigninEarlGreyUtils fakeIdentity1];
......@@ -469,7 +469,7 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
}];
// Inject typed url on server.
[ChromeEarlGrey injectTypedURLOnFakeSyncServer:mockURL.spec()];
[ChromeEarlGrey addFakeSyncServerTypedURL:mockURL];
// Sign in to sync.
ChromeIdentity* identity = [SigninEarlGreyUtils fakeIdentity1];
......@@ -507,7 +507,7 @@ void AssertNumberOfEntities(int entity_count, syncer::ModelType entity_type) {
[self setTearDownHandler:^{
[ChromeEarlGrey clearBrowsingHistory];
}];
[ChromeEarlGrey addTypedURL:mockURL];
[ChromeEarlGrey addHistoryServiceTypedURL:mockURL];
// Sign in to sync.
ChromeIdentity* identity = [SigninEarlGreyUtils fakeIdentity1];
......
......@@ -344,6 +344,7 @@ source_set("eg_app_support+eg2") {
"//base/test:test_support",
"//components/signin/core/browser",
"//components/strings",
"//components/sync/base",
"//components/unified_consent",
"//ios/chrome/app/strings",
"//ios/chrome/browser/ui/authentication/cells",
......
......@@ -146,6 +146,26 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// the real one.
- (void)tearDownFakeSyncServer;
// Gets the number of entities of the given |type|.
- (int)numberOfSyncEntitiesWithType:(syncer::ModelType)type WARN_UNUSED_RESULT;
// Adds typed URL into HistoryService.
- (void)addHistoryServiceTypedURL:(const GURL&)URL;
// Injects a bookmark with |URL| and |title| into the fake sync server.
- (void)addFakeSyncServerBookmarkWithURL:(const GURL&)URL
title:(const std::string&)title;
// Injects typed URL to sync FakeServer.
- (void)addFakeSyncServerTypedURL:(const GURL&)URL;
// Triggers a sync cycle for a |type|.
- (void)triggerSyncCycleForType:(syncer::ModelType)type;
// Deletes an autofill profile from the fake sync server with |GUID|, if it
// exists. If it doesn't exist, nothing is done.
- (void)deleteAutofillProfileOnFakeSyncServerWithGUID:(const std::string&)GUID;
// 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
......@@ -363,19 +383,10 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
#pragma mark - Sync Utilities
// Gets the number of entities of the given |type|.
- (int)numberOfSyncEntitiesWithType:(syncer::ModelType)type WARN_UNUSED_RESULT;
// Injects a bookmark into the fake sync server with |URL| and |title|.
- (void)injectBookmarkOnFakeSyncServerWithURL:(const std::string&)URL
bookmarkTitle:(const std::string&)title;
// Adds typed URL into HistoryService.
- (void)addTypedURL:(const GURL&)URL;
// Triggers a sync cycle for a |type|.
- (void)triggerSyncCycleForType:(syncer::ModelType)type;
// If the provided |url| is present (or not) if |expected_present|
// is YES (or NO) returns nil, otherwise an NSError indicating why the operation
// failed.
......@@ -386,13 +397,6 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// Deletes typed URL from HistoryService.
- (void)deleteTypedURL:(const GURL&)URL;
// Injects typed URL to sync FakeServer.
- (void)injectTypedURLOnFakeSyncServer:(const std::string&)URL;
// Deletes an autofill profile from the fake sync server with |GUID|, if it
// exists. If it doesn't exist, nothing is done.
- (void)deleteAutofillProfileOnFakeSyncServerWithGUID:(const std::string&)GUID;
@end
#endif // IOS_CHROME_TEST_EARL_GREY_CHROME_EARL_GREY_H_
......@@ -398,28 +398,28 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
[ChromeEarlGreyAppInterface stopSync];
}
- (void)clearAutofillProfileWithGUID:(const std::string&)GUID {
NSString* nsGUID = base::SysUTF8ToNSString(GUID);
[ChromeEarlGreyAppInterface clearAutofillProfileWithGUID:nsGUID];
- (void)clearAutofillProfileWithGUID:(const std::string&)UTF8GUID {
NSString* GUID = base::SysUTF8ToNSString(UTF8GUID);
[ChromeEarlGreyAppInterface clearAutofillProfileWithGUID:GUID];
}
- (void)injectAutofillProfileOnFakeSyncServerWithGUID:(const std::string&)GUID
- (void)injectAutofillProfileOnFakeSyncServerWithGUID:
(const std::string&)UTF8GUID
autofillProfileName:
(const std::string&)fullName {
NSString* nsGUID = base::SysUTF8ToNSString(GUID);
NSString* nsFullName = base::SysUTF8ToNSString(fullName);
(const std::string&)UTF8FullName {
NSString* GUID = base::SysUTF8ToNSString(UTF8GUID);
NSString* fullName = base::SysUTF8ToNSString(UTF8FullName);
[ChromeEarlGreyAppInterface
injectAutofillProfileOnFakeSyncServerWithGUID:nsGUID
autofillProfileName:nsFullName];
injectAutofillProfileOnFakeSyncServerWithGUID:GUID
autofillProfileName:fullName];
}
- (BOOL)isAutofillProfilePresentWithGUID:(const std::string&)GUID
autofillProfileName:(const std::string&)fullName {
NSString* nsGUID = base::SysUTF8ToNSString(GUID);
NSString* nsFullName = base::SysUTF8ToNSString(fullName);
return
[ChromeEarlGreyAppInterface isAutofillProfilePresentWithGUID:nsGUID
autofillProfileName:nsFullName];
- (BOOL)isAutofillProfilePresentWithGUID:(const std::string&)UTF8GUID
autofillProfileName:(const std::string&)UTF8FullName {
NSString* GUID = base::SysUTF8ToNSString(UTF8GUID);
NSString* fullName = base::SysUTF8ToNSString(UTF8FullName);
return [ChromeEarlGreyAppInterface isAutofillProfilePresentWithGUID:GUID
autofillProfileName:fullName];
}
- (void)setUpFakeSyncServer {
......@@ -430,6 +430,39 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
[ChromeEarlGreyAppInterface tearDownFakeSyncServer];
}
- (int)numberOfSyncEntitiesWithType:(syncer::ModelType)type {
return [ChromeEarlGreyAppInterface numberOfSyncEntitiesWithType:type];
}
- (void)addFakeSyncServerBookmarkWithURL:(const GURL&)URL
title:(const std::string&)UTF8Title {
NSString* spec = base::SysUTF8ToNSString(URL.spec());
NSString* title = base::SysUTF8ToNSString(UTF8Title);
[ChromeEarlGreyAppInterface addFakeSyncServerBookmarkWithURL:spec
title:title];
}
- (void)addFakeSyncServerTypedURL:(const GURL&)URL {
NSString* spec = base::SysUTF8ToNSString(URL.spec());
[ChromeEarlGreyAppInterface addFakeSyncServerTypedURL:spec];
}
- (void)addHistoryServiceTypedURL:(const GURL&)URL {
NSString* spec = base::SysUTF8ToNSString(URL.spec());
[ChromeEarlGreyAppInterface addHistoryServiceTypedURL:spec];
}
- (void)triggerSyncCycleForType:(syncer::ModelType)type {
[ChromeEarlGreyAppInterface triggerSyncCycleForType:type];
}
- (void)deleteAutofillProfileOnFakeSyncServerWithGUID:
(const std::string&)UTF8GUID {
NSString* GUID = base::SysUTF8ToNSString(UTF8GUID);
[ChromeEarlGreyAppInterface
deleteAutofillProfileOnFakeSyncServerWithGUID:GUID];
}
- (NSError*)waitForSyncInitialized:(BOOL)isInitialized
syncTimeout:(NSTimeInterval)timeout {
EG_TEST_HELPER_ASSERT_NO_ERROR([ChromeEarlGreyAppInterface
......@@ -578,23 +611,11 @@ id ExecuteJavaScript(NSString* javascript,
#pragma mark - Sync Utilities
- (int)numberOfSyncEntitiesWithType:(syncer::ModelType)type {
return chrome_test_util::GetNumberOfSyncEntities(type);
}
- (void)injectBookmarkOnFakeSyncServerWithURL:(const std::string&)URL
bookmarkTitle:(const std::string&)title {
chrome_test_util::InjectBookmarkOnFakeSyncServer(URL, title);
}
- (void)addTypedURL:(const GURL&)URL {
chrome_test_util::AddTypedURLOnClient(URL);
}
- (void)triggerSyncCycleForType:(syncer::ModelType)type {
chrome_test_util::TriggerSyncCycle(type);
}
- (NSError*)waitForTypedURL:(const GURL&)URL
expectPresent:(BOOL)expectPresent
timeout:(NSTimeInterval)timeout {
......@@ -622,14 +643,6 @@ id ExecuteJavaScript(NSString* javascript,
chrome_test_util::DeleteTypedUrlFromClient(URL);
}
- (void)injectTypedURLOnFakeSyncServer:(const std::string&)URL {
chrome_test_util::InjectTypedURLOnFakeSyncServer(URL);
}
- (void)deleteAutofillProfileOnFakeSyncServerWithGUID:(const std::string&)GUID {
chrome_test_util::DeleteAutofillProfileOnFakeSyncServer(GUID);
}
@end
#endif // defined(CHROME_EARL_GREY_1)
......@@ -8,6 +8,7 @@
#import <Foundation/Foundation.h>
#import "components/content_settings/core/common/content_settings.h"
#import "components/sync/base/model_type.h"
@class ElementSelector;
......@@ -150,6 +151,8 @@
// success, or else an NSError indicating why the operation failed.
+ (NSError*)signOutAndClearAccounts;
#pragma mark - Sync Utilities
// Clears the autofill profile for the given |GUID|.
+ (void)clearAutofillProfileWithGUID:(NSString*)GUID;
......@@ -202,6 +205,25 @@
// the real one.
+ (void)tearDownFakeSyncServer;
// Gets the number of entities of the given |type|.
+ (int)numberOfSyncEntitiesWithType:(syncer::ModelType)type;
// Injects a bookmark into the fake sync server with |URL| and |title|.
+ (void)addFakeSyncServerBookmarkWithURL:(NSString*)URL title:(NSString*)title;
// Injects typed URL to sync FakeServer.
+ (void)addFakeSyncServerTypedURL:(NSString*)URL;
// Adds typed URL into HistoryService.
+ (void)addHistoryServiceTypedURL:(NSString*)URL;
// Triggers a sync cycle for a |type|.
+ (void)triggerSyncCycleForType:(syncer::ModelType)type;
// Deletes an autofill profile from the fake sync server with |GUID|, if it
// exists. If it doesn't exist, nothing is done.
+ (void)deleteAutofillProfileOnFakeSyncServerWithGUID:(NSString*)GUID;
// 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
......
......@@ -250,6 +250,8 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC;
return nil;
}
#pragma mark - Sync Utilities
+ (void)clearAutofillProfileWithGUID:(NSString*)GUID {
std::string utfGUID = base::SysNSStringToUTF8(GUID);
chrome_test_util::ClearAutofillProfile(utfGUID);
......@@ -291,6 +293,33 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC;
return nil;
}
+ (int)numberOfSyncEntitiesWithType:(syncer::ModelType)type {
return chrome_test_util::GetNumberOfSyncEntities(type);
}
+ (void)addFakeSyncServerBookmarkWithURL:(NSString*)URL title:(NSString*)title {
chrome_test_util::InjectBookmarkOnFakeSyncServer(
base::SysNSStringToUTF8(URL), base::SysNSStringToUTF8(title));
}
+ (void)addFakeSyncServerTypedURL:(NSString*)URL {
chrome_test_util::InjectTypedURLOnFakeSyncServer(
base::SysNSStringToUTF8(URL));
}
+ (void)addHistoryServiceTypedURL:(NSString*)URL {
chrome_test_util::AddTypedURLOnClient(GURL(base::SysNSStringToUTF8(URL)));
}
+ (void)triggerSyncCycleForType:(syncer::ModelType)type {
chrome_test_util::TriggerSyncCycle(type);
}
+ (void)deleteAutofillProfileOnFakeSyncServerWithGUID:(NSString*)GUID {
chrome_test_util::DeleteAutofillProfileOnFakeSyncServer(
base::SysNSStringToUTF8(GUID));
}
#pragma mark - Sync Utilities (EG2)
+ (void)clearSyncServerData {
......
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