| 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/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/search_engines/search_terms_data.h" | 10 #include "chrome/browser/search_engines/search_terms_data.h" |
| (...skipping 1896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1907 const std::string sync_guid = "sync_guid"; | 1907 const std::string sync_guid = "sync_guid"; |
| 1908 | 1908 |
| 1909 // Initialize expectations. | 1909 // Initialize expectations. |
| 1910 string16 expected_local_keyword = local_keyword; | 1910 string16 expected_local_keyword = local_keyword; |
| 1911 string16 expected_sync_keyword = sync_keyword; | 1911 string16 expected_sync_keyword = sync_keyword; |
| 1912 | 1912 |
| 1913 // Create the data and run the actual test. | 1913 // Create the data and run the actual test. |
| 1914 TemplateURL* local_turl = CreateTestTemplateURL( | 1914 TemplateURL* local_turl = CreateTestTemplateURL( |
| 1915 local_keyword, local_url, local_guid, local_last_modified); | 1915 local_keyword, local_url, local_guid, local_last_modified); |
| 1916 model()->Add(local_turl); | 1916 model()->Add(local_turl); |
| 1917 TemplateURL* sync_turl = CreateTestTemplateURL( | 1917 scoped_ptr<TemplateURL> sync_turl(CreateTestTemplateURL( |
| 1918 sync_keyword, sync_url, sync_guid, sync_last_modified); | 1918 sync_keyword, sync_url, sync_guid, sync_last_modified)); |
| 1919 | 1919 |
| 1920 SyncDataMap sync_data; | 1920 SyncDataMap sync_data; |
| 1921 if (test_cases[i].synced_at_start == SYNC || | 1921 if (test_cases[i].synced_at_start == SYNC || |
| 1922 test_cases[i].synced_at_start == BOTH) { | 1922 test_cases[i].synced_at_start == BOTH) { |
| 1923 sync_data[sync_turl->sync_guid()] = | 1923 sync_data[sync_turl->sync_guid()] = |
| 1924 TemplateURLService::CreateSyncDataFromTemplateURL(*sync_turl); | 1924 TemplateURLService::CreateSyncDataFromTemplateURL(*sync_turl); |
| 1925 } | 1925 } |
| 1926 if (test_cases[i].synced_at_start == BOTH) { | 1926 if (test_cases[i].synced_at_start == BOTH) { |
| 1927 sync_data[local_turl->sync_guid()] = | 1927 sync_data[local_turl->sync_guid()] = |
| 1928 TemplateURLService::CreateSyncDataFromTemplateURL(*local_turl); | 1928 TemplateURLService::CreateSyncDataFromTemplateURL(*local_turl); |
| 1929 } | 1929 } |
| 1930 SyncDataMap initial_data; | 1930 SyncDataMap initial_data; |
| 1931 initial_data[local_turl->sync_guid()] = | 1931 initial_data[local_turl->sync_guid()] = |
| 1932 TemplateURLService::CreateSyncDataFromTemplateURL(*local_turl); | 1932 TemplateURLService::CreateSyncDataFromTemplateURL(*local_turl); |
| 1933 | 1933 |
| 1934 syncer::SyncChangeList change_list; | 1934 syncer::SyncChangeList change_list; |
| 1935 model()->MergeInSyncTemplateURL(sync_turl, sync_data, &change_list, | 1935 model()->MergeInSyncTemplateURL(sync_turl.get(), sync_data, &change_list, |
| 1936 &initial_data); | 1936 &initial_data); |
| 1937 | 1937 |
| 1938 // Check for expected updates, if any. | 1938 // Check for expected updates, if any. |
| 1939 std::string expected_update_guid; | 1939 std::string expected_update_guid; |
| 1940 if (test_cases[i].update_sent == LOCAL) | 1940 if (test_cases[i].update_sent == LOCAL) |
| 1941 expected_update_guid = local_guid; | 1941 expected_update_guid = local_guid; |
| 1942 else if (test_cases[i].update_sent == SYNC) | 1942 else if (test_cases[i].update_sent == SYNC) |
| 1943 expected_update_guid = sync_guid; | 1943 expected_update_guid = sync_guid; |
| 1944 if (!expected_update_guid.empty()) { | 1944 if (!expected_update_guid.empty()) { |
| 1945 ASSERT_EQ(1U, change_list.size()); | 1945 ASSERT_EQ(1U, change_list.size()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1975 if (test_cases[i].present_in_model == SYNC || | 1975 if (test_cases[i].present_in_model == SYNC || |
| 1976 test_cases[i].present_in_model == BOTH) { | 1976 test_cases[i].present_in_model == BOTH) { |
| 1977 ASSERT_TRUE(model()->GetTemplateURLForGUID(sync_guid)); | 1977 ASSERT_TRUE(model()->GetTemplateURLForGUID(sync_guid)); |
| 1978 EXPECT_EQ(expected_sync_keyword, sync_turl->keyword()); | 1978 EXPECT_EQ(expected_sync_keyword, sync_turl->keyword()); |
| 1979 EXPECT_EQ(sync_url, sync_turl->url()); | 1979 EXPECT_EQ(sync_url, sync_turl->url()); |
| 1980 EXPECT_EQ(sync_last_modified, sync_turl->last_modified().ToTimeT()); | 1980 EXPECT_EQ(sync_last_modified, sync_turl->last_modified().ToTimeT()); |
| 1981 model()->Remove(model()->GetTemplateURLForGUID(sync_guid)); | 1981 model()->Remove(model()->GetTemplateURLForGUID(sync_guid)); |
| 1982 } | 1982 } |
| 1983 } // for | 1983 } // for |
| 1984 } | 1984 } |
| OLD | NEW |