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

Side by Side Diff: net/sdch/sdch_owner_unittest.cc

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 months 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/sdch/sdch_owner.cc ('k') | net/server/http_server.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 <utility>
6
5 #include "base/memory/memory_pressure_listener.h" 7 #include "base/memory/memory_pressure_listener.h"
6 #include "base/prefs/testing_pref_store.h" 8 #include "base/prefs/testing_pref_store.h"
7 #include "base/run_loop.h" 9 #include "base/run_loop.h"
8 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
9 #include "base/test/histogram_tester.h" 11 #include "base/test/histogram_tester.h"
10 #include "base/test/simple_test_clock.h" 12 #include "base/test/simple_test_clock.h"
11 #include "base/values.h" 13 #include "base/values.h"
12 #include "net/base/sdch_manager.h" 14 #include "net/base/sdch_manager.h"
13 #include "net/log/net_log.h" 15 #include "net/log/net_log.h"
14 #include "net/sdch/sdch_owner.h" 16 #include "net/sdch/sdch_owner.h"
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 }; 769 };
768 770
769 // Test an empty persistence store. 771 // Test an empty persistence store.
770 TEST_F(SdchOwnerPersistenceTest, Empty) { 772 TEST_F(SdchOwnerPersistenceTest, Empty) {
771 ResetOwner(false); 773 ResetOwner(false);
772 EXPECT_EQ(0, owner_->GetDictionaryCountForTesting()); 774 EXPECT_EQ(0, owner_->GetDictionaryCountForTesting());
773 } 775 }
774 776
775 // Test a persistence store with an empty dictionary. 777 // Test a persistence store with an empty dictionary.
776 TEST_F(SdchOwnerPersistenceTest, Persistent_EmptyDict) { 778 TEST_F(SdchOwnerPersistenceTest, Persistent_EmptyDict) {
777 pref_store_->SetValue("SDCH", new base::DictionaryValue(), 779 pref_store_->SetValue("SDCH", make_scoped_ptr(new base::DictionaryValue()),
778 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 780 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
779 ResetOwner(false); 781 ResetOwner(false);
780 EXPECT_EQ(0, owner_->GetDictionaryCountForTesting()); 782 EXPECT_EQ(0, owner_->GetDictionaryCountForTesting());
781 } 783 }
782 784
783 // Test a persistence store with a bad version number. 785 // Test a persistence store with a bad version number.
784 TEST_F(SdchOwnerPersistenceTest, Persistent_BadVersion) { 786 TEST_F(SdchOwnerPersistenceTest, Persistent_BadVersion) {
785 base::DictionaryValue* sdch_dict = new base::DictionaryValue(); 787 scoped_ptr<base::DictionaryValue> sdch_dict(new base::DictionaryValue());
786 sdch_dict->SetInteger("version", 2); 788 sdch_dict->SetInteger("version", 2);
787 pref_store_->SetValue("SDCH", sdch_dict, 789 pref_store_->SetValue("SDCH", std::move(sdch_dict),
788 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 790 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
789 791
790 ResetOwner(false); 792 ResetOwner(false);
791 EXPECT_EQ(0, owner_->GetDictionaryCountForTesting()); 793 EXPECT_EQ(0, owner_->GetDictionaryCountForTesting());
792 } 794 }
793 795
794 // Test a persistence store with an empty dictionaries map. 796 // Test a persistence store with an empty dictionaries map.
795 TEST_F(SdchOwnerPersistenceTest, Persistent_EmptyDictList) { 797 TEST_F(SdchOwnerPersistenceTest, Persistent_EmptyDictList) {
796 base::DictionaryValue* sdch_dict = new base::DictionaryValue(); 798 scoped_ptr<base::DictionaryValue> sdch_dict(new base::DictionaryValue());
797 scoped_ptr<base::DictionaryValue> dicts(new base::DictionaryValue()); 799 scoped_ptr<base::DictionaryValue> dicts(new base::DictionaryValue());
798 sdch_dict->SetInteger("version", 1); 800 sdch_dict->SetInteger("version", 1);
799 sdch_dict->Set("dictionaries", dicts.Pass()); 801 sdch_dict->Set("dictionaries", dicts.Pass());
800 pref_store_->SetValue("SDCH", sdch_dict, 802 pref_store_->SetValue("SDCH", std::move(sdch_dict),
801 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 803 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
802 804
803 ResetOwner(false); 805 ResetOwner(false);
804 EXPECT_EQ(0, owner_->GetDictionaryCountForTesting()); 806 EXPECT_EQ(0, owner_->GetDictionaryCountForTesting());
805 } 807 }
806 808
807 TEST_F(SdchOwnerPersistenceTest, OneDict) { 809 TEST_F(SdchOwnerPersistenceTest, OneDict) {
808 const GURL url("http://www.example.com/dict"); 810 const GURL url("http://www.example.com/dict");
809 ResetOwner(false); 811 ResetOwner(false);
810 EXPECT_EQ(0, owner_->GetDictionaryCountForTesting()); 812 EXPECT_EQ(0, owner_->GetDictionaryCountForTesting());
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 915
914 EXPECT_TRUE(CompleteLoadFromURL(url0, "0", true)); 916 EXPECT_TRUE(CompleteLoadFromURL(url0, "0", true));
915 EXPECT_TRUE(CompleteLoadFromURL(url1, "1", false)); 917 EXPECT_TRUE(CompleteLoadFromURL(url1, "1", false));
916 918
917 tester.ExpectTotalCount("Sdch3.NetworkBytesSpent", 1); 919 tester.ExpectTotalCount("Sdch3.NetworkBytesSpent", 1);
918 tester.ExpectUniqueSample("Sdch3.NetworkBytesSpent", 920 tester.ExpectUniqueSample("Sdch3.NetworkBytesSpent",
919 CreateDictionary(url1, "1").size(), 1); 921 CreateDictionary(url1, "1").size(), 1);
920 } 922 }
921 923
922 } // namespace net 924 } // namespace net
OLDNEW
« no previous file with comments | « net/sdch/sdch_owner.cc ('k') | net/server/http_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698