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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller_unittest.mm

Issue 10827060: Removing instances of profile_->GetBookmarkModel() as part of converting BookmarkModel to a PKS. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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) 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_nsobject.h" 8 #include "base/memory/scoped_nsobject.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h" 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h"
12 #include "chrome/browser/ui/cocoa/browser_window_controller.h" 13 #include "chrome/browser/ui/cocoa/browser_window_controller.h"
13 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 14 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
14 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 15 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
15 #include "content/public/browser/notification_service.h" 16 #include "content/public/browser/notification_service.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 #import "testing/gtest_mac.h" 18 #import "testing/gtest_mac.h"
18 #include "testing/platform_test.h" 19 #include "testing/platform_test.h"
19 20
20 using content::WebContents; 21 using content::WebContents;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 73
73 // Returns a controller but ownership not transferred. 74 // Returns a controller but ownership not transferred.
74 // Only one of these will be valid at a time. 75 // Only one of these will be valid at a time.
75 BookmarkBubbleController* ControllerForNode(const BookmarkNode* node) { 76 BookmarkBubbleController* ControllerForNode(const BookmarkNode* node) {
76 if (controller_ && !IsWindowClosing()) { 77 if (controller_ && !IsWindowClosing()) {
77 [controller_ close]; 78 [controller_ close];
78 controller_ = nil; 79 controller_ = nil;
79 } 80 }
80 controller_ = [[BookmarkBubbleController alloc] 81 controller_ = [[BookmarkBubbleController alloc]
81 initWithParentWindow:test_window() 82 initWithParentWindow:test_window()
82 model:profile()->GetBookmarkModel() 83 model:BookmarkModelFactory::GetForProfile(
84 profile())
83 node:node 85 node:node
84 alreadyBookmarked:YES]; 86 alreadyBookmarked:YES];
85 EXPECT_TRUE([controller_ window]); 87 EXPECT_TRUE([controller_ window]);
86 // The window must be gone or we'll fail a unit test with windows left open. 88 // The window must be gone or we'll fail a unit test with windows left open.
87 [static_cast<InfoBubbleWindow*>([controller_ window]) setDelayOnClose:NO]; 89 [static_cast<InfoBubbleWindow*>([controller_ window]) setDelayOnClose:NO];
88 [controller_ showWindow:nil]; 90 [controller_ showWindow:nil];
89 return controller_; 91 return controller_;
90 } 92 }
91 93
92 BookmarkModel* GetBookmarkModel() { 94 BookmarkModel* GetBookmarkModel() {
93 return profile()->GetBookmarkModel(); 95 return BookmarkModelFactory::GetForProfile(profile());
94 } 96 }
95 97
96 bool IsWindowClosing() { 98 bool IsWindowClosing() {
97 return [static_cast<InfoBubbleWindow*>([controller_ window]) isClosing]; 99 return [static_cast<InfoBubbleWindow*>([controller_ window]) isClosing];
98 } 100 }
99 }; 101 };
100 102
101 // static 103 // static
102 int BookmarkBubbleControllerTest::edits_; 104 int BookmarkBubbleControllerTest::edits_;
103 105
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 TEST_F(BookmarkBubbleControllerTest, EscapeRemovesNewBookmark) { 390 TEST_F(BookmarkBubbleControllerTest, EscapeRemovesNewBookmark) {
389 BookmarkModel* model = GetBookmarkModel(); 391 BookmarkModel* model = GetBookmarkModel();
390 GURL gurl("http://www.google.com"); 392 GURL gurl("http://www.google.com");
391 const BookmarkNode* node = model->AddURL(model->bookmark_bar_node(), 393 const BookmarkNode* node = model->AddURL(model->bookmark_bar_node(),
392 0, 394 0,
393 ASCIIToUTF16("Bookie markie title"), 395 ASCIIToUTF16("Bookie markie title"),
394 gurl); 396 gurl);
395 BookmarkBubbleController* controller = 397 BookmarkBubbleController* controller =
396 [[BookmarkBubbleController alloc] 398 [[BookmarkBubbleController alloc]
397 initWithParentWindow:test_window() 399 initWithParentWindow:test_window()
398 model:profile()->GetBookmarkModel() 400 model:BookmarkModelFactory::GetForProfile(profile())
399 node:node 401 node:node
400 alreadyBookmarked:NO]; // The last param is the key difference. 402 alreadyBookmarked:NO]; // The last param is the key difference.
401 EXPECT_TRUE([controller window]); 403 EXPECT_TRUE([controller window]);
402 // Calls release on controller. 404 // Calls release on controller.
403 [controller cancel:nil]; 405 [controller cancel:nil];
404 EXPECT_FALSE(model->IsBookmarked(gurl)); 406 EXPECT_FALSE(model->IsBookmarked(gurl));
405 } 407 }
406 408
407 // Create a controller where the bookmark already existed prior to clicking 409 // Create a controller where the bookmark already existed prior to clicking
408 // the star and test that sending a cancel command doesn't change the state 410 // the star and test that sending a cancel command doesn't change the state
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 // Normally this would be sent up the responder tree correctly, but since 464 // Normally this would be sent up the responder tree correctly, but since
463 // tests run in the background, key window and main window are never set on 465 // tests run in the background, key window and main window are never set on
464 // NSApplication. Adding it to NSApplication directly removes the need for 466 // NSApplication. Adding it to NSApplication directly removes the need for
465 // worrying about what the current window with focus is. 467 // worrying about what the current window with focus is.
466 - (void)editBookmarkNode:(id)sender { 468 - (void)editBookmarkNode:(id)sender {
467 EXPECT_TRUE([sender respondsToSelector:@selector(node)]); 469 EXPECT_TRUE([sender respondsToSelector:@selector(node)]);
468 BookmarkBubbleControllerTest::edits_++; 470 BookmarkBubbleControllerTest::edits_++;
469 } 471 }
470 472
471 @end 473 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698