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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/test/simple_test_clock.h" | 12 #include "base/test/simple_test_clock.h" |
13 #include "net/base/net_log.h" | 13 #include "net/base/net_log.h" |
14 #include "net/base/sdch_manager.h" | 14 #include "net/base/sdch_manager.h" |
15 #include "net/base/sdch_observer.h" | 15 #include "net/base/sdch_observer.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
| 21 // Workaround for http://crbug.com/437794; remove when fixed. |
| 22 #if !defined(OS_IOS) |
| 23 |
21 //------------------------------------------------------------------------------ | 24 //------------------------------------------------------------------------------ |
22 // Provide sample data and compression results with a sample VCDIFF dictionary. | 25 // Provide sample data and compression results with a sample VCDIFF dictionary. |
23 // Note an SDCH dictionary has extra meta-data before the VCDIFF dictionary. | 26 // Note an SDCH dictionary has extra meta-data before the VCDIFF dictionary. |
24 static const char kTestVcdiffDictionary[] = "DictionaryFor" | 27 static const char kTestVcdiffDictionary[] = "DictionaryFor" |
25 "SdchCompression1SdchCompression2SdchCompression3SdchCompression\n"; | 28 "SdchCompression1SdchCompression2SdchCompression3SdchCompression\n"; |
26 | 29 |
27 //------------------------------------------------------------------------------ | 30 //------------------------------------------------------------------------------ |
28 | 31 |
29 class MockSdchObserver : public SdchObserver { | 32 class MockSdchObserver : public SdchObserver { |
30 public: | 33 public: |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 clock.Pass()); | 650 clock.Pass()); |
648 | 651 |
649 // Make sure it's not visible for advertisement, but is visible | 652 // Make sure it's not visible for advertisement, but is visible |
650 // if looked up by hash. | 653 // if looked up by hash. |
651 EXPECT_FALSE(sdch_manager()->GetDictionarySet(target_gurl)); | 654 EXPECT_FALSE(sdch_manager()->GetDictionarySet(target_gurl)); |
652 EXPECT_TRUE(sdch_manager()->GetDictionarySetByHash( | 655 EXPECT_TRUE(sdch_manager()->GetDictionarySetByHash( |
653 target_gurl, server_hash, &problem_code)); | 656 target_gurl, server_hash, &problem_code)); |
654 EXPECT_EQ(SDCH_OK, problem_code); | 657 EXPECT_EQ(SDCH_OK, problem_code); |
655 } | 658 } |
656 | 659 |
| 660 TEST_F(SdchManagerTest, SdchOnByDefault) { |
| 661 GURL google_url("http://www.google.com"); |
| 662 scoped_ptr<SdchManager> sdch_manager(new SdchManager); |
| 663 |
| 664 EXPECT_EQ(SDCH_OK, sdch_manager->IsInSupportedDomain(google_url)); |
| 665 SdchManager::EnableSdchSupport(false); |
| 666 EXPECT_EQ(SDCH_DISABLED, sdch_manager->IsInSupportedDomain(google_url)); |
| 667 } |
| 668 |
| 669 #else |
| 670 |
| 671 TEST(SdchManagerTest, SdchOffByDefault) { |
| 672 GURL google_url("http://www.google.com"); |
| 673 scoped_ptr<SdchManager> sdch_manager(new SdchManager); |
| 674 |
| 675 EXPECT_EQ(SDCH_DISABLED, sdch_manager->IsInSupportedDomain(google_url)); |
| 676 SdchManager::EnableSdchSupport(true); |
| 677 EXPECT_EQ(SDCH_OK, sdch_manager->IsInSupportedDomain(google_url)); |
| 678 } |
| 679 |
| 680 #endif // !defined(OS_IOS) |
| 681 |
657 } // namespace net | 682 } // namespace net |
OLD | NEW |