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

Side by Side Diff: chrome/browser/autocomplete/history_url_provider_unittest.cc

Issue 1912: Renames BoomarkBarModel to BookmarkModel. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "chrome/browser/autocomplete/history_url_provider.h" 8 #include "chrome/browser/autocomplete/history_url_provider.h"
9 #include "chrome/browser/bookmarks/bookmark_bar_model.h" 9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #include "chrome/browser/history/history.h" 10 #include "chrome/browser/history/history.h"
11 #include "chrome/test/testing_profile.h" 11 #include "chrome/test/testing_profile.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 struct TestURLInfo { 14 struct TestURLInfo {
15 std::wstring url; 15 std::wstring url;
16 std::wstring title; 16 std::wstring title;
17 int visit_count; 17 int visit_count;
18 int typed_count; 18 int typed_count;
19 bool starred; 19 bool starred;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 scoped_refptr<HistoryURLProvider> autocomplete_; 107 scoped_refptr<HistoryURLProvider> autocomplete_;
108 }; 108 };
109 109
110 void HistoryURLProviderTest::OnProviderUpdate(bool updated_matches) { 110 void HistoryURLProviderTest::OnProviderUpdate(bool updated_matches) {
111 if (autocomplete_->done()) 111 if (autocomplete_->done())
112 MessageLoop::current()->Quit(); 112 MessageLoop::current()->Quit();
113 } 113 }
114 114
115 void HistoryURLProviderTest::SetUp() { 115 void HistoryURLProviderTest::SetUp() {
116 profile_.reset(new TestingProfile()); 116 profile_.reset(new TestingProfile());
117 profile_->CreateBookmarkBarModel(true); 117 profile_->CreateBookmarkModel(true);
118 profile_->CreateHistoryService(true); 118 profile_->CreateHistoryService(true);
119 history_service_ = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); 119 history_service_ = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
120 120
121 autocomplete_ = new HistoryURLProvider(this, profile_.get()); 121 autocomplete_ = new HistoryURLProvider(this, profile_.get());
122 122
123 FillData(); 123 FillData();
124 } 124 }
125 125
126 void HistoryURLProviderTest::TearDown() { 126 void HistoryURLProviderTest::TearDown() {
127 autocomplete_ = NULL; 127 autocomplete_ = NULL;
128 } 128 }
129 129
130 void HistoryURLProviderTest::FillData() { 130 void HistoryURLProviderTest::FillData() {
131 // All visits are a long time ago (some tests require this since we do some 131 // All visits are a long time ago (some tests require this since we do some
132 // special logic for things visited very recently). Note that this time must 132 // special logic for things visited very recently). Note that this time must
133 // be more recent than the "archived history" threshold for the data to go 133 // be more recent than the "archived history" threshold for the data to go
134 // into the main database. 134 // into the main database.
135 // 135 //
136 // TODO(brettw) It would be nice if we could test this behavior, in which 136 // TODO(brettw) It would be nice if we could test this behavior, in which
137 // case the time would be specifed in the test_db structure. 137 // case the time would be specifed in the test_db structure.
138 Time visit_time = Time::Now() - TimeDelta::FromDays(80); 138 Time visit_time = Time::Now() - TimeDelta::FromDays(80);
139 139
140 for (int i = 0; i < arraysize(test_db); ++i) { 140 for (int i = 0; i < arraysize(test_db); ++i) {
141 const TestURLInfo& cur = test_db[i]; 141 const TestURLInfo& cur = test_db[i];
142 const GURL current_url(cur.url); 142 const GURL current_url(cur.url);
143 history_service_->AddPageWithDetails(current_url, cur.title, 143 history_service_->AddPageWithDetails(current_url, cur.title,
144 cur.visit_count, cur.typed_count, 144 cur.visit_count, cur.typed_count,
145 visit_time, false); 145 visit_time, false);
146 if (cur.starred) { 146 if (cur.starred) {
147 profile_->GetBookmarkBarModel()->SetURLStarred( 147 profile_->GetBookmarkModel()->SetURLStarred(
148 current_url, std::wstring(), true); 148 current_url, std::wstring(), true);
149 } 149 }
150 } 150 }
151 } 151 }
152 152
153 void HistoryURLProviderTest::RunTest(const std::wstring text, 153 void HistoryURLProviderTest::RunTest(const std::wstring text,
154 const std::wstring& desired_tld, 154 const std::wstring& desired_tld,
155 bool prevent_inline_autocomplete, 155 bool prevent_inline_autocomplete,
156 const std::wstring* expected_urls, 156 const std::wstring* expected_urls,
157 int num_results) { 157 int num_results) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 L"http://bogussite.com/c", 336 L"http://bogussite.com/c",
337 }; 337 };
338 RunTest(input_2, std::wstring(), false, fixup_2, arraysize(fixup_2)); 338 RunTest(input_2, std::wstring(), false, fixup_2, arraysize(fixup_2));
339 EXPECT_EQ(input_2.length(), matches_[0].inline_autocomplete_offset); 339 EXPECT_EQ(input_2.length(), matches_[0].inline_autocomplete_offset);
340 340
341 // Adding a TLD to a small number like "56" should result in "www.56.com" 341 // Adding a TLD to a small number like "56" should result in "www.56.com"
342 // rather than "0.0.0.56.com". 342 // rather than "0.0.0.56.com".
343 std::wstring fixup_3[] = {L"http://www.56.com/"}; 343 std::wstring fixup_3[] = {L"http://www.56.com/"};
344 RunTest(L"56", L"com", true, fixup_3, arraysize(fixup_3)); 344 RunTest(L"56", L"com", true, fixup_3, arraysize(fixup_3));
345 } 345 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698