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 <stdint.h> |
5 #include "base/strings/sys_string_conversions.h" | 6 #include "base/strings/sys_string_conversions.h" |
6 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 7 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 8 |
7 #include "chrome/browser/ui/cocoa/content_settings/cookie_details.h" | 9 #include "chrome/browser/ui/cocoa/content_settings/cookie_details.h" |
8 #include "net/cookies/canonical_cookie.h" | 10 #include "net/cookies/canonical_cookie.h" |
9 #include "net/cookies/parsed_cookie.h" | 11 #include "net/cookies/parsed_cookie.h" |
10 #import "testing/gtest_mac.h" | 12 #import "testing/gtest_mac.h" |
11 #include "url/gurl.h" | 13 #include "url/gurl.h" |
12 | 14 |
13 namespace { | 15 namespace { |
14 | 16 |
15 class CookiesDetailsTest : public CocoaTest { | 17 class CookiesDetailsTest : public CocoaTest { |
16 }; | 18 }; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); | 54 EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); |
53 EXPECT_FALSE([details.get() shouldShowServiceWorkerTreeDetailsView]); | 55 EXPECT_FALSE([details.get() shouldShowServiceWorkerTreeDetailsView]); |
54 EXPECT_FALSE([details.get() shouldShowCacheStorageTreeDetailsView]); | 56 EXPECT_FALSE([details.get() shouldShowCacheStorageTreeDetailsView]); |
55 } | 57 } |
56 | 58 |
57 TEST_F(CookiesDetailsTest, CreateForTreeDatabase) { | 59 TEST_F(CookiesDetailsTest, CreateForTreeDatabase) { |
58 base::scoped_nsobject<CocoaCookieDetails> details; | 60 base::scoped_nsobject<CocoaCookieDetails> details; |
59 GURL origin("http://chromium.org"); | 61 GURL origin("http://chromium.org"); |
60 std::string database_name("sassolungo"); | 62 std::string database_name("sassolungo"); |
61 std::string description("a great place to climb"); | 63 std::string description("a great place to climb"); |
62 int64 size = 1234; | 64 int64_t size = 1234; |
63 base::Time last_modified = base::Time::Now(); | 65 base::Time last_modified = base::Time::Now(); |
64 BrowsingDataDatabaseHelper::DatabaseInfo info( | 66 BrowsingDataDatabaseHelper::DatabaseInfo info( |
65 storage::DatabaseIdentifier::CreateFromOrigin(origin), | 67 storage::DatabaseIdentifier::CreateFromOrigin(origin), |
66 database_name, | 68 database_name, |
67 description, | 69 description, |
68 size, | 70 size, |
69 last_modified); | 71 last_modified); |
70 details.reset([[CocoaCookieDetails alloc] initWithDatabase:&info]); | 72 details.reset([[CocoaCookieDetails alloc] initWithDatabase:&info]); |
71 | 73 |
72 EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypeTreeDatabase); | 74 EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypeTreeDatabase); |
73 EXPECT_NSEQ(@"a great place to climb", [details.get() databaseDescription]); | 75 EXPECT_NSEQ(@"a great place to climb", [details.get() databaseDescription]); |
74 EXPECT_NSEQ(@"1,234 B", [details.get() fileSize]); | 76 EXPECT_NSEQ(@"1,234 B", [details.get() fileSize]); |
75 EXPECT_NSNE(@"", [details.get() lastModified]); | 77 EXPECT_NSNE(@"", [details.get() lastModified]); |
76 | 78 |
77 EXPECT_TRUE([details.get() shouldHideCookieDetailsView]); | 79 EXPECT_TRUE([details.get() shouldHideCookieDetailsView]); |
78 EXPECT_FALSE([details.get() shouldShowLocalStorageTreeDetailsView]); | 80 EXPECT_FALSE([details.get() shouldShowLocalStorageTreeDetailsView]); |
79 EXPECT_TRUE([details.get() shouldShowDatabaseTreeDetailsView]); | 81 EXPECT_TRUE([details.get() shouldShowDatabaseTreeDetailsView]); |
80 EXPECT_FALSE([details.get() shouldShowAppCacheTreeDetailsView]); | 82 EXPECT_FALSE([details.get() shouldShowAppCacheTreeDetailsView]); |
81 EXPECT_FALSE([details.get() shouldShowIndexedDBTreeDetailsView]); | 83 EXPECT_FALSE([details.get() shouldShowIndexedDBTreeDetailsView]); |
82 EXPECT_FALSE([details.get() shouldShowLocalStoragePromptDetailsView]); | 84 EXPECT_FALSE([details.get() shouldShowLocalStoragePromptDetailsView]); |
83 EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); | 85 EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); |
84 EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); | 86 EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); |
85 EXPECT_FALSE([details.get() shouldShowServiceWorkerTreeDetailsView]); | 87 EXPECT_FALSE([details.get() shouldShowServiceWorkerTreeDetailsView]); |
86 EXPECT_FALSE([details.get() shouldShowCacheStorageTreeDetailsView]); | 88 EXPECT_FALSE([details.get() shouldShowCacheStorageTreeDetailsView]); |
87 } | 89 } |
88 | 90 |
89 TEST_F(CookiesDetailsTest, CreateForTreeLocalStorage) { | 91 TEST_F(CookiesDetailsTest, CreateForTreeLocalStorage) { |
90 base::scoped_nsobject<CocoaCookieDetails> details; | 92 base::scoped_nsobject<CocoaCookieDetails> details; |
91 const GURL kOrigin("http://chromium.org/"); | 93 const GURL kOrigin("http://chromium.org/"); |
92 int64 size = 1234; | 94 int64_t size = 1234; |
93 base::Time last_modified = base::Time::Now(); | 95 base::Time last_modified = base::Time::Now(); |
94 BrowsingDataLocalStorageHelper::LocalStorageInfo info( | 96 BrowsingDataLocalStorageHelper::LocalStorageInfo info( |
95 kOrigin, size, last_modified); | 97 kOrigin, size, last_modified); |
96 details.reset([[CocoaCookieDetails alloc] initWithLocalStorage:&info]); | 98 details.reset([[CocoaCookieDetails alloc] initWithLocalStorage:&info]); |
97 | 99 |
98 EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypeTreeLocalStorage); | 100 EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypeTreeLocalStorage); |
99 EXPECT_NSEQ(@"http://chromium.org/", [details.get() domain]); | 101 EXPECT_NSEQ(@"http://chromium.org/", [details.get() domain]); |
100 EXPECT_NSEQ(@"1,234 B", [details.get() fileSize]); | 102 EXPECT_NSEQ(@"1,234 B", [details.get() fileSize]); |
101 EXPECT_NSNE(@"", [details.get() lastModified]); | 103 EXPECT_NSNE(@"", [details.get() lastModified]); |
102 | 104 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); | 142 EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); |
141 EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); | 143 EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); |
142 EXPECT_FALSE([details.get() shouldShowServiceWorkerTreeDetailsView]); | 144 EXPECT_FALSE([details.get() shouldShowServiceWorkerTreeDetailsView]); |
143 EXPECT_FALSE([details.get() shouldShowCacheStorageTreeDetailsView]); | 145 EXPECT_FALSE([details.get() shouldShowCacheStorageTreeDetailsView]); |
144 } | 146 } |
145 | 147 |
146 TEST_F(CookiesDetailsTest, CreateForTreeIndexedDB) { | 148 TEST_F(CookiesDetailsTest, CreateForTreeIndexedDB) { |
147 base::scoped_nsobject<CocoaCookieDetails> details; | 149 base::scoped_nsobject<CocoaCookieDetails> details; |
148 | 150 |
149 GURL origin("http://moose.org/"); | 151 GURL origin("http://moose.org/"); |
150 int64 size = 1234; | 152 int64_t size = 1234; |
151 base::Time last_modified = base::Time::Now(); | 153 base::Time last_modified = base::Time::Now(); |
152 content::IndexedDBInfo info(origin, | 154 content::IndexedDBInfo info(origin, |
153 size, | 155 size, |
154 last_modified, | 156 last_modified, |
155 0); | 157 0); |
156 | 158 |
157 details.reset([[CocoaCookieDetails alloc] initWithIndexedDBInfo:&info]); | 159 details.reset([[CocoaCookieDetails alloc] initWithIndexedDBInfo:&info]); |
158 | 160 |
159 EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypeTreeIndexedDB); | 161 EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypeTreeIndexedDB); |
160 EXPECT_NSEQ(@"http://moose.org/", [details.get() domain]); | 162 EXPECT_NSEQ(@"http://moose.org/", [details.get() domain]); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); | 280 EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); |
279 EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); | 281 EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); |
280 EXPECT_TRUE([details.get() shouldShowServiceWorkerTreeDetailsView]); | 282 EXPECT_TRUE([details.get() shouldShowServiceWorkerTreeDetailsView]); |
281 EXPECT_FALSE([details.get() shouldShowCacheStorageTreeDetailsView]); | 283 EXPECT_FALSE([details.get() shouldShowCacheStorageTreeDetailsView]); |
282 } | 284 } |
283 | 285 |
284 TEST_F(CookiesDetailsTest, CreateForTreeCacheStorage) { | 286 TEST_F(CookiesDetailsTest, CreateForTreeCacheStorage) { |
285 base::scoped_nsobject<CocoaCookieDetails> details; | 287 base::scoped_nsobject<CocoaCookieDetails> details; |
286 | 288 |
287 GURL origin("https://example.com/"); | 289 GURL origin("https://example.com/"); |
288 int64 size = 1234; | 290 int64_t size = 1234; |
289 base::Time last_modified = base::Time::Now(); | 291 base::Time last_modified = base::Time::Now(); |
290 content::CacheStorageUsageInfo info(origin, size, last_modified); | 292 content::CacheStorageUsageInfo info(origin, size, last_modified); |
291 | 293 |
292 details.reset( | 294 details.reset( |
293 [[CocoaCookieDetails alloc] initWithCacheStorageUsageInfo:&info]); | 295 [[CocoaCookieDetails alloc] initWithCacheStorageUsageInfo:&info]); |
294 | 296 |
295 EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypeTreeCacheStorage); | 297 EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypeTreeCacheStorage); |
296 EXPECT_NSEQ(@"https://example.com/", [details.get() domain]); | 298 EXPECT_NSEQ(@"https://example.com/", [details.get() domain]); |
297 EXPECT_NSEQ(@"1,234 B", [details.get() fileSize]); | 299 EXPECT_NSEQ(@"1,234 B", [details.get() fileSize]); |
298 EXPECT_NSNE(@"", [details.get() lastModified]); | 300 EXPECT_NSNE(@"", [details.get() lastModified]); |
299 | 301 |
300 EXPECT_TRUE([details.get() shouldHideCookieDetailsView]); | 302 EXPECT_TRUE([details.get() shouldHideCookieDetailsView]); |
301 EXPECT_FALSE([details.get() shouldShowLocalStorageTreeDetailsView]); | 303 EXPECT_FALSE([details.get() shouldShowLocalStorageTreeDetailsView]); |
302 EXPECT_FALSE([details.get() shouldShowDatabaseTreeDetailsView]); | 304 EXPECT_FALSE([details.get() shouldShowDatabaseTreeDetailsView]); |
303 EXPECT_FALSE([details.get() shouldShowAppCacheTreeDetailsView]); | 305 EXPECT_FALSE([details.get() shouldShowAppCacheTreeDetailsView]); |
304 EXPECT_FALSE([details.get() shouldShowIndexedDBTreeDetailsView]); | 306 EXPECT_FALSE([details.get() shouldShowIndexedDBTreeDetailsView]); |
305 EXPECT_FALSE([details.get() shouldShowLocalStoragePromptDetailsView]); | 307 EXPECT_FALSE([details.get() shouldShowLocalStoragePromptDetailsView]); |
306 EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); | 308 EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); |
307 EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); | 309 EXPECT_FALSE([details.get() shouldShowAppCachePromptDetailsView]); |
308 EXPECT_FALSE([details.get() shouldShowServiceWorkerTreeDetailsView]); | 310 EXPECT_FALSE([details.get() shouldShowServiceWorkerTreeDetailsView]); |
309 EXPECT_TRUE([details.get() shouldShowCacheStorageTreeDetailsView]); | 311 EXPECT_TRUE([details.get() shouldShowCacheStorageTreeDetailsView]); |
310 } | 312 } |
311 } | 313 } |
OLD | NEW |