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/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 bool expected_result; | 475 bool expected_result; |
476 } test_cases[] = { | 476 } test_cases[] = { |
477 // Sync is better by timestamp but local is Default. | 477 // Sync is better by timestamp but local is Default. |
478 {10, 100, true, false, true}, | 478 {10, 100, true, false, true}, |
479 // Sync is better by timestamp but local is Create by Policy. | 479 // Sync is better by timestamp but local is Create by Policy. |
480 {10, 100, false, true, true}, | 480 {10, 100, false, true, true}, |
481 // Tie. Sync wins. | 481 // Tie. Sync wins. |
482 {100, 100, false, false, false}, | 482 {100, 100, false, false, false}, |
483 }; | 483 }; |
484 | 484 |
485 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 485 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
486 TemplateURL* local_turl = CreateTestTemplateURL( | 486 TemplateURL* local_turl = CreateTestTemplateURL( |
487 ASCIIToUTF16("localkey"), "www.local.com", "localguid", | 487 ASCIIToUTF16("localkey"), "www.local.com", "localguid", |
488 test_cases[i].local_time, true, test_cases[i].local_created_by_policy); | 488 test_cases[i].local_time, true, test_cases[i].local_created_by_policy); |
489 model()->Add(local_turl); | 489 model()->Add(local_turl); |
490 if (test_cases[i].local_is_default) | 490 if (test_cases[i].local_is_default) |
491 model()->SetUserSelectedDefaultSearchProvider(local_turl); | 491 model()->SetUserSelectedDefaultSearchProvider(local_turl); |
492 | 492 |
493 scoped_ptr<TemplateURL> sync_turl(CreateTestTemplateURL( | 493 scoped_ptr<TemplateURL> sync_turl(CreateTestTemplateURL( |
494 ASCIIToUTF16("synckey"), "www.sync.com", "syncguid", | 494 ASCIIToUTF16("synckey"), "www.sync.com", "syncguid", |
495 test_cases[i].sync_time)); | 495 test_cases[i].sync_time)); |
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1968 {SYNC, SYNC, NEITHER, NEITHER, SYNC, true, {1, 0, 1}}, | 1968 {SYNC, SYNC, NEITHER, NEITHER, SYNC, true, {1, 0, 1}}, |
1969 // Local was not known to sync and the local entry is better: Local is | 1969 // Local was not known to sync and the local entry is better: Local is |
1970 // updated with sync GUID, Sync is not added. UPDATE sent for Sync. | 1970 // updated with sync GUID, Sync is not added. UPDATE sent for Sync. |
1971 {LOCAL, SYNC, SYNC, NEITHER, SYNC, true, {0, 1, 0}}, | 1971 {LOCAL, SYNC, SYNC, NEITHER, SYNC, true, {0, 1, 0}}, |
1972 // No conflicting keyword. Both should be added with their original | 1972 // No conflicting keyword. Both should be added with their original |
1973 // keywords, with no updates sent. Note that MergeDataAndStartSyncing is | 1973 // keywords, with no updates sent. Note that MergeDataAndStartSyncing is |
1974 // responsible for creating the ACTION_ADD for the local TemplateURL. | 1974 // responsible for creating the ACTION_ADD for the local TemplateURL. |
1975 {NEITHER, SYNC, NEITHER, NEITHER, BOTH, false, {1, 0, 0}}, | 1975 {NEITHER, SYNC, NEITHER, NEITHER, BOTH, false, {1, 0, 0}}, |
1976 }; | 1976 }; |
1977 | 1977 |
1978 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 1978 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
1979 // Assert all the valid states of ExpectedTemplateURLs. | 1979 // Assert all the valid states of ExpectedTemplateURLs. |
1980 ASSERT_FALSE(test_cases[i].conflict_winner == BOTH); | 1980 ASSERT_FALSE(test_cases[i].conflict_winner == BOTH); |
1981 ASSERT_FALSE(test_cases[i].synced_at_start == NEITHER); | 1981 ASSERT_FALSE(test_cases[i].synced_at_start == NEITHER); |
1982 ASSERT_FALSE(test_cases[i].synced_at_start == LOCAL); | 1982 ASSERT_FALSE(test_cases[i].synced_at_start == LOCAL); |
1983 ASSERT_FALSE(test_cases[i].update_sent == BOTH); | 1983 ASSERT_FALSE(test_cases[i].update_sent == BOTH); |
1984 ASSERT_FALSE(test_cases[i].turl_uniquified == BOTH); | 1984 ASSERT_FALSE(test_cases[i].turl_uniquified == BOTH); |
1985 ASSERT_FALSE(test_cases[i].present_in_model == NEITHER); | 1985 ASSERT_FALSE(test_cases[i].present_in_model == NEITHER); |
1986 | 1986 |
1987 const base::string16 local_keyword = ASCIIToUTF16("localkeyword"); | 1987 const base::string16 local_keyword = ASCIIToUTF16("localkeyword"); |
1988 const base::string16 sync_keyword = test_cases[i].keywords_conflict ? | 1988 const base::string16 sync_keyword = test_cases[i].keywords_conflict ? |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2230 const char kNewGUID[] = "newdefault"; | 2230 const char kNewGUID[] = "newdefault"; |
2231 model()->Add(CreateTestTemplateURL(ASCIIToUTF16("what"), | 2231 model()->Add(CreateTestTemplateURL(ASCIIToUTF16("what"), |
2232 "http://thewhat.com/{searchTerms}", | 2232 "http://thewhat.com/{searchTerms}", |
2233 kNewGUID)); | 2233 kNewGUID)); |
2234 model()->SetUserSelectedDefaultSearchProvider( | 2234 model()->SetUserSelectedDefaultSearchProvider( |
2235 model()->GetTemplateURLForGUID(kNewGUID)); | 2235 model()->GetTemplateURLForGUID(kNewGUID)); |
2236 | 2236 |
2237 EXPECT_EQ(kNewGUID, profile_a()->GetTestingPrefService()->GetString( | 2237 EXPECT_EQ(kNewGUID, profile_a()->GetTestingPrefService()->GetString( |
2238 prefs::kSyncedDefaultSearchProviderGUID)); | 2238 prefs::kSyncedDefaultSearchProviderGUID)); |
2239 } | 2239 } |
OLD | NEW |