OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/sys_string_conversions.h" | 5 #include "base/sys_string_conversions.h" |
6 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 6 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
7 #include "chrome/browser/ui/cocoa/content_settings/cookie_details.h" | 7 #include "chrome/browser/ui/cocoa/content_settings/cookie_details.h" |
8 #include "chrome/browser/ui/cocoa/content_settings/cookie_details_view_controlle
r.h" | 8 #include "chrome/browser/ui/cocoa/content_settings/cookie_details_view_controlle
r.h" |
9 #include "net/cookies/parsed_cookie.h" | 9 #include "net/cookies/parsed_cookie.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 class CookieDetailsViewControllerTest : public CocoaTest { | 13 class CookieDetailsViewControllerTest : public CocoaTest { |
14 }; | 14 }; |
15 | 15 |
16 static CocoaCookieDetails* CreateTestCookieDetails(BOOL canEditExpiration) { | 16 static CocoaCookieDetails* CreateTestCookieDetails(BOOL canEditExpiration) { |
17 GURL url("http://chromium.org"); | 17 GURL url("http://chromium.org"); |
18 std::string cookieLine( | 18 std::string cookieLine( |
19 "PHPSESSID=0123456789abcdef0123456789abcdef; path=/"); | 19 "PHPSESSID=0123456789abcdef0123456789abcdef; path=/"); |
20 net::ParsedCookie pc(cookieLine); | 20 net::ParsedCookie pc(cookieLine); |
21 net::CookieMonster::CanonicalCookie cookie(url, pc); | 21 net::CookieMonster::CanonicalCookie cookie(url, pc); |
22 NSString* origin = base::SysUTF8ToNSString("http://chromium.org"); | |
23 CocoaCookieDetails* details = [CocoaCookieDetails alloc]; | 22 CocoaCookieDetails* details = [CocoaCookieDetails alloc]; |
24 [details initWithCookie:&cookie | 23 [details initWithCookie:&cookie |
25 origin:origin | |
26 canEditExpiration:canEditExpiration]; | 24 canEditExpiration:canEditExpiration]; |
27 return [details autorelease]; | 25 return [details autorelease]; |
28 } | 26 } |
29 | 27 |
30 static CookiePromptContentDetailsAdapter* CreateCookieTestContent( | 28 static CookiePromptContentDetailsAdapter* CreateCookieTestContent( |
31 BOOL canEditExpiration) { | 29 BOOL canEditExpiration) { |
32 CocoaCookieDetails* details = CreateTestCookieDetails(canEditExpiration); | 30 CocoaCookieDetails* details = CreateTestCookieDetails(canEditExpiration); |
33 return [[[CookiePromptContentDetailsAdapter alloc] initWithDetails:details] | 31 return [[[CookiePromptContentDetailsAdapter alloc] initWithDetails:details] |
34 autorelease]; | 32 autorelease]; |
35 } | 33 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 78 |
81 EXPECT_FALSE([detailsViewController.get() hasExpiration]); | 79 EXPECT_FALSE([detailsViewController.get() hasExpiration]); |
82 [detailsViewController.get() setCookieHasExplicitExpiration:adapter.get()]; | 80 [detailsViewController.get() setCookieHasExplicitExpiration:adapter.get()]; |
83 EXPECT_TRUE([detailsViewController.get() hasExpiration]); | 81 EXPECT_TRUE([detailsViewController.get() hasExpiration]); |
84 [detailsViewController.get() | 82 [detailsViewController.get() |
85 setCookieDoesntHaveExplicitExpiration:adapter.get()]; | 83 setCookieDoesntHaveExplicitExpiration:adapter.get()]; |
86 EXPECT_FALSE([detailsViewController.get() hasExpiration]); | 84 EXPECT_FALSE([detailsViewController.get() hasExpiration]); |
87 } | 85 } |
88 | 86 |
89 } // namespace | 87 } // namespace |
OLD | NEW |