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

Side by Side Diff: net/base/mock_filter_context.h

Issue 6264013: Clean up net unit testing code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-virtualize TestDelegate::OnResponseCompleted Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
willchan no longer on Chromium 2011/01/25 23:47:39 2011
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 //
5 4
6 #ifndef NET_BASE_FILTER_UNITTEST_H_ 5 #ifndef NET_BASE_MOCK_FILTER_CONTEXT_H_
7 #define NET_BASE_FILTER_UNITTEST_H_ 6 #define NET_BASE_MOCK_FILTER_CONTEXT_H_
8 #pragma once 7 #pragma once
9 8
10 #include <string> 9 #include <string>
11 10
12 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
13 #include "net/base/filter.h" 12 #include "net/base/filter.h"
14 13
15 //------------------------------------------------------------------------------ 14 namespace net {
15
16 class MockFilterContext : public FilterContext { 16 class MockFilterContext : public FilterContext {
17 public: 17 public:
18 explicit MockFilterContext(int buffer_size) 18 explicit MockFilterContext(int buffer_size);
19 : buffer_size_(buffer_size), 19 virtual ~MockFilterContext();
20 is_cached_content_(false),
21 is_download_(false),
22 is_sdch_response_(false),
23 response_code_(-1) {
24 }
25 20
26 void SetBufferSize(int buffer_size) { buffer_size_ = buffer_size; } 21 void SetBufferSize(int buffer_size) { buffer_size_ = buffer_size; }
27 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } 22 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; }
28 void SetURL(const GURL& gurl) { gurl_ = gurl; } 23 void SetURL(const GURL& gurl) { gurl_ = gurl; }
29 void SetRequestTime(const base::Time time) { request_time_ = time; } 24 void SetRequestTime(const base::Time time) { request_time_ = time; }
30 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } 25 void SetCached(bool is_cached) { is_cached_content_ = is_cached; }
31 void SetDownload(bool is_download) { is_download_ = is_download; } 26 void SetDownload(bool is_download) { is_download_ = is_download; }
32 void SetResponseCode(int response_code) { response_code_ = response_code; } 27 void SetResponseCode(int response_code) { response_code_ = response_code; }
33 void SetSdchResponse(bool is_sdch_response) { 28 void SetSdchResponse(bool is_sdch_response) {
34 is_sdch_response_ = is_sdch_response; 29 is_sdch_response_ = is_sdch_response;
35 } 30 }
36 31
37 virtual bool GetMimeType(std::string* mime_type) const { 32 virtual bool GetMimeType(std::string* mime_type) const;
38 *mime_type = mime_type_;
39 return true;
40 }
41 33
42 // What URL was used to access this data? 34 // What URL was used to access this data?
43 // Return false if gurl is not present. 35 // Return false if gurl is not present.
44 virtual bool GetURL(GURL* gurl) const { 36 virtual bool GetURL(GURL* gurl) const;
45 *gurl = gurl_;
46 return true;
47 }
48 37
49 // What was this data requested from a server? 38 // What was this data requested from a server?
50 virtual base::Time GetRequestTime() const { 39 virtual base::Time GetRequestTime() const;
51 return request_time_;
52 }
53 40
54 // Is data supplied from cache, or fresh across the net? 41 // Is data supplied from cache, or fresh across the net?
55 virtual bool IsCachedContent() const { return is_cached_content_; } 42 virtual bool IsCachedContent() const;
56 43
57 // Is this a download? 44 // Is this a download?
58 virtual bool IsDownload() const { return is_download_; } 45 virtual bool IsDownload() const;
59 46
60 // Was this data flagged as a response to a request with an SDCH dictionary? 47 // Was this data flagged as a response to a request with an SDCH dictionary?
61 virtual bool IsSdchResponse() const { return is_sdch_response_; } 48 virtual bool IsSdchResponse() const;
62 49
63 // How many bytes were fed to filter(s) so far? 50 // How many bytes were fed to filter(s) so far?
64 virtual int64 GetByteReadCount() const { return 0; } 51 virtual int64 GetByteReadCount() const;
65 52
66 virtual int GetResponseCode() const { return response_code_; } 53 virtual int GetResponseCode() const;
67 54
68 // What is the desirable input buffer size for these filters? 55 // What is the desirable input buffer size for these filters?
69 virtual int GetInputStreamBufferSize() const { return buffer_size_; } 56 virtual int GetInputStreamBufferSize() const;
70 57
71 virtual void RecordPacketStats(StatisticSelector statistic) const {} 58 virtual void RecordPacketStats(StatisticSelector statistic) const {}
72 59
73 private: 60 private:
74 int buffer_size_; 61 int buffer_size_;
75 std::string mime_type_; 62 std::string mime_type_;
76 GURL gurl_; 63 GURL gurl_;
77 base::Time request_time_; 64 base::Time request_time_;
78 bool is_cached_content_; 65 bool is_cached_content_;
79 bool is_download_; 66 bool is_download_;
80 bool is_sdch_response_; 67 bool is_sdch_response_;
81 int response_code_; 68 int response_code_;
82 69
83 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); 70 DISALLOW_COPY_AND_ASSIGN(MockFilterContext);
84 }; 71 };
85 72
86 #endif // NET_BASE_FILTER_UNITTEST_H_ 73 } // namespace net
74
75 #endif // NET_BASE_MOCK_FILTER_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698