Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(740)

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_utils_ios_unittest.mm

Issue 2662473003: Removing "All Bookmarks" (Closed)
Patch Set: feedback Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 5 #include <memory>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 EXPECT_EQ(folder, mobileNode); 171 EXPECT_EQ(folder, mobileNode);
172 172
173 toMove.clear(); 173 toMove.clear();
174 toMove.insert(f2a); 174 toMove.insert(f2a);
175 toMove.insert(f2b); 175 toMove.insert(f2b);
176 folder = bookmark_utils_ios::defaultMoveFolder(toMove, _bookmarkModel); 176 folder = bookmark_utils_ios::defaultMoveFolder(toMove, _bookmarkModel);
177 EXPECT_EQ(folder, f2); 177 EXPECT_EQ(folder, f2);
178 } 178 }
179 179
180 TEST_F(BookmarkIOSUtilsUnitTest, TestPositionCache) { 180 TEST_F(BookmarkIOSUtilsUnitTest, TestPositionCache) {
181 // Try to store and retrieve a cache for the allMenuItem.
182 BookmarkMenuItem* item = [BookmarkMenuItem allMenuItem];
183 CGFloat position = 23;
184 bookmark_utils_ios::CachePosition(position, item);
185 CGFloat outPosition;
186 BookmarkMenuItem* outItem;
187 BOOL result = bookmark_utils_ios::GetPositionCache(_bookmarkModel, &outItem,
188 &outPosition);
189 if (experimental_flags::IsAllBookmarksEnabled()) {
190 ASSERT_TRUE(result);
191 EXPECT_NSEQ(item, outItem);
192 EXPECT_NEAR(position, outPosition, 0.01);
193 } else {
194 ASSERT_FALSE(result);
195 }
196
197 // Try to store and retrieve a cache for the folderMenuItem. 181 // Try to store and retrieve a cache for the folderMenuItem.
198 const BookmarkNode* mobileNode = _bookmarkModel->mobile_node(); 182 const BookmarkNode* mobileNode = _bookmarkModel->mobile_node();
199 const BookmarkNode* f1 = AddFolder(mobileNode, @"f1"); 183 const BookmarkNode* f1 = AddFolder(mobileNode, @"f1");
200 item = [BookmarkMenuItem folderMenuItemForNode:f1 rootAncestor:NULL]; 184 BookmarkMenuItem* item =
185 [BookmarkMenuItem folderMenuItemForNode:f1 rootAncestor:NULL];
186 CGFloat position = 23;
201 bookmark_utils_ios::CachePosition(position, item); 187 bookmark_utils_ios::CachePosition(position, item);
202 result = bookmark_utils_ios::GetPositionCache(_bookmarkModel, &outItem, 188 BookmarkMenuItem* outItem = nil;
203 &outPosition); 189 CGFloat outPosition;
190 BOOL result = bookmark_utils_ios::GetPositionCache(_bookmarkModel, &outItem,
191 &outPosition);
204 ASSERT_TRUE(result); 192 ASSERT_TRUE(result);
205 EXPECT_NSEQ(item, outItem); 193 EXPECT_NSEQ(item, outItem);
206 EXPECT_NEAR(position, outPosition, 0.01); 194 EXPECT_NEAR(position, outPosition, 0.01);
207 EXPECT_EQ(f1, outItem.folder); 195 EXPECT_EQ(f1, outItem.folder);
208 EXPECT_EQ(bookmarks::MenuItemFolder, outItem.type); 196 EXPECT_EQ(bookmarks::MenuItemFolder, outItem.type);
209 } 197 }
210 198
211 TEST_F(BookmarkIOSUtilsUnitTest, TestBookmarkModelChangesPositionCache) { 199 TEST_F(BookmarkIOSUtilsUnitTest, TestBookmarkModelChangesPositionCache) {
212 // Try to store and retrieve a cache for the folderMenuItem 200 // Try to store and retrieve a cache for the folderMenuItem
213 const BookmarkNode* mobileNode = _bookmarkModel->mobile_node(); 201 const BookmarkNode* mobileNode = _bookmarkModel->mobile_node();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 vector1.push_back(bookmark1); 387 vector1.push_back(bookmark1);
400 vector2.insert(vector2.begin(), bookmark1); 388 vector2.insert(vector2.begin(), bookmark1);
401 missingNodesIndices = 389 missingNodesIndices =
402 bookmark_utils_ios::MissingNodesIndices(vector1, vector2); 390 bookmark_utils_ios::MissingNodesIndices(vector1, vector2);
403 EXPECT_EQ(2u, missingNodesIndices.size()); 391 EXPECT_EQ(2u, missingNodesIndices.size());
404 EXPECT_EQ(2u, missingNodesIndices[0]); 392 EXPECT_EQ(2u, missingNodesIndices[0]);
405 EXPECT_EQ(3u, missingNodesIndices[1]); 393 EXPECT_EQ(3u, missingNodesIndices[1]);
406 } 394 }
407 395
408 } // namespace 396 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.mm ('k') | ios/chrome/browser/ui/bookmarks/bookmarks_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698