| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/mac/scoped_nsobject.h" | 5 #include "base/mac/scoped_nsobject.h" |
| 6 #include "components/bookmarks/browser/bookmark_model.h" | 6 #include "components/bookmarks/browser/bookmark_model.h" |
| 7 #include "components/sync_preferences/testing_pref_service_syncable.h" | |
| 8 #import "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 7 #import "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| 9 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_handset_view_controller.h
" | 8 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_handset_view_controller.h
" |
| 10 #include "ios/chrome/browser/ui/bookmarks/bookmark_ios_unittest.h" | 9 #include "ios/chrome/browser/ui/bookmarks/bookmark_ios_unittest.h" |
| 11 #import "ios/chrome/browser/ui/bookmarks/bookmark_promo_controller.h" | 10 #import "ios/chrome/browser/ui/bookmarks/bookmark_promo_controller.h" |
| 12 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" | 11 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" |
| 13 | 12 |
| 14 using bookmarks::BookmarkNode; | 13 using bookmarks::BookmarkNode; |
| 15 | 14 |
| 16 // A partial mock subclass that doesn't load any heavy weight subclasses. | 15 // A partial mock subclass that doesn't load any heavy weight subclasses. |
| 17 @interface MockBookmarkHomeHandsetViewController | 16 @interface MockBookmarkHomeHandsetViewController |
| (...skipping 13 matching lines...) Expand all Loading... |
| 31 - (void)ensureAllViewExists { | 30 - (void)ensureAllViewExists { |
| 32 // Do nothing. | 31 // Do nothing. |
| 33 } | 32 } |
| 34 - (void)loadImageService { | 33 - (void)loadImageService { |
| 35 // Do nothing. | 34 // Do nothing. |
| 36 } | 35 } |
| 37 @end | 36 @end |
| 38 | 37 |
| 39 namespace { | 38 namespace { |
| 40 | 39 |
| 41 class BookmarkHomeViewControllerTest : public BookmarkIOSUnitTest { | 40 using BookmarkHomeViewControllerTest = BookmarkIOSUnitTest; |
| 42 public: | |
| 43 void SetUp() override { | |
| 44 BookmarkIOSUnitTest::SetUp(); | |
| 45 sync_preferences::TestingPrefServiceSyncable* pref = | |
| 46 chrome_browser_state_->GetTestingPrefService(); | |
| 47 [BookmarkPromoController registerBrowserStatePrefs:pref->registry()]; | |
| 48 } | |
| 49 }; | |
| 50 | 41 |
| 51 TEST_F(BookmarkHomeViewControllerTest, DeleteNodesUpdatesEditNodes) { | 42 TEST_F(BookmarkHomeViewControllerTest, DeleteNodesUpdatesEditNodes) { |
| 52 const BookmarkNode* mobileNode = _bookmarkModel->mobile_node(); | 43 const BookmarkNode* mobileNode = _bookmarkModel->mobile_node(); |
| 53 const BookmarkNode* f1 = AddFolder(mobileNode, @"f1"); | 44 const BookmarkNode* f1 = AddFolder(mobileNode, @"f1"); |
| 54 const BookmarkNode* a = AddBookmark(mobileNode, @"a"); | 45 const BookmarkNode* a = AddBookmark(mobileNode, @"a"); |
| 55 const BookmarkNode* b = AddBookmark(mobileNode, @"b"); | 46 const BookmarkNode* b = AddBookmark(mobileNode, @"b"); |
| 56 const BookmarkNode* f2 = AddFolder(mobileNode, @"f2"); | 47 const BookmarkNode* f2 = AddFolder(mobileNode, @"f2"); |
| 57 | 48 |
| 58 const BookmarkNode* f1a = AddBookmark(f1, @"f1a"); | 49 const BookmarkNode* f1a = AddBookmark(f1, @"f1a"); |
| 59 AddBookmark(f1, @"f1b"); | 50 AddBookmark(f1, @"f1b"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 80 bookmark_utils_ios::DeleteBookmarks(toDelete, _bookmarkModel); | 71 bookmark_utils_ios::DeleteBookmarks(toDelete, _bookmarkModel); |
| 81 | 72 |
| 82 // After the deletion, only 'a' and 'f2' should be left. | 73 // After the deletion, only 'a' and 'f2' should be left. |
| 83 std::set<const BookmarkNode*> editingNodes = [controller editNodes]; | 74 std::set<const BookmarkNode*> editingNodes = [controller editNodes]; |
| 84 EXPECT_EQ(editingNodes.size(), 2u); | 75 EXPECT_EQ(editingNodes.size(), 2u); |
| 85 EXPECT_TRUE(editingNodes.find(a) != editingNodes.end()); | 76 EXPECT_TRUE(editingNodes.find(a) != editingNodes.end()); |
| 86 EXPECT_TRUE(editingNodes.find(f2) != editingNodes.end()); | 77 EXPECT_TRUE(editingNodes.find(f2) != editingNodes.end()); |
| 87 } | 78 } |
| 88 | 79 |
| 89 } // anonymous namespace | 80 } // anonymous namespace |
| OLD | NEW |