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

Side by Side Diff: chrome/browser/ui/webui/ntp/suggestions_combiner_unittest.cc

Issue 671653002: Standardize usage of virtual/override/final in chrome/browser/ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 // TODO(beaudoin): What is really needed here? 5 // TODO(beaudoin): What is really needed here?
6 6
7 #include <deque> 7 #include <deque>
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 class SuggestionsSourceStub : public SuggestionsSource { 135 class SuggestionsSourceStub : public SuggestionsSource {
136 public: 136 public:
137 explicit SuggestionsSourceStub(int weight, 137 explicit SuggestionsSourceStub(int weight,
138 const std::string& source_name, int number_of_suggestions) 138 const std::string& source_name, int number_of_suggestions)
139 : combiner_(NULL), 139 : combiner_(NULL),
140 weight_(weight), 140 weight_(weight),
141 source_name_(source_name), 141 source_name_(source_name),
142 number_of_suggestions_(number_of_suggestions), 142 number_of_suggestions_(number_of_suggestions),
143 debug_(false) { 143 debug_(false) {
144 } 144 }
145 virtual ~SuggestionsSourceStub() { 145 ~SuggestionsSourceStub() override { STLDeleteElements(&items_); }
146 STLDeleteElements(&items_);
147 }
148 146
149 // Call this method to simulate that the SuggestionsSource has received all 147 // Call this method to simulate that the SuggestionsSource has received all
150 // its suggestions. 148 // its suggestions.
151 void Done() { 149 void Done() {
152 combiner_->OnItemsReady(); 150 combiner_->OnItemsReady();
153 } 151 }
154 152
155 private: 153 private:
156 // SuggestionsSource Override and implementation. 154 // SuggestionsSource Override and implementation.
157 virtual void SetDebug(bool enable) override { 155 void SetDebug(bool enable) override { debug_ = enable; }
158 debug_ = enable; 156 int GetWeight() override { return weight_; }
159 } 157 int GetItemCount() override { return items_.size(); }
160 virtual int GetWeight() override { 158 base::DictionaryValue* PopItem() override {
161 return weight_;
162 }
163 virtual int GetItemCount() override {
164 return items_.size();
165 }
166 virtual base::DictionaryValue* PopItem() override {
167 if (items_.empty()) 159 if (items_.empty())
168 return NULL; 160 return NULL;
169 base::DictionaryValue* item = items_.front(); 161 base::DictionaryValue* item = items_.front();
170 items_.pop_front(); 162 items_.pop_front();
171 return item; 163 return item;
172 } 164 }
173 165
174 virtual void FetchItems(Profile* profile) override { 166 void FetchItems(Profile* profile) override {
175 char num_str[21]; // Enough to hold all numbers up to 64-bits. 167 char num_str[21]; // Enough to hold all numbers up to 64-bits.
176 for (int i = 0; i < number_of_suggestions_; ++i) { 168 for (int i = 0; i < number_of_suggestions_; ++i) {
177 base::snprintf(num_str, sizeof(num_str), "%d", i); 169 base::snprintf(num_str, sizeof(num_str), "%d", i);
178 AddSuggestion(source_name_ + ' ' + num_str); 170 AddSuggestion(source_name_ + ' ' + num_str);
179 } 171 }
180 } 172 }
181 173
182 // Adds a fake suggestion. This suggestion is a DictionaryValue with a single 174 // Adds a fake suggestion. This suggestion is a DictionaryValue with a single
183 // "title" field containing |title|. 175 // "title" field containing |title|.
184 void AddSuggestion(const std::string& title) { 176 void AddSuggestion(const std::string& title) {
185 base::DictionaryValue* item = new base::DictionaryValue(); 177 base::DictionaryValue* item = new base::DictionaryValue();
186 item->SetString("title", title); 178 item->SetString("title", title);
187 items_.push_back(item); 179 items_.push_back(item);
188 } 180 }
189 181
190 virtual void SetCombiner(SuggestionsCombiner* combiner) override { 182 void SetCombiner(SuggestionsCombiner* combiner) override {
191 DCHECK(!combiner_); 183 DCHECK(!combiner_);
192 combiner_ = combiner; 184 combiner_ = combiner;
193 } 185 }
194 186
195 // Our combiner. 187 // Our combiner.
196 SuggestionsCombiner* combiner_; 188 SuggestionsCombiner* combiner_;
197 189
198 int weight_; 190 int weight_;
199 std::string source_name_; 191 std::string source_name_;
200 int number_of_suggestions_; 192 int number_of_suggestions_;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } else { 287 } else {
296 EXPECT_EQ(description.results[j], static_cast<const char*>(NULL)) << 288 EXPECT_EQ(description.results[j], static_cast<const char*>(NULL)) <<
297 " test index:" << i; 289 " test index:" << i;
298 } 290 }
299 } 291 }
300 292
301 Reset(); 293 Reset();
302 } 294 }
303 } 295 }
304 296
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698