| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/guid.h" | 11 #include "base/guid.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/run_loop.h" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 18 #include "chrome/browser/history/history_service_factory.h" | 19 #include "chrome/browser/history/history_service_factory.h" |
| 19 #include "chrome/browser/prerender/prerender_field_trial.h" | 20 #include "chrome/browser/prerender/prerender_field_trial.h" |
| 20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| 22 #include "components/history/core/browser/history_service.h" | 23 #include "components/history/core/browser/history_service.h" |
| 23 #include "components/history/core/browser/in_memory_database.h" | 24 #include "components/history/core/browser/in_memory_database.h" |
| 24 #include "components/history/core/browser/url_database.h" | 25 #include "components/history/core/browser/url_database.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 : ui_thread_(BrowserThread::UI, &loop_), | 90 : ui_thread_(BrowserThread::UI, &loop_), |
| 90 db_thread_(BrowserThread::DB, &loop_), | 91 db_thread_(BrowserThread::DB, &loop_), |
| 91 file_thread_(BrowserThread::FILE, &loop_), | 92 file_thread_(BrowserThread::FILE, &loop_), |
| 92 profile_(new TestingProfile()), | 93 profile_(new TestingProfile()), |
| 93 predictor_(new AutocompleteActionPredictor(profile_.get())) { | 94 predictor_(new AutocompleteActionPredictor(profile_.get())) { |
| 94 } | 95 } |
| 95 | 96 |
| 96 ~AutocompleteActionPredictorTest() override { | 97 ~AutocompleteActionPredictorTest() override { |
| 97 predictor_.reset(NULL); | 98 predictor_.reset(NULL); |
| 98 profile_.reset(NULL); | 99 profile_.reset(NULL); |
| 99 loop_.RunUntilIdle(); | 100 base::RunLoop().RunUntilIdle(); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void SetUp() override { | 103 void SetUp() override { |
| 103 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 104 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 104 switches::kPrerenderFromOmnibox, | 105 switches::kPrerenderFromOmnibox, |
| 105 switches::kPrerenderFromOmniboxSwitchValueEnabled); | 106 switches::kPrerenderFromOmniboxSwitchValueEnabled); |
| 106 | 107 |
| 107 predictor_->CreateLocalCachesFromDatabase(); | 108 predictor_->CreateLocalCachesFromDatabase(); |
| 108 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); | 109 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); |
| 109 profile_->BlockUntilHistoryProcessesPendingRequests(); | 110 profile_->BlockUntilHistoryProcessesPendingRequests(); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 AutocompleteActionPredictor::ACTION_PRERENDER) ? | 380 AutocompleteActionPredictor::ACTION_PRERENDER) ? |
| 380 AutocompleteActionPredictor::ACTION_PRECONNECT : | 381 AutocompleteActionPredictor::ACTION_PRECONNECT : |
| 381 test_url_db[i].expected_action; | 382 test_url_db[i].expected_action; |
| 382 EXPECT_EQ(expected_action, | 383 EXPECT_EQ(expected_action, |
| 383 predictor()->RecommendAction(test_url_db[i].user_text, match)) | 384 predictor()->RecommendAction(test_url_db[i].user_text, match)) |
| 384 << "Unexpected action for " << match.destination_url; | 385 << "Unexpected action for " << match.destination_url; |
| 385 } | 386 } |
| 386 } | 387 } |
| 387 | 388 |
| 388 } // namespace predictors | 389 } // namespace predictors |
| OLD | NEW |