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

Side by Side Diff: ios/net/cookies/cookie_store_ios_test_util.h

Issue 2667753007: Divide Cookie Store IOS tests into different files (Closed)
Patch Set: rename unittest helper to test util and other renamings Created 3 years, 10 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 2017 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 IOS_NET_COOKIES_COOKIE_STORE_IOS_TEST_UTIL_H_
6 #define IOS_NET_COOKIES_COOKIE_STORE_IOS_TEST_UTIL_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback_forward.h"
12 #include "net/cookies/cookie_monster.h"
13 #include "net/cookies/cookie_store.h"
14 #include "url/gurl.h"
15
16 namespace net {
17
18 class CanonicalCookie;
19
20 // Test net::CookieMonster::PersistentCookieStore allowing to control when the
21 // initialization completes.
22 class TestPersistentCookieStore
23 : public net::CookieMonster::PersistentCookieStore {
24 public:
25 TestPersistentCookieStore();
26
27 // Runs the completion callback with a "a=b" cookie.
28 void RunLoadedCallback();
29
30 bool flushed();
31
32 private:
33 // net::CookieMonster::PersistentCookieStore implementation:
34 void Load(const LoadedCallback& loaded_callback) override;
35 void LoadCookiesForKey(const std::string& key,
36 const LoadedCallback& loaded_callback) override;
37 void AddCookie(const net::CanonicalCookie& cc) override;
38 void UpdateCookieAccessTime(const net::CanonicalCookie& cc) override;
39 void DeleteCookie(const net::CanonicalCookie& cc) override;
40 void SetForceKeepSessionState() override;
41 void Flush(const base::Closure& callback) override;
42
43 ~TestPersistentCookieStore() override;
44
45 const GURL kTestCookieURL;
46 LoadedCallback loaded_callback_;
47 bool flushed_;
48 };
49
50 // Helper callback to be passed to CookieStore::GetCookiesWithOptionsAsync().
51 class GetCookieCallback {
52 public:
53 GetCookieCallback();
54
55 // Returns true if the callback has been run.
56 bool did_run();
57
58 // Returns the parameter of the callback.
59 const std::string& cookie_line();
60
61 void Run(const std::string& cookie_line);
62
63 private:
64 bool did_run_;
65 std::string cookie_line_;
66 };
67
68 void RecordCookieChanges(std::vector<net::CanonicalCookie>* out_cookies,
69 std::vector<bool>* out_removes,
70 const net::CanonicalCookie& cookie,
71 net::CookieStore::ChangeCause cause);
72
73 // Sets a cookie.
74 void SetCookie(const std::string& cookie_line,
75 const GURL& url,
76 net::CookieStore* store);
77
78 // Clears the underlying NSHTTPCookieStorage.
79 void ClearCookies();
80
81 } // namespace net
82
83 #endif // IOS_NET_COOKIES_COOKIE_STORE_IOS_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « ios/net/cookies/cookie_store_ios_persistent_unittest.mm ('k') | ios/net/cookies/cookie_store_ios_test_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698