OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_CHROME_TEST_APP_SYNC_TEST_UTIL_H_ |
| 6 #define IOS_CHROME_TEST_APP_SYNC_TEST_UTIL_H_ |
| 7 |
| 8 #import <Foundation/Foundation.h> |
| 9 #include <string> |
| 10 |
| 11 #include "components/sync/base/model_type.h" |
| 12 #include "url/gurl.h" |
| 13 |
| 14 namespace chrome_test_util { |
| 15 |
| 16 // Sets up a fake sync server to be used by the ProfileSyncService. |
| 17 void SetUpFakeSyncServer(); |
| 18 |
| 19 // Tears down the fake sync server used by the ProfileSyncService and restores |
| 20 // the real one. |
| 21 void TearDownFakeSyncServer(); |
| 22 |
| 23 // Starts the sync server. The server should not be running when calling this. |
| 24 void StartSync(); |
| 25 |
| 26 // Stops the sync server. The server should be running when calling this. |
| 27 void StopSync(); |
| 28 |
| 29 // Triggers a sync cycle for a |type|. |
| 30 void TriggerSyncCycle(syncer::ModelType type); |
| 31 |
| 32 // Gets the number of entities of the given |type|. |
| 33 int GetNumberOfSyncEntities(syncer::ModelType type); |
| 34 |
| 35 // Verifies that |count| entities of the given |type| and |name| exist on the |
| 36 // sync FakeServer. Folders are not included in this count. |
| 37 BOOL VerifyNumberOfSyncEntitiesWithName(syncer::ModelType type, |
| 38 std::string name, |
| 39 size_t count, |
| 40 NSError** error); |
| 41 |
| 42 // Injects a bookmark into the fake sync server with |url| and |title|. |
| 43 void InjectBookmarkOnFakeSyncServer(std::string url, std::string title); |
| 44 |
| 45 // Injects an autofill profile into the fake sync server with |guid| and |
| 46 // |full_name|. |
| 47 void InjectAutofillProfileOnFakeSyncServer(std::string guid, |
| 48 std::string full_name); |
| 49 |
| 50 // Deletes an autofill profile from the fake sync server with |guid|, if it |
| 51 // exists. If it doesn't exist, nothing is done. |
| 52 void DeleteAutofillProfileOnFakeSyncServer(std::string guid); |
| 53 |
| 54 // Clears the autofill profile for the given |guid|. |
| 55 void ClearAutofillProfile(std::string guid); |
| 56 |
| 57 // Clears fake sync server data. |
| 58 void ClearSyncServerData(); |
| 59 |
| 60 // Returns true if the sync backend server is intialized. |
| 61 bool IsSyncInitialized(); |
| 62 |
| 63 // Returns the current sync cache guid. The sync server must be running when |
| 64 // calling this. |
| 65 std::string GetSyncCacheGuid(); |
| 66 |
| 67 // Returns true if there is an autofilll profile with the corresponding |guid| |
| 68 // and |full_name|. |
| 69 bool IsAutofillProfilePresent(std::string guid, std::string full_name); |
| 70 |
| 71 // Verifies the sessions hierarchy on the Sync FakeServer. |expected_urls| is |
| 72 // the collection of URLs that are to be expected for a single window. On |
| 73 // failure, returns NO and |error| is set and includes a message. See the |
| 74 // SessionsHierarchy class for documentation regarding the verification. |
| 75 BOOL VerifySessionsOnSyncServer(const std::multiset<std::string>& expected_urls, |
| 76 NSError** error); |
| 77 |
| 78 // Adds typed URL into HistoryService. |
| 79 void AddTypedURLOnClient(const GURL& url); |
| 80 |
| 81 // Injects typed URL to sync FakeServer. |
| 82 void InjectTypedURLOnFakeSyncServer(const std::string& url); |
| 83 |
| 84 // Returns YES if the provided |url| is present (or not) if |expected_present| |
| 85 // is YES (or NO). |
| 86 BOOL IsTypedUrlPresentOnClient(const GURL& url, |
| 87 BOOL expect_present, |
| 88 NSError** error); |
| 89 |
| 90 // Deletes typed URL from HistoryService. |
| 91 void DeleteTypedUrlFromClient(const GURL& url); |
| 92 |
| 93 // Deletes typed URL on FakeServer by injecting a tombstone. |
| 94 void DeleteTypedUrlFromFakeSyncServer(std::string url); |
| 95 |
| 96 } // namespace chrome_test_util |
| 97 |
| 98 #endif // IOS_CHROME_TEST_APP_SYNC_TEST_UTIL_H_ |
OLD | NEW |