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/run_loop.h" |
7 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/search_engines/search_terms_data.h" | 12 #include "chrome/browser/search_engines/search_terms_data.h" |
12 #include "chrome/browser/search_engines/template_url.h" | 13 #include "chrome/browser/search_engines/template_url.h" |
13 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 14 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
14 #include "chrome/browser/search_engines/template_url_service.h" | 15 #include "chrome/browser/search_engines/template_url_service.h" |
15 #include "chrome/browser/search_engines/template_url_service_factory.h" | 16 #include "chrome/browser/search_engines/template_url_service_factory.h" |
16 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 17 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
(...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1888 TemplateURLData data_copy(prepop_turls[0]->data()); | 1889 TemplateURLData data_copy(prepop_turls[0]->data()); |
1889 data_copy.last_modified = Time::FromTimeT(10); | 1890 data_copy.last_modified = Time::FromTimeT(10); |
1890 string16 original_keyword = data_copy.keyword(); | 1891 string16 original_keyword = data_copy.keyword(); |
1891 data_copy.SetKeyword(ASCIIToUTF16(kNewKeyword)); | 1892 data_copy.SetKeyword(ASCIIToUTF16(kNewKeyword)); |
1892 // Set safe_for_autoreplace to false so our keyword survives. | 1893 // Set safe_for_autoreplace to false so our keyword survives. |
1893 data_copy.safe_for_autoreplace = false; | 1894 data_copy.safe_for_autoreplace = false; |
1894 model()->Add(new TemplateURL(prepop_turls[0]->profile(), data_copy)); | 1895 model()->Add(new TemplateURL(prepop_turls[0]->profile(), data_copy)); |
1895 | 1896 |
1896 // Merge the prepopulate search engines. | 1897 // Merge the prepopulate search engines. |
1897 base::Time pre_merge_time = base::Time::Now(); | 1898 base::Time pre_merge_time = base::Time::Now(); |
1898 test_util_a_.BlockTillServiceProcessesRequests(); | 1899 base::RunLoop().RunUntilIdle(); |
1899 test_util_a_.ResetModel(true); | 1900 test_util_a_.ResetModel(true); |
1900 | 1901 |
1901 // The newly added search engine should have been safely merged, with an | 1902 // The newly added search engine should have been safely merged, with an |
1902 // updated time. | 1903 // updated time. |
1903 TemplateURL* added_turl = model()->GetTemplateURLForKeyword( | 1904 TemplateURL* added_turl = model()->GetTemplateURLForKeyword( |
1904 ASCIIToUTF16(kNewKeyword)); | 1905 ASCIIToUTF16(kNewKeyword)); |
1905 base::Time new_timestamp = added_turl->last_modified(); | 1906 base::Time new_timestamp = added_turl->last_modified(); |
1906 EXPECT_GE(new_timestamp, pre_merge_time); | 1907 EXPECT_GE(new_timestamp, pre_merge_time); |
1907 ASSERT_TRUE(added_turl); | 1908 ASSERT_TRUE(added_turl); |
1908 std::string sync_guid = added_turl->sync_guid(); | 1909 std::string sync_guid = added_turl->sync_guid(); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2264 syncer::SyncMergeResult merge_result = model()->MergeDataAndStartSyncing( | 2265 syncer::SyncMergeResult merge_result = model()->MergeDataAndStartSyncing( |
2265 syncer::SEARCH_ENGINES, list, PassProcessor(), | 2266 syncer::SEARCH_ENGINES, list, PassProcessor(), |
2266 CreateAndPassSyncErrorFactory()); | 2267 CreateAndPassSyncErrorFactory()); |
2267 | 2268 |
2268 const TemplateURL* result_turl = model()->GetTemplateURLForGUID("default"); | 2269 const TemplateURL* result_turl = model()->GetTemplateURLForGUID("default"); |
2269 EXPECT_TRUE(result_turl); | 2270 EXPECT_TRUE(result_turl); |
2270 EXPECT_EQ(default_turl->keyword(), result_turl->keyword()); | 2271 EXPECT_EQ(default_turl->keyword(), result_turl->keyword()); |
2271 EXPECT_EQ(default_turl->short_name(), result_turl->short_name()); | 2272 EXPECT_EQ(default_turl->short_name(), result_turl->short_name()); |
2272 EXPECT_EQ(default_turl->url(), result_turl->url()); | 2273 EXPECT_EQ(default_turl->url(), result_turl->url()); |
2273 } | 2274 } |
OLD | NEW |