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

Side by Side Diff: headless/public/util/testing/generic_url_request_mocks.h

Issue 2260793002: Headless utility classes for making deterministic protocol handlers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing files Created 4 years, 4 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef HEADLESS_PUBLIC_UTIL_TESTING_GENERIC_URL_REQUEST_MOCKS_H_
6 #define HEADLESS_PUBLIC_UTIL_TESTING_GENERIC_URL_REQUEST_MOCKS_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/macros.h"
12 #include "headless/public/util/generic_url_request_job.h"
13 #include "headless/public/util/testing/generic_url_request_mocks.h"
14 #include "net/cookies/cookie_store.h"
15 #include "net/url_request/url_request.h"
16 #include "net/url_request/url_request_context.h"
17 #include "net/url_request/url_request_job_factory.h"
18
19 namespace net {
20 class URLRequestJob;
21 } // namespace net
22
23 namespace htmlrender_webkit_headless_proto {
24 class Resource;
25 } // htmlrender_webkit_headless_proto net
26
27 namespace headless {
28
29 class MockGenericURLRequestJobDelegate : public GenericURLRequestJob::Delegate {
30 public:
31 MockGenericURLRequestJobDelegate();
32 ~MockGenericURLRequestJobDelegate() override;
33
34 bool BlockOrRewriteRequest(
35 const GURL& url,
36 const std::string& referrer,
37 GenericURLRequestJob::RewriteCallback callback) override;
38
39 const GenericURLRequestJob::HttpResponse* MaybeMatchResource(
40 const GURL& url,
41 const net::HttpRequestHeaders& request_headers) override;
42
43 void OnResourceLoadComplete(const std::string& final_url,
44 const std::string& mime_type,
45 int http_response_code) override;
46
47 private:
48 DISALLOW_COPY_AND_ASSIGN(MockGenericURLRequestJobDelegate);
49 };
50
51 class MockCookieStore : public net::CookieStore {
Sami 2016/08/19 11:54:00 Could you add a TODO to replace this with the actu
alex clarke (OOO till 29th) 2016/08/19 12:48:58 Done.
52 public:
53 MockCookieStore();
54 ~MockCookieStore() override;
55
56 // net::CookieStore implementation:
57 void SetCookieWithOptionsAsync(const GURL& url,
58 const std::string& cookie_line,
59 const net::CookieOptions& options,
60 const SetCookiesCallback& callback) override;
61
62 void SetCookieWithDetailsAsync(const GURL& url,
63 const std::string& name,
64 const std::string& value,
65 const std::string& domain,
66 const std::string& path,
67 base::Time creation_time,
68 base::Time expiration_time,
69 base::Time last_access_time,
70 bool secure,
71 bool http_only,
72 net::CookieSameSite same_site,
73 bool enforce_strict_secure,
74 net::CookiePriority priority,
75 const SetCookiesCallback& callback) override;
76
77 void GetCookiesWithOptionsAsync(const GURL& url,
78 const net::CookieOptions& options,
79 const GetCookiesCallback& callback) override;
80
81 void GetCookieListWithOptionsAsync(
82 const GURL& url,
83 const net::CookieOptions& options,
84 const GetCookieListCallback& callback) override;
85
86 void GetAllCookiesAsync(const GetCookieListCallback& callback) override;
87
88 void DeleteCookieAsync(const GURL& url,
89 const std::string& cookie_name,
90 const base::Closure& callback) override;
91
92 void DeleteCanonicalCookieAsync(const net::CanonicalCookie& cookie,
93 const DeleteCallback& callback) override;
94
95 void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin,
96 const base::Time& delete_end,
97 const DeleteCallback& callback) override;
98
99 void DeleteAllCreatedBetweenWithPredicateAsync(
100 const base::Time& delete_begin,
101 const base::Time& delete_end,
102 const CookiePredicate& predicate,
103 const DeleteCallback& callback) override;
104
105 void DeleteSessionCookiesAsync(const DeleteCallback&) override;
106
107 void FlushStore(const base::Closure& callback) override;
108
109 void SetForceKeepSessionState() override;
110
111 std::unique_ptr<CookieChangedSubscription> AddCallbackForCookie(
112 const GURL& url,
113 const std::string& name,
114 const CookieChangedCallback& callback) override;
115
116 bool IsEphemeral() override;
117
118 net::CookieList* cookies() { return &cookies_; }
119
120 private:
121 void SendCookies(const GURL& url,
122 const net::CookieOptions& options,
123 const GetCookieListCallback& callback);
124
125 net::CookieList cookies_;
126
127 DISALLOW_COPY_AND_ASSIGN(MockCookieStore);
128 };
129
130 class MockURLRequestDelegate : public net::URLRequest::Delegate {
131 public:
132 MockURLRequestDelegate();
133 ~MockURLRequestDelegate() override;
134
135 void OnResponseStarted(net::URLRequest* request) override;
136 void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
137 const std::string& response_data() const;
138 const net::IOBufferWithSize* metadata() const;
139
140 private:
141 std::string response_data_;
142
143 DISALLOW_COPY_AND_ASSIGN(MockURLRequestDelegate);
144 };
145
146 } // namespace headless
147
148 #endif // HEADLESS_PUBLIC_UTIL_TESTING_GENERIC_URL_REQUEST_MOCKS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698