| OLD | NEW |
| 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model.h" | 14 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_utils.h" | 16 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 17 #include "chrome/browser/extensions/test_extension_system.h" | 17 #include "chrome/browser/extensions/test_extension_system.h" |
| 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
| 19 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 19 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 20 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" | 20 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" |
| 21 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_unittest_helper.h" | 21 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_unittest_helper.h" |
| 22 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.h" | 22 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.h" |
| 23 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 23 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
| 24 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" | 24 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
| 25 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 25 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 26 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" | 26 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" |
| 27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/test/base/model_test_utils.h" | 29 #include "chrome/test/base/model_test_utils.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 31 #import "testing/gtest_mac.h" | 31 #import "testing/gtest_mac.h" |
| 32 #include "testing/platform_test.h" | 32 #include "testing/platform_test.h" |
| 33 #import "third_party/ocmock/OCMock/OCMock.h" |
| 33 #include "third_party/ocmock/gtest_support.h" | 34 #include "third_party/ocmock/gtest_support.h" |
| 34 #import "third_party/ocmock/OCMock/OCMock.h" | |
| 35 #include "ui/base/cocoa/animation_utils.h" | 35 #include "ui/base/cocoa/animation_utils.h" |
| 36 #include "ui/base/test/cocoa_test_event_utils.h" | 36 #include "ui/base/test/cocoa_test_event_utils.h" |
| 37 #include "ui/base/theme_provider.h" | 37 #include "ui/base/theme_provider.h" |
| 38 #include "ui/gfx/image/image_skia.h" | 38 #include "ui/gfx/image/image_skia.h" |
| 39 | 39 |
| 40 // Unit tests don't need time-consuming asynchronous animations. | 40 // Unit tests don't need time-consuming asynchronous animations. |
| 41 @interface BookmarkBarControllerTestable : BookmarkBarController { | 41 @interface BookmarkBarControllerTestable : BookmarkBarController { |
| 42 } | 42 } |
| 43 | 43 |
| 44 @end | 44 @end |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 197 } |
| 198 return dragDataNodes; | 198 return dragDataNodes; |
| 199 } | 199 } |
| 200 | 200 |
| 201 @end | 201 @end |
| 202 | 202 |
| 203 | 203 |
| 204 class FakeTheme : public ui::ThemeProvider { | 204 class FakeTheme : public ui::ThemeProvider { |
| 205 public: | 205 public: |
| 206 FakeTheme(NSColor* color) : color_(color) {} | 206 FakeTheme(NSColor* color) : color_(color) {} |
| 207 scoped_nsobject<NSColor> color_; | 207 base::scoped_nsobject<NSColor> color_; |
| 208 | 208 |
| 209 virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const OVERRIDE { | 209 virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const OVERRIDE { |
| 210 return NULL; | 210 return NULL; |
| 211 } | 211 } |
| 212 virtual SkColor GetColor(int id) const OVERRIDE { return SkColor(); } | 212 virtual SkColor GetColor(int id) const OVERRIDE { return SkColor(); } |
| 213 virtual bool GetDisplayProperty(int id, int* result) const OVERRIDE { | 213 virtual bool GetDisplayProperty(int id, int* result) const OVERRIDE { |
| 214 return false; | 214 return false; |
| 215 } | 215 } |
| 216 virtual bool ShouldUseNativeFrame() const OVERRIDE { return false; } | 216 virtual bool ShouldUseNativeFrame() const OVERRIDE { return false; } |
| 217 virtual bool HasCustomImage(int id) const OVERRIDE { return false; } | 217 virtual bool HasCustomImage(int id) const OVERRIDE { return false; } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 sourceMask_ = mask; | 285 sourceMask_ = mask; |
| 286 } | 286 } |
| 287 | 287 |
| 288 @end | 288 @end |
| 289 | 289 |
| 290 | 290 |
| 291 namespace { | 291 namespace { |
| 292 | 292 |
| 293 class BookmarkBarControllerTestBase : public CocoaProfileTest { | 293 class BookmarkBarControllerTestBase : public CocoaProfileTest { |
| 294 public: | 294 public: |
| 295 scoped_nsobject<NSView> parent_view_; | 295 base::scoped_nsobject<NSView> parent_view_; |
| 296 scoped_nsobject<ViewResizerPong> resizeDelegate_; | 296 base::scoped_nsobject<ViewResizerPong> resizeDelegate_; |
| 297 | 297 |
| 298 virtual void SetUp() { | 298 virtual void SetUp() { |
| 299 CocoaProfileTest::SetUp(); | 299 CocoaProfileTest::SetUp(); |
| 300 ASSERT_TRUE(profile()); | 300 ASSERT_TRUE(profile()); |
| 301 | 301 |
| 302 base::FilePath extension_dir; | 302 base::FilePath extension_dir; |
| 303 static_cast<extensions::TestExtensionSystem*>( | 303 static_cast<extensions::TestExtensionSystem*>( |
| 304 extensions::ExtensionSystem::Get(profile()))-> | 304 extensions::ExtensionSystem::Get(profile()))-> |
| 305 CreateExtensionService( | 305 CreateExtensionService( |
| 306 CommandLine::ForCurrentProcess(), | 306 CommandLine::ForCurrentProcess(), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 328 [contentView addSubview:parent_view_]; | 328 [contentView addSubview:parent_view_]; |
| 329 | 329 |
| 330 // Make sure it's open so certain things aren't no-ops. | 330 // Make sure it's open so certain things aren't no-ops. |
| 331 [bar updateState:BookmarkBar::SHOW | 331 [bar updateState:BookmarkBar::SHOW |
| 332 changeType:BookmarkBar::DONT_ANIMATE_STATE_CHANGE]; | 332 changeType:BookmarkBar::DONT_ANIMATE_STATE_CHANGE]; |
| 333 } | 333 } |
| 334 }; | 334 }; |
| 335 | 335 |
| 336 class BookmarkBarControllerTest : public BookmarkBarControllerTestBase { | 336 class BookmarkBarControllerTest : public BookmarkBarControllerTestBase { |
| 337 public: | 337 public: |
| 338 scoped_nsobject<NSButtonCell> cell_; | 338 base::scoped_nsobject<NSButtonCell> cell_; |
| 339 scoped_nsobject<BookmarkBarControllerNoOpen> bar_; | 339 base::scoped_nsobject<BookmarkBarControllerNoOpen> bar_; |
| 340 | 340 |
| 341 virtual void SetUp() { | 341 virtual void SetUp() { |
| 342 BookmarkBarControllerTestBase::SetUp(); | 342 BookmarkBarControllerTestBase::SetUp(); |
| 343 ASSERT_TRUE(browser()); | 343 ASSERT_TRUE(browser()); |
| 344 AddCommandLineSwitches(); | 344 AddCommandLineSwitches(); |
| 345 | 345 |
| 346 bar_.reset( | 346 bar_.reset( |
| 347 [[BookmarkBarControllerNoOpen alloc] | 347 [[BookmarkBarControllerNoOpen alloc] |
| 348 initWithBrowser:browser() | 348 initWithBrowser:browser() |
| 349 initialWidth:NSWidth([parent_view_ frame]) | 349 initialWidth:NSWidth([parent_view_ frame]) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 [bar_ updateState:BookmarkBar::DETACHED | 489 [bar_ updateState:BookmarkBar::DETACHED |
| 490 changeType:BookmarkBar::DONT_ANIMATE_STATE_CHANGE]; | 490 changeType:BookmarkBar::DONT_ANIMATE_STATE_CHANGE]; |
| 491 EXPECT_EQ(BookmarkBar::DETACHED, [bar_ currentState]); | 491 EXPECT_EQ(BookmarkBar::DETACHED, [bar_ currentState]); |
| 492 EXPECT_TRUE([bar_ isVisible]); | 492 EXPECT_TRUE([bar_ isVisible]); |
| 493 EXPECT_FALSE([bar_ isAnimationRunning]); | 493 EXPECT_FALSE([bar_ isAnimationRunning]); |
| 494 } | 494 } |
| 495 } | 495 } |
| 496 | 496 |
| 497 // Make sure we're watching for frame change notifications. | 497 // Make sure we're watching for frame change notifications. |
| 498 TEST_F(BookmarkBarControllerTest, FrameChangeNotification) { | 498 TEST_F(BookmarkBarControllerTest, FrameChangeNotification) { |
| 499 scoped_nsobject<BookmarkBarControllerTogglePong> bar; | 499 base::scoped_nsobject<BookmarkBarControllerTogglePong> bar; |
| 500 bar.reset( | 500 bar.reset( |
| 501 [[BookmarkBarControllerTogglePong alloc] | 501 [[BookmarkBarControllerTogglePong alloc] |
| 502 initWithBrowser:browser() | 502 initWithBrowser:browser() |
| 503 initialWidth:100 // arbitrary | 503 initialWidth:100 // arbitrary |
| 504 delegate:nil | 504 delegate:nil |
| 505 resizeDelegate:resizeDelegate_.get()]); | 505 resizeDelegate:resizeDelegate_.get()]); |
| 506 InstallAndToggleBar(bar.get()); | 506 InstallAndToggleBar(bar.get()); |
| 507 | 507 |
| 508 // Send a frame did change notification for the pong's view. | 508 // Send a frame did change notification for the pong's view. |
| 509 [[NSNotificationCenter defaultCenter] | 509 [[NSNotificationCenter defaultCenter] |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 EXPECT_EQ(2, [submenu numberOfItems]); | 724 EXPECT_EQ(2, [submenu numberOfItems]); |
| 725 EXPECT_TRUE([submenu itemWithTitle:@"f1"]); | 725 EXPECT_TRUE([submenu itemWithTitle:@"f1"]); |
| 726 EXPECT_TRUE([submenu itemWithTitle:@"f2"]); | 726 EXPECT_TRUE([submenu itemWithTitle:@"f2"]); |
| 727 } | 727 } |
| 728 | 728 |
| 729 // Confirm openBookmark: forwards the request to the controller's delegate | 729 // Confirm openBookmark: forwards the request to the controller's delegate |
| 730 TEST_F(BookmarkBarControllerTest, OpenBookmark) { | 730 TEST_F(BookmarkBarControllerTest, OpenBookmark) { |
| 731 GURL gurl("http://walla.walla.ding.dong.com"); | 731 GURL gurl("http://walla.walla.ding.dong.com"); |
| 732 scoped_ptr<BookmarkNode> node(new BookmarkNode(gurl)); | 732 scoped_ptr<BookmarkNode> node(new BookmarkNode(gurl)); |
| 733 | 733 |
| 734 scoped_nsobject<BookmarkButtonCell> cell([[BookmarkButtonCell alloc] init]); | 734 base::scoped_nsobject<BookmarkButtonCell> cell( |
| 735 [[BookmarkButtonCell alloc] init]); |
| 735 [cell setBookmarkNode:node.get()]; | 736 [cell setBookmarkNode:node.get()]; |
| 736 scoped_nsobject<BookmarkButton> button([[BookmarkButton alloc] init]); | 737 base::scoped_nsobject<BookmarkButton> button([[BookmarkButton alloc] init]); |
| 737 [button setCell:cell.get()]; | 738 [button setCell:cell.get()]; |
| 738 [cell setRepresentedObject:[NSValue valueWithPointer:node.get()]]; | 739 [cell setRepresentedObject:[NSValue valueWithPointer:node.get()]]; |
| 739 | 740 |
| 740 [bar_ openBookmark:button]; | 741 [bar_ openBookmark:button]; |
| 741 EXPECT_EQ(noOpenBar()->urls_[0], node->url()); | 742 EXPECT_EQ(noOpenBar()->urls_[0], node->url()); |
| 742 EXPECT_EQ(noOpenBar()->dispositions_[0], CURRENT_TAB); | 743 EXPECT_EQ(noOpenBar()->dispositions_[0], CURRENT_TAB); |
| 743 } | 744 } |
| 744 | 745 |
| 745 TEST_F(BookmarkBarControllerTest, TestAddRemoveAndClear) { | 746 TEST_F(BookmarkBarControllerTest, TestAddRemoveAndClear) { |
| 746 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 747 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 NSRect frame = [[bar_ view] frame]; | 824 NSRect frame = [[bar_ view] frame]; |
| 824 frame.size.width += 600; | 825 frame.size.width += 600; |
| 825 [[bar_ view] setFrame:frame]; | 826 [[bar_ view] setFrame:frame]; |
| 826 int finalcount = [[bar_ buttons] count]; | 827 int finalcount = [[bar_ buttons] count]; |
| 827 EXPECT_GT(finalcount, count); | 828 EXPECT_GT(finalcount, count); |
| 828 } | 829 } |
| 829 | 830 |
| 830 // Make sure that each button we add marches to the right and does not | 831 // Make sure that each button we add marches to the right and does not |
| 831 // overlap with the previous one. | 832 // overlap with the previous one. |
| 832 TEST_F(BookmarkBarControllerTest, TestButtonMarch) { | 833 TEST_F(BookmarkBarControllerTest, TestButtonMarch) { |
| 833 scoped_nsobject<NSMutableArray> cells([[NSMutableArray alloc] init]); | 834 base::scoped_nsobject<NSMutableArray> cells([[NSMutableArray alloc] init]); |
| 834 | 835 |
| 835 CGFloat widths[] = { 10, 10, 100, 10, 500, 500, 80000, 60000, 1, 345 }; | 836 CGFloat widths[] = { 10, 10, 100, 10, 500, 500, 80000, 60000, 1, 345 }; |
| 836 for (unsigned int i = 0; i < arraysize(widths); i++) { | 837 for (unsigned int i = 0; i < arraysize(widths); i++) { |
| 837 NSCell* cell = [[CellWithDesiredSize alloc] | 838 NSCell* cell = [[CellWithDesiredSize alloc] |
| 838 initTextCell:@"foo" | 839 initTextCell:@"foo" |
| 839 desiredSize:NSMakeSize(widths[i], 30)]; | 840 desiredSize:NSMakeSize(widths[i], 30)]; |
| 840 [cells addObject:cell]; | 841 [cells addObject:cell]; |
| 841 [cell release]; | 842 [cell release]; |
| 842 } | 843 } |
| 843 | 844 |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 GURL gurls[] = { GURL("http://www.foo.com/"), | 1162 GURL gurls[] = { GURL("http://www.foo.com/"), |
| 1162 GURL("http://www.bar.com/"), | 1163 GURL("http://www.bar.com/"), |
| 1163 GURL("http://www.baz.com/") }; | 1164 GURL("http://www.baz.com/") }; |
| 1164 string16 titles[] = { ASCIIToUTF16("a"), | 1165 string16 titles[] = { ASCIIToUTF16("a"), |
| 1165 ASCIIToUTF16("b"), | 1166 ASCIIToUTF16("b"), |
| 1166 ASCIIToUTF16("c") }; | 1167 ASCIIToUTF16("c") }; |
| 1167 for (size_t i = 0; i < arraysize(titles); i++) | 1168 for (size_t i = 0; i < arraysize(titles); i++) |
| 1168 bookmark_utils::AddIfNotBookmarked(model, gurls[i], titles[i]); | 1169 bookmark_utils::AddIfNotBookmarked(model, gurls[i], titles[i]); |
| 1169 | 1170 |
| 1170 // Get and retain the buttons so we can examine them after dealloc. | 1171 // Get and retain the buttons so we can examine them after dealloc. |
| 1171 scoped_nsobject<NSArray> buttons([[bar_ buttons] retain]); | 1172 base::scoped_nsobject<NSArray> buttons([[bar_ buttons] retain]); |
| 1172 EXPECT_EQ([buttons count], arraysize(titles)); | 1173 EXPECT_EQ([buttons count], arraysize(titles)); |
| 1173 | 1174 |
| 1174 // Make sure that everything is set. | 1175 // Make sure that everything is set. |
| 1175 for (BookmarkButton* button in buttons.get()) { | 1176 for (BookmarkButton* button in buttons.get()) { |
| 1176 ASSERT_TRUE([button isKindOfClass:[BookmarkButton class]]); | 1177 ASSERT_TRUE([button isKindOfClass:[BookmarkButton class]]); |
| 1177 EXPECT_TRUE([button delegate]); | 1178 EXPECT_TRUE([button delegate]); |
| 1178 EXPECT_TRUE([button target]); | 1179 EXPECT_TRUE([button target]); |
| 1179 EXPECT_TRUE([button action]); | 1180 EXPECT_TRUE([button action]); |
| 1180 } | 1181 } |
| 1181 | 1182 |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 [bar_ view]; | 1696 [bar_ view]; |
| 1696 // Awkwardness to look like we've been installed. | 1697 // Awkwardness to look like we've been installed. |
| 1697 [parent_view_ addSubview:[bar_ view]]; | 1698 [parent_view_ addSubview:[bar_ view]]; |
| 1698 NSRect frame = [[[bar_ view] superview] frame]; | 1699 NSRect frame = [[[bar_ view] superview] frame]; |
| 1699 frame.origin.y = 100; | 1700 frame.origin.y = 100; |
| 1700 [[[bar_ view] superview] setFrame:frame]; | 1701 [[[bar_ view] superview] setFrame:frame]; |
| 1701 | 1702 |
| 1702 // Do not add the bar to a window, yet. | 1703 // Do not add the bar to a window, yet. |
| 1703 } | 1704 } |
| 1704 | 1705 |
| 1705 scoped_nsobject<NSView> parent_view_; | 1706 base::scoped_nsobject<NSView> parent_view_; |
| 1706 scoped_nsobject<ViewResizerPong> resizeDelegate_; | 1707 base::scoped_nsobject<ViewResizerPong> resizeDelegate_; |
| 1707 scoped_nsobject<BookmarkBarControllerNotificationPong> bar_; | 1708 base::scoped_nsobject<BookmarkBarControllerNotificationPong> bar_; |
| 1708 }; | 1709 }; |
| 1709 | 1710 |
| 1710 TEST_F(BookmarkBarControllerNotificationTest, DeregistersForNotifications) { | 1711 TEST_F(BookmarkBarControllerNotificationTest, DeregistersForNotifications) { |
| 1711 NSWindow* window = [[CocoaTestHelperWindow alloc] init]; | 1712 NSWindow* window = [[CocoaTestHelperWindow alloc] init]; |
| 1712 [window setReleasedWhenClosed:YES]; | 1713 [window setReleasedWhenClosed:YES]; |
| 1713 | 1714 |
| 1714 // First add the bookmark bar to the temp window, then to another window. | 1715 // First add the bookmark bar to the temp window, then to another window. |
| 1715 [[window contentView] addSubview:parent_view_]; | 1716 [[window contentView] addSubview:parent_view_]; |
| 1716 [[test_window() contentView] addSubview:parent_view_]; | 1717 [[test_window() contentView] addSubview:parent_view_]; |
| 1717 | 1718 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1733 // which can be overridden to fire immediately to make behavior | 1734 // which can be overridden to fire immediately to make behavior |
| 1734 // confirmable. | 1735 // confirmable. |
| 1735 | 1736 |
| 1736 // TODO(jrg): add unit test to make sure "Other Bookmarks" responds | 1737 // TODO(jrg): add unit test to make sure "Other Bookmarks" responds |
| 1737 // properly to a hover open. | 1738 // properly to a hover open. |
| 1738 | 1739 |
| 1739 // TODO(viettrungluu): figure out how to test animations. | 1740 // TODO(viettrungluu): figure out how to test animations. |
| 1740 | 1741 |
| 1741 class BookmarkBarControllerDragDropTest : public BookmarkBarControllerTestBase { | 1742 class BookmarkBarControllerDragDropTest : public BookmarkBarControllerTestBase { |
| 1742 public: | 1743 public: |
| 1743 scoped_nsobject<BookmarkBarControllerDragData> bar_; | 1744 base::scoped_nsobject<BookmarkBarControllerDragData> bar_; |
| 1744 | 1745 |
| 1745 virtual void SetUp() { | 1746 virtual void SetUp() { |
| 1746 BookmarkBarControllerTestBase::SetUp(); | 1747 BookmarkBarControllerTestBase::SetUp(); |
| 1747 ASSERT_TRUE(browser()); | 1748 ASSERT_TRUE(browser()); |
| 1748 | 1749 |
| 1749 bar_.reset( | 1750 bar_.reset( |
| 1750 [[BookmarkBarControllerDragData alloc] | 1751 [[BookmarkBarControllerDragData alloc] |
| 1751 initWithBrowser:browser() | 1752 initWithBrowser:browser() |
| 1752 initialWidth:NSWidth([parent_view_ frame]) | 1753 initialWidth:NSWidth([parent_view_ frame]) |
| 1753 delegate:nil | 1754 delegate:nil |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1884 | 1885 |
| 1885 // Remember the little ones. | 1886 // Remember the little ones. |
| 1886 int oldChildCount = root->child_count(); | 1887 int oldChildCount = root->child_count(); |
| 1887 | 1888 |
| 1888 BookmarkButton* targetButton = [bar_ buttonWithTitleEqualTo:@"3b"]; | 1889 BookmarkButton* targetButton = [bar_ buttonWithTitleEqualTo:@"3b"]; |
| 1889 ASSERT_TRUE(targetButton); | 1890 ASSERT_TRUE(targetButton); |
| 1890 | 1891 |
| 1891 // Gen up some dragging data. | 1892 // Gen up some dragging data. |
| 1892 const BookmarkNode* newNode = other->GetChild(2); | 1893 const BookmarkNode* newNode = other->GetChild(2); |
| 1893 [bar_ setDragDataNode:newNode]; | 1894 [bar_ setDragDataNode:newNode]; |
| 1894 scoped_nsobject<FakeDragInfo> dragInfo([[FakeDragInfo alloc] init]); | 1895 base::scoped_nsobject<FakeDragInfo> dragInfo([[FakeDragInfo alloc] init]); |
| 1895 [dragInfo setDropLocation:[targetButton center]]; | 1896 [dragInfo setDropLocation:[targetButton center]]; |
| 1896 [bar_ dragBookmarkData:(id<NSDraggingInfo>)dragInfo.get()]; | 1897 [bar_ dragBookmarkData:(id<NSDraggingInfo>)dragInfo.get()]; |
| 1897 | 1898 |
| 1898 // There should one more button in the bar. | 1899 // There should one more button in the bar. |
| 1899 int newChildCount = root->child_count(); | 1900 int newChildCount = root->child_count(); |
| 1900 EXPECT_EQ(oldChildCount + 1, newChildCount); | 1901 EXPECT_EQ(oldChildCount + 1, newChildCount); |
| 1901 // Verify the model. | 1902 // Verify the model. |
| 1902 const std::string expected("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " | 1903 const std::string expected("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
| 1903 "2f3b ] O3f:[ O3f1b O3f2f ] 3b 4b "); | 1904 "2f3b ] O3f:[ O3f1b O3f2f ] 3b 4b "); |
| 1904 actual = model_test_utils::ModelStringFromNode(root); | 1905 actual = model_test_utils::ModelStringFromNode(root); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2069 "2f3b ] 4b "); | 2070 "2f3b ] 4b "); |
| 2070 actual = model_test_utils::ModelStringFromNode(root); | 2071 actual = model_test_utils::ModelStringFromNode(root); |
| 2071 EXPECT_EQ(expected, actual); | 2072 EXPECT_EQ(expected, actual); |
| 2072 | 2073 |
| 2073 // Verify that the other bookmark folder can't be deleted. | 2074 // Verify that the other bookmark folder can't be deleted. |
| 2074 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; | 2075 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; |
| 2075 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); | 2076 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); |
| 2076 } | 2077 } |
| 2077 | 2078 |
| 2078 } // namespace | 2079 } // namespace |
| OLD | NEW |