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 // 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 | 148 |
149 // Call this method to simulate that the SuggestionsSource has received all | 149 // Call this method to simulate that the SuggestionsSource has received all |
150 // its suggestions. | 150 // its suggestions. |
151 void Done() { | 151 void Done() { |
152 combiner_->OnItemsReady(); | 152 combiner_->OnItemsReady(); |
153 } | 153 } |
154 | 154 |
155 private: | 155 private: |
156 // SuggestionsSource Override and implementation. | 156 // SuggestionsSource Override and implementation. |
157 virtual void SetDebug(bool enable) OVERRIDE { | 157 virtual void SetDebug(bool enable) override { |
158 debug_ = enable; | 158 debug_ = enable; |
159 } | 159 } |
160 virtual int GetWeight() OVERRIDE { | 160 virtual int GetWeight() override { |
161 return weight_; | 161 return weight_; |
162 } | 162 } |
163 virtual int GetItemCount() OVERRIDE { | 163 virtual int GetItemCount() override { |
164 return items_.size(); | 164 return items_.size(); |
165 } | 165 } |
166 virtual base::DictionaryValue* PopItem() OVERRIDE { | 166 virtual base::DictionaryValue* PopItem() override { |
167 if (items_.empty()) | 167 if (items_.empty()) |
168 return NULL; | 168 return NULL; |
169 base::DictionaryValue* item = items_.front(); | 169 base::DictionaryValue* item = items_.front(); |
170 items_.pop_front(); | 170 items_.pop_front(); |
171 return item; | 171 return item; |
172 } | 172 } |
173 | 173 |
174 virtual void FetchItems(Profile* profile) OVERRIDE { | 174 virtual void FetchItems(Profile* profile) override { |
175 char num_str[21]; // Enough to hold all numbers up to 64-bits. | 175 char num_str[21]; // Enough to hold all numbers up to 64-bits. |
176 for (int i = 0; i < number_of_suggestions_; ++i) { | 176 for (int i = 0; i < number_of_suggestions_; ++i) { |
177 base::snprintf(num_str, sizeof(num_str), "%d", i); | 177 base::snprintf(num_str, sizeof(num_str), "%d", i); |
178 AddSuggestion(source_name_ + ' ' + num_str); | 178 AddSuggestion(source_name_ + ' ' + num_str); |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 // Adds a fake suggestion. This suggestion is a DictionaryValue with a single | 182 // Adds a fake suggestion. This suggestion is a DictionaryValue with a single |
183 // "title" field containing |title|. | 183 // "title" field containing |title|. |
184 void AddSuggestion(const std::string& title) { | 184 void AddSuggestion(const std::string& title) { |
185 base::DictionaryValue* item = new base::DictionaryValue(); | 185 base::DictionaryValue* item = new base::DictionaryValue(); |
186 item->SetString("title", title); | 186 item->SetString("title", title); |
187 items_.push_back(item); | 187 items_.push_back(item); |
188 } | 188 } |
189 | 189 |
190 virtual void SetCombiner(SuggestionsCombiner* combiner) OVERRIDE { | 190 virtual void SetCombiner(SuggestionsCombiner* combiner) override { |
191 DCHECK(!combiner_); | 191 DCHECK(!combiner_); |
192 combiner_ = combiner; | 192 combiner_ = combiner; |
193 } | 193 } |
194 | 194 |
195 // Our combiner. | 195 // Our combiner. |
196 SuggestionsCombiner* combiner_; | 196 SuggestionsCombiner* combiner_; |
197 | 197 |
198 int weight_; | 198 int weight_; |
199 std::string source_name_; | 199 std::string source_name_; |
200 int number_of_suggestions_; | 200 int number_of_suggestions_; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } else { | 295 } else { |
296 EXPECT_EQ(description.results[j], static_cast<const char*>(NULL)) << | 296 EXPECT_EQ(description.results[j], static_cast<const char*>(NULL)) << |
297 " test index:" << i; | 297 " test index:" << i; |
298 } | 298 } |
299 } | 299 } |
300 | 300 |
301 Reset(); | 301 Reset(); |
302 } | 302 } |
303 } | 303 } |
304 | 304 |
OLD | NEW |