| Index: sync/tools/testserver/chromiumsync.py
|
| diff --git a/sync/tools/testserver/chromiumsync.py b/sync/tools/testserver/chromiumsync.py
|
| index 79eb1147e7bf035c1c1580cfe0ae2995e6b2c4cb..b7c25dd80ebc3f1da8fbbb14802abdd98d5b106b 100644
|
| --- a/sync/tools/testserver/chromiumsync.py
|
| +++ b/sync/tools/testserver/chromiumsync.py
|
| @@ -46,6 +46,7 @@ import password_specifics_pb2
|
| import preference_specifics_pb2
|
| import priority_preference_specifics_pb2
|
| import search_engine_specifics_pb2
|
| +import server_app_info_specifics_pb2
|
| import session_specifics_pb2
|
| import sync_pb2
|
| import sync_enums_pb2
|
| @@ -84,11 +85,12 @@ ALL_TYPES = (
|
| SEARCH_ENGINE,
|
| SESSION,
|
| SYNCED_NOTIFICATION,
|
| + SYNCED_NOTIFICATION_APP_INFO,
|
| THEME,
|
| TYPED_URL,
|
| EXTENSION_SETTINGS,
|
| FAVICON_IMAGES,
|
| - FAVICON_TRACKING) = range(29)
|
| + FAVICON_TRACKING) = range(30)
|
|
|
| # An enumeration on the frequency at which the server should send errors
|
| # to the client. This would be specified by the url that triggers the error.
|
| @@ -132,6 +134,7 @@ SYNC_TYPE_TO_DESCRIPTOR = {
|
| SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'],
|
| SESSION: SYNC_TYPE_FIELDS['session'],
|
| SYNCED_NOTIFICATION: SYNC_TYPE_FIELDS["synced_notification"],
|
| + SYNCED_NOTIFICATION_APP_INFO:SYNC_TYPE_FIELDS["app_info"],
|
| THEME: SYNC_TYPE_FIELDS['theme'],
|
| TYPED_URL: SYNC_TYPE_FIELDS['typed_url'],
|
| }
|
| @@ -545,6 +548,9 @@ class SyncDataModel(object):
|
| PermanentItem('google_chrome_synced_notifications',
|
| name='Synced Notifications',
|
| parent_tag=ROOT_ID, sync_type=SYNCED_NOTIFICATION),
|
| + PermanentItem('google_chrome_synced_notification_app_info',
|
| + name='Synced Notification App Info',
|
| + parent_tag=ROOT_ID, sync_type=SYNCED_NOTIFICATION_APP_INFO),
|
| PermanentItem('google_chrome_search_engines', name='Search Engines',
|
| parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE),
|
| PermanentItem('google_chrome_sessions', name='Sessions',
|
| @@ -1224,7 +1230,6 @@ class SyncDataModel(object):
|
|
|
| return specifics
|
|
|
| -
|
| def _CreateSyncedNotificationClientTag(self, key):
|
| """Create the client_defined_unique_tag value for a SyncedNotification.
|
|
|
| @@ -1240,6 +1245,50 @@ class SyncDataModel(object):
|
| hash_input = serialized_type.SerializeToString() + key
|
| return base64.b64encode(hashlib.sha1(hash_input).digest())
|
|
|
| + def AddSyncedNotificationAppInfo(self, app_info):
|
| + """Adds an app info struct to the server data.
|
| +
|
| + The notification will be delivered to the client on the next GetUpdates
|
| + call.
|
| +
|
| + Args:
|
| + app_info: A serialized AppInfo.
|
| +
|
| + Returns:
|
| + The string representation of the added SyncEntity.
|
| +
|
| + Raises:
|
| + ClientNotConnectedError: if the client has not yet connected to this
|
| + server
|
| + """
|
| + # A unique string used wherever a unique ID for this notification is
|
| + # required.
|
| + unique_notification_id = str(uuid.uuid4())
|
| +
|
| + specifics = self._AppInfoEntitySpecifics(
|
| + unique_notification_id, app_info)
|
| +
|
| + # Create the root SyncEntity representing a single app info protobuf.
|
| + entity = sync_pb2.SyncEntity()
|
| + entity.specifics.CopyFrom(specifics)
|
| + entity.parent_id_string = self._ServerTagToId(
|
| + 'google_chrome_synced_notifications_app_info')
|
| + entity.name = 'App info added for testing'
|
| + entity.server_defined_unique_tag = unique_notification_id
|
| +
|
| + # Set the version to one more than the greatest version number already seen.
|
| + entries = sorted(self._entries.values(), key=operator.attrgetter('version'))
|
| + if len(entries) < 1:
|
| + raise ClientNotConnectedError
|
| + entity.version = entries[-1].version + 1
|
| +
|
| + entity.client_defined_unique_tag = entity.id_string
|
| + entity.id_string = entity.id_string
|
| +
|
| + self._entries[entity.id_string] = copy.deepcopy(entity)
|
| +
|
| + return google.protobuf.text_format.MessageToString(entity)
|
| +
|
|
|
| class TestServer(object):
|
| """An object to handle requests for one (and only one) Chrome Sync account.
|
|
|