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