| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 namespace { | 43 namespace { |
| 44 | 44 |
| 45 // SuggestionsService::AccessTokenFetcher provides an empty account ID if its | 45 // SuggestionsService::AccessTokenFetcher provides an empty account ID if its |
| 46 // SigninManager is null. | 46 // SigninManager is null. |
| 47 const char kAccountId[] = ""; | 47 const char kAccountId[] = ""; |
| 48 const char kTestTitle[] = "a title"; | 48 const char kTestTitle[] = "a title"; |
| 49 const char kTestUrl[] = "http://go.com"; | 49 const char kTestUrl[] = "http://go.com"; |
| 50 const char kTestFaviconUrl[] = | 50 const char kTestFaviconUrl[] = |
| 51 "https://s2.googleusercontent.com/s2/favicons?domain_url=" | 51 "https://s2.googleusercontent.com/s2/favicons?domain_url=" |
| 52 "http://go.com&alt=s&sz=32"; | 52 "http://go.com&alt=s&sz=32"; |
| 53 const char kTestImpressionUrl[] = | |
| 54 "https://www.google.com/chromesuggestions/click?q=123&cd=-1"; | |
| 55 const char kTestClickUrl[] = | |
| 56 "https://www.google.com/chromesuggestions/click?q=123&cd=0"; | |
| 57 const char kBlacklistedUrl[] = "http://blacklist.com"; | 53 const char kBlacklistedUrl[] = "http://blacklist.com"; |
| 58 const char kBlacklistedUrlAlt[] = "http://blacklist-atl.com"; | 54 const char kBlacklistedUrlAlt[] = "http://blacklist-atl.com"; |
| 59 const int64_t kTestDefaultExpiry = 1402200000000000; | 55 const int64_t kTestDefaultExpiry = 1402200000000000; |
| 60 const int64_t kTestSetExpiry = 1404792000000000; | 56 const int64_t kTestSetExpiry = 1404792000000000; |
| 61 | 57 |
| 62 std::unique_ptr<net::FakeURLFetcher> CreateURLFetcher( | 58 std::unique_ptr<net::FakeURLFetcher> CreateURLFetcher( |
| 63 const GURL& url, | 59 const GURL& url, |
| 64 net::URLFetcherDelegate* delegate, | 60 net::URLFetcherDelegate* delegate, |
| 65 const std::string& response_data, | 61 const std::string& response_data, |
| 66 net::HttpStatusCode response_code, | 62 net::HttpStatusCode response_code, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 177 } |
| 182 | 178 |
| 183 void CheckSuggestionsData() { | 179 void CheckSuggestionsData() { |
| 184 SuggestionsProfile suggestions_profile; | 180 SuggestionsProfile suggestions_profile; |
| 185 test_suggestions_store_->LoadSuggestions(&suggestions_profile); | 181 test_suggestions_store_->LoadSuggestions(&suggestions_profile); |
| 186 EXPECT_EQ(1, suggestions_profile.suggestions_size()); | 182 EXPECT_EQ(1, suggestions_profile.suggestions_size()); |
| 187 EXPECT_EQ(kTestTitle, suggestions_profile.suggestions(0).title()); | 183 EXPECT_EQ(kTestTitle, suggestions_profile.suggestions(0).title()); |
| 188 EXPECT_EQ(kTestUrl, suggestions_profile.suggestions(0).url()); | 184 EXPECT_EQ(kTestUrl, suggestions_profile.suggestions(0).url()); |
| 189 EXPECT_EQ(kTestFaviconUrl, | 185 EXPECT_EQ(kTestFaviconUrl, |
| 190 suggestions_profile.suggestions(0).favicon_url()); | 186 suggestions_profile.suggestions(0).favicon_url()); |
| 191 EXPECT_EQ(kTestImpressionUrl, | |
| 192 suggestions_profile.suggestions(0).impression_url()); | |
| 193 EXPECT_EQ(kTestClickUrl, suggestions_profile.suggestions(0).click_url()); | |
| 194 } | 187 } |
| 195 | 188 |
| 196 int suggestions_data_callback_count_; | 189 int suggestions_data_callback_count_; |
| 197 int suggestions_empty_data_count_; | 190 int suggestions_empty_data_count_; |
| 198 bool blacklisting_failed_; | 191 bool blacklisting_failed_; |
| 199 bool undo_blacklisting_failed_; | 192 bool undo_blacklisting_failed_; |
| 200 | 193 |
| 201 protected: | 194 protected: |
| 202 SuggestionsServiceTest() | 195 SuggestionsServiceTest() |
| 203 : suggestions_data_callback_count_(0), | 196 : suggestions_data_callback_count_(0), |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 suggestions_service->GetPageThumbnail(test_url, dummy_callback); | 737 suggestions_service->GetPageThumbnail(test_url, dummy_callback); |
| 745 | 738 |
| 746 EXPECT_CALL(*mock_thumbnail_manager_, AddImageURL(test_url, thumbnail_url)); | 739 EXPECT_CALL(*mock_thumbnail_manager_, AddImageURL(test_url, thumbnail_url)); |
| 747 EXPECT_CALL(*mock_thumbnail_manager_, GetImageForURL(test_url, _)); | 740 EXPECT_CALL(*mock_thumbnail_manager_, GetImageForURL(test_url, _)); |
| 748 suggestions_service->GetPageThumbnailWithURL(test_url, thumbnail_url, | 741 suggestions_service->GetPageThumbnailWithURL(test_url, thumbnail_url, |
| 749 dummy_callback); | 742 dummy_callback); |
| 750 | 743 |
| 751 } | 744 } |
| 752 | 745 |
| 753 } // namespace suggestions | 746 } // namespace suggestions |
| OLD | NEW |