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

Side by Side Diff: chrome/browser/ui/cocoa/options/cookies_window_controller_unittest.mm

Issue 6339002: [Mac] Consolidate all files relating to preferences in a subdir of c/b/ui/coc... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #import "base/scoped_nsobject.h" 8 #import "base/scoped_nsobject.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/browsing_data_remover.h" 11 #include "chrome/browser/browsing_data_remover.h"
12 #include "chrome/browser/cookies_tree_model.h" 12 #include "chrome/browser/cookies_tree_model.h"
13 #include "chrome/browser/mock_browsing_data_appcache_helper.h"
13 #include "chrome/browser/mock_browsing_data_database_helper.h" 14 #include "chrome/browser/mock_browsing_data_database_helper.h"
15 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h"
14 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" 16 #include "chrome/browser/mock_browsing_data_local_storage_helper.h"
15 #include "chrome/browser/mock_browsing_data_appcache_helper.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/cocoa/browser_test_helper.h" 18 #include "chrome/browser/ui/cocoa/browser_test_helper.h"
18 #include "chrome/browser/ui/cocoa/clear_browsing_data_controller.h" 19 #include "chrome/browser/ui/cocoa/clear_browsing_data_controller.h"
19 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" 20 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
20 #import "chrome/browser/ui/cocoa/cookies_window_controller.h" 21 #import "chrome/browser/ui/cocoa/options/cookies_window_controller.h"
21 #include "chrome/common/net/url_request_context_getter.h" 22 #include "chrome/common/net/url_request_context_getter.h"
22 #include "chrome/test/testing_profile.h" 23 #include "chrome/test/testing_profile.h"
23 #include "googleurl/src/gurl.h" 24 #include "googleurl/src/gurl.h"
24 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
25 #include "net/url_request/url_request_context.h" 26 #include "net/url_request/url_request_context.h"
26 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
27 #import "testing/gtest_mac.h" 28 #import "testing/gtest_mac.h"
28 #include "testing/platform_test.h" 29 #include "testing/platform_test.h"
29 #import "third_party/ocmock/OCMock/OCMock.h" 30 #import "third_party/ocmock/OCMock/OCMock.h"
30 #include "ui/base/models/tree_model.h" 31 #include "ui/base/models/tree_model.h"
(...skipping 23 matching lines...) Expand all
54 class CookiesWindowControllerTest : public CocoaTest { 55 class CookiesWindowControllerTest : public CocoaTest {
55 public: 56 public:
56 57
57 virtual void SetUp() { 58 virtual void SetUp() {
58 CocoaTest::SetUp(); 59 CocoaTest::SetUp();
59 TestingProfile* profile = browser_helper_.profile(); 60 TestingProfile* profile = browser_helper_.profile();
60 profile->CreateRequestContext(); 61 profile->CreateRequestContext();
61 database_helper_ = new MockBrowsingDataDatabaseHelper(profile); 62 database_helper_ = new MockBrowsingDataDatabaseHelper(profile);
62 local_storage_helper_ = new MockBrowsingDataLocalStorageHelper(profile); 63 local_storage_helper_ = new MockBrowsingDataLocalStorageHelper(profile);
63 appcache_helper_ = new MockBrowsingDataAppCacheHelper(profile); 64 appcache_helper_ = new MockBrowsingDataAppCacheHelper(profile);
65 indexed_db_helper_ = new MockBrowsingDataIndexedDBHelper(profile);
Nico 2011/01/14 19:17:57 looks unrelated?
64 controller_.reset( 66 controller_.reset(
65 [[CookiesWindowController alloc] initWithProfile:profile 67 [[CookiesWindowController alloc] initWithProfile:profile
66 databaseHelper:database_helper_ 68 databaseHelper:database_helper_
67 storageHelper:local_storage_helper_ 69 storageHelper:local_storage_helper_
68 appcacheHelper:appcache_helper_] 70 appcacheHelper:appcache_helper_
71 indexedDBHelper:indexed_db_helper_]
69 ); 72 );
70 } 73 }
71 74
72 virtual void TearDown() { 75 virtual void TearDown() {
73 CocoaTest::TearDown(); 76 CocoaTest::TearDown();
74 } 77 }
75 78
76 CocoaCookieTreeNode* CocoaNodeFromTreeNode(ui::TreeModelNode* node) { 79 CocoaCookieTreeNode* CocoaNodeFromTreeNode(ui::TreeModelNode* node) {
77 return [controller_ modelObserver]->CocoaNodeFromTreeNode(node); 80 return [controller_ modelObserver]->CocoaNodeFromTreeNode(node);
78 } 81 }
79 82
80 CocoaCookieTreeNode* FindCocoaNode(ui::TreeModelNode* node, 83 CocoaCookieTreeNode* FindCocoaNode(ui::TreeModelNode* node,
81 CocoaCookieTreeNode* start) { 84 CocoaCookieTreeNode* start) {
82 return [controller_ modelObserver]->FindCocoaNode(node, start); 85 return [controller_ modelObserver]->FindCocoaNode(node, start);
83 } 86 }
84 87
85 protected: 88 protected:
86 BrowserTestHelper browser_helper_; 89 BrowserTestHelper browser_helper_;
87 scoped_nsobject<CookiesWindowController> controller_; 90 scoped_nsobject<CookiesWindowController> controller_;
88 MockBrowsingDataDatabaseHelper* database_helper_; 91 MockBrowsingDataDatabaseHelper* database_helper_;
89 MockBrowsingDataLocalStorageHelper* local_storage_helper_; 92 MockBrowsingDataLocalStorageHelper* local_storage_helper_;
90 MockBrowsingDataAppCacheHelper* appcache_helper_; 93 MockBrowsingDataAppCacheHelper* appcache_helper_;
94 MockBrowsingDataIndexedDBHelper* indexed_db_helper_;
91 }; 95 };
92 96
93 TEST_F(CookiesWindowControllerTest, Construction) { 97 TEST_F(CookiesWindowControllerTest, Construction) {
94 std::vector<SkBitmap> skia_icons; 98 std::vector<SkBitmap> skia_icons;
95 [controller_ treeModel]->GetIcons(&skia_icons); 99 [controller_ treeModel]->GetIcons(&skia_icons);
96 100
97 EXPECT_EQ([[controller_ icons] count], skia_icons.size() + 1U); 101 EXPECT_EQ([[controller_ icons] count], skia_icons.size() + 1U);
98 } 102 }
99 103
100 TEST_F(CookiesWindowControllerTest, FindCocoaNodeRoot) { 104 TEST_F(CookiesWindowControllerTest, FindCocoaNodeRoot) {
101 scoped_ptr< ui::TreeNodeWithValue<int> > search( 105 scoped_ptr< ui::TreeNodeWithValue<int> > search(
102 new TreeNodeWithValue<int>(42)); 106 new ui::TreeNodeWithValue<int>(42));
103 scoped_nsobject<FakeCocoaCookieTreeNode> node( 107 scoped_nsobject<FakeCocoaCookieTreeNode> node(
104 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:search.get()]); 108 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:search.get()]);
105 EXPECT_EQ(node.get(), FindCocoaNode(search.get(), node.get())); 109 EXPECT_EQ(node.get(), FindCocoaNode(search.get(), node.get()));
106 } 110 }
107 111
108 TEST_F(CookiesWindowControllerTest, FindCocoaNodeImmediateChild) { 112 TEST_F(CookiesWindowControllerTest, FindCocoaNodeImmediateChild) {
109 scoped_ptr< ui::TreeNodeWithValue<int> > parent( 113 scoped_ptr< ui::TreeNodeWithValue<int> > parent(
110 new TreeNodeWithValue<int>(100)); 114 new ui::TreeNodeWithValue<int>(100));
111 scoped_ptr< ui::TreeNodeWithValue<int> > child1( 115 scoped_ptr< ui::TreeNodeWithValue<int> > child1(
112 new TreeNodeWithValue<int>(10)); 116 new ui::TreeNodeWithValue<int>(10));
113 scoped_ptr< ui::TreeNodeWithValue<int> > child2( 117 scoped_ptr< ui::TreeNodeWithValue<int> > child2(
114 new TreeNodeWithValue<int>(20)); 118 new ui::TreeNodeWithValue<int>(20));
115 scoped_nsobject<FakeCocoaCookieTreeNode> cocoaParent( 119 scoped_nsobject<FakeCocoaCookieTreeNode> cocoaParent(
116 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:parent.get()]); 120 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:parent.get()]);
117 scoped_nsobject<FakeCocoaCookieTreeNode> cocoaChild1( 121 scoped_nsobject<FakeCocoaCookieTreeNode> cocoaChild1(
118 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:child1.get()]); 122 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:child1.get()]);
119 scoped_nsobject<FakeCocoaCookieTreeNode> cocoaChild2( 123 scoped_nsobject<FakeCocoaCookieTreeNode> cocoaChild2(
120 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:child2.get()]); 124 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:child2.get()]);
121 [[cocoaParent mutableChildren] addObject:cocoaChild1.get()]; 125 [[cocoaParent mutableChildren] addObject:cocoaChild1.get()];
122 [[cocoaParent mutableChildren] addObject:cocoaChild2.get()]; 126 [[cocoaParent mutableChildren] addObject:cocoaChild2.get()];
123 127
124 EXPECT_EQ(cocoaChild2.get(), FindCocoaNode(child2.get(), cocoaParent.get())); 128 EXPECT_EQ(cocoaChild2.get(), FindCocoaNode(child2.get(), cocoaParent.get()));
125 } 129 }
126 130
127 TEST_F(CookiesWindowControllerTest, FindCocoaNodeRecursive) { 131 TEST_F(CookiesWindowControllerTest, FindCocoaNodeRecursive) {
128 scoped_ptr< ui::TreeNodeWithValue<int> > parent( 132 scoped_ptr< ui::TreeNodeWithValue<int> > parent(
129 new TreeNodeWithValue<int>(100)); 133 new ui::TreeNodeWithValue<int>(100));
130 scoped_ptr< ui::TreeNodeWithValue<int> > child1( 134 scoped_ptr< ui::TreeNodeWithValue<int> > child1(
131 new TreeNodeWithValue<int>(10)); 135 new ui::TreeNodeWithValue<int>(10));
132 scoped_ptr< ui::TreeNodeWithValue<int> > child2( 136 scoped_ptr< ui::TreeNodeWithValue<int> > child2(
133 new TreeNodeWithValue<int>(20)); 137 new ui::TreeNodeWithValue<int>(20));
134 scoped_nsobject<FakeCocoaCookieTreeNode> cocoaParent( 138 scoped_nsobject<FakeCocoaCookieTreeNode> cocoaParent(
135 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:parent.get()]); 139 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:parent.get()]);
136 scoped_nsobject<FakeCocoaCookieTreeNode> cocoaChild1( 140 scoped_nsobject<FakeCocoaCookieTreeNode> cocoaChild1(
137 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:child1.get()]); 141 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:child1.get()]);
138 scoped_nsobject<FakeCocoaCookieTreeNode> cocoaChild2( 142 scoped_nsobject<FakeCocoaCookieTreeNode> cocoaChild2(
139 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:child2.get()]); 143 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:child2.get()]);
140 [[cocoaParent mutableChildren] addObject:cocoaChild1.get()]; 144 [[cocoaParent mutableChildren] addObject:cocoaChild1.get()];
141 [[cocoaChild1 mutableChildren] addObject:cocoaChild2.get()]; 145 [[cocoaChild1 mutableChildren] addObject:cocoaChild2.get()];
142 146
143 EXPECT_EQ(cocoaChild2.get(), FindCocoaNode(child2.get(), cocoaParent.get())); 147 EXPECT_EQ(cocoaChild2.get(), FindCocoaNode(child2.get(), cocoaParent.get()));
144 } 148 }
145 149
146 TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeCookie) { 150 TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeCookie) {
147 net::CookieMonster* cm = browser_helper_.profile()->GetCookieMonster(); 151 net::CookieMonster* cm = browser_helper_.profile()->GetCookieMonster();
148 cm->SetCookie(GURL("http://foo.com"), "A=B"); 152 cm->SetCookie(GURL("http://foo.com"), "A=B");
149 CookiesTreeModel model(cm, database_helper_, local_storage_helper_, nil, nil); 153 CookiesTreeModel model(cm, database_helper_, local_storage_helper_, nil, nil,
154 nil);
150 155
151 // Root --> foo.com --> Cookies --> A. Create node for 'A'. 156 // Root --> foo.com --> Cookies --> A. Create node for 'A'.
152 ui::TreeModelNode* node = 157 ui::TreeModelNode* node =
153 model.GetRoot()->GetChild(0)->GetChild(0)->GetChild(0); 158 model.GetRoot()->GetChild(0)->GetChild(0)->GetChild(0);
154 CocoaCookieTreeNode* cookie = CocoaNodeFromTreeNode(node); 159 CocoaCookieTreeNode* cookie = CocoaNodeFromTreeNode(node);
155 160
156 CocoaCookieDetails* details = [cookie details]; 161 CocoaCookieDetails* details = [cookie details];
157 EXPECT_NSEQ(@"B", [details content]); 162 EXPECT_NSEQ(@"B", [details content]);
158 EXPECT_NSEQ(l10n_util::GetNSString(IDS_COOKIES_COOKIE_EXPIRES_SESSION), 163 EXPECT_NSEQ(l10n_util::GetNSString(IDS_COOKIES_COOKIE_EXPIRES_SESSION),
159 [details expires]); 164 [details expires]);
160 EXPECT_NSEQ(l10n_util::GetNSString(IDS_COOKIES_COOKIE_SENDFOR_ANY), 165 EXPECT_NSEQ(l10n_util::GetNSString(IDS_COOKIES_COOKIE_SENDFOR_ANY),
161 [details sendFor]); 166 [details sendFor]);
162 EXPECT_NSEQ(@"A", [cookie title]); 167 EXPECT_NSEQ(@"A", [cookie title]);
163 EXPECT_NSEQ(@"A", [details name]); 168 EXPECT_NSEQ(@"A", [details name]);
164 EXPECT_NSEQ(@"/", [details path]); 169 EXPECT_NSEQ(@"/", [details path]);
165 EXPECT_EQ(0U, [[cookie children] count]); 170 EXPECT_EQ(0U, [[cookie children] count]);
166 EXPECT_TRUE([details created]); 171 EXPECT_TRUE([details created]);
167 EXPECT_TRUE([cookie isLeaf]); 172 EXPECT_TRUE([cookie isLeaf]);
168 EXPECT_EQ(node, [cookie treeNode]); 173 EXPECT_EQ(node, [cookie treeNode]);
169 } 174 }
170 175
171 TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeRecursive) { 176 TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeRecursive) {
172 net::CookieMonster* cm = browser_helper_.profile()->GetCookieMonster(); 177 net::CookieMonster* cm = browser_helper_.profile()->GetCookieMonster();
173 cm->SetCookie(GURL("http://foo.com"), "A=B"); 178 cm->SetCookie(GURL("http://foo.com"), "A=B");
174 CookiesTreeModel model(cm, database_helper_, local_storage_helper_, nil, nil); 179 CookiesTreeModel model(cm, database_helper_, local_storage_helper_, nil, nil,
180 nil);
175 181
176 // Root --> foo.com --> Cookies --> A. Create node for 'foo.com'. 182 // Root --> foo.com --> Cookies --> A. Create node for 'foo.com'.
177 CookieTreeNode* node = model.GetRoot()->GetChild(0); 183 CookieTreeNode* node = model.GetRoot()->GetChild(0);
178 CocoaCookieTreeNode* domain = CocoaNodeFromTreeNode(node); 184 CocoaCookieTreeNode* domain = CocoaNodeFromTreeNode(node);
179 CocoaCookieTreeNode* cookies = [[domain children] objectAtIndex:0]; 185 CocoaCookieTreeNode* cookies = [[domain children] objectAtIndex:0];
180 CocoaCookieTreeNode* cookie = [[cookies children] objectAtIndex:0]; 186 CocoaCookieTreeNode* cookie = [[cookies children] objectAtIndex:0];
181 187
182 // Test domain-level node. 188 // Test domain-level node.
183 EXPECT_NSEQ(@"foo.com", [domain title]); 189 EXPECT_NSEQ(@"foo.com", [domain title]);
184 190
(...skipping 27 matching lines...) Expand all
212 TEST_F(CookiesWindowControllerTest, TreeNodesAdded) { 218 TEST_F(CookiesWindowControllerTest, TreeNodesAdded) {
213 const GURL url = GURL("http://foo.com"); 219 const GURL url = GURL("http://foo.com");
214 TestingProfile* profile = browser_helper_.profile(); 220 TestingProfile* profile = browser_helper_.profile();
215 net::CookieMonster* cm = profile->GetCookieMonster(); 221 net::CookieMonster* cm = profile->GetCookieMonster();
216 cm->SetCookie(url, "A=B"); 222 cm->SetCookie(url, "A=B");
217 223
218 controller_.reset( 224 controller_.reset(
219 [[CookiesWindowController alloc] initWithProfile:profile 225 [[CookiesWindowController alloc] initWithProfile:profile
220 databaseHelper:database_helper_ 226 databaseHelper:database_helper_
221 storageHelper:local_storage_helper_ 227 storageHelper:local_storage_helper_
222 appcacheHelper:appcache_helper_]); 228 appcacheHelper:appcache_helper_
229 indexedDBHelper:indexed_db_helper_]);
223 230
224 // Root --> foo.com --> Cookies. 231 // Root --> foo.com --> Cookies.
225 NSMutableArray* cocoa_children = 232 NSMutableArray* cocoa_children =
226 [[[[[[controller_ cocoaTreeModel] children] objectAtIndex:0] 233 [[[[[[controller_ cocoaTreeModel] children] objectAtIndex:0]
227 children] objectAtIndex:0] mutableChildren]; 234 children] objectAtIndex:0] mutableChildren];
228 EXPECT_EQ(1U, [cocoa_children count]); 235 EXPECT_EQ(1U, [cocoa_children count]);
229 236
230 // Create some cookies. 237 // Create some cookies.
231 cm->SetCookie(url, "C=D"); 238 cm->SetCookie(url, "C=D");
232 cm->SetCookie(url, "E=F"); 239 cm->SetCookie(url, "E=F");
(...skipping 23 matching lines...) Expand all
256 TestingProfile* profile = browser_helper_.profile(); 263 TestingProfile* profile = browser_helper_.profile();
257 net::CookieMonster* cm = profile->GetCookieMonster(); 264 net::CookieMonster* cm = profile->GetCookieMonster();
258 cm->SetCookie(url, "A=B"); 265 cm->SetCookie(url, "A=B");
259 cm->SetCookie(url, "C=D"); 266 cm->SetCookie(url, "C=D");
260 cm->SetCookie(url, "E=F"); 267 cm->SetCookie(url, "E=F");
261 268
262 controller_.reset( 269 controller_.reset(
263 [[CookiesWindowController alloc] initWithProfile:profile 270 [[CookiesWindowController alloc] initWithProfile:profile
264 databaseHelper:database_helper_ 271 databaseHelper:database_helper_
265 storageHelper:local_storage_helper_ 272 storageHelper:local_storage_helper_
266 appcacheHelper:appcache_helper_]); 273 appcacheHelper:appcache_helper_
274 indexedDBHelper:indexed_db_helper_]);
267 275
268 // Root --> foo.com --> Cookies. 276 // Root --> foo.com --> Cookies.
269 NSMutableArray* cocoa_children = 277 NSMutableArray* cocoa_children =
270 [[[[[[controller_ cocoaTreeModel] children] objectAtIndex:0] 278 [[[[[[controller_ cocoaTreeModel] children] objectAtIndex:0]
271 children] objectAtIndex:0] mutableChildren]; 279 children] objectAtIndex:0] mutableChildren];
272 EXPECT_EQ(3U, [cocoa_children count]); 280 EXPECT_EQ(3U, [cocoa_children count]);
273 281
274 CookiesTreeModel* model = [controller_ treeModel]; 282 CookiesTreeModel* model = [controller_ treeModel];
275 // Root --> foo.com --> Cookies. 283 // Root --> foo.com --> Cookies.
276 CookieTreeNode* parent = model->GetRoot()->GetChild(0)->GetChild(0); 284 CookieTreeNode* parent = model->GetRoot()->GetChild(0)->GetChild(0);
(...skipping 10 matching lines...) Expand all
287 TEST_F(CookiesWindowControllerTest, TreeNodeChanged) { 295 TEST_F(CookiesWindowControllerTest, TreeNodeChanged) {
288 const GURL url = GURL("http://foo.com"); 296 const GURL url = GURL("http://foo.com");
289 TestingProfile* profile = browser_helper_.profile(); 297 TestingProfile* profile = browser_helper_.profile();
290 net::CookieMonster* cm = profile->GetCookieMonster(); 298 net::CookieMonster* cm = profile->GetCookieMonster();
291 cm->SetCookie(url, "A=B"); 299 cm->SetCookie(url, "A=B");
292 300
293 controller_.reset( 301 controller_.reset(
294 [[CookiesWindowController alloc] initWithProfile:profile 302 [[CookiesWindowController alloc] initWithProfile:profile
295 databaseHelper:database_helper_ 303 databaseHelper:database_helper_
296 storageHelper:local_storage_helper_ 304 storageHelper:local_storage_helper_
297 appcacheHelper:appcache_helper_]); 305 appcacheHelper:appcache_helper_
306 indexedDBHelper:indexed_db_helper_]);
298 307
299 CookiesTreeModel* model = [controller_ treeModel]; 308 CookiesTreeModel* model = [controller_ treeModel];
300 // Root --> foo.com --> Cookies. 309 // Root --> foo.com --> Cookies.
301 CookieTreeNode* node = model->GetRoot()->GetChild(0)->GetChild(0); 310 CookieTreeNode* node = model->GetRoot()->GetChild(0)->GetChild(0);
302 311
303 // Root --> foo.com --> Cookies. 312 // Root --> foo.com --> Cookies.
304 CocoaCookieTreeNode* cocoa_node = 313 CocoaCookieTreeNode* cocoa_node =
305 [[[[[controller_ cocoaTreeModel] children] objectAtIndex:0] 314 [[[[[controller_ cocoaTreeModel] children] objectAtIndex:0]
306 children] objectAtIndex:0]; 315 children] objectAtIndex:0];
307 316
(...skipping 16 matching lines...) Expand all
324 cm->SetCookie(url, "A=B"); 333 cm->SetCookie(url, "A=B");
325 cm->SetCookie(url, "C=D"); 334 cm->SetCookie(url, "C=D");
326 cm->SetCookie(GURL("http://google.com"), "E=F"); 335 cm->SetCookie(GURL("http://google.com"), "E=F");
327 336
328 // This will clean itself up when we call |-closeSheet:|. If we reset the 337 // This will clean itself up when we call |-closeSheet:|. If we reset the
329 // scoper, we'd get a double-free. 338 // scoper, we'd get a double-free.
330 CookiesWindowController* controller = 339 CookiesWindowController* controller =
331 [[CookiesWindowController alloc] initWithProfile:profile 340 [[CookiesWindowController alloc] initWithProfile:profile
332 databaseHelper:database_helper_ 341 databaseHelper:database_helper_
333 storageHelper:local_storage_helper_ 342 storageHelper:local_storage_helper_
334 appcacheHelper:appcache_helper_]; 343 appcacheHelper:appcache_helper_
344 indexedDBHelper:indexed_db_helper_];
335 [controller attachSheetTo:test_window()]; 345 [controller attachSheetTo:test_window()];
336 NSTreeController* treeController = [controller treeController]; 346 NSTreeController* treeController = [controller treeController];
337 347
338 // Select cookie A. 348 // Select cookie A.
339 NSUInteger pathA[3] = {0, 0, 0}; 349 NSUInteger pathA[3] = {0, 0, 0};
340 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:pathA length:3]; 350 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:pathA length:3];
341 [treeController setSelectionIndexPath:indexPath]; 351 [treeController setSelectionIndexPath:indexPath];
342 352
343 // Press the "Delete" button. 353 // Press the "Delete" button.
344 [controller deleteCookie:nil]; 354 [controller deleteCookie:nil];
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 const GURL url = GURL("http://foo.com"); 390 const GURL url = GURL("http://foo.com");
381 TestingProfile* profile = browser_helper_.profile(); 391 TestingProfile* profile = browser_helper_.profile();
382 net::CookieMonster* cm = profile->GetCookieMonster(); 392 net::CookieMonster* cm = profile->GetCookieMonster();
383 cm->SetCookie(url, "A=B"); 393 cm->SetCookie(url, "A=B");
384 cm->SetCookie(url, "C=D"); 394 cm->SetCookie(url, "C=D");
385 395
386 controller_.reset( 396 controller_.reset(
387 [[CookiesWindowController alloc] initWithProfile:profile 397 [[CookiesWindowController alloc] initWithProfile:profile
388 databaseHelper:database_helper_ 398 databaseHelper:database_helper_
389 storageHelper:local_storage_helper_ 399 storageHelper:local_storage_helper_
390 appcacheHelper:appcache_helper_]); 400 appcacheHelper:appcache_helper_
401 indexedDBHelper:indexed_db_helper_]);
391 402
392 // Root --> foo.com. 403 // Root --> foo.com.
393 CocoaCookieTreeNode* foo = 404 CocoaCookieTreeNode* foo =
394 [[[controller_ cocoaTreeModel] children] objectAtIndex:0]; 405 [[[controller_ cocoaTreeModel] children] objectAtIndex:0];
395 406
396 // Create the objects we are going to be testing with. 407 // Create the objects we are going to be testing with.
397 id outlineView = [OCMockObject mockForClass:[NSOutlineView class]]; 408 id outlineView = [OCMockObject mockForClass:[NSOutlineView class]];
398 id treeNode = [OCMockObject mockForClass:[NSTreeNode class]]; 409 id treeNode = [OCMockObject mockForClass:[NSTreeNode class]];
399 NSTreeNode* childTreeNode = 410 NSTreeNode* childTreeNode =
400 [NSTreeNode treeNodeWithRepresentedObject:[[foo children] lastObject]]; 411 [NSTreeNode treeNodeWithRepresentedObject:[[foo children] lastObject]];
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 469
459 // This will clean itself up when we call |-closeSheet:|. If we reset the 470 // This will clean itself up when we call |-closeSheet:|. If we reset the
460 // scoper, we'd get a double-free. 471 // scoper, we'd get a double-free.
461 database_helper_ = new MockBrowsingDataDatabaseHelper(profile); 472 database_helper_ = new MockBrowsingDataDatabaseHelper(profile);
462 local_storage_helper_ = new MockBrowsingDataLocalStorageHelper(profile); 473 local_storage_helper_ = new MockBrowsingDataLocalStorageHelper(profile);
463 local_storage_helper_->AddLocalStorageSamples(); 474 local_storage_helper_->AddLocalStorageSamples();
464 CookiesWindowController* controller = 475 CookiesWindowController* controller =
465 [[CookiesWindowController alloc] initWithProfile:profile 476 [[CookiesWindowController alloc] initWithProfile:profile
466 databaseHelper:database_helper_ 477 databaseHelper:database_helper_
467 storageHelper:local_storage_helper_ 478 storageHelper:local_storage_helper_
468 appcacheHelper:appcache_helper_]; 479 appcacheHelper:appcache_helper_
480 indexedDBHelper:indexed_db_helper_];
469 local_storage_helper_->Notify(); 481 local_storage_helper_->Notify();
470 [controller attachSheetTo:test_window()]; 482 [controller attachSheetTo:test_window()];
471 483
472 // Nothing should be selected right now. 484 // Nothing should be selected right now.
473 EXPECT_FALSE([controller removeButtonEnabled]); 485 EXPECT_FALSE([controller removeButtonEnabled]);
474 486
475 { 487 {
476 // Pretend to select cookie A. 488 // Pretend to select cookie A.
477 NSUInteger path[3] = {0, 0, 0}; 489 NSUInteger path[3] = {0, 0, 0};
478 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3]; 490 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3];
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 cm->SetCookie(GURL("http://a.com"), "A=B"); 539 cm->SetCookie(GURL("http://a.com"), "A=B");
528 cm->SetCookie(GURL("http://aa.com"), "C=D"); 540 cm->SetCookie(GURL("http://aa.com"), "C=D");
529 cm->SetCookie(GURL("http://b.com"), "E=F"); 541 cm->SetCookie(GURL("http://b.com"), "E=F");
530 cm->SetCookie(GURL("http://d.com"), "G=H"); 542 cm->SetCookie(GURL("http://d.com"), "G=H");
531 cm->SetCookie(GURL("http://dd.com"), "I=J"); 543 cm->SetCookie(GURL("http://dd.com"), "I=J");
532 544
533 controller_.reset( 545 controller_.reset(
534 [[CookiesWindowController alloc] initWithProfile:profile 546 [[CookiesWindowController alloc] initWithProfile:profile
535 databaseHelper:database_helper_ 547 databaseHelper:database_helper_
536 storageHelper:local_storage_helper_ 548 storageHelper:local_storage_helper_
537 appcacheHelper:appcache_helper_]); 549 appcacheHelper:appcache_helper_
550 indexedDBHelper:indexed_db_helper_]);
538 551
539 // Make sure we registered all five cookies. 552 // Make sure we registered all five cookies.
540 EXPECT_EQ(5U, [[[controller_ cocoaTreeModel] children] count]); 553 EXPECT_EQ(5U, [[[controller_ cocoaTreeModel] children] count]);
541 554
542 NSSearchField* field = 555 NSSearchField* field =
543 [[NSSearchField alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; 556 [[NSSearchField alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
544 557
545 // Make sure we still have five cookies. 558 // Make sure we still have five cookies.
546 [field setStringValue:@""]; 559 [field setStringValue:@""];
547 [controller_ updateFilter:field]; 560 [controller_ updateFilter:field];
(...skipping 27 matching lines...) Expand all
575 588
576 TEST_F(CookiesWindowControllerTest, CreateDatabaseStorageNodes) { 589 TEST_F(CookiesWindowControllerTest, CreateDatabaseStorageNodes) {
577 TestingProfile* profile = browser_helper_.profile(); 590 TestingProfile* profile = browser_helper_.profile();
578 database_helper_ = new MockBrowsingDataDatabaseHelper(profile); 591 database_helper_ = new MockBrowsingDataDatabaseHelper(profile);
579 local_storage_helper_ = new MockBrowsingDataLocalStorageHelper(profile); 592 local_storage_helper_ = new MockBrowsingDataLocalStorageHelper(profile);
580 database_helper_->AddDatabaseSamples(); 593 database_helper_->AddDatabaseSamples();
581 controller_.reset( 594 controller_.reset(
582 [[CookiesWindowController alloc] initWithProfile:profile 595 [[CookiesWindowController alloc] initWithProfile:profile
583 databaseHelper:database_helper_ 596 databaseHelper:database_helper_
584 storageHelper:local_storage_helper_ 597 storageHelper:local_storage_helper_
585 appcacheHelper:appcache_helper_]); 598 appcacheHelper:appcache_helper_
599 indexedDBHelper:indexed_db_helper_]);
586 database_helper_->Notify(); 600 database_helper_->Notify();
587 601
588 ASSERT_EQ(2U, [[[controller_ cocoaTreeModel] children] count]); 602 ASSERT_EQ(2U, [[[controller_ cocoaTreeModel] children] count]);
589 603
590 // Root --> gdbhost1. 604 // Root --> gdbhost1.
591 CocoaCookieTreeNode* node = 605 CocoaCookieTreeNode* node =
592 [[[controller_ cocoaTreeModel] children] objectAtIndex:0]; 606 [[[controller_ cocoaTreeModel] children] objectAtIndex:0];
593 EXPECT_NSEQ(@"gdbhost1", [node title]); 607 EXPECT_NSEQ(@"gdbhost1", [node title]);
594 EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]); 608 EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]);
595 EXPECT_EQ(1U, [[node children] count]); 609 EXPECT_EQ(1U, [[node children] count]);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 net::CookieMonster* cm = profile->GetCookieMonster(); 651 net::CookieMonster* cm = profile->GetCookieMonster();
638 cm->SetCookie(GURL("http://google.com"), "A=B"); 652 cm->SetCookie(GURL("http://google.com"), "A=B");
639 cm->SetCookie(GURL("http://dev.chromium.org"), "C=D"); 653 cm->SetCookie(GURL("http://dev.chromium.org"), "C=D");
640 database_helper_ = new MockBrowsingDataDatabaseHelper(profile); 654 database_helper_ = new MockBrowsingDataDatabaseHelper(profile);
641 local_storage_helper_ = new MockBrowsingDataLocalStorageHelper(profile); 655 local_storage_helper_ = new MockBrowsingDataLocalStorageHelper(profile);
642 local_storage_helper_->AddLocalStorageSamples(); 656 local_storage_helper_->AddLocalStorageSamples();
643 controller_.reset( 657 controller_.reset(
644 [[CookiesWindowController alloc] initWithProfile:profile 658 [[CookiesWindowController alloc] initWithProfile:profile
645 databaseHelper:database_helper_ 659 databaseHelper:database_helper_
646 storageHelper:local_storage_helper_ 660 storageHelper:local_storage_helper_
647 appcacheHelper:appcache_helper_]); 661 appcacheHelper:appcache_helper_
662 indexedDBHelper:indexed_db_helper_]);
648 local_storage_helper_->Notify(); 663 local_storage_helper_->Notify();
649 664
650 ASSERT_EQ(4U, [[[controller_ cocoaTreeModel] children] count]); 665 ASSERT_EQ(4U, [[[controller_ cocoaTreeModel] children] count]);
651 666
652 // Root --> host1. 667 // Root --> host1.
653 CocoaCookieTreeNode* node = 668 CocoaCookieTreeNode* node =
654 [[[controller_ cocoaTreeModel] children] objectAtIndex:2]; 669 [[[controller_ cocoaTreeModel] children] objectAtIndex:2];
655 EXPECT_NSEQ(@"host1", [node title]); 670 EXPECT_NSEQ(@"host1", [node title]);
656 EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]); 671 EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]);
657 EXPECT_EQ(1U, [[node children] count]); 672 EXPECT_EQ(1U, [[node children] count]);
(...skipping 28 matching lines...) Expand all
686 // Local Storage --> http://host2:2/. 701 // Local Storage --> http://host2:2/.
687 node = [[node children] lastObject]; 702 node = [[node children] lastObject];
688 EXPECT_NSEQ(@"http://host2:2/", [node title]); 703 EXPECT_NSEQ(@"http://host2:2/", [node title]);
689 EXPECT_EQ(kCocoaCookieDetailsTypeTreeLocalStorage, [node nodeType]); 704 EXPECT_EQ(kCocoaCookieDetailsTypeTreeLocalStorage, [node nodeType]);
690 EXPECT_NSEQ(@"http://host2:2/", [[node details] domain]); 705 EXPECT_NSEQ(@"http://host2:2/", [[node details] domain]);
691 EXPECT_TRUE([[node details] lastModified]); 706 EXPECT_TRUE([[node details] lastModified]);
692 EXPECT_TRUE([[node details] fileSize]); 707 EXPECT_TRUE([[node details] fileSize]);
693 } 708 }
694 709
695 } // namespace 710 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698