| 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_utils.h" | 5 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_editor.h" | 9 #include "chrome/browser/bookmarks/bookmark_editor.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 TEST_F(BookmarkUtilsTest, ApplyEditsWithNoFolderChange) { | 160 TEST_F(BookmarkUtilsTest, ApplyEditsWithNoFolderChange) { |
| 161 BookmarkModel model(NULL); | 161 BookmarkModel model(NULL); |
| 162 const BookmarkNode* bookmarkbar = model.bookmark_bar_node(); | 162 const BookmarkNode* bookmarkbar = model.bookmark_bar_node(); |
| 163 model.AddURL(bookmarkbar, 0, ASCIIToUTF16("url0"), GURL("chrome://newtab")); | 163 model.AddURL(bookmarkbar, 0, ASCIIToUTF16("url0"), GURL("chrome://newtab")); |
| 164 model.AddURL(bookmarkbar, 1, ASCIIToUTF16("url1"), GURL("chrome://newtab")); | 164 model.AddURL(bookmarkbar, 1, ASCIIToUTF16("url1"), GURL("chrome://newtab")); |
| 165 | 165 |
| 166 { | 166 { |
| 167 BookmarkEditor::EditDetails detail( | 167 BookmarkEditor::EditDetails detail( |
| 168 BookmarkEditor::EditDetails::AddFolder(bookmarkbar, 1)); | 168 BookmarkEditor::EditDetails::AddFolder(bookmarkbar, 1)); |
| 169 ApplyEditsWithNoFolderChange(&model, bookmarkbar, detail, | 169 ApplyEditsWithNoFolderChange(&model, |
| 170 ASCIIToUTF16("folder0"), GURL("")); | 170 bookmarkbar, |
| 171 detail, |
| 172 ASCIIToUTF16("folder0"), |
| 173 GURL(std::string())); |
| 171 EXPECT_EQ(ASCIIToUTF16("folder0"), bookmarkbar->GetChild(1)->GetTitle()); | 174 EXPECT_EQ(ASCIIToUTF16("folder0"), bookmarkbar->GetChild(1)->GetTitle()); |
| 172 } | 175 } |
| 173 { | 176 { |
| 174 BookmarkEditor::EditDetails detail( | 177 BookmarkEditor::EditDetails detail( |
| 175 BookmarkEditor::EditDetails::AddFolder(bookmarkbar, -1)); | 178 BookmarkEditor::EditDetails::AddFolder(bookmarkbar, -1)); |
| 176 ApplyEditsWithNoFolderChange(&model, bookmarkbar, detail, | 179 ApplyEditsWithNoFolderChange(&model, |
| 177 ASCIIToUTF16("folder1"), GURL("")); | 180 bookmarkbar, |
| 181 detail, |
| 182 ASCIIToUTF16("folder1"), |
| 183 GURL(std::string())); |
| 178 EXPECT_EQ(ASCIIToUTF16("folder1"), bookmarkbar->GetChild(3)->GetTitle()); | 184 EXPECT_EQ(ASCIIToUTF16("folder1"), bookmarkbar->GetChild(3)->GetTitle()); |
| 179 } | 185 } |
| 180 { | 186 { |
| 181 BookmarkEditor::EditDetails detail( | 187 BookmarkEditor::EditDetails detail( |
| 182 BookmarkEditor::EditDetails::AddFolder(bookmarkbar, 10)); | 188 BookmarkEditor::EditDetails::AddFolder(bookmarkbar, 10)); |
| 183 ApplyEditsWithNoFolderChange(&model, bookmarkbar, detail, | 189 ApplyEditsWithNoFolderChange(&model, |
| 184 ASCIIToUTF16("folder2"), GURL("")); | 190 bookmarkbar, |
| 191 detail, |
| 192 ASCIIToUTF16("folder2"), |
| 193 GURL(std::string())); |
| 185 EXPECT_EQ(ASCIIToUTF16("folder2"), bookmarkbar->GetChild(4)->GetTitle()); | 194 EXPECT_EQ(ASCIIToUTF16("folder2"), bookmarkbar->GetChild(4)->GetTitle()); |
| 186 } | 195 } |
| 187 } | 196 } |
| 188 | 197 |
| 189 TEST_F(BookmarkUtilsTest, GetParentForNewNodes) { | 198 TEST_F(BookmarkUtilsTest, GetParentForNewNodes) { |
| 190 BookmarkModel model(NULL); | 199 BookmarkModel model(NULL); |
| 191 // This tests the case where selection contains one item and that item is a | 200 // This tests the case where selection contains one item and that item is a |
| 192 // folder. | 201 // folder. |
| 193 std::vector<const BookmarkNode*> nodes; | 202 std::vector<const BookmarkNode*> nodes; |
| 194 nodes.push_back(model.bookmark_bar_node()); | 203 nodes.push_back(model.bookmark_bar_node()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 220 | 229 |
| 221 // This tests the case where selection doesn't contain any items. | 230 // This tests the case where selection doesn't contain any items. |
| 222 nodes.clear(); | 231 nodes.clear(); |
| 223 real_parent = GetParentForNewNodes(model.bookmark_bar_node(), nodes, &index); | 232 real_parent = GetParentForNewNodes(model.bookmark_bar_node(), nodes, &index); |
| 224 EXPECT_EQ(real_parent, model.bookmark_bar_node()); | 233 EXPECT_EQ(real_parent, model.bookmark_bar_node()); |
| 225 EXPECT_EQ(2, index); | 234 EXPECT_EQ(2, index); |
| 226 } | 235 } |
| 227 | 236 |
| 228 } // namespace | 237 } // namespace |
| 229 } // namespace bookmark_utils | 238 } // namespace bookmark_utils |
| OLD | NEW |