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

Side by Side Diff: chrome/browser/search_engines/template_url_service_unittest.cc

Issue 10963018: Rework arguments of HistoryService::AddPage() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows compile Created 8 years, 3 months 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 | Annotate | Revision Log
OLDNEW
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/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/test/mock_time_provider.h" 12 #include "base/test/mock_time_provider.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "base/time.h"
14 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/history/history.h" 16 #include "chrome/browser/history/history.h"
16 #include "chrome/browser/history/history_notifications.h" 17 #include "chrome/browser/history/history_notifications.h"
17 #include "chrome/browser/history/history_service_factory.h" 18 #include "chrome/browser/history/history_service_factory.h"
18 #include "chrome/browser/search_engines/search_host_to_urls_map.h" 19 #include "chrome/browser/search_engines/search_host_to_urls_map.h"
19 #include "chrome/browser/search_engines/search_terms_data.h" 20 #include "chrome/browser/search_engines/search_terms_data.h"
20 #include "chrome/browser/search_engines/template_url.h" 21 #include "chrome/browser/search_engines/template_url.h"
21 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 22 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
22 #include "chrome/browser/search_engines/template_url_service.h" 23 #include "chrome/browser/search_engines/template_url_service.h"
23 #include "chrome/browser/search_engines/template_url_service_test_util.h" 24 #include "chrome/browser/search_engines/template_url_service_test_util.h"
25 #include "chrome/browser/webdata/web_data_service_factory.h"
24 #include "chrome/browser/webdata/web_database.h" 26 #include "chrome/browser/webdata/web_database.h"
25 #include "chrome/browser/webdata/web_data_service_factory.h"
26 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
27 #include "chrome/test/base/testing_profile.h" 28 #include "chrome/test/base/testing_profile.h"
28 #include "content/public/test/test_browser_thread.h" 29 #include "content/public/test/test_browser_thread.h"
29 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
30 31
31 using base::Time; 32 using base::Time;
32 using base::TimeDelta; 33 using base::TimeDelta;
33 using content::BrowserThread; 34 using content::BrowserThread;
34 using ::testing::Return; 35 using ::testing::Return;
35 using ::testing::StrictMock; 36 using ::testing::StrictMock;
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 "http://foo.com/foo?query={searchTerms}", "http://sugg1", "http://icon1", 1058 "http://foo.com/foo?query={searchTerms}", "http://sugg1", "http://icon1",
1058 true, "UTF-8;UTF-16", base::Time::Now(), base::Time::Now()); 1059 true, "UTF-8;UTF-16", base::Time::Now(), base::Time::Now());
1059 1060
1060 // Add a visit that matches the url of the keyword. 1061 // Add a visit that matches the url of the keyword.
1061 HistoryService* history = 1062 HistoryService* history =
1062 HistoryServiceFactory::GetForProfile(test_util_.profile(), 1063 HistoryServiceFactory::GetForProfile(test_util_.profile(),
1063 Profile::EXPLICIT_ACCESS); 1064 Profile::EXPLICIT_ACCESS);
1064 history->AddPage( 1065 history->AddPage(
1065 GURL(t_url->url_ref().ReplaceSearchTerms( 1066 GURL(t_url->url_ref().ReplaceSearchTerms(
1066 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("blah")))), 1067 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("blah")))),
1067 NULL, 0, GURL(), content::PAGE_TRANSITION_KEYWORD, 1068 base::Time::Now(), NULL, 0, GURL(), history::RedirectList(),
1068 history::RedirectList(), history::SOURCE_BROWSED, false); 1069 content::PAGE_TRANSITION_KEYWORD, history::SOURCE_BROWSED, false);
1069 1070
1070 // Wait for history to finish processing the request. 1071 // Wait for history to finish processing the request.
1071 test_util_.profile()->BlockUntilHistoryProcessesPendingRequests(); 1072 test_util_.profile()->BlockUntilHistoryProcessesPendingRequests();
1072 1073
1073 // Query history for the generated url. 1074 // Query history for the generated url.
1074 CancelableRequestConsumer consumer; 1075 CancelableRequestConsumer consumer;
1075 QueryHistoryCallbackImpl callback; 1076 QueryHistoryCallbackImpl callback;
1076 history->QueryURL(GURL("http://keyword"), true, &consumer, 1077 history->QueryURL(GURL("http://keyword"), true, &consumer,
1077 base::Bind(&QueryHistoryCallbackImpl::Callback, 1078 base::Bind(&QueryHistoryCallbackImpl::Callback,
1078 base::Unretained(&callback))); 1079 base::Unretained(&callback)));
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 EXPECT_EQ(8U, loaded_url->input_encodings().size()); 1503 EXPECT_EQ(8U, loaded_url->input_encodings().size());
1503 1504
1504 // Reload the model to verify it was actually saved to the database and the 1505 // Reload the model to verify it was actually saved to the database and the
1505 // duplicate encodings were removed. 1506 // duplicate encodings were removed.
1506 test_util_.ResetModel(true); 1507 test_util_.ResetModel(true);
1507 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); 1508 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
1508 loaded_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); 1509 loaded_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword"));
1509 ASSERT_FALSE(loaded_url == NULL); 1510 ASSERT_FALSE(loaded_url == NULL);
1510 EXPECT_EQ(4U, loaded_url->input_encodings().size()); 1511 EXPECT_EQ(4U, loaded_url->input_encodings().size());
1511 } 1512 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service.cc ('k') | chrome/browser/sync/test/integration/typed_urls_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698