| 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/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
| 8 #include "base/test/mock_time_provider.h" | 8 #include "base/test/mock_time_provider.h" |
| 9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 ASSERT_EQ(expected.keyword(), actual.keyword()); | 159 ASSERT_EQ(expected.keyword(), actual.keyword()); |
| 160 ASSERT_EQ(expected.short_name(), actual.short_name()); | 160 ASSERT_EQ(expected.short_name(), actual.short_name()); |
| 161 ASSERT_EQ(JoinString(expected.input_encodings(), ';'), | 161 ASSERT_EQ(JoinString(expected.input_encodings(), ';'), |
| 162 JoinString(actual.input_encodings(), ';')); | 162 JoinString(actual.input_encodings(), ';')); |
| 163 ASSERT_TRUE(expected.GetFaviconURL() == actual.GetFaviconURL()); | 163 ASSERT_TRUE(expected.GetFaviconURL() == actual.GetFaviconURL()); |
| 164 ASSERT_EQ(expected.id(), actual.id()); | 164 ASSERT_EQ(expected.id(), actual.id()); |
| 165 ASSERT_EQ(expected.safe_for_autoreplace(), actual.safe_for_autoreplace()); | 165 ASSERT_EQ(expected.safe_for_autoreplace(), actual.safe_for_autoreplace()); |
| 166 ASSERT_EQ(expected.show_in_default_list(), actual.show_in_default_list()); | 166 ASSERT_EQ(expected.show_in_default_list(), actual.show_in_default_list()); |
| 167 ASSERT_TRUE(expected.date_created() == actual.date_created()); | 167 ASSERT_TRUE(expected.date_created() == actual.date_created()); |
| 168 ASSERT_TRUE(expected.last_modified() == actual.last_modified()); | 168 ASSERT_TRUE(expected.last_modified() == actual.last_modified()); |
| 169 ASSERT_EQ(expected.sync_guid(), actual.sync_guid()); |
| 169 } | 170 } |
| 170 | 171 |
| 171 // Checks that the two TemplateURLs are similar. It does not check the id, the | 172 // Checks that the two TemplateURLs are similar. It does not check the id, the |
| 172 // date_created or the last_modified time. Neither pointer should be NULL. | 173 // date_created or the last_modified time. Neither pointer should be NULL. |
| 173 void ExpectSimilar(const TemplateURL* expected, const TemplateURL* actual) { | 174 void ExpectSimilar(const TemplateURL* expected, const TemplateURL* actual) { |
| 174 ASSERT_TRUE(expected != NULL); | 175 ASSERT_TRUE(expected != NULL); |
| 175 ASSERT_TRUE(actual != NULL); | 176 ASSERT_TRUE(actual != NULL); |
| 176 EXPECT_TRUE(TemplateURLRef::SameUrlRefs(expected->url(), actual->url())); | 177 EXPECT_TRUE(TemplateURLRef::SameUrlRefs(expected->url(), actual->url())); |
| 177 EXPECT_TRUE(TemplateURLRef::SameUrlRefs(expected->suggestions_url(), | 178 EXPECT_TRUE(TemplateURLRef::SameUrlRefs(expected->suggestions_url(), |
| 178 actual->suggestions_url())); | 179 actual->suggestions_url())); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 const size_t initial_count = model()->GetTemplateURLs().size(); | 390 const size_t initial_count = model()->GetTemplateURLs().size(); |
| 390 | 391 |
| 391 TemplateURL* t_url = new TemplateURL(); | 392 TemplateURL* t_url = new TemplateURL(); |
| 392 t_url->SetURL("http://www.google.com/foo/bar", 0, 0); | 393 t_url->SetURL("http://www.google.com/foo/bar", 0, 0); |
| 393 t_url->set_keyword(ASCIIToUTF16("keyword")); | 394 t_url->set_keyword(ASCIIToUTF16("keyword")); |
| 394 t_url->set_short_name(ASCIIToUTF16("google")); | 395 t_url->set_short_name(ASCIIToUTF16("google")); |
| 395 GURL favicon_url("http://favicon.url"); | 396 GURL favicon_url("http://favicon.url"); |
| 396 t_url->SetFaviconURL(favicon_url); | 397 t_url->SetFaviconURL(favicon_url); |
| 397 t_url->set_date_created(Time::FromTimeT(100)); | 398 t_url->set_date_created(Time::FromTimeT(100)); |
| 398 t_url->set_last_modified(Time::FromTimeT(100)); | 399 t_url->set_last_modified(Time::FromTimeT(100)); |
| 400 t_url->set_sync_guid("00000000-0000-0000-0000-000000000001"); |
| 399 t_url->set_safe_for_autoreplace(true); | 401 t_url->set_safe_for_autoreplace(true); |
| 400 model()->Add(t_url); | 402 model()->Add(t_url); |
| 401 ASSERT_TRUE(model()->CanReplaceKeyword(ASCIIToUTF16("keyword"), | 403 ASSERT_TRUE(model()->CanReplaceKeyword(ASCIIToUTF16("keyword"), |
| 402 GURL(), NULL)); | 404 GURL(), NULL)); |
| 403 VerifyObserverCount(1); | 405 VerifyObserverCount(1); |
| 404 BlockTillServiceProcessesRequests(); | 406 BlockTillServiceProcessesRequests(); |
| 405 // We need to clone as model takes ownership of TemplateURL and will | 407 // We need to clone as model takes ownership of TemplateURL and will |
| 406 // delete it. | 408 // delete it. |
| 407 TemplateURL cloned_url(*t_url); | 409 TemplateURL cloned_url(*t_url); |
| 408 ASSERT_EQ(1 + initial_count, model()->GetTemplateURLs().size()); | 410 ASSERT_EQ(1 + initial_count, model()->GetTemplateURLs().size()); |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 model()->SetDefaultSearchProvider(t_url); | 1237 model()->SetDefaultSearchProvider(t_url); |
| 1236 EXPECT_EQ(t_url, model()->GetDefaultSearchProvider()); | 1238 EXPECT_EQ(t_url, model()->GetDefaultSearchProvider()); |
| 1237 | 1239 |
| 1238 // Now reset the model again but load it after setting the preferences. | 1240 // Now reset the model again but load it after setting the preferences. |
| 1239 ResetModel(false); | 1241 ResetModel(false); |
| 1240 SetManagedDefaultSearchPreferences(false, "", "", "", "", "", ""); | 1242 SetManagedDefaultSearchPreferences(false, "", "", "", "", "", ""); |
| 1241 VerifyLoad(); | 1243 VerifyLoad(); |
| 1242 EXPECT_TRUE(model()->is_default_search_managed()); | 1244 EXPECT_TRUE(model()->is_default_search_managed()); |
| 1243 EXPECT_TRUE(model()->GetDefaultSearchProvider() == NULL); | 1245 EXPECT_TRUE(model()->GetDefaultSearchProvider() == NULL); |
| 1244 } | 1246 } |
| OLD | NEW |