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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/search_engines/search_terms_data.h" | 9 #include "chrome/browser/search_engines/search_terms_data.h" |
10 #include "chrome/browser/search_engines/template_url.h" | 10 #include "chrome/browser/search_engines/template_url.h" |
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 // deletion. | 1523 // deletion. |
1524 EXPECT_EQ(0U, model()->GetTemplateURLs().size()); | 1524 EXPECT_EQ(0U, model()->GetTemplateURLs().size()); |
1525 EXPECT_EQ(2U, processor()->change_list_size()); | 1525 EXPECT_EQ(2U, processor()->change_list_size()); |
1526 ASSERT_TRUE(processor()->contains_guid("key1")); | 1526 ASSERT_TRUE(processor()->contains_guid("key1")); |
1527 EXPECT_EQ(SyncChange::ACTION_DELETE, | 1527 EXPECT_EQ(SyncChange::ACTION_DELETE, |
1528 processor()->change_for_guid("key1").change_type()); | 1528 processor()->change_for_guid("key1").change_type()); |
1529 ASSERT_TRUE(processor()->contains_guid(std::string())); | 1529 ASSERT_TRUE(processor()->contains_guid(std::string())); |
1530 EXPECT_EQ(SyncChange::ACTION_DELETE, | 1530 EXPECT_EQ(SyncChange::ACTION_DELETE, |
1531 processor()->change_for_guid(std::string()).change_type()); | 1531 processor()->change_for_guid(std::string()).change_type()); |
1532 } | 1532 } |
| 1533 |
| 1534 TEST_F(TemplateURLServiceSyncTest, PreSyncDeletes) { |
| 1535 model()->pre_sync_deletes_.insert("key1"); |
| 1536 model()->pre_sync_deletes_.insert("key2"); |
| 1537 model()->pre_sync_deletes_.insert("aaa"); |
| 1538 model()->Add(CreateTestTemplateURL(ASCIIToUTF16("whatever"), |
| 1539 "http://key1.com", "bbb")); |
| 1540 model()->MergeDataAndStartSyncing(syncable::SEARCH_ENGINES, |
| 1541 CreateInitialSyncData(), PassProcessor(), |
| 1542 CreateAndPassSyncErrorFactory()); |
| 1543 |
| 1544 // We expect the model to have GUIDs {bbb, key3} after our initial merge. |
| 1545 EXPECT_TRUE(model()->GetTemplateURLForGUID("bbb")); |
| 1546 EXPECT_TRUE(model()->GetTemplateURLForGUID("key3")); |
| 1547 SyncChange change = processor()->change_for_guid("key1"); |
| 1548 EXPECT_EQ(SyncChange::ACTION_DELETE, change.change_type()); |
| 1549 change = processor()->change_for_guid("key2"); |
| 1550 EXPECT_EQ(SyncChange::ACTION_DELETE, change.change_type()); |
| 1551 // "aaa" should have been pruned out on account of not being from Sync. |
| 1552 EXPECT_FALSE(processor()->contains_guid("aaa")); |
| 1553 // The set of pre-sync deletes should be cleared so they're not reused if |
| 1554 // MergeDataAndStartSyncing gets called again. |
| 1555 EXPECT_TRUE(model()->pre_sync_deletes_.empty()); |
| 1556 } |
OLD | NEW |