| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h" |
| 11 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | 11 #include "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 12 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 12 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 13 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 13 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 14 #include "content/common/notification_service.h" | 14 #include "content/public/browser/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 #import "testing/gtest_mac.h" |
| 17 #include "testing/platform_test.h" | 17 #include "testing/platform_test.h" |
| 18 | 18 |
| 19 // 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. |
| 20 @interface BookmarkPulseObserver : NSObject { | 20 @interface BookmarkPulseObserver : NSObject { |
| 21 int notifications_; | 21 int notifications_; |
| 22 } | 22 } |
| 23 @property (assign, nonatomic) int notifications; | 23 @property (assign, nonatomic) int notifications; |
| 24 @end | 24 @end |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 BookmarkBubbleController* controller = ControllerForNode(node); | 465 BookmarkBubbleController* controller = ControllerForNode(node); |
| 466 EXPECT_TRUE(controller); | 466 EXPECT_TRUE(controller); |
| 467 EXPECT_FALSE(IsWindowClosing()); | 467 EXPECT_FALSE(IsWindowClosing()); |
| 468 | 468 |
| 469 // We can't actually create a new tab here, e.g. | 469 // We can't actually create a new tab here, e.g. |
| 470 // browser()->AddTabWithURL(...); | 470 // browser()->AddTabWithURL(...); |
| 471 // Many of our browser objects (Browser, Profile, RequestContext) | 471 // Many of our browser objects (Browser, Profile, RequestContext) |
| 472 // are "just enough" to run tests without being complete. Instead | 472 // are "just enough" to run tests without being complete. Instead |
| 473 // we fake the notification that would be triggered by a tab | 473 // we fake the notification that would be triggered by a tab |
| 474 // creation. See TabContents::NotifyConnected(). | 474 // creation. See TabContents::NotifyConnected(). |
| 475 NotificationService::current()->Notify( | 475 content::NotificationService::current()->Notify( |
| 476 content::NOTIFICATION_TAB_CONTENTS_CONNECTED, | 476 content::NOTIFICATION_TAB_CONTENTS_CONNECTED, |
| 477 content::Source<TabContents>(NULL), | 477 content::Source<TabContents>(NULL), |
| 478 NotificationService::NoDetails()); | 478 content::NotificationService::NoDetails()); |
| 479 | 479 |
| 480 // Confirm bubble going bye-bye. | 480 // Confirm bubble going bye-bye. |
| 481 EXPECT_TRUE(IsWindowClosing()); | 481 EXPECT_TRUE(IsWindowClosing()); |
| 482 } | 482 } |
| 483 | 483 |
| 484 | 484 |
| 485 } // namespace | 485 } // namespace |
| 486 | 486 |
| 487 @implementation NSApplication (BookmarkBubbleUnitTest) | 487 @implementation NSApplication (BookmarkBubbleUnitTest) |
| 488 // Add handler for the editBookmarkNode: action to NSApp for testing purposes. | 488 // Add handler for the editBookmarkNode: action to NSApp for testing purposes. |
| 489 // Normally this would be sent up the responder tree correctly, but since | 489 // Normally this would be sent up the responder tree correctly, but since |
| 490 // tests run in the background, key window and main window are never set on | 490 // tests run in the background, key window and main window are never set on |
| 491 // NSApplication. Adding it to NSApplication directly removes the need for | 491 // NSApplication. Adding it to NSApplication directly removes the need for |
| 492 // worrying about what the current window with focus is. | 492 // worrying about what the current window with focus is. |
| 493 - (void)editBookmarkNode:(id)sender { | 493 - (void)editBookmarkNode:(id)sender { |
| 494 EXPECT_TRUE([sender respondsToSelector:@selector(node)]); | 494 EXPECT_TRUE([sender respondsToSelector:@selector(node)]); |
| 495 BookmarkBubbleControllerTest::edits_++; | 495 BookmarkBubbleControllerTest::edits_++; |
| 496 } | 496 } |
| 497 | 497 |
| 498 @end | 498 @end |
| OLD | NEW |