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

Side by Side Diff: chrome/browser/predictors/autocomplete_action_predictor_unittest.cc

Issue 2538763002: Data from the autocomplete predictor wasn't deleted immediately when deleting browsing history. (Closed)
Patch Set: assume history_service always exist to ensure we definitly delete data when requested Created 4 years 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
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 "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"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 namespace predictors { 85 namespace predictors {
86 86
87 class AutocompleteActionPredictorTest : public testing::Test { 87 class AutocompleteActionPredictorTest : public testing::Test {
88 public: 88 public:
89 AutocompleteActionPredictorTest() 89 AutocompleteActionPredictorTest()
90 : ui_thread_(BrowserThread::UI, &loop_), 90 : ui_thread_(BrowserThread::UI, &loop_),
91 db_thread_(BrowserThread::DB, &loop_), 91 db_thread_(BrowserThread::DB, &loop_),
92 file_thread_(BrowserThread::FILE, &loop_), 92 file_thread_(BrowserThread::FILE, &loop_),
93 profile_(new TestingProfile()), 93 profile_(new TestingProfile()),
94 predictor_(new AutocompleteActionPredictor(profile_.get())) { 94 predictor_(nullptr) {
95 } 95 }
96 96
97 ~AutocompleteActionPredictorTest() override { 97 ~AutocompleteActionPredictorTest() override {
98 predictor_.reset(NULL); 98 predictor_.reset(NULL);
99 profile_.reset(NULL); 99 profile_.reset(NULL);
100 base::RunLoop().RunUntilIdle(); 100 base::RunLoop().RunUntilIdle();
101 } 101 }
102 102
103 void SetUp() override { 103 void SetUp() override {
104 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 104 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
105 switches::kPrerenderFromOmnibox, 105 switches::kPrerenderFromOmnibox,
106 switches::kPrerenderFromOmniboxSwitchValueEnabled); 106 switches::kPrerenderFromOmniboxSwitchValueEnabled);
107 107
108 ASSERT_TRUE(profile_->CreateHistoryService(true, false));
109 predictor_.reset(new AutocompleteActionPredictor(profile_.get()));
108 predictor_->CreateLocalCachesFromDatabase(); 110 predictor_->CreateLocalCachesFromDatabase();
109 ASSERT_TRUE(profile_->CreateHistoryService(true, false));
110 profile_->BlockUntilHistoryProcessesPendingRequests(); 111 profile_->BlockUntilHistoryProcessesPendingRequests();
111 112
112 ASSERT_TRUE(predictor_->initialized_); 113 ASSERT_TRUE(predictor_->initialized_);
113 ASSERT_TRUE(db_cache()->empty()); 114 ASSERT_TRUE(db_cache()->empty());
114 ASSERT_TRUE(db_id_cache()->empty()); 115 ASSERT_TRUE(db_id_cache()->empty());
115 } 116 }
116 117
117 void TearDown() override { 118 void TearDown() override {
119 predictor_->Shutdown();
118 profile_->DestroyHistoryService(); 120 profile_->DestroyHistoryService();
119 predictor_->Shutdown();
120 } 121 }
121 122
122 protected: 123 protected:
123 typedef AutocompleteActionPredictor::DBCacheKey DBCacheKey; 124 typedef AutocompleteActionPredictor::DBCacheKey DBCacheKey;
124 typedef AutocompleteActionPredictor::DBCacheValue DBCacheValue; 125 typedef AutocompleteActionPredictor::DBCacheValue DBCacheValue;
125 typedef AutocompleteActionPredictor::DBCacheMap DBCacheMap; 126 typedef AutocompleteActionPredictor::DBCacheMap DBCacheMap;
126 typedef AutocompleteActionPredictor::DBIdCacheMap DBIdCacheMap; 127 typedef AutocompleteActionPredictor::DBIdCacheMap DBIdCacheMap;
127 128
128 void AddAllRowsToHistory() { 129 void AddAllRowsToHistory() {
129 for (size_t i = 0; i < arraysize(test_url_db); ++i) 130 for (size_t i = 0; i < arraysize(test_url_db); ++i)
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 AutocompleteActionPredictor::ACTION_PRERENDER) ? 381 AutocompleteActionPredictor::ACTION_PRERENDER) ?
381 AutocompleteActionPredictor::ACTION_PRECONNECT : 382 AutocompleteActionPredictor::ACTION_PRECONNECT :
382 test_url_db[i].expected_action; 383 test_url_db[i].expected_action;
383 EXPECT_EQ(expected_action, 384 EXPECT_EQ(expected_action,
384 predictor()->RecommendAction(test_url_db[i].user_text, match)) 385 predictor()->RecommendAction(test_url_db[i].user_text, match))
385 << "Unexpected action for " << match.destination_url; 386 << "Unexpected action for " << match.destination_url;
386 } 387 }
387 } 388 }
388 389
389 } // namespace predictors 390 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698