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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 const BookmarkNode* of1 = | 123 const BookmarkNode* of1 = |
124 model_->AddFolder(model_->other_node(), 1, ASCIIToUTF16("OF1")); | 124 model_->AddFolder(model_->other_node(), 1, ASCIIToUTF16("OF1")); |
125 model_->AddURL(of1, 0, ASCIIToUTF16("of1a"), GURL(test_base + "of1a")); | 125 model_->AddURL(of1, 0, ASCIIToUTF16("of1a"), GURL(test_base + "of1a")); |
126 } | 126 } |
127 | 127 |
128 scoped_ptr<BookmarkEditorView> editor_; | 128 scoped_ptr<BookmarkEditorView> editor_; |
129 }; | 129 }; |
130 | 130 |
131 // Makes sure the tree model matches that of the bookmark bar model. | 131 // Makes sure the tree model matches that of the bookmark bar model. |
132 TEST_F(BookmarkEditorViewTest, ModelsMatch) { | 132 TEST_F(BookmarkEditorViewTest, ModelsMatch) { |
133 CreateEditor(profile_.get(), NULL, | 133 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(), |
134 BookmarkEditor::EditDetails::AddNodeInFolder(NULL), | |
135 BookmarkEditorView::SHOW_TREE); | 134 BookmarkEditorView::SHOW_TREE); |
136 BookmarkEditorView::EditorNode* editor_root = editor_tree_model()->GetRoot(); | 135 BookmarkEditorView::EditorNode* editor_root = editor_tree_model()->GetRoot(); |
137 // The root should have two or three children: bookmark bar, other bookmarks | 136 // The root should have two or three children: bookmark bar, other bookmarks |
138 // and conditionally synced bookmarks. | 137 // and conditionally synced bookmarks. |
139 if (model_->synced_node()->IsVisible()) { | 138 if (model_->synced_node()->IsVisible()) { |
140 ASSERT_EQ(3, editor_root->child_count()); | 139 ASSERT_EQ(3, editor_root->child_count()); |
141 } else { | 140 } else { |
142 ASSERT_EQ(2, editor_root->child_count()); | 141 ASSERT_EQ(2, editor_root->child_count()); |
143 } | 142 } |
144 | 143 |
145 BookmarkEditorView::EditorNode* bb_node = editor_root->GetChild(0); | 144 BookmarkEditorView::EditorNode* bb_node = editor_root->GetChild(0); |
146 // The root should have 2 nodes: folder F1 and F2. | 145 // The root should have 2 nodes: folder F1 and F2. |
147 ASSERT_EQ(2, bb_node->child_count()); | 146 ASSERT_EQ(2, bb_node->child_count()); |
148 ASSERT_EQ(ASCIIToUTF16("F1"), bb_node->GetChild(0)->GetTitle()); | 147 ASSERT_EQ(ASCIIToUTF16("F1"), bb_node->GetChild(0)->GetTitle()); |
149 ASSERT_EQ(ASCIIToUTF16("F2"), bb_node->GetChild(1)->GetTitle()); | 148 ASSERT_EQ(ASCIIToUTF16("F2"), bb_node->GetChild(1)->GetTitle()); |
150 | 149 |
151 // F1 should have one child, F11 | 150 // F1 should have one child, F11 |
152 ASSERT_EQ(1, bb_node->GetChild(0)->child_count()); | 151 ASSERT_EQ(1, bb_node->GetChild(0)->child_count()); |
153 ASSERT_EQ(ASCIIToUTF16("F11"), bb_node->GetChild(0)->GetChild(0)->GetTitle()); | 152 ASSERT_EQ(ASCIIToUTF16("F11"), bb_node->GetChild(0)->GetChild(0)->GetTitle()); |
154 | 153 |
155 BookmarkEditorView::EditorNode* other_node = editor_root->GetChild(1); | 154 BookmarkEditorView::EditorNode* other_node = editor_root->GetChild(1); |
156 // Other node should have one child (OF1). | 155 // Other node should have one child (OF1). |
157 ASSERT_EQ(1, other_node->child_count()); | 156 ASSERT_EQ(1, other_node->child_count()); |
158 ASSERT_EQ(ASCIIToUTF16("OF1"), other_node->GetChild(0)->GetTitle()); | 157 ASSERT_EQ(ASCIIToUTF16("OF1"), other_node->GetChild(0)->GetTitle()); |
159 } | 158 } |
160 | 159 |
161 // Changes the title and makes sure parent/visual order doesn't change. | 160 // Changes the title and makes sure parent/visual order doesn't change. |
162 TEST_F(BookmarkEditorViewTest, EditTitleKeepsPosition) { | 161 TEST_F(BookmarkEditorViewTest, EditTitleKeepsPosition) { |
163 CreateEditor(profile_.get(), NULL, | 162 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), |
164 BookmarkEditor::EditDetails::EditNode(GetNode("a")), | |
165 BookmarkEditorView::SHOW_TREE); | 163 BookmarkEditorView::SHOW_TREE); |
166 SetTitleText(L"new_a"); | 164 SetTitleText(L"new_a"); |
167 | 165 |
168 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); | 166 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); |
169 | 167 |
170 const BookmarkNode* bb_node = | 168 const BookmarkNode* bb_node = |
171 profile_->GetBookmarkModel()->bookmark_bar_node(); | 169 profile_->GetBookmarkModel()->bookmark_bar_node(); |
172 ASSERT_EQ(ASCIIToUTF16("new_a"), bb_node->GetChild(0)->GetTitle()); | 170 ASSERT_EQ(ASCIIToUTF16("new_a"), bb_node->GetChild(0)->GetTitle()); |
173 // The URL shouldn't have changed. | 171 // The URL shouldn't have changed. |
174 ASSERT_TRUE(GURL(base_path() + "a") == bb_node->GetChild(0)->url()); | 172 ASSERT_TRUE(GURL(base_path() + "a") == bb_node->GetChild(0)->url()); |
175 } | 173 } |
176 | 174 |
177 // Changes the url and makes sure parent/visual order doesn't change. | 175 // Changes the url and makes sure parent/visual order doesn't change. |
178 TEST_F(BookmarkEditorViewTest, EditURLKeepsPosition) { | 176 TEST_F(BookmarkEditorViewTest, EditURLKeepsPosition) { |
179 Time node_time = Time::Now() + TimeDelta::FromDays(2); | 177 Time node_time = Time::Now() + TimeDelta::FromDays(2); |
180 GetMutableNode("a")->set_date_added(node_time); | 178 GetMutableNode("a")->set_date_added(node_time); |
181 CreateEditor(profile_.get(), NULL, | 179 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), |
182 BookmarkEditor::EditDetails::EditNode(GetNode("a")), | |
183 BookmarkEditorView::SHOW_TREE); | 180 BookmarkEditorView::SHOW_TREE); |
184 | 181 |
185 SetURLText(UTF8ToWide(GURL(base_path() + "new_a").spec())); | 182 SetURLText(UTF8ToWide(GURL(base_path() + "new_a").spec())); |
186 | 183 |
187 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); | 184 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); |
188 | 185 |
189 const BookmarkNode* bb_node = | 186 const BookmarkNode* bb_node = |
190 profile_->GetBookmarkModel()->bookmark_bar_node(); | 187 profile_->GetBookmarkModel()->bookmark_bar_node(); |
191 ASSERT_EQ(ASCIIToUTF16("a"), bb_node->GetChild(0)->GetTitle()); | 188 ASSERT_EQ(ASCIIToUTF16("a"), bb_node->GetChild(0)->GetTitle()); |
192 // The URL should have changed. | 189 // The URL should have changed. |
193 ASSERT_TRUE(GURL(base_path() + "new_a") == bb_node->GetChild(0)->url()); | 190 ASSERT_TRUE(GURL(base_path() + "new_a") == bb_node->GetChild(0)->url()); |
194 ASSERT_TRUE(node_time == bb_node->GetChild(0)->date_added()); | 191 ASSERT_TRUE(node_time == bb_node->GetChild(0)->date_added()); |
195 } | 192 } |
196 | 193 |
197 // Moves 'a' to be a child of the other node. | 194 // Moves 'a' to be a child of the other node. |
198 TEST_F(BookmarkEditorViewTest, ChangeParent) { | 195 TEST_F(BookmarkEditorViewTest, ChangeParent) { |
199 CreateEditor(profile_.get(), NULL, | 196 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), |
200 BookmarkEditor::EditDetails::EditNode(GetNode("a")), | |
201 BookmarkEditorView::SHOW_TREE); | 197 BookmarkEditorView::SHOW_TREE); |
202 | 198 |
203 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1)); | 199 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1)); |
204 | 200 |
205 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); | 201 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); |
206 ASSERT_EQ(ASCIIToUTF16("a"), other_node->GetChild(2)->GetTitle()); | 202 ASSERT_EQ(ASCIIToUTF16("a"), other_node->GetChild(2)->GetTitle()); |
207 ASSERT_TRUE(GURL(base_path() + "a") == other_node->GetChild(2)->url()); | 203 ASSERT_TRUE(GURL(base_path() + "a") == other_node->GetChild(2)->url()); |
208 } | 204 } |
209 | 205 |
210 // Moves 'a' to be a child of the other node and changes its url to new_a. | 206 // Moves 'a' to be a child of the other node and changes its url to new_a. |
211 TEST_F(BookmarkEditorViewTest, ChangeParentAndURL) { | 207 TEST_F(BookmarkEditorViewTest, ChangeParentAndURL) { |
212 Time node_time = Time::Now() + TimeDelta::FromDays(2); | 208 Time node_time = Time::Now() + TimeDelta::FromDays(2); |
213 GetMutableNode("a")->set_date_added(node_time); | 209 GetMutableNode("a")->set_date_added(node_time); |
214 CreateEditor(profile_.get(), NULL, | 210 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), |
215 BookmarkEditor::EditDetails::EditNode(GetNode("a")), | |
216 BookmarkEditorView::SHOW_TREE); | 211 BookmarkEditorView::SHOW_TREE); |
217 | 212 |
218 SetURLText(UTF8ToWide(GURL(base_path() + "new_a").spec())); | 213 SetURLText(UTF8ToWide(GURL(base_path() + "new_a").spec())); |
219 | 214 |
220 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1)); | 215 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1)); |
221 | 216 |
222 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); | 217 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); |
223 ASSERT_EQ(ASCIIToUTF16("a"), other_node->GetChild(2)->GetTitle()); | 218 ASSERT_EQ(ASCIIToUTF16("a"), other_node->GetChild(2)->GetTitle()); |
224 ASSERT_TRUE(GURL(base_path() + "new_a") == other_node->GetChild(2)->url()); | 219 ASSERT_TRUE(GURL(base_path() + "new_a") == other_node->GetChild(2)->url()); |
225 ASSERT_TRUE(node_time == other_node->GetChild(2)->date_added()); | 220 ASSERT_TRUE(node_time == other_node->GetChild(2)->date_added()); |
226 } | 221 } |
227 | 222 |
228 // Creates a new folder and moves a node to it. | 223 // Creates a new folder and moves a node to it. |
229 TEST_F(BookmarkEditorViewTest, MoveToNewParent) { | 224 TEST_F(BookmarkEditorViewTest, MoveToNewParent) { |
230 CreateEditor(profile_.get(), NULL, | 225 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), |
231 BookmarkEditor::EditDetails::EditNode(GetNode("a")), | |
232 BookmarkEditorView::SHOW_TREE); | 226 BookmarkEditorView::SHOW_TREE); |
233 | 227 |
234 // Create two nodes: "F21" as a child of "F2" and "F211" as a child of "F21". | 228 // Create two nodes: "F21" as a child of "F2" and "F211" as a child of "F21". |
235 BookmarkEditorView::EditorNode* f2 = | 229 BookmarkEditorView::EditorNode* f2 = |
236 editor_tree_model()->GetRoot()->GetChild(0)->GetChild(1); | 230 editor_tree_model()->GetRoot()->GetChild(0)->GetChild(1); |
237 BookmarkEditorView::EditorNode* f21 = AddNewFolder(f2); | 231 BookmarkEditorView::EditorNode* f21 = AddNewFolder(f2); |
238 f21->set_title(ASCIIToUTF16("F21")); | 232 f21->set_title(ASCIIToUTF16("F21")); |
239 BookmarkEditorView::EditorNode* f211 = AddNewFolder(f21); | 233 BookmarkEditorView::EditorNode* f211 = AddNewFolder(f21); |
240 f211->set_title(ASCIIToUTF16("F211")); | 234 f211->set_title(ASCIIToUTF16("F211")); |
241 | 235 |
(...skipping 12 matching lines...) Expand all Loading... |
254 ASSERT_EQ(ASCIIToUTF16("a"), mf2->GetChild(1)->GetTitle()); | 248 ASSERT_EQ(ASCIIToUTF16("a"), mf2->GetChild(1)->GetTitle()); |
255 | 249 |
256 // F21 should have one child, F211. | 250 // F21 should have one child, F211. |
257 const BookmarkNode* mf21 = mf2->GetChild(0); | 251 const BookmarkNode* mf21 = mf2->GetChild(0); |
258 ASSERT_EQ(1, mf21->child_count()); | 252 ASSERT_EQ(1, mf21->child_count()); |
259 ASSERT_EQ(ASCIIToUTF16("F211"), mf21->GetChild(0)->GetTitle()); | 253 ASSERT_EQ(ASCIIToUTF16("F211"), mf21->GetChild(0)->GetTitle()); |
260 } | 254 } |
261 | 255 |
262 // Brings up the editor, creating a new URL on the bookmark bar. | 256 // Brings up the editor, creating a new URL on the bookmark bar. |
263 TEST_F(BookmarkEditorViewTest, NewURL) { | 257 TEST_F(BookmarkEditorViewTest, NewURL) { |
264 CreateEditor(profile_.get(), NULL, | 258 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(), |
265 BookmarkEditor::EditDetails::AddNodeInFolder(NULL), | |
266 BookmarkEditorView::SHOW_TREE); | 259 BookmarkEditorView::SHOW_TREE); |
267 | 260 |
268 SetURLText(UTF8ToWide(GURL(base_path() + "a").spec())); | 261 SetURLText(UTF8ToWide(GURL(base_path() + "a").spec())); |
269 SetTitleText(L"new_a"); | 262 SetTitleText(L"new_a"); |
270 | 263 |
271 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); | 264 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); |
272 | 265 |
273 const BookmarkNode* bb_node = | 266 const BookmarkNode* bb_node = |
274 profile_->GetBookmarkModel()->bookmark_bar_node(); | 267 profile_->GetBookmarkModel()->bookmark_bar_node(); |
275 ASSERT_EQ(4, bb_node->child_count()); | 268 ASSERT_EQ(4, bb_node->child_count()); |
276 | 269 |
277 const BookmarkNode* new_node = bb_node->GetChild(3); | 270 const BookmarkNode* new_node = bb_node->GetChild(3); |
278 | 271 |
279 EXPECT_EQ(ASCIIToUTF16("new_a"), new_node->GetTitle()); | 272 EXPECT_EQ(ASCIIToUTF16("new_a"), new_node->GetTitle()); |
280 EXPECT_TRUE(GURL(base_path() + "a") == new_node->url()); | 273 EXPECT_TRUE(GURL(base_path() + "a") == new_node->url()); |
281 } | 274 } |
282 | 275 |
283 // Brings up the editor with no tree and modifies the url. | 276 // Brings up the editor with no tree and modifies the url. |
284 TEST_F(BookmarkEditorViewTest, ChangeURLNoTree) { | 277 TEST_F(BookmarkEditorViewTest, ChangeURLNoTree) { |
285 CreateEditor(profile_.get(), NULL, | 278 CreateEditor(profile_.get(), NULL, |
286 BookmarkEditor::EditDetails::EditNode( | 279 BookmarkEditor::EditDetails(model_->other_node()->GetChild(0)), |
287 model_->other_node()->GetChild(0)), | |
288 BookmarkEditorView::NO_TREE); | 280 BookmarkEditorView::NO_TREE); |
289 | 281 |
290 SetURLText(UTF8ToWide(GURL(base_path() + "a").spec())); | 282 SetURLText(UTF8ToWide(GURL(base_path() + "a").spec())); |
291 SetTitleText(L"new_a"); | 283 SetTitleText(L"new_a"); |
292 | 284 |
293 ApplyEdits(NULL); | 285 ApplyEdits(NULL); |
294 | 286 |
295 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); | 287 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); |
296 ASSERT_EQ(2, other_node->child_count()); | 288 ASSERT_EQ(2, other_node->child_count()); |
297 | 289 |
298 const BookmarkNode* new_node = other_node->GetChild(0); | 290 const BookmarkNode* new_node = other_node->GetChild(0); |
299 | 291 |
300 EXPECT_EQ(ASCIIToUTF16("new_a"), new_node->GetTitle()); | 292 EXPECT_EQ(ASCIIToUTF16("new_a"), new_node->GetTitle()); |
301 EXPECT_TRUE(GURL(base_path() + "a") == new_node->url()); | 293 EXPECT_TRUE(GURL(base_path() + "a") == new_node->url()); |
302 } | 294 } |
303 | 295 |
304 // Brings up the editor with no tree and modifies only the title. | 296 // Brings up the editor with no tree and modifies only the title. |
305 TEST_F(BookmarkEditorViewTest, ChangeTitleNoTree) { | 297 TEST_F(BookmarkEditorViewTest, ChangeTitleNoTree) { |
306 CreateEditor(profile_.get(), NULL, | 298 CreateEditor(profile_.get(), NULL, |
307 BookmarkEditor::EditDetails::EditNode( | 299 BookmarkEditor::EditDetails(model_->other_node()->GetChild(0)), |
308 model_->other_node()->GetChild(0)), | |
309 BookmarkEditorView::NO_TREE); | 300 BookmarkEditorView::NO_TREE); |
310 | 301 |
311 SetTitleText(L"new_a"); | 302 SetTitleText(L"new_a"); |
312 | 303 |
313 ApplyEdits(NULL); | 304 ApplyEdits(NULL); |
314 | 305 |
315 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); | 306 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); |
316 ASSERT_EQ(2, other_node->child_count()); | 307 ASSERT_EQ(2, other_node->child_count()); |
317 | 308 |
318 const BookmarkNode* new_node = other_node->GetChild(0); | 309 const BookmarkNode* new_node = other_node->GetChild(0); |
319 | 310 |
320 EXPECT_EQ(ASCIIToUTF16("new_a"), new_node->GetTitle()); | 311 EXPECT_EQ(ASCIIToUTF16("new_a"), new_node->GetTitle()); |
321 } | 312 } |
322 | 313 |
323 // Creates a new folder. | 314 // Creates a new folder. |
324 TEST_F(BookmarkEditorViewTest, NewFolder) { | 315 TEST_F(BookmarkEditorViewTest, NewFolder) { |
325 const BookmarkNode* bb_node = model_->bookmark_bar_node(); | 316 const BookmarkNode* bb_node = model_->bookmark_bar_node(); |
326 BookmarkEditor::EditDetails details = | 317 BookmarkEditor::EditDetails details; |
327 BookmarkEditor::EditDetails::AddFolder(bb_node); | |
328 details.urls.push_back(std::make_pair(GURL(base_path() + "x"), | 318 details.urls.push_back(std::make_pair(GURL(base_path() + "x"), |
329 ASCIIToUTF16("z"))); | 319 ASCIIToUTF16("z"))); |
| 320 details.type = BookmarkEditor::EditDetails::NEW_FOLDER; |
330 CreateEditor(profile_.get(), bb_node, details, BookmarkEditorView::SHOW_TREE); | 321 CreateEditor(profile_.get(), bb_node, details, BookmarkEditorView::SHOW_TREE); |
331 | 322 |
332 // The url field shouldn't be visible. | 323 // The url field shouldn't be visible. |
333 EXPECT_FALSE(URLTFHasParent()); | 324 EXPECT_FALSE(URLTFHasParent()); |
334 SetTitleText(L"new_F"); | 325 SetTitleText(L"new_F"); |
335 | 326 |
336 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); | 327 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); |
337 | 328 |
338 // Make sure the folder was created. | 329 // Make sure the folder was created. |
339 ASSERT_EQ(4, bb_node->child_count()); | 330 ASSERT_EQ(4, bb_node->child_count()); |
340 const BookmarkNode* new_node = bb_node->GetChild(3); | 331 const BookmarkNode* new_node = bb_node->GetChild(3); |
341 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type()); | 332 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type()); |
342 EXPECT_EQ(ASCIIToUTF16("new_F"), new_node->GetTitle()); | 333 EXPECT_EQ(ASCIIToUTF16("new_F"), new_node->GetTitle()); |
343 // The node should have one child. | 334 // The node should have one child. |
344 ASSERT_EQ(1, new_node->child_count()); | 335 ASSERT_EQ(1, new_node->child_count()); |
345 const BookmarkNode* new_child = new_node->GetChild(0); | 336 const BookmarkNode* new_child = new_node->GetChild(0); |
346 // Make sure the child url/title match. | 337 // Make sure the child url/title match. |
347 EXPECT_EQ(BookmarkNode::URL, new_child->type()); | 338 EXPECT_EQ(BookmarkNode::URL, new_child->type()); |
348 EXPECT_EQ(WideToUTF16Hack(details.urls[0].second), new_child->GetTitle()); | 339 EXPECT_EQ(WideToUTF16Hack(details.urls[0].second), new_child->GetTitle()); |
349 EXPECT_EQ(details.urls[0].first, new_child->url()); | 340 EXPECT_EQ(details.urls[0].first, new_child->url()); |
350 } | 341 } |
351 | 342 |
352 // Creates a new folder and selects a different folder for the folder to appear | 343 // Creates a new folder and selects a different folder for the folder to appear |
353 // in then the editor is initially created showing. | 344 // in then the editor is initially created showing. |
354 TEST_F(BookmarkEditorViewTest, MoveFolder) { | 345 TEST_F(BookmarkEditorViewTest, MoveFolder) { |
355 BookmarkEditor::EditDetails details = BookmarkEditor::EditDetails::AddFolder( | 346 BookmarkEditor::EditDetails details; |
356 model_->bookmark_bar_node()); | |
357 details.urls.push_back(std::make_pair(GURL(base_path() + "x"), | 347 details.urls.push_back(std::make_pair(GURL(base_path() + "x"), |
358 ASCIIToUTF16("z"))); | 348 ASCIIToUTF16("z"))); |
| 349 details.type = BookmarkEditor::EditDetails::NEW_FOLDER; |
359 CreateEditor(profile_.get(), model_->bookmark_bar_node(), | 350 CreateEditor(profile_.get(), model_->bookmark_bar_node(), |
360 details, BookmarkEditorView::SHOW_TREE); | 351 details, BookmarkEditorView::SHOW_TREE); |
361 | 352 |
362 SetTitleText(L"new_F"); | 353 SetTitleText(L"new_F"); |
363 | 354 |
364 // Create the folder in the 'other' folder. | 355 // Create the folder in the 'other' folder. |
365 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1)); | 356 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1)); |
366 | 357 |
367 // Make sure the folder we edited is still there. | 358 // Make sure the folder we edited is still there. |
368 ASSERT_EQ(3, model_->other_node()->child_count()); | 359 ASSERT_EQ(3, model_->other_node()->child_count()); |
369 const BookmarkNode* new_node = model_->other_node()->GetChild(2); | 360 const BookmarkNode* new_node = model_->other_node()->GetChild(2); |
370 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type()); | 361 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type()); |
371 EXPECT_EQ(ASCIIToUTF16("new_F"), new_node->GetTitle()); | 362 EXPECT_EQ(ASCIIToUTF16("new_F"), new_node->GetTitle()); |
372 // The node should have one child. | 363 // The node should have one child. |
373 ASSERT_EQ(1, new_node->child_count()); | 364 ASSERT_EQ(1, new_node->child_count()); |
374 const BookmarkNode* new_child = new_node->GetChild(0); | 365 const BookmarkNode* new_child = new_node->GetChild(0); |
375 // Make sure the child url/title match. | 366 // Make sure the child url/title match. |
376 EXPECT_EQ(BookmarkNode::URL, new_child->type()); | 367 EXPECT_EQ(BookmarkNode::URL, new_child->type()); |
377 EXPECT_EQ(WideToUTF16Hack(details.urls[0].second), new_child->GetTitle()); | 368 EXPECT_EQ(WideToUTF16Hack(details.urls[0].second), new_child->GetTitle()); |
378 EXPECT_EQ(details.urls[0].first, new_child->url()); | 369 EXPECT_EQ(details.urls[0].first, new_child->url()); |
379 } | 370 } |
OLD | NEW |