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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/bookmarks/bookmark_editor.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "components/bookmarks/browser/bookmark_model.h"
9 #include "components/bookmarks/test/test_bookmark_client.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 using base::ASCIIToUTF16
;
13 using bookmarks::BookmarkModel
;
14 using bookmarks::BookmarkNode
;
18 TEST(BookmarkEditorTest
, ApplyEditsWithNoFolderChange
) {
19 bookmarks::TestBookmarkClient client
;
20 scoped_ptr
<BookmarkModel
> model(client
.CreateModel());
21 const BookmarkNode
* bookmarkbar
= model
->bookmark_bar_node();
22 model
->AddURL(bookmarkbar
, 0, ASCIIToUTF16("url0"), GURL("chrome://newtab"));
23 model
->AddURL(bookmarkbar
, 1, ASCIIToUTF16("url1"), GURL("chrome://newtab"));
26 BookmarkEditor::EditDetails
detail(
27 BookmarkEditor::EditDetails::AddFolder(bookmarkbar
, 1));
28 BookmarkEditor::ApplyEditsWithNoFolderChange(model
.get(),
31 ASCIIToUTF16("folder0"),
33 EXPECT_EQ(ASCIIToUTF16("folder0"), bookmarkbar
->GetChild(1)->GetTitle());
36 BookmarkEditor::EditDetails
detail(
37 BookmarkEditor::EditDetails::AddFolder(bookmarkbar
, -1));
38 BookmarkEditor::ApplyEditsWithNoFolderChange(model
.get(),
41 ASCIIToUTF16("folder1"),
43 EXPECT_EQ(ASCIIToUTF16("folder1"), bookmarkbar
->GetChild(3)->GetTitle());
46 BookmarkEditor::EditDetails
detail(
47 BookmarkEditor::EditDetails::AddFolder(bookmarkbar
, 10));
48 BookmarkEditor::ApplyEditsWithNoFolderChange(model
.get(),
51 ASCIIToUTF16("folder2"),
53 EXPECT_EQ(ASCIIToUTF16("folder2"), bookmarkbar
->GetChild(4)->GetTitle());