| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/suggestions/suggestions_service.h" | 5 #include "components/suggestions/suggestions_service.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | |
| 13 #include "components/suggestions/blacklist_store.h" | 12 #include "components/suggestions/blacklist_store.h" |
| 14 #include "components/suggestions/image_manager.h" | 13 #include "components/suggestions/image_manager.h" |
| 15 #include "components/suggestions/proto/suggestions.pb.h" | 14 #include "components/suggestions/proto/suggestions.pb.h" |
| 16 #include "components/suggestions/suggestions_store.h" | 15 #include "components/suggestions/suggestions_store.h" |
| 17 #include "components/suggestions/suggestions_utils.h" | 16 #include "components/suggestions/suggestions_utils.h" |
| 18 #include "net/http/http_response_headers.h" | 17 #include "net/http/http_response_headers.h" |
| 19 #include "net/http/http_status_code.h" | 18 #include "net/http/http_status_code.h" |
| 20 #include "net/url_request/test_url_fetcher_factory.h" | 19 #include "net/url_request/test_url_fetcher_factory.h" |
| 21 #include "net/url_request/url_request_status.h" | 20 #include "net/url_request/url_request_status.h" |
| 22 #include "net/url_request/url_request_test_util.h" | 21 #include "net/url_request/url_request_test_util.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 blacklisting_failed_(false), | 183 blacklisting_failed_(false), |
| 185 undo_blacklisting_failed_(false), | 184 undo_blacklisting_failed_(false), |
| 186 factory_(NULL, base::Bind(&CreateURLFetcher)), | 185 factory_(NULL, base::Bind(&CreateURLFetcher)), |
| 187 mock_thumbnail_manager_(NULL), | 186 mock_thumbnail_manager_(NULL), |
| 188 mock_blacklist_store_(NULL), | 187 mock_blacklist_store_(NULL), |
| 189 test_suggestions_store_(NULL) {} | 188 test_suggestions_store_(NULL) {} |
| 190 | 189 |
| 191 ~SuggestionsServiceTest() override {} | 190 ~SuggestionsServiceTest() override {} |
| 192 | 191 |
| 193 void SetUp() override { | 192 void SetUp() override { |
| 194 request_context_ = new net::TestURLRequestContextGetter( | 193 request_context_ = |
| 195 io_message_loop_.message_loop_proxy()); | 194 new net::TestURLRequestContextGetter(io_message_loop_.task_runner()); |
| 196 } | 195 } |
| 197 | 196 |
| 198 void FetchSuggestionsDataHelper(SyncState sync_state) { | 197 void FetchSuggestionsDataHelper(SyncState sync_state) { |
| 199 scoped_ptr<SuggestionsService> suggestions_service( | 198 scoped_ptr<SuggestionsService> suggestions_service( |
| 200 CreateSuggestionsServiceWithMocks()); | 199 CreateSuggestionsServiceWithMocks()); |
| 201 EXPECT_TRUE(suggestions_service != NULL); | 200 EXPECT_TRUE(suggestions_service != NULL); |
| 202 | 201 |
| 203 // Add some suggestions in the cache. | 202 // Add some suggestions in the cache. |
| 204 FillSuggestionsStore(); | 203 FillSuggestionsStore(); |
| 205 SuggestionsProfile suggestions_profile; | 204 SuggestionsProfile suggestions_profile; |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 scoped_ptr<SuggestionsService> suggestions_service( | 598 scoped_ptr<SuggestionsService> suggestions_service( |
| 600 CreateSuggestionsServiceWithMocks()); | 599 CreateSuggestionsServiceWithMocks()); |
| 601 SuggestionsProfile suggestions = | 600 SuggestionsProfile suggestions = |
| 602 CreateSuggestionsProfileWithExpiryTimestamps(); | 601 CreateSuggestionsProfileWithExpiryTimestamps(); |
| 603 suggestions_service->SetDefaultExpiryTimestamp(&suggestions, | 602 suggestions_service->SetDefaultExpiryTimestamp(&suggestions, |
| 604 kTestDefaultExpiry); | 603 kTestDefaultExpiry); |
| 605 EXPECT_EQ(kTestSetExpiry, suggestions.suggestions(0).expiry_ts()); | 604 EXPECT_EQ(kTestSetExpiry, suggestions.suggestions(0).expiry_ts()); |
| 606 EXPECT_EQ(kTestDefaultExpiry, suggestions.suggestions(1).expiry_ts()); | 605 EXPECT_EQ(kTestDefaultExpiry, suggestions.suggestions(1).expiry_ts()); |
| 607 } | 606 } |
| 608 } // namespace suggestions | 607 } // namespace suggestions |
| OLD | NEW |