OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "chrome/browser/bookmarks/bookmark_model.h" | 7 #include "chrome/browser/bookmarks/bookmark_model.h" |
8 #include "chrome/browser/chrome_thread.h" | 8 #include "chrome/browser/chrome_thread.h" |
9 #include "chrome/browser/pref_service.h" | 9 #include "chrome/browser/pref_service.h" |
10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 return const_cast<BookmarkNode*>(GetNode(name)); | 55 return const_cast<BookmarkNode*>(GetNode(name)); |
56 } | 56 } |
57 | 57 |
58 BookmarkEditorView::EditorTreeModel* editor_tree_model() { | 58 BookmarkEditorView::EditorTreeModel* editor_tree_model() { |
59 return editor_->tree_model_.get(); | 59 return editor_->tree_model_.get(); |
60 } | 60 } |
61 | 61 |
62 void CreateEditor(Profile* profile, | 62 void CreateEditor(Profile* profile, |
63 const BookmarkNode* parent, | 63 const BookmarkNode* parent, |
64 const BookmarkEditor::EditDetails& details, | 64 const BookmarkEditor::EditDetails& details, |
65 BookmarkEditor::Configuration configuration, | 65 BookmarkEditor::Configuration configuration) { |
66 BookmarkEditor::Handler* handler) { | |
67 editor_.reset(new BookmarkEditorView(profile, parent, details, | 66 editor_.reset(new BookmarkEditorView(profile, parent, details, |
68 configuration, handler)); | 67 configuration)); |
69 } | 68 } |
70 | 69 |
71 void SetTitleText(const std::wstring& title) { | 70 void SetTitleText(const std::wstring& title) { |
72 editor_->title_tf_.SetText(title); | 71 editor_->title_tf_.SetText(title); |
73 } | 72 } |
74 | 73 |
75 void SetURLText(const std::wstring& text) { | 74 void SetURLText(const std::wstring& text) { |
76 editor_->url_tf_.SetText(text); | 75 editor_->url_tf_.SetText(text); |
77 } | 76 } |
78 | 77 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 122 } |
124 | 123 |
125 scoped_ptr<BookmarkEditorView> editor_; | 124 scoped_ptr<BookmarkEditorView> editor_; |
126 ChromeThread ui_thread_; | 125 ChromeThread ui_thread_; |
127 ChromeThread file_thread_; | 126 ChromeThread file_thread_; |
128 }; | 127 }; |
129 | 128 |
130 // Makes sure the tree model matches that of the bookmark bar model. | 129 // Makes sure the tree model matches that of the bookmark bar model. |
131 TEST_F(BookmarkEditorViewTest, ModelsMatch) { | 130 TEST_F(BookmarkEditorViewTest, ModelsMatch) { |
132 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(), | 131 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(), |
133 BookmarkEditorView::SHOW_TREE, NULL); | 132 BookmarkEditorView::SHOW_TREE); |
134 BookmarkEditorView::EditorNode* editor_root = editor_tree_model()->GetRoot(); | 133 BookmarkEditorView::EditorNode* editor_root = editor_tree_model()->GetRoot(); |
135 // The root should have two children, one for the bookmark bar node, | 134 // The root should have two children, one for the bookmark bar node, |
136 // the other for the 'other bookmarks' folder. | 135 // the other for the 'other bookmarks' folder. |
137 ASSERT_EQ(2, editor_root->GetChildCount()); | 136 ASSERT_EQ(2, editor_root->GetChildCount()); |
138 | 137 |
139 BookmarkEditorView::EditorNode* bb_node = editor_root->GetChild(0); | 138 BookmarkEditorView::EditorNode* bb_node = editor_root->GetChild(0); |
140 // The root should have 2 nodes: folder F1 and F2. | 139 // The root should have 2 nodes: folder F1 and F2. |
141 ASSERT_EQ(2, bb_node->GetChildCount()); | 140 ASSERT_EQ(2, bb_node->GetChildCount()); |
142 ASSERT_EQ(L"F1", bb_node->GetChild(0)->GetTitle()); | 141 ASSERT_EQ(L"F1", bb_node->GetChild(0)->GetTitle()); |
143 ASSERT_EQ(L"F2", bb_node->GetChild(1)->GetTitle()); | 142 ASSERT_EQ(L"F2", bb_node->GetChild(1)->GetTitle()); |
144 | 143 |
145 // F1 should have one child, F11 | 144 // F1 should have one child, F11 |
146 ASSERT_EQ(1, bb_node->GetChild(0)->GetChildCount()); | 145 ASSERT_EQ(1, bb_node->GetChild(0)->GetChildCount()); |
147 ASSERT_EQ(L"F11", bb_node->GetChild(0)->GetChild(0)->GetTitle()); | 146 ASSERT_EQ(L"F11", bb_node->GetChild(0)->GetChild(0)->GetTitle()); |
148 | 147 |
149 BookmarkEditorView::EditorNode* other_node = editor_root->GetChild(1); | 148 BookmarkEditorView::EditorNode* other_node = editor_root->GetChild(1); |
150 // Other node should have one child (OF1). | 149 // Other node should have one child (OF1). |
151 ASSERT_EQ(1, other_node->GetChildCount()); | 150 ASSERT_EQ(1, other_node->GetChildCount()); |
152 ASSERT_EQ(L"OF1", other_node->GetChild(0)->GetTitle()); | 151 ASSERT_EQ(L"OF1", other_node->GetChild(0)->GetTitle()); |
153 } | 152 } |
154 | 153 |
155 // Changes the title and makes sure parent/visual order doesn't change. | 154 // Changes the title and makes sure parent/visual order doesn't change. |
156 TEST_F(BookmarkEditorViewTest, EditTitleKeepsPosition) { | 155 TEST_F(BookmarkEditorViewTest, EditTitleKeepsPosition) { |
157 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), | 156 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), |
158 BookmarkEditorView::SHOW_TREE, NULL); | 157 BookmarkEditorView::SHOW_TREE); |
159 SetTitleText(L"new_a"); | 158 SetTitleText(L"new_a"); |
160 | 159 |
161 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); | 160 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); |
162 | 161 |
163 const BookmarkNode* bb_node = | 162 const BookmarkNode* bb_node = |
164 profile_->GetBookmarkModel()->GetBookmarkBarNode(); | 163 profile_->GetBookmarkModel()->GetBookmarkBarNode(); |
165 ASSERT_EQ(L"new_a", bb_node->GetChild(0)->GetTitle()); | 164 ASSERT_EQ(L"new_a", bb_node->GetChild(0)->GetTitle()); |
166 // The URL shouldn't have changed. | 165 // The URL shouldn't have changed. |
167 ASSERT_TRUE(GURL(base_path() + "a") == bb_node->GetChild(0)->GetURL()); | 166 ASSERT_TRUE(GURL(base_path() + "a") == bb_node->GetChild(0)->GetURL()); |
168 } | 167 } |
169 | 168 |
170 // Changes the url and makes sure parent/visual order doesn't change. | 169 // Changes the url and makes sure parent/visual order doesn't change. |
171 TEST_F(BookmarkEditorViewTest, EditURLKeepsPosition) { | 170 TEST_F(BookmarkEditorViewTest, EditURLKeepsPosition) { |
172 Time node_time = Time::Now() + TimeDelta::FromDays(2); | 171 Time node_time = Time::Now() + TimeDelta::FromDays(2); |
173 GetMutableNode("a")->set_date_added(node_time); | 172 GetMutableNode("a")->set_date_added(node_time); |
174 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), | 173 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), |
175 BookmarkEditorView::SHOW_TREE, NULL); | 174 BookmarkEditorView::SHOW_TREE); |
176 | 175 |
177 SetURLText(UTF8ToWide(GURL(base_path() + "new_a").spec())); | 176 SetURLText(UTF8ToWide(GURL(base_path() + "new_a").spec())); |
178 | 177 |
179 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); | 178 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); |
180 | 179 |
181 const BookmarkNode* bb_node = | 180 const BookmarkNode* bb_node = |
182 profile_->GetBookmarkModel()->GetBookmarkBarNode(); | 181 profile_->GetBookmarkModel()->GetBookmarkBarNode(); |
183 ASSERT_EQ(L"a", bb_node->GetChild(0)->GetTitle()); | 182 ASSERT_EQ(L"a", bb_node->GetChild(0)->GetTitle()); |
184 // The URL should have changed. | 183 // The URL should have changed. |
185 ASSERT_TRUE(GURL(base_path() + "new_a") == bb_node->GetChild(0)->GetURL()); | 184 ASSERT_TRUE(GURL(base_path() + "new_a") == bb_node->GetChild(0)->GetURL()); |
186 ASSERT_TRUE(node_time == bb_node->GetChild(0)->date_added()); | 185 ASSERT_TRUE(node_time == bb_node->GetChild(0)->date_added()); |
187 } | 186 } |
188 | 187 |
189 // Moves 'a' to be a child of the other node. | 188 // Moves 'a' to be a child of the other node. |
190 TEST_F(BookmarkEditorViewTest, ChangeParent) { | 189 TEST_F(BookmarkEditorViewTest, ChangeParent) { |
191 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), | 190 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), |
192 BookmarkEditorView::SHOW_TREE, NULL); | 191 BookmarkEditorView::SHOW_TREE); |
193 | 192 |
194 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1)); | 193 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1)); |
195 | 194 |
196 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); | 195 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); |
197 ASSERT_EQ(L"a", other_node->GetChild(2)->GetTitle()); | 196 ASSERT_EQ(L"a", other_node->GetChild(2)->GetTitle()); |
198 ASSERT_TRUE(GURL(base_path() + "a") == other_node->GetChild(2)->GetURL()); | 197 ASSERT_TRUE(GURL(base_path() + "a") == other_node->GetChild(2)->GetURL()); |
199 } | 198 } |
200 | 199 |
201 // Moves 'a' to be a child of the other node and changes its url to new_a. | 200 // Moves 'a' to be a child of the other node and changes its url to new_a. |
202 TEST_F(BookmarkEditorViewTest, ChangeParentAndURL) { | 201 TEST_F(BookmarkEditorViewTest, ChangeParentAndURL) { |
203 Time node_time = Time::Now() + TimeDelta::FromDays(2); | 202 Time node_time = Time::Now() + TimeDelta::FromDays(2); |
204 GetMutableNode("a")->set_date_added(node_time); | 203 GetMutableNode("a")->set_date_added(node_time); |
205 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), | 204 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), |
206 BookmarkEditorView::SHOW_TREE, NULL); | 205 BookmarkEditorView::SHOW_TREE); |
207 | 206 |
208 SetURLText(UTF8ToWide(GURL(base_path() + "new_a").spec())); | 207 SetURLText(UTF8ToWide(GURL(base_path() + "new_a").spec())); |
209 | 208 |
210 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1)); | 209 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1)); |
211 | 210 |
212 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); | 211 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); |
213 ASSERT_EQ(L"a", other_node->GetChild(2)->GetTitle()); | 212 ASSERT_EQ(L"a", other_node->GetChild(2)->GetTitle()); |
214 ASSERT_TRUE(GURL(base_path() + "new_a") == other_node->GetChild(2)->GetURL()); | 213 ASSERT_TRUE(GURL(base_path() + "new_a") == other_node->GetChild(2)->GetURL()); |
215 ASSERT_TRUE(node_time == other_node->GetChild(2)->date_added()); | 214 ASSERT_TRUE(node_time == other_node->GetChild(2)->date_added()); |
216 } | 215 } |
217 | 216 |
218 // Creates a new folder and moves a node to it. | 217 // Creates a new folder and moves a node to it. |
219 TEST_F(BookmarkEditorViewTest, MoveToNewParent) { | 218 TEST_F(BookmarkEditorViewTest, MoveToNewParent) { |
220 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), | 219 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(GetNode("a")), |
221 BookmarkEditorView::SHOW_TREE, NULL); | 220 BookmarkEditorView::SHOW_TREE); |
222 | 221 |
223 // Create two nodes: "F21" as a child of "F2" and "F211" as a child of "F21". | 222 // Create two nodes: "F21" as a child of "F2" and "F211" as a child of "F21". |
224 BookmarkEditorView::EditorNode* f2 = | 223 BookmarkEditorView::EditorNode* f2 = |
225 editor_tree_model()->GetRoot()->GetChild(0)->GetChild(1); | 224 editor_tree_model()->GetRoot()->GetChild(0)->GetChild(1); |
226 BookmarkEditorView::EditorNode* f21 = AddNewGroup(f2); | 225 BookmarkEditorView::EditorNode* f21 = AddNewGroup(f2); |
227 f21->SetTitle(L"F21"); | 226 f21->SetTitle(L"F21"); |
228 BookmarkEditorView::EditorNode* f211 = AddNewGroup(f21); | 227 BookmarkEditorView::EditorNode* f211 = AddNewGroup(f21); |
229 f211->SetTitle(L"F211"); | 228 f211->SetTitle(L"F211"); |
230 | 229 |
231 // Parent the node to "F21". | 230 // Parent the node to "F21". |
(...skipping 12 matching lines...) Expand all Loading... |
244 | 243 |
245 // F21 should have one child, F211. | 244 // F21 should have one child, F211. |
246 const BookmarkNode* mf21 = mf2->GetChild(0); | 245 const BookmarkNode* mf21 = mf2->GetChild(0); |
247 ASSERT_EQ(1, mf21->GetChildCount()); | 246 ASSERT_EQ(1, mf21->GetChildCount()); |
248 ASSERT_EQ(L"F211", mf21->GetChild(0)->GetTitle()); | 247 ASSERT_EQ(L"F211", mf21->GetChild(0)->GetTitle()); |
249 } | 248 } |
250 | 249 |
251 // Brings up the editor, creating a new URL on the bookmark bar. | 250 // Brings up the editor, creating a new URL on the bookmark bar. |
252 TEST_F(BookmarkEditorViewTest, NewURL) { | 251 TEST_F(BookmarkEditorViewTest, NewURL) { |
253 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(), | 252 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(), |
254 BookmarkEditorView::SHOW_TREE, NULL); | 253 BookmarkEditorView::SHOW_TREE); |
255 | 254 |
256 SetURLText(UTF8ToWide(GURL(base_path() + "a").spec())); | 255 SetURLText(UTF8ToWide(GURL(base_path() + "a").spec())); |
257 SetTitleText(L"new_a"); | 256 SetTitleText(L"new_a"); |
258 | 257 |
259 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); | 258 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); |
260 | 259 |
261 const BookmarkNode* bb_node = | 260 const BookmarkNode* bb_node = |
262 profile_->GetBookmarkModel()->GetBookmarkBarNode(); | 261 profile_->GetBookmarkModel()->GetBookmarkBarNode(); |
263 ASSERT_EQ(4, bb_node->GetChildCount()); | 262 ASSERT_EQ(4, bb_node->GetChildCount()); |
264 | 263 |
265 const BookmarkNode* new_node = bb_node->GetChild(3); | 264 const BookmarkNode* new_node = bb_node->GetChild(3); |
266 | 265 |
267 EXPECT_EQ(L"new_a", new_node->GetTitle()); | 266 EXPECT_EQ(L"new_a", new_node->GetTitle()); |
268 EXPECT_TRUE(GURL(base_path() + "a") == new_node->GetURL()); | 267 EXPECT_TRUE(GURL(base_path() + "a") == new_node->GetURL()); |
269 } | 268 } |
270 | 269 |
271 // Brings up the editor with no tree and modifies the url. | 270 // Brings up the editor with no tree and modifies the url. |
272 TEST_F(BookmarkEditorViewTest, ChangeURLNoTree) { | 271 TEST_F(BookmarkEditorViewTest, ChangeURLNoTree) { |
273 CreateEditor(profile_.get(), NULL, | 272 CreateEditor(profile_.get(), NULL, |
274 BookmarkEditor::EditDetails(model_->other_node()->GetChild(0)), | 273 BookmarkEditor::EditDetails(model_->other_node()->GetChild(0)), |
275 BookmarkEditorView::NO_TREE, NULL); | 274 BookmarkEditorView::NO_TREE); |
276 | 275 |
277 SetURLText(UTF8ToWide(GURL(base_path() + "a").spec())); | 276 SetURLText(UTF8ToWide(GURL(base_path() + "a").spec())); |
278 SetTitleText(L"new_a"); | 277 SetTitleText(L"new_a"); |
279 | 278 |
280 ApplyEdits(NULL); | 279 ApplyEdits(NULL); |
281 | 280 |
282 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); | 281 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); |
283 ASSERT_EQ(2, other_node->GetChildCount()); | 282 ASSERT_EQ(2, other_node->GetChildCount()); |
284 | 283 |
285 const BookmarkNode* new_node = other_node->GetChild(0); | 284 const BookmarkNode* new_node = other_node->GetChild(0); |
286 | 285 |
287 EXPECT_EQ(L"new_a", new_node->GetTitle()); | 286 EXPECT_EQ(L"new_a", new_node->GetTitle()); |
288 EXPECT_TRUE(GURL(base_path() + "a") == new_node->GetURL()); | 287 EXPECT_TRUE(GURL(base_path() + "a") == new_node->GetURL()); |
289 } | 288 } |
290 | 289 |
291 // Brings up the editor with no tree and modifies only the title. | 290 // Brings up the editor with no tree and modifies only the title. |
292 TEST_F(BookmarkEditorViewTest, ChangeTitleNoTree) { | 291 TEST_F(BookmarkEditorViewTest, ChangeTitleNoTree) { |
293 CreateEditor(profile_.get(), NULL, | 292 CreateEditor(profile_.get(), NULL, |
294 BookmarkEditor::EditDetails(model_->other_node()->GetChild(0)), | 293 BookmarkEditor::EditDetails(model_->other_node()->GetChild(0)), |
295 BookmarkEditorView::NO_TREE, NULL); | 294 BookmarkEditorView::NO_TREE); |
296 | 295 |
297 SetTitleText(L"new_a"); | 296 SetTitleText(L"new_a"); |
298 | 297 |
299 ApplyEdits(NULL); | 298 ApplyEdits(NULL); |
300 | 299 |
301 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); | 300 const BookmarkNode* other_node = profile_->GetBookmarkModel()->other_node(); |
302 ASSERT_EQ(2, other_node->GetChildCount()); | 301 ASSERT_EQ(2, other_node->GetChildCount()); |
303 | 302 |
304 const BookmarkNode* new_node = other_node->GetChild(0); | 303 const BookmarkNode* new_node = other_node->GetChild(0); |
305 | 304 |
306 EXPECT_EQ(L"new_a", new_node->GetTitle()); | 305 EXPECT_EQ(L"new_a", new_node->GetTitle()); |
307 } | 306 } |
308 | 307 |
309 // Creates a new folder. | 308 // Creates a new folder. |
310 TEST_F(BookmarkEditorViewTest, NewFolder) { | 309 TEST_F(BookmarkEditorViewTest, NewFolder) { |
311 BookmarkEditor::EditDetails details; | 310 BookmarkEditor::EditDetails details; |
312 details.urls.push_back(std::make_pair(GURL(base_path() + "x"), L"z")); | 311 details.urls.push_back(std::make_pair(GURL(base_path() + "x"), L"z")); |
313 details.type = BookmarkEditor::EditDetails::NEW_FOLDER; | 312 details.type = BookmarkEditor::EditDetails::NEW_FOLDER; |
314 CreateEditor(profile_.get(), model_->GetBookmarkBarNode(), | 313 CreateEditor(profile_.get(), model_->GetBookmarkBarNode(), |
315 details, BookmarkEditorView::SHOW_TREE, NULL); | 314 details, BookmarkEditorView::SHOW_TREE); |
316 | 315 |
317 // The url field shouldn't be visible. | 316 // The url field shouldn't be visible. |
318 EXPECT_FALSE(URLTFHasParent()); | 317 EXPECT_FALSE(URLTFHasParent()); |
319 SetTitleText(L"new_F"); | 318 SetTitleText(L"new_F"); |
320 | 319 |
321 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); | 320 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); |
322 | 321 |
323 // Make sure the folder was created. | 322 // Make sure the folder was created. |
324 ASSERT_EQ(4, model_->GetBookmarkBarNode()->GetChildCount()); | 323 ASSERT_EQ(4, model_->GetBookmarkBarNode()->GetChildCount()); |
325 const BookmarkNode* new_node = | 324 const BookmarkNode* new_node = |
326 model_->GetBookmarkBarNode()->GetChild(3); | 325 model_->GetBookmarkBarNode()->GetChild(3); |
327 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type()); | 326 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type()); |
328 EXPECT_EQ(L"new_F", new_node->GetTitle()); | 327 EXPECT_EQ(L"new_F", new_node->GetTitle()); |
329 // The node should have one child. | 328 // The node should have one child. |
330 ASSERT_EQ(1, new_node->GetChildCount()); | 329 ASSERT_EQ(1, new_node->GetChildCount()); |
331 const BookmarkNode* new_child = new_node->GetChild(0); | 330 const BookmarkNode* new_child = new_node->GetChild(0); |
332 // Make sure the child url/title match. | 331 // Make sure the child url/title match. |
333 EXPECT_EQ(BookmarkNode::URL, new_child->type()); | 332 EXPECT_EQ(BookmarkNode::URL, new_child->type()); |
334 EXPECT_EQ(details.urls[0].second, new_child->GetTitle()); | 333 EXPECT_EQ(details.urls[0].second, new_child->GetTitle()); |
335 EXPECT_TRUE(details.urls[0].first == new_child->GetURL()); | 334 EXPECT_TRUE(details.urls[0].first == new_child->GetURL()); |
336 } | 335 } |
337 | 336 |
338 // Creates a new folder and selects a different folder for the folder to appear | 337 // Creates a new folder and selects a different folder for the folder to appear |
339 // in then the editor is initially created showing. | 338 // in then the editor is initially created showing. |
340 TEST_F(BookmarkEditorViewTest, MoveFolder) { | 339 TEST_F(BookmarkEditorViewTest, MoveFolder) { |
341 BookmarkEditor::EditDetails details; | 340 BookmarkEditor::EditDetails details; |
342 details.urls.push_back(std::make_pair(GURL(base_path() + "x"), L"z")); | 341 details.urls.push_back(std::make_pair(GURL(base_path() + "x"), L"z")); |
343 details.type = BookmarkEditor::EditDetails::NEW_FOLDER; | 342 details.type = BookmarkEditor::EditDetails::NEW_FOLDER; |
344 CreateEditor(profile_.get(), model_->GetBookmarkBarNode(), | 343 CreateEditor(profile_.get(), model_->GetBookmarkBarNode(), |
345 details, BookmarkEditorView::SHOW_TREE, NULL); | 344 details, BookmarkEditorView::SHOW_TREE); |
346 | 345 |
347 SetTitleText(L"new_F"); | 346 SetTitleText(L"new_F"); |
348 | 347 |
349 // Create the folder in the 'other' folder. | 348 // Create the folder in the 'other' folder. |
350 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1)); | 349 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1)); |
351 | 350 |
352 // Make sure the folder we edited is still there. | 351 // Make sure the folder we edited is still there. |
353 ASSERT_EQ(3, model_->other_node()->GetChildCount()); | 352 ASSERT_EQ(3, model_->other_node()->GetChildCount()); |
354 const BookmarkNode* new_node = model_->other_node()->GetChild(2); | 353 const BookmarkNode* new_node = model_->other_node()->GetChild(2); |
355 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type()); | 354 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type()); |
356 EXPECT_EQ(L"new_F", new_node->GetTitle()); | 355 EXPECT_EQ(L"new_F", new_node->GetTitle()); |
357 // The node should have one child. | 356 // The node should have one child. |
358 ASSERT_EQ(1, new_node->GetChildCount()); | 357 ASSERT_EQ(1, new_node->GetChildCount()); |
359 const BookmarkNode* new_child = new_node->GetChild(0); | 358 const BookmarkNode* new_child = new_node->GetChild(0); |
360 // Make sure the child url/title match. | 359 // Make sure the child url/title match. |
361 EXPECT_EQ(BookmarkNode::URL, new_child->type()); | 360 EXPECT_EQ(BookmarkNode::URL, new_child->type()); |
362 EXPECT_EQ(details.urls[0].second, new_child->GetTitle()); | 361 EXPECT_EQ(details.urls[0].second, new_child->GetTitle()); |
363 EXPECT_TRUE(details.urls[0].first == new_child->GetURL()); | 362 EXPECT_TRUE(details.urls[0].first == new_child->GetURL()); |
364 } | 363 } |
OLD | NEW |