Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "chrome/browser/cocoa/browser_window_controller.h" | 11 #include "chrome/browser/cocoa/browser_window_controller.h" |
| 12 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 12 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 13 #import "chrome/browser/cocoa/info_bubble_window.h" | 13 #import "chrome/browser/cocoa/info_bubble_window.h" |
| 14 #include "chrome/common/notification_service.h" | 14 #include "chrome/common/notification_service.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #import "testing/gtest_mac.h" | |
| 16 #include "testing/platform_test.h" | 17 #include "testing/platform_test.h" |
| 17 | 18 |
| 18 // Watch for bookmark pulse notifications so we can confirm they were sent. | 19 // Watch for bookmark pulse notifications so we can confirm they were sent. |
| 19 @interface BookmarkPulseObserver : NSObject { | 20 @interface BookmarkPulseObserver : NSObject { |
| 20 int notifications_; | 21 int notifications_; |
| 21 } | 22 } |
| 22 @property (assign, nonatomic) int notifications; | 23 @property (assign, nonatomic) int notifications; |
| 23 @end | 24 @end |
| 24 | 25 |
| 25 | 26 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 EXPECT_TRUE(node1); | 312 EXPECT_TRUE(node1); |
| 312 const BookmarkNode* node2 = model->AddGroup(bookmarkBarNode, 0, L"NAME"); | 313 const BookmarkNode* node2 = model->AddGroup(bookmarkBarNode, 0, L"NAME"); |
| 313 EXPECT_TRUE(node2); | 314 EXPECT_TRUE(node2); |
| 314 BookmarkBubbleController* controller = ControllerForNode(bookmarkBarNode); | 315 BookmarkBubbleController* controller = ControllerForNode(bookmarkBarNode); |
| 315 EXPECT_TRUE(controller); | 316 EXPECT_TRUE(controller); |
| 316 | 317 |
| 317 NSPopUpButton* button = [controller folderPopUpButton]; | 318 NSPopUpButton* button = [controller folderPopUpButton]; |
| 318 [controller setParentFolderSelection:node1]; | 319 [controller setParentFolderSelection:node1]; |
| 319 NSMenuItem* item = [button selectedItem]; | 320 NSMenuItem* item = [button selectedItem]; |
| 320 id itemObject = [item representedObject]; | 321 id itemObject = [item representedObject]; |
| 321 EXPECT_TRUE([itemObject isEqual:[NSValue valueWithPointer:node1]]); | 322 EXPECT_NSEQ(itemObject, [NSValue valueWithPointer:node1]); |
|
Mark Mentovai
2010/08/06 20:01:01
I think that this and the one on line 326 should b
| |
| 322 [controller setParentFolderSelection:node2]; | 323 [controller setParentFolderSelection:node2]; |
| 323 item = [button selectedItem]; | 324 item = [button selectedItem]; |
| 324 itemObject = [item representedObject]; | 325 itemObject = [item representedObject]; |
| 325 EXPECT_TRUE([itemObject isEqual:[NSValue valueWithPointer:node2]]); | 326 EXPECT_NSEQ(itemObject, [NSValue valueWithPointer:node2]); |
| 326 } | 327 } |
| 327 | 328 |
| 328 // Click the "remove" button | 329 // Click the "remove" button |
| 329 TEST_F(BookmarkBubbleControllerTest, TestRemove) { | 330 TEST_F(BookmarkBubbleControllerTest, TestRemove) { |
| 330 BookmarkModel* model = GetBookmarkModel(); | 331 BookmarkModel* model = GetBookmarkModel(); |
| 331 GURL gurl("http://www.google.com"); | 332 GURL gurl("http://www.google.com"); |
| 332 const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(), | 333 const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(), |
| 333 0, | 334 0, |
| 334 L"Bookie markie title", | 335 L"Bookie markie title", |
| 335 gurl); | 336 gurl); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 465 // Normally this would be sent up the responder tree correctly, but since | 466 // Normally this would be sent up the responder tree correctly, but since |
| 466 // tests run in the background, key window and main window are never set on | 467 // tests run in the background, key window and main window are never set on |
| 467 // NSApplication. Adding it to NSApplication directly removes the need for | 468 // NSApplication. Adding it to NSApplication directly removes the need for |
| 468 // worrying about what the current window with focus is. | 469 // worrying about what the current window with focus is. |
| 469 - (void)editBookmarkNode:(id)sender { | 470 - (void)editBookmarkNode:(id)sender { |
| 470 EXPECT_TRUE([sender respondsToSelector:@selector(node)]); | 471 EXPECT_TRUE([sender respondsToSelector:@selector(node)]); |
| 471 BookmarkBubbleControllerTest::edits_++; | 472 BookmarkBubbleControllerTest::edits_++; |
| 472 } | 473 } |
| 473 | 474 |
| 474 @end | 475 @end |
| OLD | NEW |