Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(984)

Side by Side Diff: components/search_engines/default_search_manager_unittest.cc

Issue 2498053002: Add field to monitor last visited time for each search engine (Closed)
Patch Set: Update Nit comment. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/search_engines/default_search_manager.h" 5 #include "components/search_engines/default_search_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 11 matching lines...) Expand all
22 #include "components/search_engines/template_url_prepopulate_data.h" 22 #include "components/search_engines/template_url_prepopulate_data.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 24
25 namespace { 25 namespace {
26 // A dictionary to hold all data related to the Default Search Engine. 26 // A dictionary to hold all data related to the Default Search Engine.
27 // Eventually, this should replace all the data stored in the 27 // Eventually, this should replace all the data stored in the
28 // default_search_provider.* prefs. 28 // default_search_provider.* prefs.
29 const char kDefaultSearchProviderData[] = 29 const char kDefaultSearchProviderData[] =
30 "default_search_provider_data.template_url_data"; 30 "default_search_provider_data.template_url_data";
31 31
32 // Checks that the two TemplateURLs are similar. Does not check the id, the 32 // Checks that the two TemplateURLs are similar. Does not check the id or
33 // date_created or the last_modified time. Neither pointer should be NULL. 33 // any time-related fields. Neither pointer should be null.
34 void ExpectSimilar(const TemplateURLData* expected, 34 void ExpectSimilar(const TemplateURLData* expected,
35 const TemplateURLData* actual) { 35 const TemplateURLData* actual) {
36 ASSERT_TRUE(expected != NULL); 36 ASSERT_TRUE(expected != NULL);
37 ASSERT_TRUE(actual != NULL); 37 ASSERT_TRUE(actual != NULL);
38 38
39 EXPECT_EQ(expected->short_name(), actual->short_name()); 39 EXPECT_EQ(expected->short_name(), actual->short_name());
40 EXPECT_EQ(expected->keyword(), actual->keyword()); 40 EXPECT_EQ(expected->keyword(), actual->keyword());
41 EXPECT_EQ(expected->url(), actual->url()); 41 EXPECT_EQ(expected->url(), actual->url());
42 EXPECT_EQ(expected->suggestions_url, actual->suggestions_url); 42 EXPECT_EQ(expected->suggestions_url, actual->suggestions_url);
43 EXPECT_EQ(expected->favicon_url, actual->favicon_url); 43 EXPECT_EQ(expected->favicon_url, actual->favicon_url);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 data->SetURL(std::string("http://").append(type).append("foo/{searchTerms}")); 104 data->SetURL(std::string("http://").append(type).append("foo/{searchTerms}"));
105 data->suggestions_url = std::string("http://").append(type).append("sugg"); 105 data->suggestions_url = std::string("http://").append(type).append("sugg");
106 data->alternate_urls.push_back( 106 data->alternate_urls.push_back(
107 std::string("http://").append(type).append("foo/alt")); 107 std::string("http://").append(type).append("foo/alt"));
108 data->favicon_url = GURL("http://icon1"); 108 data->favicon_url = GURL("http://icon1");
109 data->safe_for_autoreplace = true; 109 data->safe_for_autoreplace = true;
110 data->input_encodings = base::SplitString( 110 data->input_encodings = base::SplitString(
111 "UTF-8;UTF-16", ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 111 "UTF-8;UTF-16", ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
112 data->date_created = base::Time(); 112 data->date_created = base::Time();
113 data->last_modified = base::Time(); 113 data->last_modified = base::Time();
114 data->last_visited = base::Time();
114 return data; 115 return data;
115 } 116 }
116 117
117 } // namespace 118 } // namespace
118 119
119 class DefaultSearchManagerTest : public testing::Test { 120 class DefaultSearchManagerTest : public testing::Test {
120 public: 121 public:
121 DefaultSearchManagerTest() {}; 122 DefaultSearchManagerTest() {};
122 123
123 void SetUp() override { 124 void SetUp() override {
(...skipping 21 matching lines...) Expand all
145 data.SetKeyword(base::UTF8ToUTF16("key1")); 146 data.SetKeyword(base::UTF8ToUTF16("key1"));
146 data.SetURL("http://foo1/{searchTerms}"); 147 data.SetURL("http://foo1/{searchTerms}");
147 data.suggestions_url = "http://sugg1"; 148 data.suggestions_url = "http://sugg1";
148 data.alternate_urls.push_back("http://foo1/alt"); 149 data.alternate_urls.push_back("http://foo1/alt");
149 data.favicon_url = GURL("http://icon1"); 150 data.favicon_url = GURL("http://icon1");
150 data.safe_for_autoreplace = true; 151 data.safe_for_autoreplace = true;
151 data.input_encodings = base::SplitString( 152 data.input_encodings = base::SplitString(
152 "UTF-8;UTF-16", ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 153 "UTF-8;UTF-16", ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
153 data.date_created = base::Time(); 154 data.date_created = base::Time();
154 data.last_modified = base::Time(); 155 data.last_modified = base::Time();
156 data.last_modified = base::Time();
155 157
156 manager.SetUserSelectedDefaultSearchEngine(data); 158 manager.SetUserSelectedDefaultSearchEngine(data);
157 TemplateURLData* read_data = manager.GetDefaultSearchEngine(NULL); 159 TemplateURLData* read_data = manager.GetDefaultSearchEngine(NULL);
158 ExpectSimilar(&data, read_data); 160 ExpectSimilar(&data, read_data);
159 } 161 }
160 162
161 // Test DefaultSearchmanager handles user-selected DSEs correctly. 163 // Test DefaultSearchmanager handles user-selected DSEs correctly.
162 TEST_F(DefaultSearchManagerTest, DefaultSearchSetByUserPref) { 164 TEST_F(DefaultSearchManagerTest, DefaultSearchSetByUserPref) {
163 size_t default_search_index = 0; 165 size_t default_search_index = 0;
164 DefaultSearchManager manager(pref_service(), 166 DefaultSearchManager manager(pref_service(),
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 297
296 ExpectSimilar(extension_data_3.get(), 298 ExpectSimilar(extension_data_3.get(),
297 manager.GetDefaultSearchEngine(&source)); 299 manager.GetDefaultSearchEngine(&source));
298 EXPECT_EQ(DefaultSearchManager::FROM_EXTENSION, source); 300 EXPECT_EQ(DefaultSearchManager::FROM_EXTENSION, source);
299 301
300 manager.ClearExtensionControlledDefaultSearchEngine(); 302 manager.ClearExtensionControlledDefaultSearchEngine();
301 303
302 ExpectSimilar(data.get(), manager.GetDefaultSearchEngine(&source)); 304 ExpectSimilar(data.get(), manager.GetDefaultSearchEngine(&source));
303 EXPECT_EQ(DefaultSearchManager::FROM_USER, source); 305 EXPECT_EQ(DefaultSearchManager::FROM_USER, source);
304 } 306 }
OLDNEW
« no previous file with comments | « components/search_engines/default_search_manager.cc ('k') | components/search_engines/keyword_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698