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

Side by Side Diff: ios/chrome/browser/net/cookie_util_unittest.mm

Issue 2517633002: [ObjC ARC] Converts ios/chrome/browser/net:unit_tests to ARC.Automatically generated ARCMigrate c… (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « ios/chrome/browser/net/BUILD.gn ('k') | ios/chrome/browser/net/image_fetcher_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #include "ios/chrome/browser/net/cookie_util.h" 5 #include "ios/chrome/browser/net/cookie_util.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support."
13 #endif
14
11 namespace { 15 namespace {
12 16
13 // Date of the last cookie deletion. 17 // Date of the last cookie deletion.
14 NSString* const kLastCookieDeletionDate = @"LastCookieDeletionDate"; 18 NSString* const kLastCookieDeletionDate = @"LastCookieDeletionDate";
15 19
16 } // namespace 20 } // namespace
17 21
18 TEST(CookieUtil, ShouldClearSessionCookies) { 22 TEST(CookieUtil, ShouldClearSessionCookies) {
19 time_t start_test_time; 23 time_t start_test_time;
20 time(&start_test_time); 24 time(&start_test_time);
21 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; 25 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
22 // Delete cookies if the key is not present. 26 // Delete cookies if the key is not present.
23 [defaults removeObjectForKey:kLastCookieDeletionDate]; 27 [defaults removeObjectForKey:kLastCookieDeletionDate];
24 EXPECT_TRUE(cookie_util::ShouldClearSessionCookies()); 28 EXPECT_TRUE(cookie_util::ShouldClearSessionCookies());
25 // The deletion time should be created. 29 // The deletion time should be created.
26 time_t deletion_time = [defaults integerForKey:kLastCookieDeletionDate]; 30 time_t deletion_time = [defaults integerForKey:kLastCookieDeletionDate];
27 time_t now; 31 time_t now;
28 time(&now); 32 time(&now);
29 EXPECT_LE(start_test_time, deletion_time); 33 EXPECT_LE(start_test_time, deletion_time);
30 EXPECT_LE(deletion_time, now); 34 EXPECT_LE(deletion_time, now);
31 // Cookies are not deleted again. 35 // Cookies are not deleted again.
32 EXPECT_FALSE(cookie_util::ShouldClearSessionCookies()); 36 EXPECT_FALSE(cookie_util::ShouldClearSessionCookies());
33 37
34 // Set the deletion time before the machine was started. 38 // Set the deletion time before the machine was started.
35 // Sometime in year 1980. 39 // Sometime in year 1980.
36 [defaults setInteger:328697227 forKey:kLastCookieDeletionDate]; 40 [defaults setInteger:328697227 forKey:kLastCookieDeletionDate];
37 EXPECT_TRUE(cookie_util::ShouldClearSessionCookies()); 41 EXPECT_TRUE(cookie_util::ShouldClearSessionCookies());
38 EXPECT_LE(now, [defaults integerForKey:kLastCookieDeletionDate]); 42 EXPECT_LE(now, [defaults integerForKey:kLastCookieDeletionDate]);
39 } 43 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/net/BUILD.gn ('k') | ios/chrome/browser/net/image_fetcher_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698