| 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 <limits.h> | 5 #include <limits.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 sdch_manager()->RemoveObserver(&observer); | 549 sdch_manager()->RemoveObserver(&observer); |
| 550 sdch_manager()->OnGetDictionary(test_request_gurl, test_dictionary_gurl); | 550 sdch_manager()->OnGetDictionary(test_request_gurl, test_dictionary_gurl); |
| 551 EXPECT_EQ(1, observer.get_dictionary_notifications()); | 551 EXPECT_EQ(1, observer.get_dictionary_notifications()); |
| 552 EXPECT_EQ(test_request_gurl, observer.last_dictionary_request_url()); | 552 EXPECT_EQ(test_request_gurl, observer.last_dictionary_request_url()); |
| 553 EXPECT_EQ(test_dictionary_gurl, observer.last_dictionary_url()); | 553 EXPECT_EQ(test_dictionary_gurl, observer.last_dictionary_url()); |
| 554 } | 554 } |
| 555 | 555 |
| 556 TEST_F(SdchManagerTest, ExpirationCheckedProperly) { | 556 TEST_F(SdchManagerTest, ExpirationCheckedProperly) { |
| 557 // Create an SDCH dictionary with an expiration time in the past. | 557 // Create an SDCH dictionary with an expiration time in the past. |
| 558 std::string dictionary_domain("x.y.z.google.com"); | 558 std::string dictionary_domain("x.y.z.google.com"); |
| 559 // TODO(eroman): "max-age: -1" is invalid. -1 is not a valid production of |
| 560 // delta-seconds (must be non-negative). |
| 559 std::string dictionary_text(base::StringPrintf("Domain: %s\nMax-age: -1\n\n", | 561 std::string dictionary_text(base::StringPrintf("Domain: %s\nMax-age: -1\n\n", |
| 560 dictionary_domain.c_str())); | 562 dictionary_domain.c_str())); |
| 561 dictionary_text.append( | 563 dictionary_text.append( |
| 562 kTestVcdiffDictionary, sizeof(kTestVcdiffDictionary) - 1); | 564 kTestVcdiffDictionary, sizeof(kTestVcdiffDictionary) - 1); |
| 563 std::string client_hash; | 565 std::string client_hash; |
| 564 std::string server_hash; | 566 std::string server_hash; |
| 565 SdchManager::GenerateHash(dictionary_text, &client_hash, &server_hash); | 567 SdchManager::GenerateHash(dictionary_text, &client_hash, &server_hash); |
| 566 GURL target_gurl("http://" + dictionary_domain); | 568 GURL target_gurl("http://" + dictionary_domain); |
| 567 AddSdchDictionary(dictionary_text, target_gurl); | 569 AddSdchDictionary(dictionary_text, target_gurl); |
| 568 | 570 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 EXPECT_EQ(server_hash, observer.last_server_hash()); | 628 EXPECT_EQ(server_hash, observer.last_server_hash()); |
| 627 | 629 |
| 628 EXPECT_EQ(SDCH_OK, sdch_manager()->RemoveSdchDictionary(server_hash)); | 630 EXPECT_EQ(SDCH_OK, sdch_manager()->RemoveSdchDictionary(server_hash)); |
| 629 EXPECT_EQ(1, observer.dictionary_removed_notifications()); | 631 EXPECT_EQ(1, observer.dictionary_removed_notifications()); |
| 630 EXPECT_EQ(server_hash, observer.last_server_hash()); | 632 EXPECT_EQ(server_hash, observer.last_server_hash()); |
| 631 | 633 |
| 632 sdch_manager()->RemoveObserver(&observer); | 634 sdch_manager()->RemoveObserver(&observer); |
| 633 } | 635 } |
| 634 | 636 |
| 635 } // namespace net | 637 } // namespace net |
| OLD | NEW |