diff options
author | mferreria@chromium.org <mferreria@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 19:50:30 +0000 |
---|---|---|
committer | mferreria@chromium.org <mferreria@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 19:50:30 +0000 |
commit | 0706341097163814a7bacf89aec118ebfd5ba69c (patch) | |
tree | b8b73237bb393fcf54f2c3410d3e08186e6ff819 | |
parent | e82a750a739a620495eaee902dd7759cdb1e20a1 (diff) | |
download | chromium_src-0706341097163814a7bacf89aec118ebfd5ba69c.zip chromium_src-0706341097163814a7bacf89aec118ebfd5ba69c.tar.gz chromium_src-0706341097163814a7bacf89aec118ebfd5ba69c.tar.bz2 |
Removed redundant notifications info from about:sync-internals
This patch removes the tab 'Notifications' from about:sync-internals.
This tab used to be useful for debugging notifications as they arrived,
but now that its functionality has been replaced and augmented
in the new about:invalidations, with more general functionality and extended
logging information, it is no longer necessary to have it here.
BUG=351559
Review URL: https://codereview.chromium.org/196373004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257182 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/sync_internals/chrome_sync.js | 5 | ||||
-rw-r--r-- | chrome/browser/resources/sync_internals/notifications.html | 25 | ||||
-rw-r--r-- | chrome/browser/resources/sync_internals/notifications.js | 101 | ||||
-rw-r--r-- | chrome/browser/resources/sync_internals/sync_index.html | 4 | ||||
-rw-r--r-- | chrome/browser/resources/sync_internals_resources.grd | 1 | ||||
-rw-r--r-- | chrome/browser/ui/webui/sync_internals_ui.cc | 2 | ||||
-rw-r--r-- | sync/internal_api/public/sync_manager.h | 28 | ||||
-rw-r--r-- | sync/internal_api/sync_manager_impl.cc | 124 | ||||
-rw-r--r-- | sync/internal_api/sync_manager_impl.h | 14 | ||||
-rw-r--r-- | sync/internal_api/sync_manager_impl_unittest.cc | 108 |
10 files changed, 3 insertions, 409 deletions
diff --git a/chrome/browser/resources/sync_internals/chrome_sync.js b/chrome/browser/resources/sync_internals/chrome_sync.js index e624739..81793d4 100644 --- a/chrome/browser/resources/sync_internals/chrome_sync.js +++ b/chrome/browser/resources/sync_internals/chrome_sync.js @@ -34,11 +34,6 @@ cr.define('chrome.sync', function() { } var syncFunctions = [ - // Notification functions. See chrome/browser/sync/engine/syncapi.h - // for docs. - 'getNotificationState', - 'getNotificationInfo', - // Client server communication logging functions. 'getClientServerTraffic', diff --git a/chrome/browser/resources/sync_internals/notifications.html b/chrome/browser/resources/sync_internals/notifications.html deleted file mode 100644 index 652fcd8..0000000 --- a/chrome/browser/resources/sync_internals/notifications.html +++ /dev/null @@ -1,25 +0,0 @@ -<script src="chrome://sync-internals/notifications.js"></script> - -<style> -table#notificationInfo tr:nth-child(odd) { - background: #eff3ff; -} -</style> - -<p id='notificationStateInfo'> - State: <span jscontent='notificationState'></span> -</p> -<table id='notificationInfo'> - <tr> - <th>Type</th> - <th>Total count</th> - <th>Session count</th> - <th>Payload</th> - </tr> - <tr jsselect='notifications'> - <td jscontent='type'></td> - <td jscontent='totalCount'></td> - <td jscontent='sessionCount'></td> - <td jscontent='payload'></td> - </tr> -</table> diff --git a/chrome/browser/resources/sync_internals/notifications.js b/chrome/browser/resources/sync_internals/notifications.js deleted file mode 100644 index b355fb4..0000000 --- a/chrome/browser/resources/sync_internals/notifications.js +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -(function() { - -// TODO(akalin): Use table.js. - -function updateNotificationStateInfo(notificationState) { - var notificationStateInfo = $('notificationStateInfo'); - jstProcess( - new JsEvalContext({ 'notificationState': notificationState }), - notificationStateInfo); -} - -// Contains all notification data. The keys are sync types (as strings) and -// the value is a dictionary with: -// -// type: the sync type again (for convenience when using JsTemplate) -// totalCount: Number of notifications received since browser start. -// sessionCount: Number of notifications received this -// chrome://sync-internals session. -// payload: The last received payload. -// -chrome.sync.notifications = {}; - -/** - * Merges d1 and d2 (with d2 taking precedence) and returns the result. - */ -function mergeDictionaries(d1, d2) { - var d = {}; - for (var k in d1) { - d[k] = d1[k]; - } - for (var k in d2) { - d[k] = d2[k]; - } - return d; -} - -/** - * Merge notificationInfo into chrome.sync.notifications. - */ -function updateNotificationsFromNotificationInfo(notificationInfo) { - for (var k in notificationInfo) { - chrome.sync.notifications[k] = - mergeDictionaries(chrome.sync.notifications[k] || {}, - notificationInfo[k]); - // notificationInfo[k] has values for the totalCount and payload keys, - // so fill in the rest (if necessary). - chrome.sync.notifications[k].type = k; - chrome.sync.notifications[k].sessionCount = - chrome.sync.notifications[k].sessionCount || 0; - } -} - -function incrementSessionNotificationCount(changedType) { - chrome.sync.notifications[changedType].sessionCount = - chrome.sync.notifications[changedType].sessionCount || 0; - ++chrome.sync.notifications[changedType].sessionCount; -} - -function updateNotificationInfoTable() { - var notificationInfoTable = $('notificationInfo'); - var infos = []; - for (var k in chrome.sync.notifications) { - infos.push(chrome.sync.notifications[k]); - } - jstProcess(new JsEvalContext({ 'notifications': infos }), - notificationInfoTable); -} - -function updateNotificationInfo(notificationInfo) { - updateNotificationsFromNotificationInfo(notificationInfo); - updateNotificationInfoTable(); -} - -function onLoad() { - chrome.sync.getNotificationState(updateNotificationStateInfo); - chrome.sync.getNotificationInfo(updateNotificationInfo); - - chrome.sync.events.addEventListener( - 'onNotificationStateChange', - function(e) { - updateNotificationStateInfo(e.details.state); - }); - - chrome.sync.events.addEventListener('onIncomingNotification', function(e) { - var changedTypes = e.details.changedTypes; - for (var i = 0; i < changedTypes.length; ++i) { - incrementSessionNotificationCount(changedTypes[i]); - } - updateNotificationInfoTable(); - - // Also update total counts. - chrome.sync.getNotificationInfo(updateNotificationInfo); - }); -} - -document.addEventListener('DOMContentLoaded', onLoad, false); -})(); diff --git a/chrome/browser/resources/sync_internals/sync_index.html b/chrome/browser/resources/sync_internals/sync_index.html index 05e3f29..a6241af 100644 --- a/chrome/browser/resources/sync_internals/sync_index.html +++ b/chrome/browser/resources/sync_internals/sync_index.html @@ -56,7 +56,6 @@ chrome/test/functional/special_tabs.py. --> <tabs> <tab id="sync-about-tab">About</tab> <tab id="sync-data-tab">Data</tab> - <tab id="sync-notifications-tab">Notifications</tab> <tab id="sync-events-tab">Events</tab> <tab id="sync-browser-tab">Sync Node Browser</tab> <tab id="sync-search-tab">Search</tab> @@ -70,9 +69,6 @@ chrome/test/functional/special_tabs.py. --> <include src="data.html" /> </tabpanel> <tabpanel> - <include src="notifications.html" /> - </tabpanel> - <tabpanel> <include src="events.html" /> </tabpanel> <tabpanel> diff --git a/chrome/browser/resources/sync_internals_resources.grd b/chrome/browser/resources/sync_internals_resources.grd index 71fe6ab..9d1f349 100644 --- a/chrome/browser/resources/sync_internals_resources.grd +++ b/chrome/browser/resources/sync_internals_resources.grd @@ -20,7 +20,6 @@ <include name="IDR_SYNC_INTERNALS_ABOUT_JS" file="sync_internals/about.js" type="BINDATA" /> <include name="IDR_SYNC_INTERNALS_DATA_JS" file="sync_internals/data.js" type="BINDATA" /> <include name="IDR_SYNC_INTERNALS_EVENTS_JS" file="sync_internals/events.js" type="BINDATA" /> - <include name="IDR_SYNC_INTERNALS_NOTIFICATIONS_JS" file="sync_internals/notifications.js" type="BINDATA" /> <include name="IDR_SYNC_INTERNALS_SEARCH_JS" file="sync_internals/search.js" type="BINDATA" /> <include name="IDR_SYNC_INTERNALS_TRAFFIC_JS" file="sync_internals/traffic.js" type="BINDATA" /> </includes> diff --git a/chrome/browser/ui/webui/sync_internals_ui.cc b/chrome/browser/ui/webui/sync_internals_ui.cc index 4268b3f..280c866 100644 --- a/chrome/browser/ui/webui/sync_internals_ui.cc +++ b/chrome/browser/ui/webui/sync_internals_ui.cc @@ -31,8 +31,6 @@ content::WebUIDataSource* CreateSyncInternalsHTMLSource() { source->AddResourcePath("about.js", IDR_SYNC_INTERNALS_ABOUT_JS); source->AddResourcePath("data.js", IDR_SYNC_INTERNALS_DATA_JS); source->AddResourcePath("events.js", IDR_SYNC_INTERNALS_EVENTS_JS); - source->AddResourcePath("notifications.js", - IDR_SYNC_INTERNALS_NOTIFICATIONS_JS); source->AddResourcePath("search.js", IDR_SYNC_INTERNALS_SEARCH_JS); source->AddResourcePath("traffic.js", IDR_SYNC_INTERNALS_TRAFFIC_JS); source->SetDefaultResource(IDR_SYNC_INTERNALS_INDEX_HTML); diff --git a/sync/internal_api/public/sync_manager.h b/sync/internal_api/public/sync_manager.h index b90c597..fa2e585 100644 --- a/sync/internal_api/public/sync_manager.h +++ b/sync/internal_api/public/sync_manager.h @@ -184,34 +184,6 @@ class SYNC_EXPORT SyncManager : public syncer::InvalidationHandler { // notification is illegal! // WARNING: Calling methods on the SyncManager before receiving this // message, unless otherwise specified, produces undefined behavior. - // - // |js_backend| is what about:sync interacts with. It can emit - // the following events: - - /** - * @param {{ enabled: boolean }} details A dictionary containing: - * - enabled: whether or not notifications are enabled. - */ - // function onNotificationStateChange(details); - - /** - * @param {{ changedTypes: Array.<string> }} details A dictionary - * containing: - * - changedTypes: a list of types (as strings) for which there - are new updates. - */ - // function onIncomingNotification(details); - - // Also, it responds to the following messages (all other messages - // are ignored): - - /** - * Gets the current notification state. - * - * @param {function(boolean)} callback Called with whether or not - * notifications are enabled. - */ - // function getNotificationState(callback); virtual void OnInitializationComplete( const WeakHandle<JsBackend>& js_backend, diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc index edd79a9..68c6e5c 100644 --- a/sync/internal_api/sync_manager_impl.cc +++ b/sync/internal_api/sync_manager_impl.cc @@ -35,8 +35,6 @@ #include "sync/internal_api/syncapi_internal.h" #include "sync/internal_api/syncapi_server_connection_manager.h" #include "sync/js/js_arg_list.h" -#include "sync/js/js_event_details.h" -#include "sync/js/js_event_handler.h" #include "sync/js/js_reply_handler.h" #include "sync/notifier/invalidation_util.h" #include "sync/notifier/invalidator.h" @@ -185,12 +183,6 @@ SyncManagerImpl::SyncManagerImpl(const std::string& name) // Bind message handlers. BindJsMessageHandler( - "getNotificationState", - &SyncManagerImpl::GetNotificationState); - BindJsMessageHandler( - "getNotificationInfo", - &SyncManagerImpl::GetNotificationInfo); - BindJsMessageHandler( "getAllNodes", &SyncManagerImpl::GetAllNodes); BindJsMessageHandler( @@ -953,10 +945,9 @@ void SyncManagerImpl::OnMigrationRequested(ModelTypeSet types) { void SyncManagerImpl::SetJsEventHandler( const WeakHandle<JsEventHandler>& event_handler) { - js_event_handler_ = event_handler; - js_sync_manager_observer_.SetJsEventHandler(js_event_handler_); - js_mutation_event_observer_.SetJsEventHandler(js_event_handler_); - js_sync_encryption_handler_observer_.SetJsEventHandler(js_event_handler_); + js_sync_manager_observer_.SetJsEventHandler(event_handler); + js_mutation_event_observer_.SetJsEventHandler(event_handler); + js_sync_encryption_handler_observer_.SetJsEventHandler(event_handler); } void SyncManagerImpl::ProcessJsMessage( @@ -992,47 +983,6 @@ void SyncManagerImpl::BindJsMessageHandler( base::Bind(unbound_message_handler, base::Unretained(this)); } -base::DictionaryValue* SyncManagerImpl::NotificationInfoToValue( - const NotificationInfoMap& notification_info) { - base::DictionaryValue* value = new base::DictionaryValue(); - - for (NotificationInfoMap::const_iterator it = notification_info.begin(); - it != notification_info.end(); ++it) { - const std::string model_type_str = ModelTypeToString(it->first); - value->Set(model_type_str, it->second.ToValue()); - } - - return value; -} - -std::string SyncManagerImpl::NotificationInfoToString( - const NotificationInfoMap& notification_info) { - scoped_ptr<base::DictionaryValue> value( - NotificationInfoToValue(notification_info)); - std::string str; - base::JSONWriter::Write(value.get(), &str); - return str; -} - -JsArgList SyncManagerImpl::GetNotificationState( - const JsArgList& args) { - const std::string& notification_state = - InvalidatorStateToString(invalidator_state_); - DVLOG(1) << "GetNotificationState: " << notification_state; - base::ListValue return_args; - return_args.Append(new base::StringValue(notification_state)); - return JsArgList(&return_args); -} - -JsArgList SyncManagerImpl::GetNotificationInfo( - const JsArgList& args) { - DVLOG(1) << "GetNotificationInfo: " - << NotificationInfoToString(notification_info_map_); - base::ListValue return_args; - return_args.Append(NotificationInfoToValue(notification_info_map_)); - return JsArgList(&return_args); -} - JsArgList SyncManagerImpl::GetClientServerTraffic( const JsArgList& args) { base::ListValue return_args; @@ -1051,28 +1001,6 @@ JsArgList SyncManagerImpl::GetAllNodes(const JsArgList& args) { return JsArgList(&return_args); } -void SyncManagerImpl::UpdateNotificationInfo( - const ObjectIdInvalidationMap& invalidation_map) { - ObjectIdSet ids = invalidation_map.GetObjectIds(); - for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { - ModelType type = UNSPECIFIED; - if (!ObjectIdToRealModelType(*it, &type)) { - continue; - } - const SingleObjectInvalidationSet& type_invalidations = - invalidation_map.ForObject(*it); - for (SingleObjectInvalidationSet::const_iterator inv_it = - type_invalidations.begin(); inv_it != type_invalidations.end(); - ++inv_it) { - NotificationInfo* info = ¬ification_info_map_[type]; - info->total_count++; - std::string payload = - inv_it->is_unknown_version() ? "UNKNOWN" : inv_it->payload(); - info->payload = payload; - } - } -} - void SyncManagerImpl::OnInvalidatorStateChange(InvalidatorState state) { DCHECK(thread_checker_.CalledOnValidThread()); @@ -1083,15 +1011,6 @@ void SyncManagerImpl::OnInvalidatorStateChange(InvalidatorState state) { (invalidator_state_ == INVALIDATIONS_ENABLED); allstatus_.SetNotificationsEnabled(notifications_enabled); scheduler_->SetNotificationsEnabled(notifications_enabled); - - if (js_event_handler_.IsInitialized()) { - base::DictionaryValue details; - details.SetString("state", state_str); - js_event_handler_.Call(FROM_HERE, - &JsEventHandler::HandleJsEvent, - "onNotificationStateChange", - JsEventDetails(&details)); - } } void SyncManagerImpl::OnIncomingInvalidation( @@ -1115,29 +1034,8 @@ void SyncManagerImpl::OnIncomingInvalidation( TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), invalidation_map, FROM_HERE); allstatus_.IncrementNotificationsReceived(); - UpdateNotificationInfo(invalidation_map); debug_info_event_listener_.OnIncomingNotification(invalidation_map); } - - if (js_event_handler_.IsInitialized()) { - base::DictionaryValue details; - base::ListValue* changed_types = new base::ListValue(); - details.Set("changedTypes", changed_types); - - ObjectIdSet id_set = invalidation_map.GetObjectIds(); - ModelTypeSet nudged_types = ObjectIdSetToModelTypeSet(id_set); - DCHECK(!nudged_types.Empty()); - for (ModelTypeSet::Iterator it = nudged_types.First(); - it.Good(); it.Inc()) { - const std::string model_type_str = ModelTypeToString(it.Get()); - changed_types->Append(new base::StringValue(model_type_str)); - } - details.SetString("source", "REMOTE_INVALIDATION"); - js_event_handler_.Call(FROM_HERE, - &JsEventHandler::HandleJsEvent, - "onIncomingNotification", - JsEventDetails(&details)); - } } std::string SyncManagerImpl::GetOwnerName() const { return "SyncManagerImpl"; } @@ -1152,22 +1050,6 @@ void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec), types, FROM_HERE); } - - if (js_event_handler_.IsInitialized()) { - base::DictionaryValue details; - base::ListValue* changed_types = new base::ListValue(); - details.Set("changedTypes", changed_types); - for (ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) { - const std::string& model_type_str = - ModelTypeToString(it.Get()); - changed_types->Append(new base::StringValue(model_type_str)); - } - details.SetString("source", "LOCAL_INVALIDATION"); - js_event_handler_.Call(FROM_HERE, - &JsEventHandler::HandleJsEvent, - "onIncomingNotification", - JsEventDetails(&details)); - } } SyncStatus SyncManagerImpl::GetDetailedStatus() const { diff --git a/sync/internal_api/sync_manager_impl.h b/sync/internal_api/sync_manager_impl.h index 75593fc..e2b3fb4 100644 --- a/sync/internal_api/sync_manager_impl.h +++ b/sync/internal_api/sync_manager_impl.h @@ -259,10 +259,6 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl : bool existed_before, bool exists_now); - // Called for every notification. This updates the notification statistics - // to be displayed in about:sync. - void UpdateNotificationInfo(const ObjectIdInvalidationMap& invalidation_map); - // Checks for server reachabilty and requests a nudge. void OnNetworkConnectivityChangedImpl(); @@ -270,16 +266,7 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl : void BindJsMessageHandler( const std::string& name, UnboundJsMessageHandler unbound_message_handler); - // Returned pointer is owned by the caller. - static base::DictionaryValue* NotificationInfoToValue( - const NotificationInfoMap& notification_info); - - static std::string NotificationInfoToString( - const NotificationInfoMap& notification_info); - // JS message handlers. - JsArgList GetNotificationState(const JsArgList& args); - JsArgList GetNotificationInfo(const JsArgList& args); JsArgList GetAllNodes(const JsArgList& args); JsArgList GetNodeSummariesById(const JsArgList& args); JsArgList GetNodeDetailsById(const JsArgList& args); @@ -359,7 +346,6 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl : // These are for interacting with chrome://sync-internals. JsMessageHandlerMap js_message_handlers_; - WeakHandle<JsEventHandler> js_event_handler_; JsSyncManagerObserver js_sync_manager_observer_; JsMutationEventObserver js_mutation_event_observer_; JsSyncEncryptionHandlerObserver js_sync_encryption_handler_observer_; diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc index ca1167d..064db9e 100644 --- a/sync/internal_api/sync_manager_impl_unittest.cc +++ b/sync/internal_api/sync_manager_impl_unittest.cc @@ -938,20 +938,6 @@ class SyncManagerTest : public testing::Test, InternalComponentsFactory::Switches switches_; }; -TEST_F(SyncManagerTest, ProcessJsMessage) { - const JsArgList kNoArgs; - - StrictMock<MockJsReplyHandler> reply_handler; - - EXPECT_CALL(reply_handler, - HandleJsReply("getNotificationInfo", _)); - - // This message should be dropped. - SendJsMessage("unknownMessage", kNoArgs, reply_handler.AsWeakHandle()); - - SendJsMessage("getNotificationInfo", kNoArgs, reply_handler.AsWeakHandle()); -} - TEST_F(SyncManagerTest, GetAllNodesTest) { StrictMock<MockJsReplyHandler> reply_handler; JsArgList return_args; @@ -993,100 +979,6 @@ TEST_F(SyncManagerTest, GetAllNodesTest) { EXPECT_TRUE(first_result->HasKey("NON_UNIQUE_NAME")); } -// Simulate various invalidator state changes. Those should propagate -// JS events. -TEST_F(SyncManagerTest, OnInvalidatorStateChangeJsEvents) { - StrictMock<MockJsEventHandler> event_handler; - - base::DictionaryValue enabled_details; - enabled_details.SetString("state", "INVALIDATIONS_ENABLED"); - base::DictionaryValue credentials_rejected_details; - credentials_rejected_details.SetString( - "state", "INVALIDATION_CREDENTIALS_REJECTED"); - base::DictionaryValue transient_error_details; - transient_error_details.SetString("state", "TRANSIENT_INVALIDATION_ERROR"); - base::DictionaryValue auth_error_details; - auth_error_details.SetString("status", "CONNECTION_AUTH_ERROR"); - - EXPECT_CALL(event_handler, - HandleJsEvent("onNotificationStateChange", - HasDetailsAsDictionary(enabled_details))); - - EXPECT_CALL( - event_handler, - HandleJsEvent("onNotificationStateChange", - HasDetailsAsDictionary(credentials_rejected_details))) - .Times(2); - - EXPECT_CALL(event_handler, - HandleJsEvent("onNotificationStateChange", - HasDetailsAsDictionary(transient_error_details))); - - // Test needs to simulate INVALIDATION_CREDENTIALS_REJECTED with event handler - // attached because this is the only time when CONNECTION_AUTH_ERROR - // notification will be generated, therefore the only chance to verify that - // "onConnectionStatusChange" event is delivered - SetJsEventHandler(event_handler.AsWeakHandle()); - SimulateInvalidatorStateChangeForTest(INVALIDATION_CREDENTIALS_REJECTED); - SetJsEventHandler(WeakHandle<JsEventHandler>()); - - SimulateInvalidatorStateChangeForTest(INVALIDATIONS_ENABLED); - SimulateInvalidatorStateChangeForTest(INVALIDATION_CREDENTIALS_REJECTED); - SimulateInvalidatorStateChangeForTest(TRANSIENT_INVALIDATION_ERROR); - - SetJsEventHandler(event_handler.AsWeakHandle()); - SimulateInvalidatorStateChangeForTest(INVALIDATIONS_ENABLED); - SimulateInvalidatorStateChangeForTest(INVALIDATION_CREDENTIALS_REJECTED); - SimulateInvalidatorStateChangeForTest(TRANSIENT_INVALIDATION_ERROR); - SetJsEventHandler(WeakHandle<JsEventHandler>()); - - SimulateInvalidatorStateChangeForTest(INVALIDATIONS_ENABLED); - SimulateInvalidatorStateChangeForTest(INVALIDATION_CREDENTIALS_REJECTED); - SimulateInvalidatorStateChangeForTest(TRANSIENT_INVALIDATION_ERROR); - - // Should trigger the replies. - PumpLoop(); -} - -TEST_F(SyncManagerTest, OnIncomingNotification) { - StrictMock<MockJsEventHandler> event_handler; - - const ModelTypeSet empty_model_types; - const ModelTypeSet model_types( - BOOKMARKS, THEMES); - - // Build expected_args to have a single argument with the string - // equivalents of model_types. - base::DictionaryValue expected_details; - { - base::ListValue* model_type_list = new base::ListValue(); - expected_details.SetString("source", "REMOTE_INVALIDATION"); - expected_details.Set("changedTypes", model_type_list); - for (ModelTypeSet::Iterator it = model_types.First(); - it.Good(); it.Inc()) { - model_type_list->Append( - new base::StringValue(ModelTypeToString(it.Get()))); - } - } - - EXPECT_CALL(event_handler, - HandleJsEvent("onIncomingNotification", - HasDetailsAsDictionary(expected_details))); - - TriggerOnIncomingNotificationForTest(empty_model_types); - TriggerOnIncomingNotificationForTest(model_types); - - SetJsEventHandler(event_handler.AsWeakHandle()); - TriggerOnIncomingNotificationForTest(model_types); - SetJsEventHandler(WeakHandle<JsEventHandler>()); - - TriggerOnIncomingNotificationForTest(empty_model_types); - TriggerOnIncomingNotificationForTest(model_types); - - // Should trigger the replies. - PumpLoop(); -} - TEST_F(SyncManagerTest, RefreshEncryptionReady) { EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); EXPECT_CALL(encryption_observer_, OnEncryptionComplete()); |