Chromium Code Reviews| Index: chrome/browser/search_engines/template_url_service_unittest.cc |
| diff --git a/chrome/browser/search_engines/template_url_service_unittest.cc b/chrome/browser/search_engines/template_url_service_unittest.cc |
| index 69ced91afaf2e84640a9ce3c355b33ff505e7036..f57a4ae0d716eeee578a1272e9c73cd0c8a09ac3 100644 |
| --- a/chrome/browser/search_engines/template_url_service_unittest.cc |
| +++ b/chrome/browser/search_engines/template_url_service_unittest.cc |
| @@ -1,4 +1,4 @@ |
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| @@ -568,6 +568,44 @@ TEST_F(TemplateURLServiceTest, ClearBrowsingData_Keywords) { |
| EXPECT_EQ(2U, model()->GetTemplateURLs().size()); |
| } |
| +TEST_F(TemplateURLServiceTest, ClearBrowsingData_KeywordsForOrigin) { |
|
Peter Kasting
2012/02/16 18:16:35
Nit: It might be nice to expand this test to have
Use mkwst_at_chromium.org plz.
2012/02/17 10:12:36
Done.
|
| + Time now = Time::Now(); |
| + TimeDelta one_day = TimeDelta::FromDays(1); |
| + Time month_ago = now - TimeDelta::FromDays(30); |
| + |
| + // Nothing has been added. |
| + EXPECT_EQ(0U, model()->GetTemplateURLs().size()); |
| + |
| + // Create one for now and +/- 1 day. |
| + AddKeywordWithDate("key1", false, "http://foo1", "http://suggest1", |
| + "http://icon2", "UTF-8;UTF-16", "name2", true, |
| + now - one_day, Time()); |
| + AddKeywordWithDate("key2", false, "http://foo2", "", "", "", "name2", |
| + true, now, Time()); |
| + AddKeywordWithDate("key3", false, "http://foo3", "", "", "", "name3", |
| + true, now + one_day, Time()); |
| + |
| + // We just added a few items, validate them. |
| + EXPECT_EQ(3U, model()->GetTemplateURLs().size()); |
| + |
| + // Try removing foo2. This should delete foo2, but leave foo1 and 3 untouched. |
| + model()->RemoveAutoGeneratedForOriginBetween(month_ago, now + one_day, |
| + GURL("http://foo2")); |
| + EXPECT_EQ(2U, model()->GetTemplateURLs().size()); |
| + EXPECT_EQ(ASCIIToUTF16("key1"), model()->GetTemplateURLs()[0]->keyword()); |
| + EXPECT_TRUE(model()->GetTemplateURLs()[0]->safe_for_autoreplace()); |
| + |
| + EXPECT_EQ(ASCIIToUTF16("key3"), model()->GetTemplateURLs()[1]->keyword()); |
| + EXPECT_TRUE(model()->GetTemplateURLs()[1]->safe_for_autoreplace()); |
| + |
| + // Try removing foo1. This should delete foo1, but leave foo3 untouched. |
| + model()->RemoveAutoGeneratedForOriginBetween(month_ago, now + one_day, |
| + GURL("http://foo1")); |
| + EXPECT_EQ(1U, model()->GetTemplateURLs().size()); |
| + EXPECT_EQ(ASCIIToUTF16("key3"), model()->GetTemplateURLs()[0]->keyword()); |
| + EXPECT_TRUE(model()->GetTemplateURLs()[0]->safe_for_autoreplace()); |
| +} |
| + |
| TEST_F(TemplateURLServiceTest, Reset) { |
| // Add a new TemplateURL. |
| VerifyLoad(); |