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

Unified Diff: components/cronet/ios/test/cronet_http_test.mm

Issue 2617853002: [Cronet] Use CookieStoreIOS to sync cookies to system store. (Closed)
Patch Set: 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: components/cronet/ios/test/cronet_http_test.mm
diff --git a/components/cronet/ios/test/cronet_http_test.mm b/components/cronet/ios/test/cronet_http_test.mm
index 21d0419e6c3ef5ffec62cc19b248071bc4d45db5..8624bcd7e7dd6152a701bf19b32051854f5858af 100644
--- a/components/cronet/ios/test/cronet_http_test.mm
+++ b/components/cronet/ios/test/cronet_http_test.mm
@@ -258,6 +258,16 @@ TEST_F(HttpTest, SetUserAgentIsExact) {
TEST_F(HttpTest, SetCookie) {
const char kCookieHeader[] = "Cookie";
const char kCookieLine[] = "aaaa=bbb";
+ NSHTTPCookieStorage* systemCookieStorage =
+ [NSHTTPCookieStorage sharedHTTPCookieStorage];
+ NSURL* cookieUrl =
+ [NSURL URLWithString:base::SysUTF8ToNSString(
+ TestServer::GetEchoHeaderURL(kCookieHeader))];
+ // Verify that cookie is not set in system storage.
+ for (NSHTTPCookie* cookie in [systemCookieStorage cookiesForURL:cookieUrl]) {
+ EXPECT_FALSE([[cookie name] containsString:@"aaaa"]);
kapishnikov 2017/01/06 15:24:45 Since 'isEqual' (or better 'isEqualToString') is u
mef 2017/01/06 15:52:55 Done.
+ }
+
NSURL* echoCookieUrl =
net::NSURLWithGURL(GURL(TestServer::GetEchoHeaderURL(kCookieHeader)));
StartDataTaskAndWaitForCompletion([session_ dataTaskWithURL:echoCookieUrl]);
@@ -275,6 +285,17 @@ TEST_F(HttpTest, SetCookie) {
EXPECT_EQ(nil, [delegate_ error]);
EXPECT_TRUE([[delegate_ responseBody]
containsString:base::SysUTF8ToNSString(kCookieLine)]);
+
+ // Verify that cookie is set in system storage.
+ NSHTTPCookie* systemCookie = nil;
+ for (NSHTTPCookie* cookie in [systemCookieStorage cookiesForURL:cookieUrl]) {
+ if ([cookie.name isEqual:@"aaaa"]) {
kapishnikov 2017/01/06 15:24:45 isEqualToString should be a little faster.
mef 2017/01/06 15:52:55 Done.
+ systemCookie = cookie;
+ break;
+ }
+ }
+ EXPECT_TRUE([[systemCookie value] containsString:@"bbb"]);
kapishnikov 2017/01/06 15:24:45 Why don't use isEqualToString instead of containsS
mef 2017/01/06 15:52:55 Done.
+ [systemCookieStorage deleteCookie:systemCookie];
}
TEST_F(HttpTest, FilterOutRequest) {
« components/cronet/ios/cronet_environment.mm ('K') | « components/cronet/ios/cronet_environment.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698