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 // 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 <map> | 9 #include <map> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_temp_dir.h" | 14 #include "base/memory/scoped_temp_dir.h" |
15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "base/stringprintf.h" |
16 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
17 #include "base/string_util.h" | |
18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "chrome/browser/sync/engine/http_post_provider_factory.h" | 20 #include "chrome/browser/sync/engine/http_post_provider_factory.h" |
21 #include "chrome/browser/sync/engine/http_post_provider_interface.h" | 21 #include "chrome/browser/sync/engine/http_post_provider_interface.h" |
22 #include "chrome/browser/sync/engine/model_safe_worker.h" | 22 #include "chrome/browser/sync/engine/model_safe_worker.h" |
23 #include "chrome/browser/sync/engine/syncapi.h" | 23 #include "chrome/browser/sync/engine/syncapi.h" |
24 #include "chrome/browser/sync/js_arg_list.h" | 24 #include "chrome/browser/sync/js_arg_list.h" |
25 #include "chrome/browser/sync/js_backend.h" | 25 #include "chrome/browser/sync/js_backend.h" |
26 #include "chrome/browser/sync/js_event_handler.h" | 26 #include "chrome/browser/sync/js_event_handler.h" |
27 #include "chrome/browser/sync/js_event_router.h" | 27 #include "chrome/browser/sync/js_event_router.h" |
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 | 1070 |
1071 // Create some unencrypted unsynced data. | 1071 // Create some unencrypted unsynced data. |
1072 int64 folder = MakeFolderWithParent(sync_manager_.GetUserShare(), | 1072 int64 folder = MakeFolderWithParent(sync_manager_.GetUserShare(), |
1073 syncable::BOOKMARKS, | 1073 syncable::BOOKMARKS, |
1074 GetIdForDataType(syncable::BOOKMARKS), | 1074 GetIdForDataType(syncable::BOOKMARKS), |
1075 NULL); | 1075 NULL); |
1076 // First batch_size nodes are children of folder. | 1076 // First batch_size nodes are children of folder. |
1077 size_t i; | 1077 size_t i; |
1078 for (i = 0; i < batch_size; ++i) { | 1078 for (i = 0; i < batch_size; ++i) { |
1079 MakeNodeWithParent(sync_manager_.GetUserShare(), syncable::BOOKMARKS, | 1079 MakeNodeWithParent(sync_manager_.GetUserShare(), syncable::BOOKMARKS, |
1080 StringPrintf("%"PRIuS"", i), folder); | 1080 base::StringPrintf("%"PRIuS"", i), folder); |
1081 } | 1081 } |
1082 // Next batch_size nodes are a different type and on their own. | 1082 // Next batch_size nodes are a different type and on their own. |
1083 for (; i < 2*batch_size; ++i) { | 1083 for (; i < 2*batch_size; ++i) { |
1084 MakeNodeWithParent(sync_manager_.GetUserShare(), syncable::SESSIONS, | 1084 MakeNodeWithParent(sync_manager_.GetUserShare(), syncable::SESSIONS, |
1085 StringPrintf("%"PRIuS"", i), | 1085 base::StringPrintf("%"PRIuS"", i), |
1086 GetIdForDataType(syncable::SESSIONS)); | 1086 GetIdForDataType(syncable::SESSIONS)); |
1087 } | 1087 } |
1088 // Last batch_size nodes are a third type that will not need encryption. | 1088 // Last batch_size nodes are a third type that will not need encryption. |
1089 for (; i < 3*batch_size; ++i) { | 1089 for (; i < 3*batch_size; ++i) { |
1090 MakeNodeWithParent(sync_manager_.GetUserShare(), syncable::THEMES, | 1090 MakeNodeWithParent(sync_manager_.GetUserShare(), syncable::THEMES, |
1091 StringPrintf("%"PRIuS"", i), | 1091 base::StringPrintf("%"PRIuS"", i), |
1092 GetIdForDataType(syncable::THEMES)); | 1092 GetIdForDataType(syncable::THEMES)); |
1093 } | 1093 } |
1094 | 1094 |
1095 { | 1095 { |
1096 ReadTransaction trans(sync_manager_.GetUserShare()); | 1096 ReadTransaction trans(sync_manager_.GetUserShare()); |
1097 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1097 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
1098 syncable::BOOKMARKS, | 1098 syncable::BOOKMARKS, |
1099 false /* not encrypted */)); | 1099 false /* not encrypted */)); |
1100 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1100 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
1101 syncable::SESSIONS, | 1101 syncable::SESSIONS, |
(...skipping 23 matching lines...) Expand all Loading... |
1125 true /* is encrypted */)); | 1125 true /* is encrypted */)); |
1126 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1126 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
1127 syncable::THEMES, | 1127 syncable::THEMES, |
1128 false /* not encrypted */)); | 1128 false /* not encrypted */)); |
1129 } | 1129 } |
1130 } | 1130 } |
1131 | 1131 |
1132 } // namespace | 1132 } // namespace |
1133 | 1133 |
1134 } // namespace browser_sync | 1134 } // namespace browser_sync |
OLD | NEW |