| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/ntp_snippets/ntp_snippets_service.h" | 5 #include "components/ntp_snippets/ntp_snippets_service.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 EXPECT_CALL(*scheduler_, Schedule(_, _, _, _)); | 149 EXPECT_CALL(*scheduler_, Schedule(_, _, _, _)); |
| 150 else | 150 else |
| 151 EXPECT_CALL(*scheduler_, Unschedule()); | 151 EXPECT_CALL(*scheduler_, Unschedule()); |
| 152 service_->Init(enabled); | 152 service_->Init(enabled); |
| 153 } | 153 } |
| 154 | 154 |
| 155 protected: | 155 protected: |
| 156 NTPSnippetsService* service() { return service_.get(); } | 156 NTPSnippetsService* service() { return service_.get(); } |
| 157 | 157 |
| 158 void LoadFromJSONString(const std::string& json) { | 158 void LoadFromJSONString(const std::string& json) { |
| 159 service_->OnSnippetsDownloaded(json); | 159 service_->OnSnippetsDownloaded(json, std::string()); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void SetExpectJsonParseSuccess(bool expect_success) { | 162 void SetExpectJsonParseSuccess(bool expect_success) { |
| 163 service_->parse_json_callback_ = base::Bind(&ParseJson, expect_success); | 163 service_->parse_json_callback_ = base::Bind(&ParseJson, expect_success); |
| 164 } | 164 } |
| 165 | 165 |
| 166 private: | 166 private: |
| 167 base::MessageLoop message_loop_; | 167 base::MessageLoop message_loop_; |
| 168 scoped_ptr<TestingPrefServiceSimple> pref_service_; | 168 scoped_ptr<TestingPrefServiceSimple> pref_service_; |
| 169 scoped_ptr<NTPSnippetsService> service_; | 169 scoped_ptr<NTPSnippetsService> service_; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 } | 353 } |
| 354 | 354 |
| 355 TEST_F(NTPSnippetsServiceTest, RemoveExpiredContent) { | 355 TEST_F(NTPSnippetsServiceTest, RemoveExpiredContent) { |
| 356 std::string json_str(GetTestExpiredJson()); | 356 std::string json_str(GetTestExpiredJson()); |
| 357 | 357 |
| 358 LoadFromJSONString(json_str); | 358 LoadFromJSONString(json_str); |
| 359 EXPECT_EQ(service()->size(), 0u); | 359 EXPECT_EQ(service()->size(), 0u); |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // namespace ntp_snippets | 362 } // namespace ntp_snippets |
| OLD | NEW |