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

Side by Side Diff: net/filter/sdch_filter_unittest.cc

Issue 1051933002: Split SdchManager::Dictionary out into separate class/file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated comments. Created 5 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/filter/sdch_filter.h ('k') | net/net.gypi » ('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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/test/simple_test_clock.h" 13 #include "base/test/simple_test_clock.h"
14 #include "net/base/io_buffer.h" 14 #include "net/base/io_buffer.h"
15 #include "net/base/sdch_dictionary.h"
16 #include "net/base/sdch_manager.h"
15 #include "net/base/sdch_observer.h" 17 #include "net/base/sdch_observer.h"
16 #include "net/filter/mock_filter_context.h" 18 #include "net/filter/mock_filter_context.h"
17 #include "net/filter/sdch_filter.h" 19 #include "net/filter/sdch_filter.h"
18 #include "net/url_request/url_request_context.h" 20 #include "net/url_request/url_request_context.h"
19 #include "net/url_request/url_request_http_job.h" 21 #include "net/url_request/url_request_http_job.h"
20 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
21 #include "third_party/zlib/zlib.h" 23 #include "third_party/zlib/zlib.h"
22 24
23 namespace net { 25 namespace net {
24 26
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 scoped_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock); 1206 scoped_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock);
1205 clock->SetNow(base::Time::Now()); 1207 clock->SetNow(base::Time::Now());
1206 clock->Advance(base::TimeDelta::FromMinutes(5)); 1208 clock->Advance(base::TimeDelta::FromMinutes(5));
1207 SdchProblemCode problem_code; 1209 SdchProblemCode problem_code;
1208 scoped_ptr<SdchManager::DictionarySet> hash_set( 1210 scoped_ptr<SdchManager::DictionarySet> hash_set(
1209 sdch_manager_->GetDictionarySetByHash( 1211 sdch_manager_->GetDictionarySetByHash(
1210 url, server_hash, &problem_code).Pass()); 1212 url, server_hash, &problem_code).Pass());
1211 ASSERT_TRUE(hash_set); 1213 ASSERT_TRUE(hash_set);
1212 ASSERT_EQ(SDCH_OK, problem_code); 1214 ASSERT_EQ(SDCH_OK, problem_code);
1213 1215
1214 const_cast<SdchManager::Dictionary*>( 1216 const_cast<SdchDictionary*>(hash_set->GetDictionary(server_hash))
1215 hash_set->GetDictionary(server_hash))->SetClockForTesting( 1217 ->SetClockForTesting(clock.Pass());
1216 clock.Pass());
1217 1218
1218 // Encode output with the second dictionary. 1219 // Encode output with the second dictionary.
1219 std::string sdch_compressed(NewSdchCompressedData(expired_dictionary)); 1220 std::string sdch_compressed(NewSdchCompressedData(expired_dictionary));
1220 1221
1221 // See if the filter decodes it. 1222 // See if the filter decodes it.
1222 std::string output; 1223 std::string output;
1223 EXPECT_TRUE(FilterTestData(sdch_compressed, 100, 100, filter.get(), &output)); 1224 EXPECT_TRUE(FilterTestData(sdch_compressed, 100, 100, filter.get(), &output));
1224 EXPECT_EQ(expanded_, output); 1225 EXPECT_EQ(expanded_, output);
1225 } 1226 }
1226 1227
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 1289
1289 filter.reset(nullptr); 1290 filter.reset(nullptr);
1290 1291
1291 // Confirm that we got a "DictionaryUsed" signal from the SdchManager 1292 // Confirm that we got a "DictionaryUsed" signal from the SdchManager
1292 // for our dictionary. 1293 // for our dictionary.
1293 EXPECT_EQ(1, observer.dictionary_used_calls()); 1294 EXPECT_EQ(1, observer.dictionary_used_calls());
1294 EXPECT_EQ(server_hash, observer.last_server_hash()); 1295 EXPECT_EQ(server_hash, observer.last_server_hash());
1295 } 1296 }
1296 1297
1297 } // namespace net 1298 } // namespace net
OLDNEW
« no previous file with comments | « net/filter/sdch_filter.h ('k') | net/net.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698