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

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

Issue 1540009: [Mac] Move star button into page-actions area of omnibox. (Closed)
Patch Set: Why did the trybot fail? I can't see anything. Created 10 years, 8 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/scoped_nsobject.h" 8 #include "base/scoped_nsobject.h"
9 #import "chrome/browser/cocoa/bookmark_bubble_controller.h" 9 #import "chrome/browser/cocoa/bookmark_bubble_controller.h"
10 #include "chrome/browser/cocoa/browser_test_helper.h" 10 #include "chrome/browser/cocoa/browser_test_helper.h"
(...skipping 24 matching lines...) Expand all
35 35
36 // Returns a controller but ownership not transferred. 36 // Returns a controller but ownership not transferred.
37 // Only one of these will be valid at a time. 37 // Only one of these will be valid at a time.
38 BookmarkBubbleController* ControllerForNode(const BookmarkNode* node) { 38 BookmarkBubbleController* ControllerForNode(const BookmarkNode* node) {
39 if (controller_ && !IsWindowClosing()) { 39 if (controller_ && !IsWindowClosing()) {
40 [controller_ close]; 40 [controller_ close];
41 controller_ = nil; 41 controller_ = nil;
42 } 42 }
43 controller_ = [[BookmarkBubbleController alloc] 43 controller_ = [[BookmarkBubbleController alloc]
44 initWithParentWindow:test_window() 44 initWithParentWindow:test_window()
45 topLeftForBubble:TopLeftForBubble() 45 topRightForBubble:TopRightForBubble()
46 model:helper_.profile()->GetBookmarkModel() 46 model:helper_.profile()->GetBookmarkModel()
47 node:node 47 node:node
48 alreadyBookmarked:YES]; 48 alreadyBookmarked:YES];
49 EXPECT_TRUE([controller_ window]); 49 EXPECT_TRUE([controller_ window]);
50 // The window must be gone or we'll fail a unit test with windows left open. 50 // The window must be gone or we'll fail a unit test with windows left open.
51 [static_cast<InfoBubbleWindow*>([controller_ window]) setDelayOnClose:NO]; 51 [static_cast<InfoBubbleWindow*>([controller_ window]) setDelayOnClose:NO];
52 [controller_ showWindow:nil]; 52 [controller_ showWindow:nil];
53 return controller_; 53 return controller_;
54 } 54 }
55 55
56 BookmarkModel* GetBookmarkModel() { 56 BookmarkModel* GetBookmarkModel() {
57 return helper_.profile()->GetBookmarkModel(); 57 return helper_.profile()->GetBookmarkModel();
58 } 58 }
59 59
60 bool IsWindowClosing() { 60 bool IsWindowClosing() {
61 return [static_cast<InfoBubbleWindow*>([controller_ window]) isClosing]; 61 return [static_cast<InfoBubbleWindow*>([controller_ window]) isClosing];
62 } 62 }
63 63
64 NSPoint TopLeftForBubble() { 64 NSPoint TopRightForBubble() {
65 return NSMakePoint(10, 300); 65 return NSMakePoint(NSWidth([test_window() frame]) - 10, 300);
66 } 66 }
67 }; 67 };
68 68
69 // Confirm basics about the bubble window (e.g. that it is inside the 69 // Confirm basics about the bubble window (e.g. that it is inside the
70 // parent window) 70 // parent window)
71 TEST_F(BookmarkBubbleControllerTest, TestBubbleWindow) { 71 TEST_F(BookmarkBubbleControllerTest, TestBubbleWindow) {
72 BookmarkModel* model = GetBookmarkModel(); 72 BookmarkModel* model = GetBookmarkModel();
73 const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(), 73 const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(),
74 0, 74 0,
75 L"Bookie markie title", 75 L"Bookie markie title",
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 TEST_F(BookmarkBubbleControllerTest, EscapeRemovesNewBookmark) { 327 TEST_F(BookmarkBubbleControllerTest, EscapeRemovesNewBookmark) {
328 BookmarkModel* model = GetBookmarkModel(); 328 BookmarkModel* model = GetBookmarkModel();
329 GURL gurl("http://www.google.com"); 329 GURL gurl("http://www.google.com");
330 const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(), 330 const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(),
331 0, 331 0,
332 L"Bookie markie title", 332 L"Bookie markie title",
333 gurl); 333 gurl);
334 BookmarkBubbleController* controller = 334 BookmarkBubbleController* controller =
335 [[BookmarkBubbleController alloc] 335 [[BookmarkBubbleController alloc]
336 initWithParentWindow:test_window() 336 initWithParentWindow:test_window()
337 topLeftForBubble:TopLeftForBubble() 337 topRightForBubble:TopRightForBubble()
338 model:helper_.profile()->GetBookmarkModel() 338 model:helper_.profile()->GetBookmarkModel()
339 node:node 339 node:node
340 alreadyBookmarked:NO]; // The last param is the key difference. 340 alreadyBookmarked:NO]; // The last param is the key difference.
341 EXPECT_TRUE([controller window]); 341 EXPECT_TRUE([controller window]);
342 // Calls release on controller. 342 // Calls release on controller.
343 [controller cancel:nil]; 343 [controller cancel:nil];
344 EXPECT_FALSE(model->IsBookmarked(gurl)); 344 EXPECT_FALSE(model->IsBookmarked(gurl));
345 } 345 }
346 346
347 // Create a controller where the bookmark already existed prior to clicking 347 // Create a controller where the bookmark already existed prior to clicking
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 // Normally this would be sent up the responder tree correctly, but since 398 // Normally this would be sent up the responder tree correctly, but since
399 // tests run in the background, key window and main window are never set on 399 // tests run in the background, key window and main window are never set on
400 // NSApplication. Adding it to NSApplication directly removes the need for 400 // NSApplication. Adding it to NSApplication directly removes the need for
401 // worrying about what the current window with focus is. 401 // worrying about what the current window with focus is.
402 - (void)editBookmarkNode:(id)sender { 402 - (void)editBookmarkNode:(id)sender {
403 EXPECT_TRUE([sender respondsToSelector:@selector(node)]); 403 EXPECT_TRUE([sender respondsToSelector:@selector(node)]);
404 BookmarkBubbleControllerTest::edits_++; 404 BookmarkBubbleControllerTest::edits_++;
405 } 405 }
406 406
407 @end 407 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_bubble_controller.mm ('k') | chrome/browser/cocoa/browser_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698