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_bar_controller.h" | 9 #import "chrome/browser/cocoa/bookmark_bar_controller.h" |
10 #include "chrome/browser/cocoa/browser_test_helper.h" | 10 #include "chrome/browser/cocoa/browser_test_helper.h" |
11 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 11 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 12 #include "chrome/browser/cocoa/test_event_utils.h" |
12 #import "chrome/browser/cocoa/view_resizer_pong.h" | 13 #import "chrome/browser/cocoa/view_resizer_pong.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 // Pretend BookmarkURLOpener delegate to keep track of requests | 16 // Pretend BookmarkURLOpener delegate to keep track of requests |
16 @interface BookmarkURLOpenerPong : NSObject<BookmarkURLOpener> { | 17 @interface BookmarkURLOpenerPong : NSObject<BookmarkURLOpener> { |
17 @public | 18 @public |
18 std::vector<GURL> urls_; | 19 std::vector<GURL> urls_; |
19 std::vector<WindowOpenDisposition> dispositions_; | 20 std::vector<WindowOpenDisposition> dispositions_; |
20 } | 21 } |
21 @end | 22 @end |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 TEST_F(BookmarkBarControllerTest, Contents) { | 497 TEST_F(BookmarkBarControllerTest, Contents) { |
497 // TODO(jrg): addNodesToBar has a LOT of TODOs; when flushed out, write | 498 // TODO(jrg): addNodesToBar has a LOT of TODOs; when flushed out, write |
498 // appropriate tests. | 499 // appropriate tests. |
499 } | 500 } |
500 | 501 |
501 // Test drawing, mostly to ensure nothing leaks or crashes. | 502 // Test drawing, mostly to ensure nothing leaks or crashes. |
502 TEST_F(BookmarkBarControllerTest, Display) { | 503 TEST_F(BookmarkBarControllerTest, Display) { |
503 [[bar_ view] display]; | 504 [[bar_ view] display]; |
504 } | 505 } |
505 | 506 |
| 507 // Test that middle clicking on a bookmark button results in an open action. |
| 508 TEST_F(BookmarkBarControllerTest, MiddleClick) { |
| 509 BookmarkModel* model = helper_.profile()->GetBookmarkModel(); |
| 510 GURL gurl1("http://www.google.com/"); |
| 511 std::wstring title1(L"x"); |
| 512 model->SetURLStarred(gurl1, title1, true); |
| 513 |
| 514 EXPECT_EQ(1U, [[bar_ buttons] count]); |
| 515 NSButton* first = [[bar_ buttons] objectAtIndex:0]; |
| 516 EXPECT_TRUE(first); |
| 517 |
| 518 scoped_nsobject<BookmarkURLOpenerPong> pong([[BookmarkURLOpenerPong alloc] |
| 519 init]); |
| 520 [bar_ setUrlDelegate:pong.get()]; |
| 521 [first otherMouseUp:test_event_utils::MakeMouseEvent(NSOtherMouseUp, 0)]; |
| 522 EXPECT_EQ(pong.get()->urls_.size(), 1U); |
| 523 [bar_ setUrlDelegate:nil]; |
| 524 } |
| 525 |
506 // Cannot test these methods since they simply call a single static | 526 // Cannot test these methods since they simply call a single static |
507 // method, BookmarkEditor::Show(), which is impossible to mock. | 527 // method, BookmarkEditor::Show(), which is impossible to mock. |
508 // editBookmark:, addPage: | 528 // editBookmark:, addPage: |
509 | 529 |
510 | 530 |
511 } // namespace | 531 } // namespace |
OLD | NEW |