Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: sync/internal_api/sync_manager_impl_unittest.cc

Issue 10837111: [Sync] Print out notification state explicitly in about:sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/internal_api/sync_manager_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Unit tests for the SyncApi. Note that a lot of the underlying 5 // Unit tests for the SyncApi. Note that a lot of the underlying
6 // functionality is provided by the Syncable layer, which has its own 6 // functionality is provided by the Syncable layer, which has its own
7 // unit tests. We'll test SyncApi specific things in this harness. 7 // unit tests. We'll test SyncApi specific things in this harness.
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 TEST_F(SyncManagerTest, UpdateRegisteredInvalidationIds) { 966 TEST_F(SyncManagerTest, UpdateRegisteredInvalidationIds) {
967 EXPECT_CALL(*sync_notifier_mock_, UpdateRegisteredIds(NULL, ObjectIdSet())); 967 EXPECT_CALL(*sync_notifier_mock_, UpdateRegisteredIds(NULL, ObjectIdSet()));
968 sync_manager_.UpdateRegisteredInvalidationIds(NULL, ObjectIdSet()); 968 sync_manager_.UpdateRegisteredInvalidationIds(NULL, ObjectIdSet());
969 } 969 }
970 970
971 TEST_F(SyncManagerTest, ProcessJsMessage) { 971 TEST_F(SyncManagerTest, ProcessJsMessage) {
972 const JsArgList kNoArgs; 972 const JsArgList kNoArgs;
973 973
974 StrictMock<MockJsReplyHandler> reply_handler; 974 StrictMock<MockJsReplyHandler> reply_handler;
975 975
976 ListValue false_args; 976 ListValue disabled_args;
977 false_args.Append(Value::CreateBooleanValue(false)); 977 disabled_args.Append(
978 Value::CreateStringValue("TRANSIENT_NOTIFICATION_ERROR"));
978 979
979 EXPECT_CALL(reply_handler, 980 EXPECT_CALL(reply_handler,
980 HandleJsReply("getNotificationState", 981 HandleJsReply("getNotificationState",
981 HasArgsAsList(false_args))); 982 HasArgsAsList(disabled_args)));
982 983
983 // This message should be dropped. 984 // This message should be dropped.
984 SendJsMessage("unknownMessage", kNoArgs, reply_handler.AsWeakHandle()); 985 SendJsMessage("unknownMessage", kNoArgs, reply_handler.AsWeakHandle());
985 986
986 SendJsMessage("getNotificationState", kNoArgs, reply_handler.AsWeakHandle()); 987 SendJsMessage("getNotificationState", kNoArgs, reply_handler.AsWeakHandle());
987 } 988 }
988 989
989 TEST_F(SyncManagerTest, ProcessJsMessageGetRootNodeDetails) { 990 TEST_F(SyncManagerTest, ProcessJsMessageGetRootNodeDetails) {
990 const JsArgList kNoArgs; 991 const JsArgList kNoArgs;
991 992
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 ASSERT_EQ(directory_size, node_list->GetSize()); 1255 ASSERT_EQ(directory_size, node_list->GetSize());
1255 ASSERT_TRUE(node_list->GetDictionary(0, &first_result)); 1256 ASSERT_TRUE(node_list->GetDictionary(0, &first_result));
1256 EXPECT_TRUE(first_result->HasKey("ID")); 1257 EXPECT_TRUE(first_result->HasKey("ID"));
1257 EXPECT_TRUE(first_result->HasKey("NON_UNIQUE_NAME")); 1258 EXPECT_TRUE(first_result->HasKey("NON_UNIQUE_NAME"));
1258 } 1259 }
1259 1260
1260 TEST_F(SyncManagerTest, OnNotificationStateChange) { 1261 TEST_F(SyncManagerTest, OnNotificationStateChange) {
1261 InSequence dummy; 1262 InSequence dummy;
1262 StrictMock<MockJsEventHandler> event_handler; 1263 StrictMock<MockJsEventHandler> event_handler;
1263 1264
1264 DictionaryValue true_details; 1265 DictionaryValue enabled_details;
1265 true_details.SetBoolean("enabled", true); 1266 enabled_details.SetString("state", "NO_NOTIFICATION_ERROR");
1266 DictionaryValue false_details; 1267 DictionaryValue disabled_details;
1267 false_details.SetBoolean("enabled", false); 1268 disabled_details.SetString("state", "TRANSIENT_NOTIFICATION_ERROR");
1268 1269
1269 EXPECT_CALL(event_handler, 1270 EXPECT_CALL(event_handler,
1270 HandleJsEvent("onNotificationStateChange", 1271 HandleJsEvent("onNotificationStateChange",
1271 HasDetailsAsDictionary(true_details))); 1272 HasDetailsAsDictionary(enabled_details)));
1272 EXPECT_CALL(event_handler, 1273 EXPECT_CALL(event_handler,
1273 HandleJsEvent("onNotificationStateChange", 1274 HandleJsEvent("onNotificationStateChange",
1274 HasDetailsAsDictionary(false_details))); 1275 HasDetailsAsDictionary(disabled_details)));
1275 1276
1276 SimulateEnableNotificationsForTest(); 1277 SimulateEnableNotificationsForTest();
1277 SimulateDisableNotificationsForTest(TRANSIENT_NOTIFICATION_ERROR); 1278 SimulateDisableNotificationsForTest(TRANSIENT_NOTIFICATION_ERROR);
1278 1279
1279 SetJsEventHandler(event_handler.AsWeakHandle()); 1280 SetJsEventHandler(event_handler.AsWeakHandle());
1280 SimulateEnableNotificationsForTest(); 1281 SimulateEnableNotificationsForTest();
1281 SimulateDisableNotificationsForTest(TRANSIENT_NOTIFICATION_ERROR); 1282 SimulateDisableNotificationsForTest(TRANSIENT_NOTIFICATION_ERROR);
1282 SetJsEventHandler(WeakHandle<JsEventHandler>()); 1283 SetJsEventHandler(WeakHandle<JsEventHandler>());
1283 1284
1284 SimulateEnableNotificationsForTest(); 1285 SimulateEnableNotificationsForTest();
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after
2782 2783
2783 // Verify only the non-disabled types remain after cleanup. 2784 // Verify only the non-disabled types remain after cleanup.
2784 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types); 2785 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types);
2785 EXPECT_TRUE(new_enabled_types.Equals( 2786 EXPECT_TRUE(new_enabled_types.Equals(
2786 Union(sync_manager_.InitialSyncEndedTypes(), partial_enabled_types))); 2787 Union(sync_manager_.InitialSyncEndedTypes(), partial_enabled_types)));
2787 EXPECT_TRUE(disabled_types.Equals( 2788 EXPECT_TRUE(disabled_types.Equals(
2788 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); 2789 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All())));
2789 } 2790 }
2790 2791
2791 } // namespace 2792 } // namespace
OLDNEW
« no previous file with comments | « sync/internal_api/sync_manager_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698