| 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/guid.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 public: | 83 public: |
| 84 AutocompleteActionPredictorTest() | 84 AutocompleteActionPredictorTest() |
| 85 : loop_(MessageLoop::TYPE_DEFAULT), | 85 : loop_(MessageLoop::TYPE_DEFAULT), |
| 86 ui_thread_(BrowserThread::UI, &loop_), | 86 ui_thread_(BrowserThread::UI, &loop_), |
| 87 db_thread_(BrowserThread::DB, &loop_), | 87 db_thread_(BrowserThread::DB, &loop_), |
| 88 file_thread_(BrowserThread::FILE, &loop_), | 88 file_thread_(BrowserThread::FILE, &loop_), |
| 89 profile_(new TestingProfile()), | 89 profile_(new TestingProfile()), |
| 90 predictor_(new AutocompleteActionPredictor(profile_.get())) { | 90 predictor_(new AutocompleteActionPredictor(profile_.get())) { |
| 91 } | 91 } |
| 92 | 92 |
| 93 ~AutocompleteActionPredictorTest() { | 93 virtual ~AutocompleteActionPredictorTest() { |
| 94 predictor_.reset(NULL); | 94 predictor_.reset(NULL); |
| 95 profile_.reset(NULL); | 95 profile_.reset(NULL); |
| 96 loop_.RunUntilIdle(); | 96 loop_.RunUntilIdle(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void SetUp() { | 99 virtual void SetUp() { |
| 100 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 100 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 101 switches::kPrerenderFromOmnibox, | 101 switches::kPrerenderFromOmnibox, |
| 102 switches::kPrerenderFromOmniboxSwitchValueEnabled); | 102 switches::kPrerenderFromOmniboxSwitchValueEnabled); |
| 103 | 103 |
| 104 predictor_->CreateLocalCachesFromDatabase(); | 104 predictor_->CreateLocalCachesFromDatabase(); |
| 105 profile_->CreateHistoryService(true, false); | 105 profile_->CreateHistoryService(true, false); |
| 106 profile_->BlockUntilHistoryProcessesPendingRequests(); | 106 profile_->BlockUntilHistoryProcessesPendingRequests(); |
| 107 | 107 |
| 108 ASSERT_TRUE(predictor_->initialized_); | 108 ASSERT_TRUE(predictor_->initialized_); |
| 109 ASSERT_TRUE(db_cache()->empty()); | 109 ASSERT_TRUE(db_cache()->empty()); |
| 110 ASSERT_TRUE(db_id_cache()->empty()); | 110 ASSERT_TRUE(db_id_cache()->empty()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void TearDown() { | 113 virtual void TearDown() { |
| 114 profile_->DestroyHistoryService(); | 114 profile_->DestroyHistoryService(); |
| 115 predictor_->Shutdown(); | 115 predictor_->Shutdown(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 protected: | 118 protected: |
| 119 typedef AutocompleteActionPredictor::DBCacheKey DBCacheKey; | 119 typedef AutocompleteActionPredictor::DBCacheKey DBCacheKey; |
| 120 typedef AutocompleteActionPredictor::DBCacheValue DBCacheValue; | 120 typedef AutocompleteActionPredictor::DBCacheValue DBCacheValue; |
| 121 typedef AutocompleteActionPredictor::DBCacheMap DBCacheMap; | 121 typedef AutocompleteActionPredictor::DBCacheMap DBCacheMap; |
| 122 typedef AutocompleteActionPredictor::DBIdCacheMap DBIdCacheMap; | 122 typedef AutocompleteActionPredictor::DBIdCacheMap DBIdCacheMap; |
| 123 | 123 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 AutocompleteActionPredictor::ACTION_PRERENDER) ? | 375 AutocompleteActionPredictor::ACTION_PRERENDER) ? |
| 376 AutocompleteActionPredictor::ACTION_PRECONNECT : | 376 AutocompleteActionPredictor::ACTION_PRECONNECT : |
| 377 test_url_db[i].expected_action; | 377 test_url_db[i].expected_action; |
| 378 EXPECT_EQ(expected_action, | 378 EXPECT_EQ(expected_action, |
| 379 predictor()->RecommendAction(test_url_db[i].user_text, match)) | 379 predictor()->RecommendAction(test_url_db[i].user_text, match)) |
| 380 << "Unexpected action for " << match.destination_url; | 380 << "Unexpected action for " << match.destination_url; |
| 381 } | 381 } |
| 382 } | 382 } |
| 383 | 383 |
| 384 } // namespace predictors | 384 } // namespace predictors |
| OLD | NEW |