OLD | NEW |
1 // Copyright (c) 2009-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009-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/tree_model.h" | 7 #include "app/tree_model.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 "chrome/browser/cocoa/browser_test_helper.h" | 10 #include "chrome/browser/cocoa/browser_test_helper.h" |
11 #include "chrome/browser/browsing_data_remover.h" | 11 #include "chrome/browser/browsing_data_remover.h" |
12 #include "chrome/browser/cocoa/clear_browsing_data_controller.h" | 12 #include "chrome/browser/cocoa/clear_browsing_data_controller.h" |
13 #import "chrome/browser/cocoa/cookies_window_controller.h" | 13 #import "chrome/browser/cocoa/cookies_window_controller.h" |
14 #include "chrome/browser/cocoa/cocoa_test_helper.h" | 14 #include "chrome/browser/cocoa/cocoa_test_helper.h" |
| 15 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" |
15 #include "chrome/browser/net/url_request_context_getter.h" | 16 #include "chrome/browser/net/url_request_context_getter.h" |
16 #include "chrome/browser/cookies_tree_model.h" | 17 #include "chrome/browser/cookies_tree_model.h" |
17 #include "chrome/test/testing_profile.h" | 18 #include "chrome/test/testing_profile.h" |
18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
19 #include "net/url_request/url_request_context.h" | 20 #include "net/url_request/url_request_context.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "testing/platform_test.h" | 22 #include "testing/platform_test.h" |
22 #import "third_party/ocmock/OCMock/OCMock.h" | 23 #import "third_party/ocmock/OCMock/OCMock.h" |
23 | 24 |
24 // Used to test FindCocoaNode. This only sets the title and node, without | 25 // Used to test FindCocoaNode. This only sets the title and node, without |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 @end | 59 @end |
59 | 60 |
60 namespace { | 61 namespace { |
61 | 62 |
62 class CookiesWindowControllerTest : public CocoaTest { | 63 class CookiesWindowControllerTest : public CocoaTest { |
63 public: | 64 public: |
64 virtual void SetUp() { | 65 virtual void SetUp() { |
65 CocoaTest::SetUp(); | 66 CocoaTest::SetUp(); |
66 TestingProfile* profile = browser_helper_.profile(); | 67 TestingProfile* profile = browser_helper_.profile(); |
67 profile->CreateRequestContext(); | 68 profile->CreateRequestContext(); |
| 69 local_storage_helper_ = new MockBrowsingDataLocalStorageHelper(profile); |
68 controller_.reset( | 70 controller_.reset( |
69 [[CookiesWindowController alloc] initWithProfile:profile]); | 71 [[CookiesWindowController alloc] initWithProfile:profile |
| 72 storageHelper:local_storage_helper_] |
| 73 ); |
70 } | 74 } |
71 | 75 |
72 virtual void TearDown() { | 76 virtual void TearDown() { |
73 CocoaTest::TearDown(); | 77 CocoaTest::TearDown(); |
74 } | 78 } |
75 | 79 |
76 CocoaCookieTreeNode* CocoaNodeFromTreeNode(TreeModelNode* node, | 80 CocoaCookieTreeNode* CocoaNodeFromTreeNode(TreeModelNode* node, |
77 bool recurse) { | 81 bool recurse) { |
78 return [controller_ modelObserver]->CocoaNodeFromTreeNode(node, recurse); | 82 return [controller_ modelObserver]->CocoaNodeFromTreeNode(node, recurse); |
79 } | 83 } |
80 | 84 |
81 CocoaCookieTreeNode* FindCocoaNode(TreeModelNode* node, | 85 CocoaCookieTreeNode* FindCocoaNode(TreeModelNode* node, |
82 CocoaCookieTreeNode* start) { | 86 CocoaCookieTreeNode* start) { |
83 return [controller_ modelObserver]->FindCocoaNode(node, start); | 87 return [controller_ modelObserver]->FindCocoaNode(node, start); |
84 } | 88 } |
85 | 89 |
86 protected: | 90 protected: |
87 BrowserTestHelper browser_helper_; | 91 BrowserTestHelper browser_helper_; |
88 scoped_nsobject<CookiesWindowController> controller_; | 92 scoped_nsobject<CookiesWindowController> controller_; |
| 93 BrowsingDataLocalStorageHelper* local_storage_helper_; |
89 }; | 94 }; |
90 | 95 |
91 TEST_F(CookiesWindowControllerTest, Construction) { | 96 TEST_F(CookiesWindowControllerTest, Construction) { |
92 std::vector<SkBitmap> skia_icons; | 97 std::vector<SkBitmap> skia_icons; |
93 [controller_ treeModel]->GetIcons(&skia_icons); | 98 [controller_ treeModel]->GetIcons(&skia_icons); |
94 | 99 |
95 EXPECT_EQ([[controller_ icons] count], skia_icons.size() + 1U); | 100 EXPECT_EQ([[controller_ icons] count], skia_icons.size() + 1U); |
96 } | 101 } |
97 | 102 |
98 TEST_F(CookiesWindowControllerTest, FindCocoaNodeRoot) { | 103 TEST_F(CookiesWindowControllerTest, FindCocoaNodeRoot) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:child2.get()]); | 135 [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:child2.get()]); |
131 [[cocoaParent childs] addObject:cocoaChild1.get()]; | 136 [[cocoaParent childs] addObject:cocoaChild1.get()]; |
132 [[cocoaChild1 childs] addObject:cocoaChild2.get()]; | 137 [[cocoaChild1 childs] addObject:cocoaChild2.get()]; |
133 | 138 |
134 EXPECT_EQ(cocoaChild2.get(), FindCocoaNode(child2.get(), cocoaParent.get())); | 139 EXPECT_EQ(cocoaChild2.get(), FindCocoaNode(child2.get(), cocoaParent.get())); |
135 } | 140 } |
136 | 141 |
137 TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeCookie) { | 142 TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeCookie) { |
138 net::CookieMonster* cm = browser_helper_.profile()->GetCookieMonster(); | 143 net::CookieMonster* cm = browser_helper_.profile()->GetCookieMonster(); |
139 cm->SetCookie(GURL("http://foo.com"), "A=B"); | 144 cm->SetCookie(GURL("http://foo.com"), "A=B"); |
140 CookiesTreeModel model(browser_helper_.profile()); | 145 CookiesTreeModel model(browser_helper_.profile(), local_storage_helper_); |
141 | 146 |
142 // Root --> foo.com --> Cookies --> A. Create node for 'A'. | 147 // Root --> foo.com --> Cookies --> A. Create node for 'A'. |
143 TreeModelNode* node = model.GetRoot()->GetChild(0)->GetChild(0)->GetChild(0); | 148 TreeModelNode* node = model.GetRoot()->GetChild(0)->GetChild(0)->GetChild(0); |
144 CocoaCookieTreeNode* cookie = CocoaNodeFromTreeNode(node, false); | 149 CocoaCookieTreeNode* cookie = CocoaNodeFromTreeNode(node, false); |
145 | 150 |
146 EXPECT_TRUE([@"B" isEqualToString:[cookie content]]); | 151 EXPECT_TRUE([@"B" isEqualToString:[cookie content]]); |
147 EXPECT_TRUE([@"End of the session" isEqualToString:[cookie expires]]); | 152 EXPECT_TRUE([@"End of the session" isEqualToString:[cookie expires]]); |
148 EXPECT_TRUE([@"Any kind of connection" isEqualToString:[cookie sendFor]]); | 153 EXPECT_TRUE([@"Any kind of connection" isEqualToString:[cookie sendFor]]); |
149 EXPECT_TRUE([@"A" isEqualToString:[cookie title]]); | 154 EXPECT_TRUE([@"A" isEqualToString:[cookie title]]); |
150 EXPECT_TRUE([@"A" isEqualToString:[cookie name]]); | 155 EXPECT_TRUE([@"A" isEqualToString:[cookie name]]); |
151 EXPECT_TRUE([@"/" isEqualToString:[cookie path]]); | 156 EXPECT_TRUE([@"/" isEqualToString:[cookie path]]); |
152 EXPECT_EQ(0U, [[cookie childs] count]); | 157 EXPECT_EQ(0U, [[cookie childs] count]); |
153 EXPECT_TRUE([cookie created]); | 158 EXPECT_TRUE([cookie created]); |
154 EXPECT_TRUE([cookie isLeaf]); | 159 EXPECT_TRUE([cookie isLeaf]); |
155 EXPECT_EQ(node, [cookie treeNode]); | 160 EXPECT_EQ(node, [cookie treeNode]); |
156 } | 161 } |
157 | 162 |
158 TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeRecursive) { | 163 TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeRecursive) { |
159 net::CookieMonster* cm = browser_helper_.profile()->GetCookieMonster(); | 164 net::CookieMonster* cm = browser_helper_.profile()->GetCookieMonster(); |
160 cm->SetCookie(GURL("http://foo.com"), "A=B"); | 165 cm->SetCookie(GURL("http://foo.com"), "A=B"); |
161 CookiesTreeModel model(browser_helper_.profile()); | 166 CookiesTreeModel model(browser_helper_.profile(), local_storage_helper_); |
162 | 167 |
163 // Root --> foo.com --> Cookies --> A. Create node for 'foo.com'. | 168 // Root --> foo.com --> Cookies --> A. Create node for 'foo.com'. |
164 CookieTreeNode* node = model.GetRoot()->GetChild(0); | 169 CookieTreeNode* node = model.GetRoot()->GetChild(0); |
165 CocoaCookieTreeNode* domain = CocoaNodeFromTreeNode(node, true); | 170 CocoaCookieTreeNode* domain = CocoaNodeFromTreeNode(node, true); |
166 CocoaCookieTreeNode* cookies = [[domain childs] objectAtIndex:0]; | 171 CocoaCookieTreeNode* cookies = [[domain childs] objectAtIndex:0]; |
167 CocoaCookieTreeNode* cookie = [[cookies childs] objectAtIndex:0]; | 172 CocoaCookieTreeNode* cookie = [[cookies childs] objectAtIndex:0]; |
168 | 173 |
169 // Test domain-level node. | 174 // Test domain-level node. |
170 EXPECT_TRUE([@"foo.com" isEqualToString:[domain title]]); | 175 EXPECT_TRUE([@"foo.com" isEqualToString:[domain title]]); |
171 | 176 |
(...skipping 21 matching lines...) Expand all Loading... |
193 EXPECT_EQ(node->GetChild(0)->GetChild(0), [cookie treeNode]); | 198 EXPECT_EQ(node->GetChild(0)->GetChild(0), [cookie treeNode]); |
194 } | 199 } |
195 | 200 |
196 TEST_F(CookiesWindowControllerTest, TreeNodesAdded) { | 201 TEST_F(CookiesWindowControllerTest, TreeNodesAdded) { |
197 const GURL url = GURL("http://foo.com"); | 202 const GURL url = GURL("http://foo.com"); |
198 TestingProfile* profile = browser_helper_.profile(); | 203 TestingProfile* profile = browser_helper_.profile(); |
199 net::CookieMonster* cm = profile->GetCookieMonster(); | 204 net::CookieMonster* cm = profile->GetCookieMonster(); |
200 cm->SetCookie(url, "A=B"); | 205 cm->SetCookie(url, "A=B"); |
201 | 206 |
202 controller_.reset( | 207 controller_.reset( |
203 [[CookiesWindowController alloc] initWithProfile:profile]); | 208 [[CookiesWindowController alloc] initWithProfile:profile |
| 209 storageHelper:local_storage_helper_]); |
204 | 210 |
205 // Root --> foo.com --> Cookies. | 211 // Root --> foo.com --> Cookies. |
206 NSMutableArray* cocoa_children = | 212 NSMutableArray* cocoa_children = |
207 [[[[[[controller_ cocoaTreeModel] childs] objectAtIndex:0] | 213 [[[[[[controller_ cocoaTreeModel] childs] objectAtIndex:0] |
208 childs] objectAtIndex:0] childs]; | 214 childs] objectAtIndex:0] childs]; |
209 EXPECT_EQ(1U, [cocoa_children count]); | 215 EXPECT_EQ(1U, [cocoa_children count]); |
210 | 216 |
211 // Create some cookies. | 217 // Create some cookies. |
212 cm->SetCookie(url, "C=D"); | 218 cm->SetCookie(url, "C=D"); |
213 cm->SetCookie(url, "E=F"); | 219 cm->SetCookie(url, "E=F"); |
(...skipping 20 matching lines...) Expand all Loading... |
234 | 240 |
235 TEST_F(CookiesWindowControllerTest, TreeNodesRemoved) { | 241 TEST_F(CookiesWindowControllerTest, TreeNodesRemoved) { |
236 const GURL url = GURL("http://foo.com"); | 242 const GURL url = GURL("http://foo.com"); |
237 TestingProfile* profile = browser_helper_.profile(); | 243 TestingProfile* profile = browser_helper_.profile(); |
238 net::CookieMonster* cm = profile->GetCookieMonster(); | 244 net::CookieMonster* cm = profile->GetCookieMonster(); |
239 cm->SetCookie(url, "A=B"); | 245 cm->SetCookie(url, "A=B"); |
240 cm->SetCookie(url, "C=D"); | 246 cm->SetCookie(url, "C=D"); |
241 cm->SetCookie(url, "E=F"); | 247 cm->SetCookie(url, "E=F"); |
242 | 248 |
243 controller_.reset( | 249 controller_.reset( |
244 [[CookiesWindowController alloc] initWithProfile:profile]); | 250 [[CookiesWindowController alloc] initWithProfile:profile |
| 251 storageHelper:local_storage_helper_]); |
245 | 252 |
246 // Root --> foo.com --> Cookies. | 253 // Root --> foo.com --> Cookies. |
247 NSMutableArray* cocoa_children = | 254 NSMutableArray* cocoa_children = |
248 [[[[[[controller_ cocoaTreeModel] childs] objectAtIndex:0] | 255 [[[[[[controller_ cocoaTreeModel] childs] objectAtIndex:0] |
249 childs] objectAtIndex:0] childs]; | 256 childs] objectAtIndex:0] childs]; |
250 EXPECT_EQ(3U, [cocoa_children count]); | 257 EXPECT_EQ(3U, [cocoa_children count]); |
251 | 258 |
252 CookiesTreeModel* model = [controller_ treeModel]; | 259 CookiesTreeModel* model = [controller_ treeModel]; |
253 // Root --> foo.com --> Cookies. | 260 // Root --> foo.com --> Cookies. |
254 CookieTreeNode* parent = model->GetRoot()->GetChild(0)->GetChild(0); | 261 CookieTreeNode* parent = model->GetRoot()->GetChild(0)->GetChild(0); |
255 | 262 |
256 // Pretend to remove the nodes. | 263 // Pretend to remove the nodes. |
257 [controller_ modelObserver]->TreeNodesRemoved(model, parent, 1, 2); | 264 [controller_ modelObserver]->TreeNodesRemoved(model, parent, 1, 2); |
258 | 265 |
259 EXPECT_EQ(1U, [cocoa_children count]); | 266 EXPECT_EQ(1U, [cocoa_children count]); |
260 | 267 |
261 NSString* title = [[cocoa_children objectAtIndex:0] name]; | 268 NSString* title = [[cocoa_children objectAtIndex:0] name]; |
262 EXPECT_TRUE([@"A" isEqualToString:title]); | 269 EXPECT_TRUE([@"A" isEqualToString:title]); |
263 } | 270 } |
264 | 271 |
265 TEST_F(CookiesWindowControllerTest, TreeNodeChildrenReordered) { | 272 TEST_F(CookiesWindowControllerTest, TreeNodeChildrenReordered) { |
266 const GURL url = GURL("http://foo.com"); | 273 const GURL url = GURL("http://foo.com"); |
267 TestingProfile* profile = browser_helper_.profile(); | 274 TestingProfile* profile = browser_helper_.profile(); |
268 net::CookieMonster* cm = profile->GetCookieMonster(); | 275 net::CookieMonster* cm = profile->GetCookieMonster(); |
269 cm->SetCookie(url, "A=B"); | 276 cm->SetCookie(url, "A=B"); |
270 cm->SetCookie(url, "C=D"); | 277 cm->SetCookie(url, "C=D"); |
271 cm->SetCookie(url, "E=F"); | 278 cm->SetCookie(url, "E=F"); |
272 | 279 |
273 controller_.reset( | 280 controller_.reset( |
274 [[CookiesWindowController alloc] initWithProfile:profile]); | 281 [[CookiesWindowController alloc] initWithProfile:profile |
| 282 storageHelper:local_storage_helper_]); |
275 | 283 |
276 // Root --> foo.com --> Cookies. | 284 // Root --> foo.com --> Cookies. |
277 NSMutableArray* cocoa_children = | 285 NSMutableArray* cocoa_children = |
278 [[[[[[controller_ cocoaTreeModel] childs] objectAtIndex:0] | 286 [[[[[[controller_ cocoaTreeModel] childs] objectAtIndex:0] |
279 childs] objectAtIndex:0] childs]; | 287 childs] objectAtIndex:0] childs]; |
280 EXPECT_EQ(3U, [cocoa_children count]); | 288 EXPECT_EQ(3U, [cocoa_children count]); |
281 | 289 |
282 // Check default ordering. | 290 // Check default ordering. |
283 CocoaCookieTreeNode* node = [cocoa_children objectAtIndex:0]; | 291 CocoaCookieTreeNode* node = [cocoa_children objectAtIndex:0]; |
284 EXPECT_TRUE([@"A" isEqualToString:[node name]]); | 292 EXPECT_TRUE([@"A" isEqualToString:[node name]]); |
(...skipping 24 matching lines...) Expand all Loading... |
309 EXPECT_TRUE([@"C" isEqualToString:[node name]]); | 317 EXPECT_TRUE([@"C" isEqualToString:[node name]]); |
310 } | 318 } |
311 | 319 |
312 TEST_F(CookiesWindowControllerTest, TreeNodeChanged) { | 320 TEST_F(CookiesWindowControllerTest, TreeNodeChanged) { |
313 const GURL url = GURL("http://foo.com"); | 321 const GURL url = GURL("http://foo.com"); |
314 TestingProfile* profile = browser_helper_.profile(); | 322 TestingProfile* profile = browser_helper_.profile(); |
315 net::CookieMonster* cm = profile->GetCookieMonster(); | 323 net::CookieMonster* cm = profile->GetCookieMonster(); |
316 cm->SetCookie(url, "A=B"); | 324 cm->SetCookie(url, "A=B"); |
317 | 325 |
318 controller_.reset( | 326 controller_.reset( |
319 [[CookiesWindowController alloc] initWithProfile:profile]); | 327 [[CookiesWindowController alloc] initWithProfile:profile |
| 328 storageHelper:local_storage_helper_]); |
320 | 329 |
321 CookiesTreeModel* model = [controller_ treeModel]; | 330 CookiesTreeModel* model = [controller_ treeModel]; |
322 // Root --> foo.com --> Cookies. | 331 // Root --> foo.com --> Cookies. |
323 CookieTreeNode* node = model->GetRoot()->GetChild(0)->GetChild(0); | 332 CookieTreeNode* node = model->GetRoot()->GetChild(0)->GetChild(0); |
324 | 333 |
325 // Root --> foo.com --> Cookies. | 334 // Root --> foo.com --> Cookies. |
326 CocoaCookieTreeNode* cocoa_node = | 335 CocoaCookieTreeNode* cocoa_node = |
327 [[[[[controller_ cocoaTreeModel] childs] objectAtIndex:0] | 336 [[[[[controller_ cocoaTreeModel] childs] objectAtIndex:0] |
328 childs] objectAtIndex:0]; | 337 childs] objectAtIndex:0]; |
329 | 338 |
(...skipping 11 matching lines...) Expand all Loading... |
341 TEST_F(CookiesWindowControllerTest, TestDeleteCookie) { | 350 TEST_F(CookiesWindowControllerTest, TestDeleteCookie) { |
342 const GURL url = GURL("http://foo.com"); | 351 const GURL url = GURL("http://foo.com"); |
343 TestingProfile* profile = browser_helper_.profile(); | 352 TestingProfile* profile = browser_helper_.profile(); |
344 net::CookieMonster* cm = profile->GetCookieMonster(); | 353 net::CookieMonster* cm = profile->GetCookieMonster(); |
345 cm->SetCookie(url, "A=B"); | 354 cm->SetCookie(url, "A=B"); |
346 cm->SetCookie(url, "C=D"); | 355 cm->SetCookie(url, "C=D"); |
347 | 356 |
348 // This will clean itself up when we call |-closeSheet:|. If we reset the | 357 // This will clean itself up when we call |-closeSheet:|. If we reset the |
349 // scoper, we'd get a double-free. | 358 // scoper, we'd get a double-free. |
350 CookiesWindowController* controller = | 359 CookiesWindowController* controller = |
351 [[CookiesWindowController alloc] initWithProfile:profile]; | 360 [[CookiesWindowController alloc] initWithProfile:profile |
| 361 storageHelper:local_storage_helper_]; |
352 [controller attachSheetTo:test_window()]; | 362 [controller attachSheetTo:test_window()]; |
353 NSTreeController* treeController = [controller treeController]; | 363 NSTreeController* treeController = [controller treeController]; |
354 | 364 |
355 // Pretend to select cookie A. | 365 // Pretend to select cookie A. |
356 NSUInteger path[3] = {0, 0, 0}; | 366 NSUInteger path[3] = {0, 0, 0}; |
357 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3]; | 367 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3]; |
358 [treeController setSelectionIndexPath:indexPath]; | 368 [treeController setSelectionIndexPath:indexPath]; |
359 | 369 |
360 // Press the "Delete" button. | 370 // Press the "Delete" button. |
361 [controller deleteCookie:nil]; | 371 [controller deleteCookie:nil]; |
362 | 372 |
363 // Root --> foo.com --> Cookies. | 373 // Root --> foo.com --> Cookies. |
364 NSArray* cookies = [[[[[[controller cocoaTreeModel] childs] objectAtIndex:0] | 374 NSArray* cookies = [[[[[[controller cocoaTreeModel] childs] objectAtIndex:0] |
365 childs] objectAtIndex:0] childs]; | 375 childs] objectAtIndex:0] childs]; |
366 EXPECT_EQ(1U, [cookies count]); | 376 EXPECT_EQ(1U, [cookies count]); |
367 EXPECT_TRUE([@"C" isEqualToString:[[cookies lastObject] title]]); | 377 EXPECT_TRUE([@"C" isEqualToString:[[cookies lastObject] title]]); |
368 EXPECT_TRUE([indexPath isEqual:[treeController selectionIndexPath]]); | 378 EXPECT_TRUE([indexPath isEqual:[treeController selectionIndexPath]]); |
369 | 379 |
370 [controller closeSheet:nil]; | 380 [controller closeSheet:nil]; |
371 } | 381 } |
372 | 382 |
373 TEST_F(CookiesWindowControllerTest, TestDidExpandItem) { | 383 TEST_F(CookiesWindowControllerTest, TestDidExpandItem) { |
374 const GURL url = GURL("http://foo.com"); | 384 const GURL url = GURL("http://foo.com"); |
375 TestingProfile* profile = browser_helper_.profile(); | 385 TestingProfile* profile = browser_helper_.profile(); |
376 net::CookieMonster* cm = profile->GetCookieMonster(); | 386 net::CookieMonster* cm = profile->GetCookieMonster(); |
377 cm->SetCookie(url, "A=B"); | 387 cm->SetCookie(url, "A=B"); |
378 cm->SetCookie(url, "C=D"); | 388 cm->SetCookie(url, "C=D"); |
379 | 389 |
380 controller_.reset( | 390 controller_.reset( |
381 [[CookiesWindowController alloc] initWithProfile:profile]); | 391 [[CookiesWindowController alloc] initWithProfile:profile |
| 392 storageHelper:local_storage_helper_]); |
382 | 393 |
383 // Root --> foo.com. | 394 // Root --> foo.com. |
384 CocoaCookieTreeNode* foo = | 395 CocoaCookieTreeNode* foo = |
385 [[[controller_ cocoaTreeModel] childs] objectAtIndex:0]; | 396 [[[controller_ cocoaTreeModel] childs] objectAtIndex:0]; |
386 | 397 |
387 // Create the objects we are going to be testing with. | 398 // Create the objects we are going to be testing with. |
388 id outlineView = [OCMockObject mockForClass:[NSOutlineView class]]; | 399 id outlineView = [OCMockObject mockForClass:[NSOutlineView class]]; |
389 id treeNode = [OCMockObject mockForClass:[NSTreeNode class]]; | 400 id treeNode = [OCMockObject mockForClass:[NSTreeNode class]]; |
390 NSTreeNode* childTreeNode = | 401 NSTreeNode* childTreeNode = |
391 [NSTreeNode treeNodeWithRepresentedObject:[[foo childs] lastObject]]; | 402 [NSTreeNode treeNodeWithRepresentedObject:[[foo childs] lastObject]]; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 TEST_F(CookiesWindowControllerTest, RemoveButtonEnabled) { | 448 TEST_F(CookiesWindowControllerTest, RemoveButtonEnabled) { |
438 const GURL url = GURL("http://foo.com"); | 449 const GURL url = GURL("http://foo.com"); |
439 TestingProfile* profile = browser_helper_.profile(); | 450 TestingProfile* profile = browser_helper_.profile(); |
440 net::CookieMonster* cm = profile->GetCookieMonster(); | 451 net::CookieMonster* cm = profile->GetCookieMonster(); |
441 cm->SetCookie(url, "A=B"); | 452 cm->SetCookie(url, "A=B"); |
442 cm->SetCookie(url, "C=D"); | 453 cm->SetCookie(url, "C=D"); |
443 | 454 |
444 // This will clean itself up when we call |-closeSheet:|. If we reset the | 455 // This will clean itself up when we call |-closeSheet:|. If we reset the |
445 // scoper, we'd get a double-free. | 456 // scoper, we'd get a double-free. |
446 CookiesWindowController* controller = | 457 CookiesWindowController* controller = |
447 [[CookiesWindowController alloc] initWithProfile:profile]; | 458 [[CookiesWindowController alloc] initWithProfile:profile |
| 459 storageHelper:local_storage_helper_]; |
448 [controller attachSheetTo:test_window()]; | 460 [controller attachSheetTo:test_window()]; |
449 | 461 |
450 // Nothing should be selected right now. | 462 // Nothing should be selected right now. |
451 EXPECT_FALSE([controller removeButtonEnabled]); | 463 EXPECT_FALSE([controller removeButtonEnabled]); |
452 | 464 |
453 { | 465 { |
454 // Pretend to select cookie A. | 466 // Pretend to select cookie A. |
455 NSUInteger path[3] = {0, 0, 0}; | 467 NSUInteger path[3] = {0, 0, 0}; |
456 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3]; | 468 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3]; |
457 [[controller treeController] setSelectionIndexPath:indexPath]; | 469 [[controller treeController] setSelectionIndexPath:indexPath]; |
(...skipping 25 matching lines...) Expand all Loading... |
483 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3]; | 495 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3]; |
484 [[controller treeController] setSelectionIndexPath:indexPath]; | 496 [[controller treeController] setSelectionIndexPath:indexPath]; |
485 [controller outlineViewSelectionDidChange:nil]; | 497 [controller outlineViewSelectionDidChange:nil]; |
486 EXPECT_FALSE([controller removeButtonEnabled]); | 498 EXPECT_FALSE([controller removeButtonEnabled]); |
487 } | 499 } |
488 | 500 |
489 [controller closeSheet:nil]; | 501 [controller closeSheet:nil]; |
490 } | 502 } |
491 | 503 |
492 } // namespace | 504 } // namespace |
OLD | NEW |