| 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" |
| 11 #include "base/tracked.h" | 11 #include "base/tracked.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/sync/internal_api/read_node.h" | 13 #include "chrome/browser/sync/internal_api/read_node.h" |
| 14 #include "chrome/browser/sync/internal_api/read_transaction.h" | 14 #include "chrome/browser/sync/internal_api/read_transaction.h" |
| 15 #include "chrome/browser/sync/internal_api/write_node.h" | 15 #include "chrome/browser/sync/internal_api/write_node.h" |
| 16 #include "chrome/browser/sync/internal_api/write_transaction.h" | 16 #include "chrome/browser/sync/internal_api/write_transaction.h" |
| 17 #include "chrome/browser/sync/js/js_arg_list.h" | 17 #include "chrome/browser/sync/js/js_arg_list.h" |
| 18 #include "chrome/browser/sync/js/js_event_details.h" | 18 #include "chrome/browser/sync/js/js_event_details.h" |
| 19 #include "chrome/browser/sync/js/js_test_util.h" | 19 #include "chrome/browser/sync/js/js_test_util.h" |
| 20 #include "chrome/browser/sync/protocol/sync_protocol_error.h" | 20 #include "chrome/browser/sync/protocol/sync_protocol_error.h" |
| 21 #include "chrome/browser/sync/sessions/session_state.h" | 21 #include "chrome/browser/sync/sessions/session_state.h" |
| 22 #include "chrome/browser/sync/syncable/model_type.h" | 22 #include "chrome/browser/sync/syncable/model_type.h" |
| 23 #include "chrome/browser/sync/syncable/syncable.h" |
| 23 #include "chrome/browser/sync/test/engine/test_user_share.h" | 24 #include "chrome/browser/sync/test/engine/test_user_share.h" |
| 24 #include "chrome/browser/sync/util/weak_handle.h" | 25 #include "chrome/browser/sync/util/weak_handle.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 27 |
| 27 namespace browser_sync { | 28 namespace browser_sync { |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 using ::testing::InSequence; | 31 using ::testing::InSequence; |
| 31 using ::testing::StrictMock; | 32 using ::testing::StrictMock; |
| 32 | 33 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 for (int i = syncable::AUTOFILL_PROFILE; | 326 for (int i = syncable::AUTOFILL_PROFILE; |
| 326 i < syncable::MODEL_TYPE_COUNT; ++i) { | 327 i < syncable::MODEL_TYPE_COUNT; ++i) { |
| 327 const std::string& model_type_str = | 328 const std::string& model_type_str = |
| 328 syncable::ModelTypeToString(syncable::ModelTypeFromInt(i)); | 329 syncable::ModelTypeToString(syncable::ModelTypeFromInt(i)); |
| 329 DictionaryValue expected_details; | 330 DictionaryValue expected_details; |
| 330 expected_details.SetString("modelType", model_type_str); | 331 expected_details.SetString("modelType", model_type_str); |
| 331 ListValue* expected_changes = new ListValue(); | 332 ListValue* expected_changes = new ListValue(); |
| 332 expected_details.Set("changes", expected_changes); | 333 expected_details.Set("changes", expected_changes); |
| 333 for (int j = i; j < syncable::MODEL_TYPE_COUNT; ++j) { | 334 for (int j = i; j < syncable::MODEL_TYPE_COUNT; ++j) { |
| 334 sync_api::ReadTransaction trans(FROM_HERE, test_user_share.user_share()); | 335 sync_api::ReadTransaction trans(FROM_HERE, test_user_share.user_share()); |
| 335 expected_changes->Append(changes[j].ToValue(&trans)); | 336 expected_changes->Append(changes[j].ToValue( |
| 337 syncable::ImmutableEntryKernelMutationMap())); |
| 336 } | 338 } |
| 337 EXPECT_CALL(mock_js_event_handler_, | 339 EXPECT_CALL(mock_js_event_handler_, |
| 338 HandleJsEvent("onChangesApplied", | 340 HandleJsEvent("onChangesApplied", |
| 339 HasDetailsAsDictionary(expected_details))); | 341 HasDetailsAsDictionary(expected_details))); |
| 340 } | 342 } |
| 341 | 343 |
| 342 // Fire OnChangesApplied() for each data type. | 344 // Fire OnChangesApplied() for each data type. |
| 343 for (int i = syncable::AUTOFILL_PROFILE; | 345 for (int i = syncable::AUTOFILL_PROFILE; |
| 344 i < syncable::MODEL_TYPE_COUNT; ++i) { | 346 i < syncable::MODEL_TYPE_COUNT; ++i) { |
| 345 sync_api::ReadTransaction trans(FROM_HERE, test_user_share.user_share()); | 347 sync_api::ReadTransaction trans(FROM_HERE, test_user_share.user_share()); |
| 346 sync_api::ChangeRecordList | 348 sync_api::ChangeRecordList |
| 347 local_changes(changes + i, changes + arraysize(changes)); | 349 local_changes(changes + i, changes + arraysize(changes)); |
| 348 js_sync_manager_observer_.OnChangesApplied( | 350 js_sync_manager_observer_.OnChangesApplied( |
| 349 syncable::ModelTypeFromInt(i), | 351 syncable::ModelTypeFromInt(i), |
| 350 &trans, | 352 syncable::ImmutableEntryKernelMutationMap(), |
| 351 sync_api::ImmutableChangeRecordList(&local_changes)); | 353 sync_api::ImmutableChangeRecordList(&local_changes)); |
| 352 } | 354 } |
| 353 | 355 |
| 354 test_user_share.TearDown(); | 356 test_user_share.TearDown(); |
| 355 PumpLoop(); | 357 PumpLoop(); |
| 356 } | 358 } |
| 357 | 359 |
| 358 } // namespace | 360 } // namespace |
| 359 } // namespace browser_sync | 361 } // namespace browser_sync |
| OLD | NEW |