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

Side by Side Diff: ios/net/cookies/cookie_store_ios_persistent_unittest.mm

Issue 2937963003: Shift cookie system callbacks to OnceCallback to impedance match mojo. (Closed)
Patch Set: Finish Merge Created 3 years, 6 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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 #import "ios/net/cookies/cookie_store_ios_persistent.h" 5 #import "ios/net/cookies/cookie_store_ios_persistent.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 base::MakeUnique<net::CookieStoreIOSPersistent>(backend_.get())) { 56 base::MakeUnique<net::CookieStoreIOSPersistent>(backend_.get())) {
57 cookie_changed_callback_ = store_->AddCallbackForCookie( 57 cookie_changed_callback_ = store_->AddCallbackForCookie(
58 kTestCookieURL, "abc", 58 kTestCookieURL, "abc",
59 base::Bind(&net::RecordCookieChanges, &cookies_changed_, 59 base::Bind(&net::RecordCookieChanges, &cookies_changed_,
60 &cookies_removed_)); 60 &cookies_removed_));
61 } 61 }
62 62
63 ~CookieStoreIOSPersistentTest() override {} 63 ~CookieStoreIOSPersistentTest() override {}
64 64
65 // Gets the cookies. |callback| will be called on completion. 65 // Gets the cookies. |callback| will be called on completion.
66 void GetCookies(const net::CookieStore::GetCookiesCallback& callback) { 66 void GetCookies(net::CookieStore::GetCookiesCallback callback) {
67 net::CookieOptions options; 67 net::CookieOptions options;
68 options.set_include_httponly(); 68 options.set_include_httponly();
69 store_->GetCookiesWithOptionsAsync(kTestCookieURL, options, callback); 69 store_->GetCookiesWithOptionsAsync(kTestCookieURL, options,
70 std::move(callback));
70 } 71 }
71 72
72 // Sets a cookie. 73 // Sets a cookie.
73 void SetCookie(const std::string& cookie_line) { 74 void SetCookie(const std::string& cookie_line) {
74 net::SetCookie(cookie_line, kTestCookieURL, store_.get()); 75 net::SetCookie(cookie_line, kTestCookieURL, store_.get());
75 } 76 }
76 77
77 private: 78 private:
78 const GURL kTestCookieURL; 79 const GURL kTestCookieURL;
79 80
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 EXPECT_TRUE(cookies_removed_[1]); 113 EXPECT_TRUE(cookies_removed_[1]);
113 EXPECT_EQ("abc", cookies_changed_[2].Name()); 114 EXPECT_EQ("abc", cookies_changed_[2].Name());
114 EXPECT_EQ("ghi", cookies_changed_[2].Value()); 115 EXPECT_EQ("ghi", cookies_changed_[2].Value());
115 EXPECT_FALSE(cookies_removed_[2]); 116 EXPECT_FALSE(cookies_removed_[2]);
116 } 117 }
117 118
118 // Tests that cookies can be read before the backend is loaded. 119 // Tests that cookies can be read before the backend is loaded.
119 TEST_F(CookieStoreIOSPersistentTest, NotSynchronized) { 120 TEST_F(CookieStoreIOSPersistentTest, NotSynchronized) {
120 // Start fetching the cookie. 121 // Start fetching the cookie.
121 GetCookieCallback callback; 122 GetCookieCallback callback;
122 GetCookies(base::Bind(&GetCookieCallback::Run, base::Unretained(&callback))); 123 GetCookies(
124 base::BindOnce(&GetCookieCallback::Run, base::Unretained(&callback)));
123 // Backend loading completes. 125 // Backend loading completes.
124 backend_->RunLoadedCallback(); 126 backend_->RunLoadedCallback();
125 EXPECT_TRUE(callback.did_run()); 127 EXPECT_TRUE(callback.did_run());
126 EXPECT_EQ("a=b", callback.cookie_line()); 128 EXPECT_EQ("a=b", callback.cookie_line());
127 } 129 }
128 130
129 } // namespace net 131 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698