Chromium Code Reviews| 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 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 5 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 6 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h" | 6 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h" |
| 7 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 7 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 8 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" | 8 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" |
| 9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 delegate:nil])) { | 44 delegate:nil])) { |
| 45 callbacks_.reset([[NSMutableArray alloc] init]); | 45 callbacks_.reset([[NSMutableArray alloc] init]); |
| 46 } | 46 } |
| 47 return self; | 47 return self; |
| 48 } | 48 } |
| 49 | 49 |
| 50 - (void)loaded:(BookmarkModel*)model { | 50 - (void)loaded:(BookmarkModel*)model { |
| 51 [callbacks_ addObject:[NSNumber numberWithInt:0]]; | 51 [callbacks_ addObject:[NSNumber numberWithInt:0]]; |
| 52 } | 52 } |
| 53 | 53 |
| 54 - (void)beingDeleted:(BookmarkModel*)model { | |
| 55 [callbacks_ addObject:[NSNumber numberWithInt:1]]; | |
| 56 } | |
| 57 | |
| 58 - (void)nodeMoved:(BookmarkModel*)model | 54 - (void)nodeMoved:(BookmarkModel*)model |
| 59 oldParent:(const BookmarkNode*)oldParent oldIndex:(int)oldIndex | 55 oldParent:(const BookmarkNode*)oldParent oldIndex:(int)oldIndex |
| 60 newParent:(const BookmarkNode*)newParent newIndex:(int)newIndex { | 56 newParent:(const BookmarkNode*)newParent newIndex:(int)newIndex { |
| 61 [callbacks_ addObject:[NSNumber numberWithInt:2]]; | 57 [callbacks_ addObject:[NSNumber numberWithInt:1]]; |
|
Elly Fong-Jones
2017/04/04 19:07:33
are these intended to mean something? should they
lgrey
2017/04/04 19:42:21
Per offline discussion, switched to storing/compar
| |
| 62 } | 58 } |
| 63 | 59 |
| 64 - (void)nodeAdded:(BookmarkModel*)model | 60 - (void)nodeAdded:(BookmarkModel*)model |
| 65 parent:(const BookmarkNode*)oldParent index:(int)index { | 61 parent:(const BookmarkNode*)oldParent index:(int)index { |
| 66 [callbacks_ addObject:[NSNumber numberWithInt:3]]; | 62 [callbacks_ addObject:[NSNumber numberWithInt:2]]; |
| 67 } | 63 } |
| 68 | 64 |
| 69 - (void)nodeChanged:(BookmarkModel*)model | 65 - (void)nodeChanged:(BookmarkModel*)model |
| 70 node:(const BookmarkNode*)node { | 66 node:(const BookmarkNode*)node { |
| 71 [callbacks_ addObject:[NSNumber numberWithInt:4]]; | 67 [callbacks_ addObject:[NSNumber numberWithInt:3]]; |
| 72 } | 68 } |
| 73 | 69 |
| 74 - (void)nodeFaviconLoaded:(BookmarkModel*)model | 70 - (void)nodeFaviconLoaded:(BookmarkModel*)model |
| 75 node:(const BookmarkNode*)node { | 71 node:(const BookmarkNode*)node { |
| 76 [callbacks_ addObject:[NSNumber numberWithInt:5]]; | 72 [callbacks_ addObject:[NSNumber numberWithInt:4]]; |
| 77 } | 73 } |
| 78 | 74 |
| 79 - (void)nodeChildrenReordered:(BookmarkModel*)model | 75 - (void)nodeChildrenReordered:(BookmarkModel*)model |
| 80 node:(const BookmarkNode*)node { | 76 node:(const BookmarkNode*)node { |
| 81 [callbacks_ addObject:[NSNumber numberWithInt:6]]; | 77 [callbacks_ addObject:[NSNumber numberWithInt:5]]; |
| 82 } | 78 } |
| 83 | 79 |
| 84 - (void)nodeRemoved:(BookmarkModel*)model | 80 - (void)nodeRemoved:(BookmarkModel*)model |
| 85 parent:(const BookmarkNode*)oldParent index:(int)index { | 81 parent:(const BookmarkNode*)oldParent index:(int)index { |
| 86 [callbacks_ addObject:[NSNumber numberWithInt:7]]; | 82 [callbacks_ addObject:[NSNumber numberWithInt:6]]; |
| 87 } | 83 } |
| 88 | 84 |
| 89 // Save the request. | 85 // Save the request. |
| 90 - (void)openBookmarkURL:(const GURL&)url | 86 - (void)openBookmarkURL:(const GURL&)url |
| 91 disposition:(WindowOpenDisposition)disposition { | 87 disposition:(WindowOpenDisposition)disposition { |
| 92 opens_.push_back(OpenInfo(url, disposition)); | 88 opens_.push_back(OpenInfo(url, disposition)); |
| 93 } | 89 } |
| 94 | 90 |
| 95 @end | 91 @end |
| 96 | 92 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 110 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]); | 106 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]); |
| 111 | 107 |
| 112 base::scoped_nsobject<FakeBookmarkBarController> controller( | 108 base::scoped_nsobject<FakeBookmarkBarController> controller( |
| 113 [[FakeBookmarkBarController alloc] initWithBrowser:browser()]); | 109 [[FakeBookmarkBarController alloc] initWithBrowser:browser()]); |
| 114 EXPECT_TRUE(controller.get()); | 110 EXPECT_TRUE(controller.get()); |
| 115 std::unique_ptr<BookmarkBarBridge> bridge( | 111 std::unique_ptr<BookmarkBarBridge> bridge( |
| 116 new BookmarkBarBridge(profile(), controller.get(), model)); | 112 new BookmarkBarBridge(profile(), controller.get(), model)); |
| 117 EXPECT_TRUE(bridge.get()); | 113 EXPECT_TRUE(bridge.get()); |
| 118 | 114 |
| 119 bridge->BookmarkModelLoaded(NULL, false); | 115 bridge->BookmarkModelLoaded(NULL, false); |
| 120 bridge->BookmarkModelBeingDeleted(NULL); | 116 // |BookmarkModelBeingDeleted| is a no-op. |
| 121 bridge->BookmarkNodeMoved(NULL, NULL, 0, NULL, 0); | 117 bridge->BookmarkNodeMoved(NULL, NULL, 0, NULL, 0); |
| 122 bridge->BookmarkNodeAdded(NULL, NULL, 0); | 118 bridge->BookmarkNodeAdded(NULL, NULL, 0); |
| 123 bridge->BookmarkNodeChanged(NULL, NULL); | 119 bridge->BookmarkNodeChanged(NULL, NULL); |
| 124 bridge->BookmarkNodeFaviconChanged(NULL, NULL); | 120 bridge->BookmarkNodeFaviconChanged(NULL, NULL); |
| 125 bridge->BookmarkNodeChildrenReordered(NULL, NULL); | 121 bridge->BookmarkNodeChildrenReordered(NULL, NULL); |
| 126 bridge->BookmarkNodeRemoved(NULL, NULL, 0, NULL, std::set<GURL>()); | 122 bridge->BookmarkNodeRemoved(NULL, NULL, 0, NULL, std::set<GURL>()); |
| 123 // 7 calls above plus an initial Loaded() in init routine makes 8 | |
| 124 EXPECT_TRUE([controller.get()->callbacks_ count] == 8); | |
|
Elly Fong-Jones
2017/04/04 19:07:33
EXPECT_EQ() surely?
lgrey
2017/04/04 19:42:21
Done.
| |
| 127 | 125 |
| 128 // 8 calls above plus an initial Loaded() in init routine makes 9 | 126 for (int x = 1; x < 8; x++) { |
| 129 EXPECT_TRUE([controller.get()->callbacks_ count] == 9); | 127 NSNumber* num = [NSNumber numberWithInt:x - 1]; |
| 130 | |
| 131 for (int x = 1; x < 9; x++) { | |
| 132 NSNumber* num = [NSNumber numberWithInt:x-1]; | |
| 133 EXPECT_NSEQ(num, [controller.get()->callbacks_ objectAtIndex:x]); | 128 EXPECT_NSEQ(num, [controller.get()->callbacks_ objectAtIndex:x]); |
| 134 } | 129 } |
| 135 } | 130 } |
| OLD | NEW |