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 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 scoped_ptr<net::FakeURLFetcher> fetcher; | 442 scoped_ptr<net::FakeURLFetcher> fetcher; |
443 GURL retrieved_url; | 443 GURL retrieved_url; |
444 | 444 |
445 // Not a blacklist request. | 445 // Not a blacklist request. |
446 request_url.reset(new GURL("http://not-blacklisting.com/a?b=c")); | 446 request_url.reset(new GURL("http://not-blacklisting.com/a?b=c")); |
447 fetcher = CreateURLFetcher(*request_url, NULL, "", net::HTTP_OK, | 447 fetcher = CreateURLFetcher(*request_url, NULL, "", net::HTTP_OK, |
448 net::URLRequestStatus::SUCCESS); | 448 net::URLRequestStatus::SUCCESS); |
449 EXPECT_FALSE(SuggestionsService::GetBlacklistedUrl(*fetcher, &retrieved_url)); | 449 EXPECT_FALSE(SuggestionsService::GetBlacklistedUrl(*fetcher, &retrieved_url)); |
450 | 450 |
451 // An actual blacklist request. | 451 // An actual blacklist request. |
452 string blacklisted_url = "http://blacklisted.com/a?b=c&d=e"; | 452 std::string blacklisted_url = "http://blacklisted.com/a?b=c&d=e"; |
453 string encoded_blacklisted_url = | 453 std::string encoded_blacklisted_url = |
454 "http%3A%2F%2Fblacklisted.com%2Fa%3Fb%3Dc%26d%3De"; | 454 "http%3A%2F%2Fblacklisted.com%2Fa%3Fb%3Dc%26d%3De"; |
455 string blacklist_request_prefix(kSuggestionsBlacklistURLPrefix); | 455 std::string blacklist_request_prefix(kSuggestionsBlacklistURLPrefix); |
456 request_url.reset( | 456 request_url.reset( |
457 new GURL(blacklist_request_prefix + encoded_blacklisted_url)); | 457 new GURL(blacklist_request_prefix + encoded_blacklisted_url)); |
458 fetcher.reset(); | 458 fetcher.reset(); |
459 fetcher = CreateURLFetcher(*request_url, NULL, "", net::HTTP_OK, | 459 fetcher = CreateURLFetcher(*request_url, NULL, "", net::HTTP_OK, |
460 net::URLRequestStatus::SUCCESS); | 460 net::URLRequestStatus::SUCCESS); |
461 EXPECT_TRUE(SuggestionsService::GetBlacklistedUrl(*fetcher, &retrieved_url)); | 461 EXPECT_TRUE(SuggestionsService::GetBlacklistedUrl(*fetcher, &retrieved_url)); |
462 EXPECT_EQ(blacklisted_url, retrieved_url.spec()); | 462 EXPECT_EQ(blacklisted_url, retrieved_url.spec()); |
463 } | 463 } |
464 | 464 |
465 TEST_F(SuggestionsServiceTest, UpdateBlacklistDelay) { | 465 TEST_F(SuggestionsServiceTest, UpdateBlacklistDelay) { |
(...skipping 18 matching lines...) Expand all Loading... |
484 scoped_ptr<SuggestionsService> suggestions_service( | 484 scoped_ptr<SuggestionsService> suggestions_service( |
485 CreateSuggestionsServiceWithMocks()); | 485 CreateSuggestionsServiceWithMocks()); |
486 SuggestionsProfile suggestions = | 486 SuggestionsProfile suggestions = |
487 CreateSuggestionsProfileWithExpiryTimestamps(); | 487 CreateSuggestionsProfileWithExpiryTimestamps(); |
488 suggestions_service->SetDefaultExpiryTimestamp(&suggestions, | 488 suggestions_service->SetDefaultExpiryTimestamp(&suggestions, |
489 kTestDefaultExpiry); | 489 kTestDefaultExpiry); |
490 EXPECT_EQ(kTestSetExpiry, suggestions.suggestions(0).expiry_ts()); | 490 EXPECT_EQ(kTestSetExpiry, suggestions.suggestions(0).expiry_ts()); |
491 EXPECT_EQ(kTestDefaultExpiry, suggestions.suggestions(1).expiry_ts()); | 491 EXPECT_EQ(kTestDefaultExpiry, suggestions.suggestions(1).expiry_ts()); |
492 } | 492 } |
493 } // namespace suggestions | 493 } // namespace suggestions |
OLD | NEW |