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/callback.h" | 13 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
19 #include "base/scoped_temp_dir.h" | 19 #include "base/scoped_temp_dir.h" |
20 #include "base/string_number_conversions.h" | 20 #include "base/string_number_conversions.h" |
21 #include "base/stringprintf.h" | 21 #include "base/stringprintf.h" |
22 #include "base/test/thread_test_helper.h" | 22 #include "base/test/thread_test_helper.h" |
23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
24 #include "base/values.h" | 24 #include "base/values.h" |
25 #include "chrome/browser/password_manager/encryptor.h" | 25 #include "chrome/browser/password_manager/encryptor.h" |
26 #include "chrome/browser/sync/engine/model_safe_worker.h" | 26 #include "chrome/browser/sync/engine/model_safe_worker.h" |
27 #include "chrome/browser/sync/engine/nigori_util.h" | 27 #include "chrome/browser/sync/engine/nigori_util.h" |
| 28 #include "chrome/browser/sync/engine/polling_constants.h" |
28 #include "chrome/browser/sync/engine/syncapi_internal.h" | 29 #include "chrome/browser/sync/engine/syncapi_internal.h" |
29 #include "chrome/browser/sync/internal_api/change_record.h" | 30 #include "chrome/browser/sync/internal_api/change_record.h" |
30 #include "chrome/browser/sync/internal_api/http_post_provider_factory.h" | 31 #include "chrome/browser/sync/internal_api/http_post_provider_factory.h" |
31 #include "chrome/browser/sync/internal_api/http_post_provider_interface.h" | 32 #include "chrome/browser/sync/internal_api/http_post_provider_interface.h" |
32 #include "chrome/browser/sync/internal_api/read_node.h" | 33 #include "chrome/browser/sync/internal_api/read_node.h" |
33 #include "chrome/browser/sync/internal_api/read_transaction.h" | 34 #include "chrome/browser/sync/internal_api/read_transaction.h" |
34 #include "chrome/browser/sync/internal_api/sync_manager.h" | 35 #include "chrome/browser/sync/internal_api/sync_manager.h" |
35 #include "chrome/browser/sync/internal_api/write_node.h" | 36 #include "chrome/browser/sync/internal_api/write_node.h" |
36 #include "chrome/browser/sync/internal_api/write_transaction.h" | 37 #include "chrome/browser/sync/internal_api/write_transaction.h" |
37 #include "chrome/browser/sync/js/js_arg_list.h" | 38 #include "chrome/browser/sync/js/js_arg_list.h" |
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 EXPECT_FALSE(password_node.InitByClientTagLookup(syncable::PASSWORDS, | 1528 EXPECT_FALSE(password_node.InitByClientTagLookup(syncable::PASSWORDS, |
1528 tag)); | 1529 tag)); |
1529 } | 1530 } |
1530 { | 1531 { |
1531 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); | 1532 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); |
1532 ReadNode password_node(&trans); | 1533 ReadNode password_node(&trans); |
1533 EXPECT_FALSE(password_node.InitByIdLookup(node_id)); | 1534 EXPECT_FALSE(password_node.InitByIdLookup(node_id)); |
1534 } | 1535 } |
1535 } | 1536 } |
1536 | 1537 |
| 1538 TEST_F(SyncManagerTest, NudgeDelayTest) { |
| 1539 EXPECT_EQ(sync_manager_.GetNudgeDelayTimeDelta(syncable::BOOKMARKS), |
| 1540 base::TimeDelta::FromMilliseconds( |
| 1541 SyncManager::kDefaultNudgeDelayMilliseconds)); |
| 1542 |
| 1543 EXPECT_EQ(sync_manager_.GetNudgeDelayTimeDelta(syncable::AUTOFILL), |
| 1544 base::TimeDelta::FromSeconds( |
| 1545 browser_sync::kDefaultShortPollIntervalSeconds)); |
| 1546 |
| 1547 EXPECT_EQ(sync_manager_.GetNudgeDelayTimeDelta(syncable::PREFERENCES), |
| 1548 base::TimeDelta::FromMilliseconds( |
| 1549 SyncManager::kPreferencesNudgeDelayMilliseconds)); |
| 1550 } |
| 1551 |
1537 // Friended by WriteNode, so can't be in an anonymouse namespace. | 1552 // Friended by WriteNode, so can't be in an anonymouse namespace. |
1538 TEST_F(SyncManagerTest, EncryptBookmarksWithLegacyData) { | 1553 TEST_F(SyncManagerTest, EncryptBookmarksWithLegacyData) { |
1539 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); | 1554 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); |
1540 std::string title; | 1555 std::string title; |
1541 SyncAPINameToServerName("Google", &title); | 1556 SyncAPINameToServerName("Google", &title); |
1542 std::string url = "http://www.google.com"; | 1557 std::string url = "http://www.google.com"; |
1543 std::string raw_title2 = ".."; // An invalid cosmo title. | 1558 std::string raw_title2 = ".."; // An invalid cosmo title. |
1544 std::string title2; | 1559 std::string title2; |
1545 SyncAPINameToServerName(raw_title2, &title2); | 1560 SyncAPINameToServerName(raw_title2, &title2); |
1546 std::string url2 = "http://www.bla.com"; | 1561 std::string url2 = "http://www.bla.com"; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 EXPECT_TRUE(specifics.has_encrypted()); | 1780 EXPECT_TRUE(specifics.has_encrypted()); |
1766 EXPECT_TRUE(node_entry->Get(IS_UNSYNCED)); | 1781 EXPECT_TRUE(node_entry->Get(IS_UNSYNCED)); |
1767 EXPECT_EQ(kEncryptedString, node_entry->Get(NON_UNIQUE_NAME)); | 1782 EXPECT_EQ(kEncryptedString, node_entry->Get(NON_UNIQUE_NAME)); |
1768 Cryptographer* cryptographer = trans.GetCryptographer(); | 1783 Cryptographer* cryptographer = trans.GetCryptographer(); |
1769 EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey( | 1784 EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey( |
1770 specifics.encrypted())); | 1785 specifics.encrypted())); |
1771 } | 1786 } |
1772 } | 1787 } |
1773 | 1788 |
1774 } // namespace browser_sync | 1789 } // namespace browser_sync |
OLD | NEW |