| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 model_->AddURL(of1, 0, ASCIIToUTF16("of1a"), GURL(test_base + "of1a")); | 94 model_->AddURL(of1, 0, ASCIIToUTF16("of1a"), GURL(test_base + "of1a")); |
| 95 | 95 |
| 96 // Children of the synced node. | 96 // Children of the synced node. |
| 97 model_->AddURL(model_->synced_node(), 0, ASCIIToUTF16("sa"), | 97 model_->AddURL(model_->synced_node(), 0, ASCIIToUTF16("sa"), |
| 98 GURL(test_base + "sa")); | 98 GURL(test_base + "sa")); |
| 99 } | 99 } |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 // Makes sure the tree model matches that of the bookmark bar model. | 102 // Makes sure the tree model matches that of the bookmark bar model. |
| 103 TEST_F(BookmarkEditorGtkTest, ModelsMatch) { | 103 TEST_F(BookmarkEditorGtkTest, ModelsMatch) { |
| 104 BookmarkEditorGtk editor(NULL, profile_.get(), NULL, | 104 BookmarkEditorGtk editor( |
| 105 BookmarkEditor::EditDetails::AddNodeInFolder(NULL), | 105 NULL, |
| 106 BookmarkEditor::SHOW_TREE); | 106 profile_.get(), |
| 107 NULL, |
| 108 BookmarkEditor::EditDetails::AddNodeInFolder(NULL, -1), |
| 109 BookmarkEditor::SHOW_TREE); |
| 107 | 110 |
| 108 // The root should have two or three children, one for the bookmark bar node, | 111 // The root should have two or three children, one for the bookmark bar node, |
| 109 // another for the 'other bookmarks' folder, and depending on the visib | 112 // another for the 'other bookmarks' folder, and depending on the visib |
| 110 GtkTreeModel* store = GTK_TREE_MODEL(editor.tree_store_); | 113 GtkTreeModel* store = GTK_TREE_MODEL(editor.tree_store_); |
| 111 GtkTreeIter toplevel; | 114 GtkTreeIter toplevel; |
| 112 ASSERT_TRUE(gtk_tree_model_get_iter_first(store, &toplevel)); | 115 ASSERT_TRUE(gtk_tree_model_get_iter_first(store, &toplevel)); |
| 113 GtkTreeIter bookmark_bar_node = toplevel; | 116 GtkTreeIter bookmark_bar_node = toplevel; |
| 114 ASSERT_TRUE(gtk_tree_model_iter_next(store, &toplevel)); | 117 ASSERT_TRUE(gtk_tree_model_iter_next(store, &toplevel)); |
| 115 GtkTreeIter other_node = toplevel; | 118 GtkTreeIter other_node = toplevel; |
| 116 if (model_->synced_node()->IsVisible()) { | 119 if (model_->synced_node()->IsVisible()) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 ASSERT_EQ(ASCIIToUTF16("a"), mf2->GetChild(1)->GetTitle()); | 273 ASSERT_EQ(ASCIIToUTF16("a"), mf2->GetChild(1)->GetTitle()); |
| 271 | 274 |
| 272 // F21 should have one child, F211. | 275 // F21 should have one child, F211. |
| 273 const BookmarkNode* mf21 = mf2->GetChild(0); | 276 const BookmarkNode* mf21 = mf2->GetChild(0); |
| 274 ASSERT_EQ(1, mf21->child_count()); | 277 ASSERT_EQ(1, mf21->child_count()); |
| 275 ASSERT_EQ(ASCIIToUTF16("F211"), mf21->GetChild(0)->GetTitle()); | 278 ASSERT_EQ(ASCIIToUTF16("F211"), mf21->GetChild(0)->GetTitle()); |
| 276 } | 279 } |
| 277 | 280 |
| 278 // Brings up the editor, creating a new URL on the bookmark bar. | 281 // Brings up the editor, creating a new URL on the bookmark bar. |
| 279 TEST_F(BookmarkEditorGtkTest, NewURL) { | 282 TEST_F(BookmarkEditorGtkTest, NewURL) { |
| 280 BookmarkEditorGtk editor(NULL, profile_.get(), NULL, | 283 BookmarkEditorGtk editor( |
| 281 BookmarkEditor::EditDetails::AddNodeInFolder(NULL), | 284 NULL, |
| 282 BookmarkEditor::SHOW_TREE); | 285 profile_.get(), |
| 286 NULL, |
| 287 BookmarkEditor::EditDetails::AddNodeInFolder(NULL, -1), |
| 288 BookmarkEditor::SHOW_TREE); |
| 283 | 289 |
| 284 gtk_entry_set_text(GTK_ENTRY(editor.url_entry_), | 290 gtk_entry_set_text(GTK_ENTRY(editor.url_entry_), |
| 285 GURL(base_path() + "a").spec().c_str()); | 291 GURL(base_path() + "a").spec().c_str()); |
| 286 gtk_entry_set_text(GTK_ENTRY(editor.name_entry_), "new_a"); | 292 gtk_entry_set_text(GTK_ENTRY(editor.name_entry_), "new_a"); |
| 287 | 293 |
| 288 GtkTreeIter bookmark_bar_node; | 294 GtkTreeIter bookmark_bar_node; |
| 289 GtkTreeModel* store = GTK_TREE_MODEL(editor.tree_store_); | 295 GtkTreeModel* store = GTK_TREE_MODEL(editor.tree_store_); |
| 290 ASSERT_TRUE(gtk_tree_model_get_iter_first(store, &bookmark_bar_node)); | 296 ASSERT_TRUE(gtk_tree_model_get_iter_first(store, &bookmark_bar_node)); |
| 291 editor.ApplyEdits(&bookmark_bar_node); | 297 editor.ApplyEdits(&bookmark_bar_node); |
| 292 | 298 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 gtk_entry_set_text(GTK_ENTRY(editor.name_entry_), "new_a"); | 336 gtk_entry_set_text(GTK_ENTRY(editor.name_entry_), "new_a"); |
| 331 | 337 |
| 332 editor.ApplyEdits(); | 338 editor.ApplyEdits(); |
| 333 | 339 |
| 334 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); | 340 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); |
| 335 ASSERT_EQ(2, other_node->child_count()); | 341 ASSERT_EQ(2, other_node->child_count()); |
| 336 | 342 |
| 337 const BookmarkNode* new_node = other_node->GetChild(0); | 343 const BookmarkNode* new_node = other_node->GetChild(0); |
| 338 EXPECT_EQ(ASCIIToUTF16("new_a"), new_node->GetTitle()); | 344 EXPECT_EQ(ASCIIToUTF16("new_a"), new_node->GetTitle()); |
| 339 } | 345 } |
| OLD | NEW |