| 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" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h" | 14 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h" |
| 15 #include "chrome/browser/ui/webui/ntp/suggestions_page_handler.h" | 15 #include "chrome/browser/ui/webui/ntp/suggestions_page_handler.h" |
| 16 #include "chrome/browser/ui/webui/ntp/suggestions_source.h" | 16 #include "chrome/browser/ui/webui/ntp/suggestions_source.h" |
| 17 #include "chrome/test/base/testing_profile.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 struct SourceInfo { | 22 struct SourceInfo { |
| 22 int weight; | 23 int weight; |
| 23 const char* source_name; | 24 const char* source_name; |
| 24 int number_of_suggestions; | 25 int number_of_suggestions; |
| 25 }; | 26 }; |
| 26 | 27 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 205 |
| 205 DISALLOW_COPY_AND_ASSIGN(SuggestionsSourceStub); | 206 DISALLOW_COPY_AND_ASSIGN(SuggestionsSourceStub); |
| 206 }; | 207 }; |
| 207 | 208 |
| 208 class SuggestionsCombinerTest : public testing::Test { | 209 class SuggestionsCombinerTest : public testing::Test { |
| 209 public: | 210 public: |
| 210 SuggestionsCombinerTest() { | 211 SuggestionsCombinerTest() { |
| 211 } | 212 } |
| 212 | 213 |
| 213 protected: | 214 protected: |
| 215 Profile* profile_; |
| 214 SuggestionsHandler* suggestions_handler_; | 216 SuggestionsHandler* suggestions_handler_; |
| 215 SuggestionsCombiner* combiner_; | 217 SuggestionsCombiner* combiner_; |
| 216 | 218 |
| 217 void Reset() { | 219 void Reset() { |
| 218 delete combiner_; | 220 delete combiner_; |
| 219 combiner_ = new SuggestionsCombiner(suggestions_handler_); | 221 combiner_ = new SuggestionsCombiner(suggestions_handler_, profile_); |
| 220 } | 222 } |
| 221 | 223 |
| 222 private: | 224 private: |
| 223 virtual void SetUp() { | 225 virtual void SetUp() { |
| 226 profile_ = new TestingProfile(); |
| 224 suggestions_handler_ = new SuggestionsHandler(); | 227 suggestions_handler_ = new SuggestionsHandler(); |
| 225 combiner_ = new SuggestionsCombiner(suggestions_handler_); | 228 combiner_ = new SuggestionsCombiner(suggestions_handler_, profile_); |
| 226 } | 229 } |
| 227 | 230 |
| 228 virtual void TearDown() { | 231 virtual void TearDown() { |
| 229 delete combiner_; | 232 delete combiner_; |
| 230 delete suggestions_handler_; | 233 delete suggestions_handler_; |
| 234 delete profile_; |
| 231 } | 235 } |
| 232 | 236 |
| 233 DISALLOW_COPY_AND_ASSIGN(SuggestionsCombinerTest); | 237 DISALLOW_COPY_AND_ASSIGN(SuggestionsCombinerTest); |
| 234 }; | 238 }; |
| 235 | 239 |
| 236 TEST_F(SuggestionsCombinerTest, NoSource) { | 240 TEST_F(SuggestionsCombinerTest, NoSource) { |
| 237 combiner_->FetchItems(NULL); | 241 combiner_->FetchItems(NULL); |
| 238 EXPECT_EQ(0UL, combiner_->GetPageValues()->GetSize()); | 242 EXPECT_EQ(0UL, combiner_->GetPageValues()->GetSize()); |
| 239 } | 243 } |
| 240 | 244 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } else { | 296 } else { |
| 293 EXPECT_EQ(description.results[j], static_cast<const char*>(NULL)) << | 297 EXPECT_EQ(description.results[j], static_cast<const char*>(NULL)) << |
| 294 " test index:" << i; | 298 " test index:" << i; |
| 295 } | 299 } |
| 296 } | 300 } |
| 297 | 301 |
| 298 Reset(); | 302 Reset(); |
| 299 } | 303 } |
| 300 } | 304 } |
| 301 | 305 |
| OLD | NEW |