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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: ios/net/cookies/cookie_store_ios_test_util.h
diff --git a/ios/net/cookies/cookie_store_ios_test_util.h b/ios/net/cookies/cookie_store_ios_test_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..436ffebf2830d725a4ff97f050c6f398015eef4c
--- /dev/null
+++ b/ios/net/cookies/cookie_store_ios_test_util.h
@@ -0,0 +1,83 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_NET_COOKIES_COOKIE_STORE_IOS_TEST_UTIL_H_
+#define IOS_NET_COOKIES_COOKIE_STORE_IOS_TEST_UTIL_H_
+
+#include <string>
+#include <vector>
+
+#include "base/callback_forward.h"
+#include "net/cookies/cookie_monster.h"
+#include "net/cookies/cookie_store.h"
+#include "url/gurl.h"
+
+namespace net {
+
+class CanonicalCookie;
+
+// Test net::CookieMonster::PersistentCookieStore allowing to control when the
+// initialization completes.
+class TestPersistentCookieStore
+ : public net::CookieMonster::PersistentCookieStore {
+ public:
+ TestPersistentCookieStore();
+
+ // Runs the completion callback with a "a=b" cookie.
+ void RunLoadedCallback();
+
+ bool flushed();
+
+ private:
+ // net::CookieMonster::PersistentCookieStore implementation:
+ void Load(const LoadedCallback& loaded_callback) override;
+ void LoadCookiesForKey(const std::string& key,
+ const LoadedCallback& loaded_callback) override;
+ void AddCookie(const net::CanonicalCookie& cc) override;
+ void UpdateCookieAccessTime(const net::CanonicalCookie& cc) override;
+ void DeleteCookie(const net::CanonicalCookie& cc) override;
+ void SetForceKeepSessionState() override;
+ void Flush(const base::Closure& callback) override;
+
+ ~TestPersistentCookieStore() override;
+
+ const GURL kTestCookieURL;
+ LoadedCallback loaded_callback_;
+ bool flushed_;
+};
+
+// Helper callback to be passed to CookieStore::GetCookiesWithOptionsAsync().
+class GetCookieCallback {
+ public:
+ GetCookieCallback();
+
+ // Returns true if the callback has been run.
+ bool did_run();
+
+ // Returns the parameter of the callback.
+ const std::string& cookie_line();
+
+ void Run(const std::string& cookie_line);
+
+ private:
+ bool did_run_;
+ std::string cookie_line_;
+};
+
+void RecordCookieChanges(std::vector<net::CanonicalCookie>* out_cookies,
+ std::vector<bool>* out_removes,
+ const net::CanonicalCookie& cookie,
+ net::CookieStore::ChangeCause cause);
+
+// Sets a cookie.
+void SetCookie(const std::string& cookie_line,
+ const GURL& url,
+ net::CookieStore* store);
+
+// Clears the underlying NSHTTPCookieStorage.
+void ClearCookies();
+
+} // namespace net
+
+#endif // IOS_NET_COOKIES_COOKIE_STORE_IOS_TEST_UTIL_H_
« 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