Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: net/base/sdch_manager_unittest.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/base/sdch_manager.cc ('k') | net/base/upload_file_element_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/base/sdch_manager.h" 11 #include "net/base/sdch_manager.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 //------------------------------------------------------------------------------ 16 //------------------------------------------------------------------------------
17 // Workaround for http://crbug.com/418975; remove when fixed.
18 #if !defined(OS_IOS)
19
20 //------------------------------------------------------------------------------
17 // Provide sample data and compression results with a sample VCDIFF dictionary. 21 // Provide sample data and compression results with a sample VCDIFF dictionary.
18 // Note an SDCH dictionary has extra meta-data before the VCDIFF dictionary. 22 // Note an SDCH dictionary has extra meta-data before the VCDIFF dictionary.
19 static const char kTestVcdiffDictionary[] = "DictionaryFor" 23 static const char kTestVcdiffDictionary[] = "DictionaryFor"
20 "SdchCompression1SdchCompression2SdchCompression3SdchCompression\n"; 24 "SdchCompression1SdchCompression2SdchCompression3SdchCompression\n";
21 25
22 //------------------------------------------------------------------------------ 26 //------------------------------------------------------------------------------
23 27
24 class SdchManagerTest : public testing::Test { 28 class SdchManagerTest : public testing::Test {
25 protected: 29 protected:
26 SdchManagerTest() 30 SdchManagerTest()
(...skipping 25 matching lines...) Expand all
52 // The list of hashes should change iff the addition succeeds. 56 // The list of hashes should change iff the addition succeeds.
53 return (list != list2); 57 return (list != list2);
54 } 58 }
55 59
56 private: 60 private:
57 scoped_ptr<SdchManager> sdch_manager_; 61 scoped_ptr<SdchManager> sdch_manager_;
58 bool default_support_; 62 bool default_support_;
59 bool default_https_support_; 63 bool default_https_support_;
60 }; 64 };
61 65
62 //------------------------------------------------------------------------------
63 static std::string NewSdchDictionary(const std::string& domain) { 66 static std::string NewSdchDictionary(const std::string& domain) {
64 std::string dictionary; 67 std::string dictionary;
65 if (!domain.empty()) { 68 if (!domain.empty()) {
66 dictionary.append("Domain: "); 69 dictionary.append("Domain: ");
67 dictionary.append(domain); 70 dictionary.append(domain);
68 dictionary.append("\n"); 71 dictionary.append("\n");
69 } 72 }
70 dictionary.append("\n"); 73 dictionary.append("\n");
71 dictionary.append(kTestVcdiffDictionary, sizeof(kTestVcdiffDictionary) - 1); 74 dictionary.append(kTestVcdiffDictionary, sizeof(kTestVcdiffDictionary) - 1);
72 return dictionary; 75 return dictionary;
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 565
563 dictionary = NULL; 566 dictionary = NULL;
564 sdch_manager()->GetVcdiffDictionary( 567 sdch_manager()->GetVcdiffDictionary(
565 server_hash, 568 server_hash,
566 GURL("http://" + dictionary_domain + "/random_url"), 569 GURL("http://" + dictionary_domain + "/random_url"),
567 &dictionary); 570 &dictionary);
568 EXPECT_FALSE(dictionary.get()); 571 EXPECT_FALSE(dictionary.get());
569 EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(blacklist_url)); 572 EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(blacklist_url));
570 } 573 }
571 574
575 #else
576
577 TEST(SdchManagerTest, SdchOffByDefault) {
578 GURL google_url("http://www.google.com");
579 SdchManager* sdch_manager(new SdchManager);
580
581 EXPECT_FALSE(sdch_manager->IsInSupportedDomain(google_url));
582 SdchManager::EnableSdchSupport(true);
583 EXPECT_TRUE(sdch_manager->IsInSupportedDomain(google_url));
584 }
585
586 #endif // !defined(OS_IOS)
587
572 } // namespace net 588 } // namespace net
OLDNEW
« no previous file with comments | « net/base/sdch_manager.cc ('k') | net/base/upload_file_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698