| 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 "chrome/browser/ui/bookmarks/bookmark_editor.h" | 5 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/bookmarks/test_bookmark_client.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 10 |
| 10 using base::ASCIIToUTF16; | 11 using base::ASCIIToUTF16; |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 TEST(BookmarkEditorTest, ApplyEditsWithNoFolderChange) { | 15 TEST(BookmarkEditorTest, ApplyEditsWithNoFolderChange) { |
| 15 BookmarkModel model(NULL, false); | 16 test::TestBookmarkClient client; |
| 16 const BookmarkNode* bookmarkbar = model.bookmark_bar_node(); | 17 scoped_ptr<BookmarkModel> model(client.CreateModel(false)); |
| 17 model.AddURL(bookmarkbar, 0, ASCIIToUTF16("url0"), GURL("chrome://newtab")); | 18 const BookmarkNode* bookmarkbar = model->bookmark_bar_node(); |
| 18 model.AddURL(bookmarkbar, 1, ASCIIToUTF16("url1"), GURL("chrome://newtab")); | 19 model->AddURL(bookmarkbar, 0, ASCIIToUTF16("url0"), GURL("chrome://newtab")); |
| 20 model->AddURL(bookmarkbar, 1, ASCIIToUTF16("url1"), GURL("chrome://newtab")); |
| 19 | 21 |
| 20 { | 22 { |
| 21 BookmarkEditor::EditDetails detail( | 23 BookmarkEditor::EditDetails detail( |
| 22 BookmarkEditor::EditDetails::AddFolder(bookmarkbar, 1)); | 24 BookmarkEditor::EditDetails::AddFolder(bookmarkbar, 1)); |
| 23 BookmarkEditor::ApplyEditsWithNoFolderChange(&model, | 25 BookmarkEditor::ApplyEditsWithNoFolderChange(model.get(), |
| 24 bookmarkbar, | 26 bookmarkbar, |
| 25 detail, | 27 detail, |
| 26 ASCIIToUTF16("folder0"), | 28 ASCIIToUTF16("folder0"), |
| 27 GURL(std::string())); | 29 GURL(std::string())); |
| 28 EXPECT_EQ(ASCIIToUTF16("folder0"), bookmarkbar->GetChild(1)->GetTitle()); | 30 EXPECT_EQ(ASCIIToUTF16("folder0"), bookmarkbar->GetChild(1)->GetTitle()); |
| 29 } | 31 } |
| 30 { | 32 { |
| 31 BookmarkEditor::EditDetails detail( | 33 BookmarkEditor::EditDetails detail( |
| 32 BookmarkEditor::EditDetails::AddFolder(bookmarkbar, -1)); | 34 BookmarkEditor::EditDetails::AddFolder(bookmarkbar, -1)); |
| 33 BookmarkEditor::ApplyEditsWithNoFolderChange(&model, | 35 BookmarkEditor::ApplyEditsWithNoFolderChange(model.get(), |
| 34 bookmarkbar, | 36 bookmarkbar, |
| 35 detail, | 37 detail, |
| 36 ASCIIToUTF16("folder1"), | 38 ASCIIToUTF16("folder1"), |
| 37 GURL(std::string())); | 39 GURL(std::string())); |
| 38 EXPECT_EQ(ASCIIToUTF16("folder1"), bookmarkbar->GetChild(3)->GetTitle()); | 40 EXPECT_EQ(ASCIIToUTF16("folder1"), bookmarkbar->GetChild(3)->GetTitle()); |
| 39 } | 41 } |
| 40 { | 42 { |
| 41 BookmarkEditor::EditDetails detail( | 43 BookmarkEditor::EditDetails detail( |
| 42 BookmarkEditor::EditDetails::AddFolder(bookmarkbar, 10)); | 44 BookmarkEditor::EditDetails::AddFolder(bookmarkbar, 10)); |
| 43 BookmarkEditor::ApplyEditsWithNoFolderChange(&model, | 45 BookmarkEditor::ApplyEditsWithNoFolderChange(model.get(), |
| 44 bookmarkbar, | 46 bookmarkbar, |
| 45 detail, | 47 detail, |
| 46 ASCIIToUTF16("folder2"), | 48 ASCIIToUTF16("folder2"), |
| 47 GURL(std::string())); | 49 GURL(std::string())); |
| 48 EXPECT_EQ(ASCIIToUTF16("folder2"), bookmarkbar->GetChild(4)->GetTitle()); | 50 EXPECT_EQ(ASCIIToUTF16("folder2"), bookmarkbar->GetChild(4)->GetTitle()); |
| 49 } | 51 } |
| 50 } | 52 } |
| 51 | 53 |
| 52 } // namespace | 54 } // namespace |
| OLD | NEW |