OLD | NEW |
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 "chrome/browser/predictors/autocomplete_action_predictor.h" | 5 #include "chrome/browser/predictors/autocomplete_action_predictor.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/guid.h" |
9 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
12 #include "base/time.h" | 13 #include "base/time.h" |
13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/autocomplete/autocomplete_match.h" | 15 #include "chrome/browser/autocomplete/autocomplete_match.h" |
15 #include "chrome/browser/history/history.h" | 16 #include "chrome/browser/history/history.h" |
16 #include "chrome/browser/history/in_memory_database.h" | 17 #include "chrome/browser/history/in_memory_database.h" |
17 #include "chrome/browser/history/url_database.h" | 18 #include "chrome/browser/history/url_database.h" |
18 #include "chrome/browser/prerender/prerender_field_trial.h" | 19 #include "chrome/browser/prerender/prerender_field_trial.h" |
19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/guid.h" | |
21 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
22 #include "content/public/test/test_browser_thread.h" | 22 #include "content/public/test/test_browser_thread.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
24 | 24 |
25 using content::BrowserThread; | 25 using content::BrowserThread; |
26 using predictors::AutocompleteActionPredictor; | 26 using predictors::AutocompleteActionPredictor; |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 struct TestUrlInfo { | 30 struct TestUrlInfo { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 history::URLRow row(test_row.url); | 131 history::URLRow row(test_row.url); |
132 row.set_title(test_row.title); | 132 row.set_title(test_row.title); |
133 row.set_last_visit(visit_time); | 133 row.set_last_visit(visit_time); |
134 | 134 |
135 return url_db->AddURL(row); | 135 return url_db->AddURL(row); |
136 } | 136 } |
137 | 137 |
138 AutocompleteActionPredictorTable::Row CreateRowFromTestUrlInfo( | 138 AutocompleteActionPredictorTable::Row CreateRowFromTestUrlInfo( |
139 const TestUrlInfo& test_row) const { | 139 const TestUrlInfo& test_row) const { |
140 AutocompleteActionPredictorTable::Row row; | 140 AutocompleteActionPredictorTable::Row row; |
141 row.id = guid::GenerateGUID(); | 141 row.id = base::GenerateGUID(); |
142 row.user_text = test_row.user_text; | 142 row.user_text = test_row.user_text; |
143 row.url = test_row.url; | 143 row.url = test_row.url; |
144 row.number_of_hits = test_row.number_of_hits; | 144 row.number_of_hits = test_row.number_of_hits; |
145 row.number_of_misses = test_row.number_of_misses; | 145 row.number_of_misses = test_row.number_of_misses; |
146 return row; | 146 return row; |
147 } | 147 } |
148 | 148 |
149 void AddAllRows() { | 149 void AddAllRows() { |
150 for (size_t i = 0; i < arraysize(test_url_db); ++i) | 150 for (size_t i = 0; i < arraysize(test_url_db); ++i) |
151 AddRow(test_url_db[i]); | 151 AddRow(test_url_db[i]); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 AutocompleteActionPredictor::ACTION_PRERENDER) ? | 366 AutocompleteActionPredictor::ACTION_PRERENDER) ? |
367 AutocompleteActionPredictor::ACTION_PRECONNECT : | 367 AutocompleteActionPredictor::ACTION_PRECONNECT : |
368 test_url_db[i].expected_action; | 368 test_url_db[i].expected_action; |
369 EXPECT_EQ(expected_action, | 369 EXPECT_EQ(expected_action, |
370 predictor()->RecommendAction(test_url_db[i].user_text, match)) | 370 predictor()->RecommendAction(test_url_db[i].user_text, match)) |
371 << "Unexpected action for " << match.destination_url; | 371 << "Unexpected action for " << match.destination_url; |
372 } | 372 } |
373 } | 373 } |
374 | 374 |
375 } // namespace predictors | 375 } // namespace predictors |
OLD | NEW |