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 <cstddef> | 9 #include <cstddef> |
10 #include <map> | 10 #include <map> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/format_macros.h" | 14 #include "base/format_macros.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
18 #include "base/scoped_temp_dir.h" | 18 #include "base/scoped_temp_dir.h" |
19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
20 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
22 #include "base/values.h" | 22 #include "base/values.h" |
23 #include "chrome/browser/password_manager/encryptor.h" | 23 #include "chrome/browser/password_manager/encryptor.h" |
24 #include "chrome/browser/sync/engine/model_safe_worker.h" | 24 #include "chrome/browser/sync/engine/model_safe_worker.h" |
25 #include "chrome/browser/sync/engine/nigori_util.h" | 25 #include "chrome/browser/sync/engine/nigori_util.h" |
| 26 #include "chrome/browser/sync/engine/polling_constants.h" |
26 #include "chrome/browser/sync/engine/syncapi_internal.h" | 27 #include "chrome/browser/sync/engine/syncapi_internal.h" |
27 #include "chrome/browser/sync/internal_api/change_record.h" | 28 #include "chrome/browser/sync/internal_api/change_record.h" |
28 #include "chrome/browser/sync/internal_api/http_post_provider_factory.h" | 29 #include "chrome/browser/sync/internal_api/http_post_provider_factory.h" |
29 #include "chrome/browser/sync/internal_api/http_post_provider_interface.h" | 30 #include "chrome/browser/sync/internal_api/http_post_provider_interface.h" |
30 #include "chrome/browser/sync/internal_api/read_node.h" | 31 #include "chrome/browser/sync/internal_api/read_node.h" |
31 #include "chrome/browser/sync/internal_api/read_transaction.h" | 32 #include "chrome/browser/sync/internal_api/read_transaction.h" |
32 #include "chrome/browser/sync/internal_api/sync_manager.h" | 33 #include "chrome/browser/sync/internal_api/sync_manager.h" |
33 #include "chrome/browser/sync/internal_api/write_node.h" | 34 #include "chrome/browser/sync/internal_api/write_node.h" |
34 #include "chrome/browser/sync/internal_api/write_transaction.h" | 35 #include "chrome/browser/sync/internal_api/write_transaction.h" |
35 #include "chrome/browser/sync/js/js_arg_list.h" | 36 #include "chrome/browser/sync/js/js_arg_list.h" |
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 EXPECT_FALSE(password_node.InitByClientTagLookup(syncable::PASSWORDS, | 1490 EXPECT_FALSE(password_node.InitByClientTagLookup(syncable::PASSWORDS, |
1490 tag)); | 1491 tag)); |
1491 } | 1492 } |
1492 { | 1493 { |
1493 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); | 1494 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); |
1494 ReadNode password_node(&trans); | 1495 ReadNode password_node(&trans); |
1495 EXPECT_FALSE(password_node.InitByIdLookup(node_id)); | 1496 EXPECT_FALSE(password_node.InitByIdLookup(node_id)); |
1496 } | 1497 } |
1497 } | 1498 } |
1498 | 1499 |
| 1500 TEST_F(SyncManagerTest, NudgeDelayTest) { |
| 1501 EXPECT_EQ(sync_manager_.GetNudgeDelayTimeDelta(syncable::BOOKMARKS), |
| 1502 base::TimeDelta::FromMilliseconds( |
| 1503 SyncManager::kDefaultNudgeDelayMilliseconds)); |
| 1504 |
| 1505 EXPECT_EQ(sync_manager_.GetNudgeDelayTimeDelta(syncable::AUTOFILL), |
| 1506 base::TimeDelta::FromSeconds( |
| 1507 browser_sync::kDefaultShortPollIntervalSeconds)); |
| 1508 |
| 1509 EXPECT_EQ(sync_manager_.GetNudgeDelayTimeDelta(syncable::PREFERENCES), |
| 1510 base::TimeDelta::FromMilliseconds( |
| 1511 SyncManager::kPreferencesNudgeDelayMilliseconds)); |
| 1512 } |
| 1513 |
1499 // Friended by WriteNode, so can't be in an anonymouse namespace. | 1514 // Friended by WriteNode, so can't be in an anonymouse namespace. |
1500 TEST_F(SyncManagerTest, EncryptBookmarksWithLegacyData) { | 1515 TEST_F(SyncManagerTest, EncryptBookmarksWithLegacyData) { |
1501 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); | 1516 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); |
1502 std::string title; | 1517 std::string title; |
1503 SyncAPINameToServerName("Google", &title); | 1518 SyncAPINameToServerName("Google", &title); |
1504 std::string url = "http://www.google.com"; | 1519 std::string url = "http://www.google.com"; |
1505 std::string raw_title2 = ".."; // An invalid cosmo title. | 1520 std::string raw_title2 = ".."; // An invalid cosmo title. |
1506 std::string title2; | 1521 std::string title2; |
1507 SyncAPINameToServerName(raw_title2, &title2); | 1522 SyncAPINameToServerName(raw_title2, &title2); |
1508 std::string url2 = "http://www.bla.com"; | 1523 std::string url2 = "http://www.bla.com"; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 EXPECT_TRUE(specifics.has_encrypted()); | 1729 EXPECT_TRUE(specifics.has_encrypted()); |
1715 EXPECT_TRUE(node_entry->Get(IS_UNSYNCED)); | 1730 EXPECT_TRUE(node_entry->Get(IS_UNSYNCED)); |
1716 EXPECT_EQ(kEncryptedString, node_entry->Get(NON_UNIQUE_NAME)); | 1731 EXPECT_EQ(kEncryptedString, node_entry->Get(NON_UNIQUE_NAME)); |
1717 Cryptographer* cryptographer = trans.GetCryptographer(); | 1732 Cryptographer* cryptographer = trans.GetCryptographer(); |
1718 EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey( | 1733 EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey( |
1719 specifics.encrypted())); | 1734 specifics.encrypted())); |
1720 } | 1735 } |
1721 } | 1736 } |
1722 | 1737 |
1723 } // namespace browser_sync | 1738 } // namespace browser_sync |
OLD | NEW |