OLD | NEW |
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 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 } | 1198 } |
1199 | 1199 |
1200 { | 1200 { |
1201 ListValue args; | 1201 ListValue args; |
1202 args.Append(Value::CreateStringValue("9999")); | 1202 args.Append(Value::CreateStringValue("9999")); |
1203 SendJsMessage("getChildNodeIds", | 1203 SendJsMessage("getChildNodeIds", |
1204 JsArgList(&args), reply_handler.AsWeakHandle()); | 1204 JsArgList(&args), reply_handler.AsWeakHandle()); |
1205 } | 1205 } |
1206 } | 1206 } |
1207 | 1207 |
1208 // TODO(akalin): Add unit tests for findNodesContainingString message. | 1208 TEST_F(SyncManagerTest, GetAllNodesTest) { |
| 1209 StrictMock<MockJsReplyHandler> reply_handler; |
| 1210 JsArgList return_args; |
| 1211 |
| 1212 EXPECT_CALL(reply_handler, |
| 1213 HandleJsReply("getAllNodes", _)) |
| 1214 .Times(1).WillRepeatedly(SaveArg<1>(&return_args)); |
| 1215 |
| 1216 { |
| 1217 ListValue args; |
| 1218 SendJsMessage("getAllNodes", |
| 1219 JsArgList(&args), reply_handler.AsWeakHandle()); |
| 1220 } |
| 1221 |
| 1222 // There's not much value in verifying every attribute on every node here. |
| 1223 // Most of the value of this test has already been achieved: we've verified we |
| 1224 // can call the above function without crashing or leaking memory. |
| 1225 // |
| 1226 // Let's just check the list size and a few of its elements. Anything more |
| 1227 // would make this test brittle without greatly increasing our chances of |
| 1228 // catching real bugs. |
| 1229 |
| 1230 ListValue* node_list; |
| 1231 DictionaryValue* first_result; |
| 1232 |
| 1233 // The resulting argument list should have one argument, a list of nodes. |
| 1234 ASSERT_EQ(1U, return_args.Get().GetSize()); |
| 1235 ASSERT_TRUE(return_args.Get().GetList(0, &node_list)); |
| 1236 |
| 1237 // The database creation logic depends on the routing info. |
| 1238 // Refer to setup methods for more information. |
| 1239 ModelSafeRoutingInfo routes; |
| 1240 GetModelSafeRoutingInfo(&routes); |
| 1241 size_t directory_size = routes.size() + 1; |
| 1242 |
| 1243 ASSERT_EQ(directory_size, node_list->GetSize()); |
| 1244 ASSERT_TRUE(node_list->GetDictionary(0, &first_result)); |
| 1245 EXPECT_TRUE(first_result->HasKey("ID")); |
| 1246 EXPECT_TRUE(first_result->HasKey("NON_UNIQUE_NAME")); |
| 1247 } |
1209 | 1248 |
1210 TEST_F(SyncManagerTest, OnNotificationStateChange) { | 1249 TEST_F(SyncManagerTest, OnNotificationStateChange) { |
1211 InSequence dummy; | 1250 InSequence dummy; |
1212 StrictMock<MockJsEventHandler> event_handler; | 1251 StrictMock<MockJsEventHandler> event_handler; |
1213 | 1252 |
1214 DictionaryValue true_details; | 1253 DictionaryValue true_details; |
1215 true_details.SetBoolean("enabled", true); | 1254 true_details.SetBoolean("enabled", true); |
1216 DictionaryValue false_details; | 1255 DictionaryValue false_details; |
1217 false_details.SetBoolean("enabled", false); | 1256 false_details.SetBoolean("enabled", false); |
1218 | 1257 |
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2432 EXPECT_EQ(title, node.GetTitle()); | 2471 EXPECT_EQ(title, node.GetTitle()); |
2433 EXPECT_EQ(GURL(url2), node.GetURL()); | 2472 EXPECT_EQ(GURL(url2), node.GetURL()); |
2434 const syncable::Entry* node_entry = node.GetEntry(); | 2473 const syncable::Entry* node_entry = node.GetEntry(); |
2435 EXPECT_EQ(kEncryptedString, node_entry->Get(NON_UNIQUE_NAME)); | 2474 EXPECT_EQ(kEncryptedString, node_entry->Get(NON_UNIQUE_NAME)); |
2436 const sync_pb::EntitySpecifics& specifics = node_entry->Get(SPECIFICS); | 2475 const sync_pb::EntitySpecifics& specifics = node_entry->Get(SPECIFICS); |
2437 EXPECT_TRUE(specifics.has_encrypted()); | 2476 EXPECT_TRUE(specifics.has_encrypted()); |
2438 } | 2477 } |
2439 } | 2478 } |
2440 | 2479 |
2441 } // namespace browser_sync | 2480 } // namespace browser_sync |
OLD | NEW |