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 #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/template_url.h" | 9 #include "chrome/browser/search_engines/template_url.h" |
10 #include "chrome/browser/search_engines/template_url_service.h" | 10 #include "chrome/browser/search_engines/template_url_service.h" |
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 EXPECT_TRUE(model()->is_default_search_managed()); | 1268 EXPECT_TRUE(model()->is_default_search_managed()); |
1269 | 1269 |
1270 // Go unmanaged. Ensure that the DSP changes to the expected pending entry | 1270 // Go unmanaged. Ensure that the DSP changes to the expected pending entry |
1271 // from Sync. | 1271 // from Sync. |
1272 const TemplateURL* expected_default = | 1272 const TemplateURL* expected_default = |
1273 model()->GetTemplateURLForGUID("newdefault"); | 1273 model()->GetTemplateURLForGUID("newdefault"); |
1274 RemoveManagedDefaultSearchPreferences(model(), profile_a_.get()); | 1274 RemoveManagedDefaultSearchPreferences(model(), profile_a_.get()); |
1275 | 1275 |
1276 EXPECT_EQ(expected_default, model()->GetDefaultSearchProvider()); | 1276 EXPECT_EQ(expected_default, model()->GetDefaultSearchProvider()); |
1277 } | 1277 } |
| 1278 |
| 1279 TEST_F(TemplateURLServiceSyncTest, SyncMergeDeletesDefault) { |
| 1280 // If the value from Sync is a duplicate of the local default and is newer, it |
| 1281 // should safely replace the local value and set as the new default. |
| 1282 TemplateURL* default_turl = |
| 1283 CreateTestTemplateURL("key1", "http://key1.com", "whateverguid", 10); |
| 1284 model()->Add(default_turl); |
| 1285 model()->SetDefaultSearchProvider(default_turl); |
| 1286 |
| 1287 // The key1 entry should be a duplicate of the default. |
| 1288 model()->MergeDataAndStartSyncing( |
| 1289 syncable::SEARCH_ENGINES, |
| 1290 CreateInitialSyncData(), |
| 1291 processor()); |
| 1292 |
| 1293 EXPECT_EQ(3U, model()->GetAllSyncData(syncable::SEARCH_ENGINES).size()); |
| 1294 EXPECT_FALSE(model()->GetTemplateURLForGUID("whateverguid")); |
| 1295 EXPECT_EQ(model()->GetDefaultSearchProvider(), |
| 1296 model()->GetTemplateURLForGUID("key1")); |
| 1297 } |
OLD | NEW |