| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/sync/js/js_sync_manager_observer.h" | 5 #include "chrome/browser/sync/js/js_sync_manager_observer.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 283 |
| 284 TEST_F(JsSyncManagerObserverTest, OnChangesApplied) { | 284 TEST_F(JsSyncManagerObserverTest, OnChangesApplied) { |
| 285 InSequence dummy; | 285 InSequence dummy; |
| 286 | 286 |
| 287 TestUserShare test_user_share; | 287 TestUserShare test_user_share; |
| 288 test_user_share.SetUp(); | 288 test_user_share.SetUp(); |
| 289 | 289 |
| 290 // We don't test with passwords as that requires additional setup. | 290 // We don't test with passwords as that requires additional setup. |
| 291 | 291 |
| 292 // Build a list of example ChangeRecords. | 292 // Build a list of example ChangeRecords. |
| 293 sync_api::SyncManager::ChangeRecord changes[syncable::MODEL_TYPE_COUNT]; | 293 sync_api::ChangeRecord changes[syncable::MODEL_TYPE_COUNT]; |
| 294 for (int i = syncable::AUTOFILL_PROFILE; | 294 for (int i = syncable::AUTOFILL_PROFILE; |
| 295 i < syncable::MODEL_TYPE_COUNT; ++i) { | 295 i < syncable::MODEL_TYPE_COUNT; ++i) { |
| 296 changes[i].id = | 296 changes[i].id = |
| 297 MakeNode(test_user_share.user_share(), syncable::ModelTypeFromInt(i)); | 297 MakeNode(test_user_share.user_share(), syncable::ModelTypeFromInt(i)); |
| 298 switch (i % 3) { | 298 switch (i % 3) { |
| 299 case 0: | 299 case 0: |
| 300 changes[i].action = | 300 changes[i].action = |
| 301 sync_api::SyncManager::ChangeRecord::ACTION_ADD; | 301 sync_api::ChangeRecord::ACTION_ADD; |
| 302 break; | 302 break; |
| 303 case 1: | 303 case 1: |
| 304 changes[i].action = | 304 changes[i].action = |
| 305 sync_api::SyncManager::ChangeRecord::ACTION_UPDATE; | 305 sync_api::ChangeRecord::ACTION_UPDATE; |
| 306 break; | 306 break; |
| 307 default: | 307 default: |
| 308 changes[i].action = | 308 changes[i].action = |
| 309 sync_api::SyncManager::ChangeRecord::ACTION_DELETE; | 309 sync_api::ChangeRecord::ACTION_DELETE; |
| 310 break; | 310 break; |
| 311 } | 311 } |
| 312 { | 312 { |
| 313 sync_api::ReadTransaction trans(FROM_HERE, test_user_share.user_share()); | 313 sync_api::ReadTransaction trans(FROM_HERE, test_user_share.user_share()); |
| 314 sync_api::ReadNode node(&trans); | 314 sync_api::ReadNode node(&trans); |
| 315 EXPECT_TRUE(node.InitByIdLookup(changes[i].id)); | 315 EXPECT_TRUE(node.InitByIdLookup(changes[i].id)); |
| 316 changes[i].specifics = node.GetEntry()->Get(syncable::SPECIFICS); | 316 changes[i].specifics = node.GetEntry()->Get(syncable::SPECIFICS); |
| 317 } | 317 } |
| 318 } | 318 } |
| 319 | 319 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 336 } | 336 } |
| 337 EXPECT_CALL(mock_js_event_handler_, | 337 EXPECT_CALL(mock_js_event_handler_, |
| 338 HandleJsEvent("onChangesApplied", | 338 HandleJsEvent("onChangesApplied", |
| 339 HasDetailsAsDictionary(expected_details))); | 339 HasDetailsAsDictionary(expected_details))); |
| 340 } | 340 } |
| 341 | 341 |
| 342 // Fire OnChangesApplied() for each data type. | 342 // Fire OnChangesApplied() for each data type. |
| 343 for (int i = syncable::AUTOFILL_PROFILE; | 343 for (int i = syncable::AUTOFILL_PROFILE; |
| 344 i < syncable::MODEL_TYPE_COUNT; ++i) { | 344 i < syncable::MODEL_TYPE_COUNT; ++i) { |
| 345 sync_api::ReadTransaction trans(FROM_HERE, test_user_share.user_share()); | 345 sync_api::ReadTransaction trans(FROM_HERE, test_user_share.user_share()); |
| 346 js_sync_manager_observer_.OnChangesApplied(syncable::ModelTypeFromInt(i), | 346 sync_api::ChangeRecordList |
| 347 &trans, &changes[i], | 347 local_changes(changes + i, changes + arraysize(changes)); |
| 348 syncable::MODEL_TYPE_COUNT - i); | 348 js_sync_manager_observer_.OnChangesApplied( |
| 349 syncable::ModelTypeFromInt(i), |
| 350 &trans, |
| 351 sync_api::ImmutableChangeRecordList(&local_changes)); |
| 349 } | 352 } |
| 350 | 353 |
| 351 test_user_share.TearDown(); | 354 test_user_share.TearDown(); |
| 352 PumpLoop(); | 355 PumpLoop(); |
| 353 } | 356 } |
| 354 | 357 |
| 355 } // namespace | 358 } // namespace |
| 356 } // namespace browser_sync | 359 } // namespace browser_sync |
| OLD | NEW |