| 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 #include "sync/internal_api/js_sync_manager_observer.h" | 5 #include "sync/internal_api/js_sync_manager_observer.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 EXPECT_CALL(mock_js_event_handler_, | 50 EXPECT_CALL(mock_js_event_handler_, |
| 51 HandleJsEvent("onStopSyncingPermanently", | 51 HandleJsEvent("onStopSyncingPermanently", |
| 52 HasDetails(JsEventDetails()))); | 52 HasDetails(JsEventDetails()))); |
| 53 | 53 |
| 54 js_sync_manager_observer_.OnStopSyncingPermanently(); | 54 js_sync_manager_observer_.OnStopSyncingPermanently(); |
| 55 PumpLoop(); | 55 PumpLoop(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 TEST_F(JsSyncManagerObserverTest, OnInitializationComplete) { | 58 TEST_F(JsSyncManagerObserverTest, OnInitializationComplete) { |
| 59 DictionaryValue expected_details; | 59 base::DictionaryValue expected_details; |
| 60 syncer::ModelTypeSet restored_types; | 60 syncer::ModelTypeSet restored_types; |
| 61 restored_types.Put(BOOKMARKS); | 61 restored_types.Put(BOOKMARKS); |
| 62 restored_types.Put(NIGORI); | 62 restored_types.Put(NIGORI); |
| 63 expected_details.Set("restoredTypes", ModelTypeSetToValue(restored_types)); | 63 expected_details.Set("restoredTypes", ModelTypeSetToValue(restored_types)); |
| 64 | 64 |
| 65 EXPECT_CALL(mock_js_event_handler_, | 65 EXPECT_CALL(mock_js_event_handler_, |
| 66 HandleJsEvent("onInitializationComplete", | 66 HandleJsEvent("onInitializationComplete", |
| 67 HasDetailsAsDictionary(expected_details))); | 67 HasDetailsAsDictionary(expected_details))); |
| 68 | 68 |
| 69 js_sync_manager_observer_.OnInitializationComplete( | 69 js_sync_manager_observer_.OnInitializationComplete( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 81 false, | 81 false, |
| 82 5, | 82 5, |
| 83 2, | 83 2, |
| 84 7, | 84 7, |
| 85 sessions::SyncSourceInfo(), | 85 sessions::SyncSourceInfo(), |
| 86 false, | 86 false, |
| 87 0, | 87 0, |
| 88 base::Time::Now(), | 88 base::Time::Now(), |
| 89 std::vector<int>(MODEL_TYPE_COUNT, 0), | 89 std::vector<int>(MODEL_TYPE_COUNT, 0), |
| 90 std::vector<int>(MODEL_TYPE_COUNT, 0)); | 90 std::vector<int>(MODEL_TYPE_COUNT, 0)); |
| 91 DictionaryValue expected_details; | 91 base::DictionaryValue expected_details; |
| 92 expected_details.Set("snapshot", snapshot.ToValue()); | 92 expected_details.Set("snapshot", snapshot.ToValue()); |
| 93 | 93 |
| 94 EXPECT_CALL(mock_js_event_handler_, | 94 EXPECT_CALL(mock_js_event_handler_, |
| 95 HandleJsEvent("onSyncCycleCompleted", | 95 HandleJsEvent("onSyncCycleCompleted", |
| 96 HasDetailsAsDictionary(expected_details))); | 96 HasDetailsAsDictionary(expected_details))); |
| 97 | 97 |
| 98 js_sync_manager_observer_.OnSyncCycleCompleted(snapshot); | 98 js_sync_manager_observer_.OnSyncCycleCompleted(snapshot); |
| 99 PumpLoop(); | 99 PumpLoop(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 TEST_F(JsSyncManagerObserverTest, OnActionableError) { | 102 TEST_F(JsSyncManagerObserverTest, OnActionableError) { |
| 103 SyncProtocolError sync_error; | 103 SyncProtocolError sync_error; |
| 104 sync_error.action = CLEAR_USER_DATA_AND_RESYNC; | 104 sync_error.action = CLEAR_USER_DATA_AND_RESYNC; |
| 105 sync_error.error_type = TRANSIENT_ERROR; | 105 sync_error.error_type = TRANSIENT_ERROR; |
| 106 DictionaryValue expected_details; | 106 base::DictionaryValue expected_details; |
| 107 expected_details.Set("syncError", sync_error.ToValue()); | 107 expected_details.Set("syncError", sync_error.ToValue()); |
| 108 | 108 |
| 109 EXPECT_CALL(mock_js_event_handler_, | 109 EXPECT_CALL(mock_js_event_handler_, |
| 110 HandleJsEvent("onActionableError", | 110 HandleJsEvent("onActionableError", |
| 111 HasDetailsAsDictionary(expected_details))); | 111 HasDetailsAsDictionary(expected_details))); |
| 112 | 112 |
| 113 js_sync_manager_observer_.OnActionableError(sync_error); | 113 js_sync_manager_observer_.OnActionableError(sync_error); |
| 114 PumpLoop(); | 114 PumpLoop(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 | 117 |
| 118 TEST_F(JsSyncManagerObserverTest, OnConnectionStatusChange) { | 118 TEST_F(JsSyncManagerObserverTest, OnConnectionStatusChange) { |
| 119 const ConnectionStatus kStatus = CONNECTION_AUTH_ERROR; | 119 const ConnectionStatus kStatus = CONNECTION_AUTH_ERROR; |
| 120 DictionaryValue expected_details; | 120 base::DictionaryValue expected_details; |
| 121 expected_details.SetString("status", | 121 expected_details.SetString("status", |
| 122 ConnectionStatusToString(kStatus)); | 122 ConnectionStatusToString(kStatus)); |
| 123 | 123 |
| 124 EXPECT_CALL(mock_js_event_handler_, | 124 EXPECT_CALL(mock_js_event_handler_, |
| 125 HandleJsEvent("onConnectionStatusChange", | 125 HandleJsEvent("onConnectionStatusChange", |
| 126 HasDetailsAsDictionary(expected_details))); | 126 HasDetailsAsDictionary(expected_details))); |
| 127 | 127 |
| 128 js_sync_manager_observer_.OnConnectionStatusChange(kStatus); | 128 js_sync_manager_observer_.OnConnectionStatusChange(kStatus); |
| 129 PumpLoop(); | 129 PumpLoop(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 TEST_F(JsSyncManagerObserverTest, SensitiveNotifiations) { | 132 TEST_F(JsSyncManagerObserverTest, SensitiveNotifiations) { |
| 133 DictionaryValue redacted_token_details; | 133 base::DictionaryValue redacted_token_details; |
| 134 redacted_token_details.SetString("token", "<redacted>"); | 134 redacted_token_details.SetString("token", "<redacted>"); |
| 135 DictionaryValue redacted_bootstrap_token_details; | 135 base::DictionaryValue redacted_bootstrap_token_details; |
| 136 redacted_bootstrap_token_details.SetString("bootstrapToken", "<redacted>"); | 136 redacted_bootstrap_token_details.SetString("bootstrapToken", "<redacted>"); |
| 137 | 137 |
| 138 EXPECT_CALL(mock_js_event_handler_, | 138 EXPECT_CALL(mock_js_event_handler_, |
| 139 HandleJsEvent("onUpdatedToken", | 139 HandleJsEvent("onUpdatedToken", |
| 140 HasDetailsAsDictionary(redacted_token_details))); | 140 HasDetailsAsDictionary(redacted_token_details))); |
| 141 | 141 |
| 142 js_sync_manager_observer_.OnUpdatedToken("sensitive_token"); | 142 js_sync_manager_observer_.OnUpdatedToken("sensitive_token"); |
| 143 PumpLoop(); | 143 PumpLoop(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 } // namespace | 146 } // namespace |
| 147 } // namespace syncer | 147 } // namespace syncer |
| OLD | NEW |