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

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

Issue 2666833003: Revert of Removing "All Bookmarks" (Closed)
Patch Set: 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
181 // Try to store and retrieve a cache for the folderMenuItem. 197 // Try to store and retrieve a cache for the folderMenuItem.
182 const BookmarkNode* mobileNode = _bookmarkModel->mobile_node(); 198 const BookmarkNode* mobileNode = _bookmarkModel->mobile_node();
183 const BookmarkNode* f1 = AddFolder(mobileNode, @"f1"); 199 const BookmarkNode* f1 = AddFolder(mobileNode, @"f1");
184 BookmarkMenuItem* item = 200 item = [BookmarkMenuItem folderMenuItemForNode:f1 rootAncestor:NULL];
185 [BookmarkMenuItem folderMenuItemForNode:f1 rootAncestor:NULL];
186 CGFloat position = 23;
187 bookmark_utils_ios::CachePosition(position, item); 201 bookmark_utils_ios::CachePosition(position, item);
188 BookmarkMenuItem* outItem = nil; 202 result = bookmark_utils_ios::GetPositionCache(_bookmarkModel, &outItem,
189 CGFloat outPosition; 203 &outPosition);
190 BOOL result = bookmark_utils_ios::GetPositionCache(_bookmarkModel, &outItem,
191 &outPosition);
192 ASSERT_TRUE(result); 204 ASSERT_TRUE(result);
193 EXPECT_NSEQ(item, outItem); 205 EXPECT_NSEQ(item, outItem);
194 EXPECT_NEAR(position, outPosition, 0.01); 206 EXPECT_NEAR(position, outPosition, 0.01);
195 EXPECT_EQ(f1, outItem.folder); 207 EXPECT_EQ(f1, outItem.folder);
196 EXPECT_EQ(bookmarks::MenuItemFolder, outItem.type); 208 EXPECT_EQ(bookmarks::MenuItemFolder, outItem.type);
197 } 209 }
198 210
199 TEST_F(BookmarkIOSUtilsUnitTest, TestBookmarkModelChangesPositionCache) { 211 TEST_F(BookmarkIOSUtilsUnitTest, TestBookmarkModelChangesPositionCache) {
200 // Try to store and retrieve a cache for the folderMenuItem 212 // Try to store and retrieve a cache for the folderMenuItem
201 const BookmarkNode* mobileNode = _bookmarkModel->mobile_node(); 213 const BookmarkNode* mobileNode = _bookmarkModel->mobile_node();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 vector1.push_back(bookmark1); 399 vector1.push_back(bookmark1);
388 vector2.insert(vector2.begin(), bookmark1); 400 vector2.insert(vector2.begin(), bookmark1);
389 missingNodesIndices = 401 missingNodesIndices =
390 bookmark_utils_ios::MissingNodesIndices(vector1, vector2); 402 bookmark_utils_ios::MissingNodesIndices(vector1, vector2);
391 EXPECT_EQ(2u, missingNodesIndices.size()); 403 EXPECT_EQ(2u, missingNodesIndices.size());
392 EXPECT_EQ(2u, missingNodesIndices[0]); 404 EXPECT_EQ(2u, missingNodesIndices[0]);
393 EXPECT_EQ(3u, missingNodesIndices[1]); 405 EXPECT_EQ(3u, missingNodesIndices[1]);
394 } 406 }
395 407
396 } // namespace 408 } // 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