Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(868)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc

Issue 12314090: Add utf_string_conversions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 178 }
179 179
180 // Changes the url and makes sure parent/visual order doesn't change. 180 // Changes the url and makes sure parent/visual order doesn't change.
181 TEST_F(BookmarkEditorViewTest, EditURLKeepsPosition) { 181 TEST_F(BookmarkEditorViewTest, EditURLKeepsPosition) {
182 Time node_time = Time::Now() + TimeDelta::FromDays(2); 182 Time node_time = Time::Now() + TimeDelta::FromDays(2);
183 GetMutableNode("a")->set_date_added(node_time); 183 GetMutableNode("a")->set_date_added(node_time);
184 CreateEditor(profile_.get(), NULL, 184 CreateEditor(profile_.get(), NULL,
185 BookmarkEditor::EditDetails::EditNode(GetNode("a")), 185 BookmarkEditor::EditDetails::EditNode(GetNode("a")),
186 BookmarkEditorView::SHOW_TREE); 186 BookmarkEditorView::SHOW_TREE);
187 187
188 SetURLText(UTF8ToWide(GURL(base_path() + "new_a").spec())); 188 SetURLText(base::UTF8ToWide(GURL(base_path() + "new_a").spec()));
189 189
190 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); 190 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0));
191 191
192 const BookmarkNode* bb_node = 192 const BookmarkNode* bb_node =
193 BookmarkModelFactory::GetForProfile(profile_.get())->bookmark_bar_node(); 193 BookmarkModelFactory::GetForProfile(profile_.get())->bookmark_bar_node();
194 ASSERT_EQ(ASCIIToUTF16("a"), bb_node->GetChild(0)->GetTitle()); 194 ASSERT_EQ(ASCIIToUTF16("a"), bb_node->GetChild(0)->GetTitle());
195 // The URL should have changed. 195 // The URL should have changed.
196 ASSERT_TRUE(GURL(base_path() + "new_a") == bb_node->GetChild(0)->url()); 196 ASSERT_TRUE(GURL(base_path() + "new_a") == bb_node->GetChild(0)->url());
197 ASSERT_TRUE(node_time == bb_node->GetChild(0)->date_added()); 197 ASSERT_TRUE(node_time == bb_node->GetChild(0)->date_added());
198 } 198 }
(...skipping 13 matching lines...) Expand all
212 } 212 }
213 213
214 // Moves 'a' to be a child of the other node and changes its url to new_a. 214 // Moves 'a' to be a child of the other node and changes its url to new_a.
215 TEST_F(BookmarkEditorViewTest, ChangeParentAndURL) { 215 TEST_F(BookmarkEditorViewTest, ChangeParentAndURL) {
216 Time node_time = Time::Now() + TimeDelta::FromDays(2); 216 Time node_time = Time::Now() + TimeDelta::FromDays(2);
217 GetMutableNode("a")->set_date_added(node_time); 217 GetMutableNode("a")->set_date_added(node_time);
218 CreateEditor(profile_.get(), NULL, 218 CreateEditor(profile_.get(), NULL,
219 BookmarkEditor::EditDetails::EditNode(GetNode("a")), 219 BookmarkEditor::EditDetails::EditNode(GetNode("a")),
220 BookmarkEditorView::SHOW_TREE); 220 BookmarkEditorView::SHOW_TREE);
221 221
222 SetURLText(UTF8ToWide(GURL(base_path() + "new_a").spec())); 222 SetURLText(base::UTF8ToWide(GURL(base_path() + "new_a").spec()));
223 223
224 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1)); 224 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(1));
225 225
226 const BookmarkNode* other_node = 226 const BookmarkNode* other_node =
227 BookmarkModelFactory::GetForProfile(profile_.get())->other_node(); 227 BookmarkModelFactory::GetForProfile(profile_.get())->other_node();
228 ASSERT_EQ(ASCIIToUTF16("a"), other_node->GetChild(2)->GetTitle()); 228 ASSERT_EQ(ASCIIToUTF16("a"), other_node->GetChild(2)->GetTitle());
229 ASSERT_TRUE(GURL(base_path() + "new_a") == other_node->GetChild(2)->url()); 229 ASSERT_TRUE(GURL(base_path() + "new_a") == other_node->GetChild(2)->url());
230 ASSERT_TRUE(node_time == other_node->GetChild(2)->date_added()); 230 ASSERT_TRUE(node_time == other_node->GetChild(2)->date_added());
231 } 231 }
232 232
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // Brings up the editor, creating a new URL on the bookmark bar. 267 // Brings up the editor, creating a new URL on the bookmark bar.
268 TEST_F(BookmarkEditorViewTest, NewURL) { 268 TEST_F(BookmarkEditorViewTest, NewURL) {
269 const BookmarkNode* bb_node = 269 const BookmarkNode* bb_node =
270 BookmarkModelFactory::GetForProfile(profile_.get())->bookmark_bar_node(); 270 BookmarkModelFactory::GetForProfile(profile_.get())->bookmark_bar_node();
271 271
272 CreateEditor(profile_.get(), bb_node, 272 CreateEditor(profile_.get(), bb_node,
273 BookmarkEditor::EditDetails::AddNodeInFolder( 273 BookmarkEditor::EditDetails::AddNodeInFolder(
274 bb_node, 1, GURL(), string16()), 274 bb_node, 1, GURL(), string16()),
275 BookmarkEditorView::SHOW_TREE); 275 BookmarkEditorView::SHOW_TREE);
276 276
277 SetURLText(UTF8ToWide(GURL(base_path() + "a").spec())); 277 SetURLText(base::UTF8ToWide(GURL(base_path() + "a").spec()));
278 SetTitleText(L"new_a"); 278 SetTitleText(L"new_a");
279 279
280 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0)); 280 ApplyEdits(editor_tree_model()->GetRoot()->GetChild(0));
281 281
282 ASSERT_EQ(4, bb_node->child_count()); 282 ASSERT_EQ(4, bb_node->child_count());
283 283
284 const BookmarkNode* new_node = bb_node->GetChild(1); 284 const BookmarkNode* new_node = bb_node->GetChild(1);
285 285
286 EXPECT_EQ(ASCIIToUTF16("new_a"), new_node->GetTitle()); 286 EXPECT_EQ(ASCIIToUTF16("new_a"), new_node->GetTitle());
287 EXPECT_TRUE(GURL(base_path() + "a") == new_node->url()); 287 EXPECT_TRUE(GURL(base_path() + "a") == new_node->url());
288 } 288 }
289 289
290 // Brings up the editor with no tree and modifies the url. 290 // Brings up the editor with no tree and modifies the url.
291 TEST_F(BookmarkEditorViewTest, ChangeURLNoTree) { 291 TEST_F(BookmarkEditorViewTest, ChangeURLNoTree) {
292 CreateEditor(profile_.get(), NULL, 292 CreateEditor(profile_.get(), NULL,
293 BookmarkEditor::EditDetails::EditNode( 293 BookmarkEditor::EditDetails::EditNode(
294 model_->other_node()->GetChild(0)), 294 model_->other_node()->GetChild(0)),
295 BookmarkEditorView::NO_TREE); 295 BookmarkEditorView::NO_TREE);
296 296
297 SetURLText(UTF8ToWide(GURL(base_path() + "a").spec())); 297 SetURLText(base::UTF8ToWide(GURL(base_path() + "a").spec()));
298 SetTitleText(L"new_a"); 298 SetTitleText(L"new_a");
299 299
300 ApplyEdits(NULL); 300 ApplyEdits(NULL);
301 301
302 const BookmarkNode* other_node = 302 const BookmarkNode* other_node =
303 BookmarkModelFactory::GetForProfile(profile_.get())->other_node(); 303 BookmarkModelFactory::GetForProfile(profile_.get())->other_node();
304 ASSERT_EQ(2, other_node->child_count()); 304 ASSERT_EQ(2, other_node->child_count());
305 305
306 const BookmarkNode* new_node = other_node->GetChild(0); 306 const BookmarkNode* new_node = other_node->GetChild(0);
307 307
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type()); 379 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type());
380 EXPECT_EQ(ASCIIToUTF16("new_F"), new_node->GetTitle()); 380 EXPECT_EQ(ASCIIToUTF16("new_F"), new_node->GetTitle());
381 // The node should have one child. 381 // The node should have one child.
382 ASSERT_EQ(1, new_node->child_count()); 382 ASSERT_EQ(1, new_node->child_count());
383 const BookmarkNode* new_child = new_node->GetChild(0); 383 const BookmarkNode* new_child = new_node->GetChild(0);
384 // Make sure the child url/title match. 384 // Make sure the child url/title match.
385 EXPECT_EQ(BookmarkNode::URL, new_child->type()); 385 EXPECT_EQ(BookmarkNode::URL, new_child->type());
386 EXPECT_EQ(details.urls[0].second, new_child->GetTitle()); 386 EXPECT_EQ(details.urls[0].second, new_child->GetTitle());
387 EXPECT_EQ(details.urls[0].first, new_child->url()); 387 EXPECT_EQ(details.urls[0].first, new_child->url());
388 } 388 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698