diff options
Diffstat (limited to 'chrome/browser/cocoa')
12 files changed, 220 insertions, 185 deletions
diff --git a/chrome/browser/cocoa/applescript/bookmark_folder_applescript.mm b/chrome/browser/cocoa/applescript/bookmark_folder_applescript.mm index d7acc58..05e2c27 100644 --- a/chrome/browser/cocoa/applescript/bookmark_folder_applescript.mm +++ b/chrome/browser/cocoa/applescript/bookmark_folder_applescript.mm @@ -5,6 +5,7 @@ #import "chrome/browser/cocoa/applescript/bookmark_folder_applescript.h" #import "base/scoped_nsobject.h" +#import "base/string16.h" #include "base/sys_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_model.h" #import "chrome/browser/cocoa/applescript/bookmark_item_applescript.h" @@ -45,7 +46,7 @@ const BookmarkNode* node = model->AddGroup(bookmarkNode_, bookmarkNode_->GetChildCount(), - std::wstring()); + string16()); if (!node) { AppleScript::SetError(AppleScript::errCreateBookmarkFolder); return; @@ -67,7 +68,7 @@ const BookmarkNode* node = model->AddGroup(bookmarkNode_, position, - std::wstring()); + string16()); if (!node) { AppleScript::SetError(AppleScript::errCreateBookmarkFolder); return; diff --git a/chrome/browser/cocoa/bookmark_all_tabs_controller.mm b/chrome/browser/cocoa/bookmark_all_tabs_controller.mm index 2d8184a..97269dc 100644 --- a/chrome/browser/cocoa/bookmark_all_tabs_controller.mm +++ b/chrome/browser/cocoa/bookmark_all_tabs_controller.mm @@ -4,6 +4,7 @@ #import "chrome/browser/cocoa/bookmark_all_tabs_controller.h" #include "app/l10n_util_mac.h" +#include "base/string16.h" #include "base/sys_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/browser.h" @@ -60,7 +61,7 @@ int newIndex = newParentNode->GetChildCount(); // Create the new folder which will contain all of the tab URLs. NSString* newFolderName = [self displayName]; - std::wstring newFolderString = base::SysNSStringToWide(newFolderName); + string16 newFolderString = base::SysNSStringToUTF16(newFolderName); BookmarkModel* model = [self bookmarkModel]; const BookmarkNode* newFolder = model->AddGroup(newParentNode, newIndex, newFolderString); diff --git a/chrome/browser/cocoa/bookmark_all_tabs_controller_unittest.mm b/chrome/browser/cocoa/bookmark_all_tabs_controller_unittest.mm index f562f56..c2cb712 100644 --- a/chrome/browser/cocoa/bookmark_all_tabs_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_all_tabs_controller_unittest.mm @@ -6,6 +6,7 @@ #include "base/scoped_nsobject.h" #include "base/sys_string_conversions.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_model.h" #import "chrome/browser/cocoa/bookmark_all_tabs_controller.h" #include "chrome/browser/cocoa/browser_test_helper.h" @@ -42,10 +43,10 @@ class BookmarkAllTabsControllerTest : public CocoaTest { BookmarkAllTabsControllerTest() { BookmarkModel& model(*(helper_.profile()->GetBookmarkModel())); const BookmarkNode* root = model.GetBookmarkBarNode(); - group_a_ = model.AddGroup(root, 0, L"a"); - model.AddURL(group_a_, 0, L"a-0", GURL("http://a-0.com")); - model.AddURL(group_a_, 1, L"a-1", GURL("http://a-1.com")); - model.AddURL(group_a_, 2, L"a-2", GURL("http://a-2.com")); + group_a_ = model.AddGroup(root, 0, ASCIIToUTF16("a")); + model.AddURL(group_a_, 0, ASCIIToUTF16("a-0"), GURL("http://a-0.com")); + model.AddURL(group_a_, 1, ASCIIToUTF16("a-1"), GURL("http://a-1.com")); + model.AddURL(group_a_, 2, ASCIIToUTF16("a-2"), GURL("http://a-2.com")); } virtual BookmarkAllTabsControllerOverride* CreateController() { @@ -76,6 +77,6 @@ TEST_F(BookmarkAllTabsControllerTest, BookmarkAllTabs) { [controller_ ok:nil]; EXPECT_EQ(4, group_a_->GetChildCount()); const BookmarkNode* folderChild = group_a_->GetChild(3); - EXPECT_EQ(folderChild->GetTitle(), L"ALL MY TABS"); + EXPECT_EQ(folderChild->GetTitleAsString16(), ASCIIToUTF16("ALL MY TABS")); EXPECT_EQ(3, folderChild->GetChildCount()); } diff --git a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm index 48174c4..494b58d 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm @@ -320,7 +320,7 @@ class BookmarkBarControllerTest : public BookmarkBarControllerTestBase { BookmarkModel* model = helper_.profile()->GetBookmarkModel(); const BookmarkNode* parent = model->GetBookmarkBarNode(); const BookmarkNode* node = model->AddURL(parent, parent->GetChildCount(), - L"A title", gurl); + ASCIIToUTF16("A title"), gurl); [menu_ setRepresentedObject:[NSNumber numberWithLongLong:node->id()]]; return menu_item_; } @@ -516,7 +516,7 @@ TEST_F(BookmarkBarControllerTest, NoItemContainerGoesAway) { EXPECT_FALSE([noItemContainer isHidden]); const BookmarkNode* node = model->AddURL(bar, bar->GetChildCount(), - L"title", + ASCIIToUTF16("title"), GURL("http://www.google.com")); EXPECT_TRUE([noItemContainer isHidden]); model->Remove(bar, bar->IndexOfChild(node)); @@ -525,7 +525,7 @@ TEST_F(BookmarkBarControllerTest, NoItemContainerGoesAway) { // Now try it using a bookmark from the Other Bookmarks. const BookmarkNode* otherBookmarks = model->other_node(); node = model->AddURL(otherBookmarks, otherBookmarks->GetChildCount(), - L"TheOther", + ASCIIToUTF16("TheOther"), GURL("http://www.other.com")); EXPECT_FALSE([noItemContainer isHidden]); // Move it from Other Bookmarks to the bar. @@ -553,7 +553,7 @@ TEST_F(BookmarkBarControllerTest, OffTheSideButtonHidden) { const BookmarkNode* parent = model->GetBookmarkBarNode(); for (int i = 0; i < 20; i++) { model->AddURL(parent, parent->GetChildCount(), - L"super duper wide title", + ASCIIToUTF16("super duper wide title"), GURL("http://superfriends.hall-of-justice.edu")); } EXPECT_FALSE([bar_ offTheSideButtonIsHidden]); @@ -707,11 +707,11 @@ TEST_F(BookmarkBarControllerTest, MenuForFolderNode) { const BookmarkNode* parent = model->GetBookmarkBarNode(); const BookmarkNode* folder = model->AddGroup(parent, parent->GetChildCount(), - L"group"); + ASCIIToUTF16("group")); model->AddURL(folder, folder->GetChildCount(), - L"f1", GURL("http://framma-lamma.com")); + ASCIIToUTF16("f1"), GURL("http://framma-lamma.com")); model->AddURL(folder, folder->GetChildCount(), - L"f2", GURL("http://framma-lamma-ding-dong.com")); + ASCIIToUTF16("f2"), GURL("http://framma-lamma-ding-dong.com")); menu = [bar_ menuForFolderNode:model->GetBookmarkBarNode()]; EXPECT_EQ([menu numberOfItems], 3); @@ -820,7 +820,7 @@ TEST_F(BookmarkBarControllerTest, TestButtonLimits) { // Add one; make sure we see it. const BookmarkNode* parent = model->GetBookmarkBarNode(); model->AddURL(parent, parent->GetChildCount(), - L"title", GURL("http://www.google.com")); + ASCIIToUTF16("title"), GURL("http://www.google.com")); EXPECT_EQ(1U, [[bar_ buttons] count]); // Add 30 which we expect to be 'too many'. Make sure we don't see @@ -829,7 +829,7 @@ TEST_F(BookmarkBarControllerTest, TestButtonLimits) { EXPECT_EQ(0U, [[bar_ buttons] count]); for (int i=0; i<30; i++) { model->AddURL(parent, parent->GetChildCount(), - L"title", GURL("http://www.google.com")); + ASCIIToUTF16("title"), GURL("http://www.google.com")); } int count = [[bar_ buttons] count]; EXPECT_LT(count, 30L); @@ -838,7 +838,7 @@ TEST_F(BookmarkBarControllerTest, TestButtonLimits) { // would change) and make sure the count stays the same. for (int i=0; i<10; i++) { model->AddURL(parent, 0, /* index is 0, so front, not end */ - L"title", GURL("http://www.google.com")); + ASCIIToUTF16("title"), GURL("http://www.google.com")); } // Finally, grow the view and make sure the button count goes up. @@ -909,7 +909,7 @@ TEST_F(BookmarkBarControllerTest, DeleteBookmark) { const BookmarkNode* parent = model->GetBookmarkBarNode(); for (unsigned int i = 0; i < arraysize(urls); i++) { model->AddURL(parent, parent->GetChildCount(), - L"title", GURL(urls[i])); + ASCIIToUTF16("title"), GURL(urls[i])); } EXPECT_EQ(3, parent->GetChildCount()); const BookmarkNode* middle_node = parent->GetChild(1); @@ -931,7 +931,7 @@ TEST_F(BookmarkBarControllerTest, Cell) { const BookmarkNode* parent = model->GetBookmarkBarNode(); model->AddURL(parent, parent->GetChildCount(), - L"supertitle", + ASCIIToUTF16("supertitle"), GURL("http://superfriends.hall-of-justice.edu")); const BookmarkNode* node = parent->GetChild(0); @@ -981,7 +981,7 @@ TEST_F(BookmarkBarControllerTest, HidesHelpMessageWithBookmark) { const BookmarkNode* parent = model->GetBookmarkBarNode(); model->AddURL(parent, parent->GetChildCount(), - L"title", GURL("http://one.com")); + ASCIIToUTF16("title"), GURL("http://one.com")); [bar_ loaded:model]; EXPECT_TRUE([[[bar_ buttonView] noItemContainer] isHidden]); @@ -992,7 +992,7 @@ TEST_F(BookmarkBarControllerTest, BookmarkButtonSizing) { const BookmarkNode* parent = model->GetBookmarkBarNode(); model->AddURL(parent, parent->GetChildCount(), - L"title", GURL("http://one.com")); + ASCIIToUTF16("title"), GURL("http://one.com")); [bar_ loaded:model]; @@ -1083,7 +1083,7 @@ TEST_F(BookmarkBarControllerTest, TestMenuNodeAndDisable) { const BookmarkNode* parent = model->GetBookmarkBarNode(); const BookmarkNode* folder = model->AddGroup(parent, parent->GetChildCount(), - L"group"); + ASCIIToUTF16("group")); NSButton* button = [[bar_ buttons] objectAtIndex:0]; EXPECT_TRUE(button); @@ -1100,7 +1100,7 @@ TEST_F(BookmarkBarControllerTest, TestMenuNodeAndDisable) { // Now add a child and make sure the item would be enabled. model->AddURL(folder, folder->GetChildCount(), - L"super duper wide title", + ASCIIToUTF16("super duper wide title"), GURL("http://superfriends.hall-of-justice.edu")); EXPECT_TRUE([bar_ validateUserInterfaceItem:item]); } @@ -1158,9 +1158,10 @@ TEST_F(BookmarkBarControllerTest, TestDragButton) { // A drop on a folder button. const BookmarkNode* folder = model->AddGroup(model->GetBookmarkBarNode(), 0, - L"awesome group"); + ASCIIToUTF16("awesome group")); DCHECK(folder); - model->AddURL(folder, 0, L"already", GURL("http://www.google.com")); + model->AddURL(folder, 0, ASCIIToUTF16("already"), + GURL("http://www.google.com")); EXPECT_EQ(arraysize(titles) + 1, [[bar_ buttons] count]); EXPECT_EQ(1, folder->GetChildCount()); x = NSMidX([[[bar_ buttons] objectAtIndex:0] frame]); @@ -1274,10 +1275,11 @@ TEST_F(BookmarkBarControllerTest, TestFolders) { const BookmarkNode* parent = model->GetBookmarkBarNode(); const BookmarkNode* folder = model->AddGroup(parent, parent->GetChildCount(), - L"group"); + ASCIIToUTF16("group")); model->AddURL(folder, folder->GetChildCount(), - L"f1", GURL("http://framma-lamma.com")); - folder = model->AddGroup(parent, parent->GetChildCount(), L"empty"); + ASCIIToUTF16("f1"), GURL("http://framma-lamma.com")); + folder = model->AddGroup(parent, parent->GetChildCount(), + ASCIIToUTF16("empty")); EXPECT_EQ([[bar_ buttons] count], 2U); @@ -1322,7 +1324,7 @@ TEST_F(BookmarkBarControllerTest, TestFolderButtons) { // Add a real bookmark so we can click on it. const BookmarkNode* folder = root->GetChild(3); - model.AddURL(folder, folder->GetChildCount(), L"CLICK ME", + model.AddURL(folder, folder->GetChildCount(), ASCIIToUTF16("CLICK ME"), GURL("http://www.google.com/")); // Click on a folder button. @@ -1386,13 +1388,15 @@ TEST_F(BookmarkBarControllerTest, OffTheSideFolder) { const BookmarkNode* parent = model->GetBookmarkBarNode(); for (int x = 0; x < 30; x++) { model->AddURL(parent, parent->GetChildCount(), - L"medium-size-title", GURL("http://framma-lamma.com")); + ASCIIToUTF16("medium-size-title"), + GURL("http://framma-lamma.com")); } // Add a couple more so we can delete one and make sure its button goes away. model->AddURL(parent, parent->GetChildCount(), - L"DELETE_ME", GURL("http://ashton-tate.com")); + ASCIIToUTF16("DELETE_ME"), GURL("http://ashton-tate.com")); model->AddURL(parent, parent->GetChildCount(), - L"medium-size-title", GURL("http://framma-lamma.com")); + ASCIIToUTF16("medium-size-title"), + GURL("http://framma-lamma.com")); // Should no longer be hidden. EXPECT_FALSE([bar_ offTheSideButtonIsHidden]); @@ -1461,8 +1465,8 @@ TEST_F(BookmarkBarControllerTest, DropDestination) { // Make some buttons. BookmarkModel* model = helper_.profile()->GetBookmarkModel(); const BookmarkNode* parent = model->GetBookmarkBarNode(); - model->AddGroup(parent, parent->GetChildCount(), L"group 1"); - model->AddGroup(parent, parent->GetChildCount(), L"group 2"); + model->AddGroup(parent, parent->GetChildCount(), ASCIIToUTF16("group 1")); + model->AddGroup(parent, parent->GetChildCount(), ASCIIToUTF16("group 2")); EXPECT_EQ([[bar_ buttons] count], 2U); // Confirm "off to left" and "off to right" match nothing. @@ -1503,7 +1507,7 @@ TEST_F(BookmarkBarControllerTest, NodeDeletedWhileMenuIsOpen) { const BookmarkNode* parent = model->GetBookmarkBarNode(); const BookmarkNode* initialNode = model->AddURL( parent, parent->GetChildCount(), - L"initial", + ASCIIToUTF16("initial"), GURL("http://www.google.com")); NSMenuItem* item = ItemForBookmarkBarMenu(initialNode); @@ -1542,9 +1546,9 @@ TEST_F(BookmarkBarControllerTest, NodeDeletedWhileContextMenuIsOpen) { const BookmarkNode* parent = model->GetBookmarkBarNode(); const BookmarkNode* folder = model->AddGroup(parent, parent->GetChildCount(), - L"group"); + ASCIIToUTF16("group")); const BookmarkNode* framma = model->AddURL(folder, folder->GetChildCount(), - L"f1", + ASCIIToUTF16("f1"), GURL("http://framma-lamma.com")); // Mock in a menu @@ -1566,14 +1570,14 @@ TEST_F(BookmarkBarControllerTest, CloseFolderOnAnimate) { const BookmarkNode* parent = model->GetBookmarkBarNode(); const BookmarkNode* folder = model->AddGroup(parent, parent->GetChildCount(), - L"group"); + ASCIIToUTF16("group")); model->AddGroup(parent, parent->GetChildCount(), - L"sibbling group"); - model->AddURL(folder, folder->GetChildCount(), L"title a", + ASCIIToUTF16("sibbling group")); + model->AddURL(folder, folder->GetChildCount(), ASCIIToUTF16("title a"), GURL("http://www.google.com/a")); model->AddURL(folder, folder->GetChildCount(), - L"title super duper long long whoa momma title you betcha", - GURL("http://www.google.com/b")); + ASCIIToUTF16("title super duper long long whoa momma title you betcha"), + GURL("http://www.google.com/b")); BookmarkButton* button = [[bar_ buttons] objectAtIndex:0]; EXPECT_FALSE([bar_ folderController]); [bar_ openBookmarkFolderFromButton:button]; @@ -1688,15 +1692,16 @@ public: BookmarkModel* model = helper_.profile()->GetBookmarkModel(); parent_ = model->GetBookmarkBarNode(); // { one, { two-one, two-two }, three } - model->AddURL(parent_, parent_->GetChildCount(), L"title", + model->AddURL(parent_, parent_->GetChildCount(), ASCIIToUTF16("title"), GURL("http://one.com")); - folder_ = model->AddGroup(parent_, parent_->GetChildCount(), L"group"); + folder_ = model->AddGroup(parent_, parent_->GetChildCount(), + ASCIIToUTF16("group")); model->AddURL(folder_, folder_->GetChildCount(), - L"title", GURL("http://two-one.com")); + ASCIIToUTF16("title"), GURL("http://two-one.com")); model->AddURL(folder_, folder_->GetChildCount(), - L"title", GURL("http://two-two.com")); + ASCIIToUTF16("title"), GURL("http://two-two.com")); model->AddURL(parent_, parent_->GetChildCount(), - L"title", GURL("https://three.com")); + ASCIIToUTF16("title"), GURL("https://three.com")); } const BookmarkNode* parent_; // Weak const BookmarkNode* folder_; // Weak @@ -2042,7 +2047,7 @@ TEST_F(BookmarkBarControllerDragDropTest, PulseButton) { const BookmarkNode* root = model->GetBookmarkBarNode(); GURL gurl("http://www.google.com"); const BookmarkNode* node = model->AddURL(root, root->GetChildCount(), - L"title", gurl); + ASCIIToUTF16("title"), gurl); BookmarkButton* button = [[bar_ buttons] objectAtIndex:0]; EXPECT_FALSE([button isContinuousPulsing]); diff --git a/chrome/browser/cocoa/bookmark_bar_folder_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_folder_controller_unittest.mm index 555a3c9..fc7e80b 100644 --- a/chrome/browser/cocoa/bookmark_bar_folder_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_folder_controller_unittest.mm @@ -6,6 +6,7 @@ #include "base/basictypes.h" #include "base/scoped_nsobject.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_model.h" #import "chrome/browser/cocoa/bookmark_bar_constants.h" // namespace bookmarks #import "chrome/browser/cocoa/bookmark_bar_controller.h" @@ -132,23 +133,23 @@ class BookmarkBarFolderControllerTest : public CocoaTest { const BookmarkNode* parent = model->GetBookmarkBarNode(); const BookmarkNode* folderA = model->AddGroup(parent, parent->GetChildCount(), - L"group"); + ASCIIToUTF16("group")); folderA_ = folderA; model->AddGroup(parent, parent->GetChildCount(), - L"sibbling group"); + ASCIIToUTF16("sibbling group")); const BookmarkNode* folderB = model->AddGroup(folderA, folderA->GetChildCount(), - L"subgroup 1"); + ASCIIToUTF16("subgroup 1")); model->AddGroup(folderA, folderA->GetChildCount(), - L"subgroup 2"); - model->AddURL(folderA, folderA->GetChildCount(), L"title a", + ASCIIToUTF16("subgroup 2")); + model->AddURL(folderA, folderA->GetChildCount(), ASCIIToUTF16("title a"), GURL("http://www.google.com/a")); longTitleNode_ = model->AddURL( folderA, folderA->GetChildCount(), - L"title super duper long long whoa momma title you betcha", + ASCIIToUTF16("title super duper long long whoa momma title you betcha"), GURL("http://www.google.com/b")); - model->AddURL(folderB, folderB->GetChildCount(), L"t", + model->AddURL(folderB, folderB->GetChildCount(), ASCIIToUTF16("t"), GURL("http://www.google.com/c")); bar_.reset( @@ -180,7 +181,8 @@ class BookmarkBarFolderControllerTest : public CocoaTest { int AddLotsOfNodes() { BookmarkModel* model = helper_.profile()->GetBookmarkModel(); for (int i = 0; i < kLotsOfNodesCount; i++) { - model->AddURL(folderA_, folderA_->GetChildCount(), L"repeated title", + model->AddURL(folderA_, folderA_->GetChildCount(), + ASCIIToUTF16("repeated title"), GURL("http://www.google.com/repeated/url")); } return kLotsOfNodesCount; @@ -291,7 +293,7 @@ TEST_F(BookmarkBarFolderControllerTest, PositionRightLeftRight) { int i; // Make some super duper deeply nested folders. for (i=0; i<count; i++) { - folder = model->AddGroup(folder, 0, L"nested folder"); + folder = model->AddGroup(folder, 0, ASCIIToUTF16("nested folder")); } // Setup initial state for opening all folders. @@ -1121,7 +1123,7 @@ TEST_F(BookmarkBarFolderControllerMenuTest, MenuSizingAndScrollArrows) { const BookmarkNode* parent = model.GetBookmarkBarNode(); const BookmarkNode* folder = model.AddGroup(parent, parent->GetChildCount(), - L"BIG"); + ASCIIToUTF16("BIG")); // Pop open the new folder window and verify it has one (empty) item. BookmarkButton* button = [bar_ buttonWithTitleEqualTo:@"BIG"]; @@ -1139,7 +1141,8 @@ TEST_F(BookmarkBarFolderControllerMenuTest, MenuSizingAndScrollArrows) { EXPECT_FALSE([folderController scrollable]); // Now add a real bookmark and reopen. - model.AddURL(folder, folder->GetChildCount(), L"a", GURL("http://a.com/")); + model.AddURL(folder, folder->GetChildCount(), ASCIIToUTF16("a"), + GURL("http://a.com/")); folderController = [bar_ folderController]; EXPECT_TRUE(folderController); folderMenu = [folderController window]; @@ -1156,7 +1159,8 @@ TEST_F(BookmarkBarFolderControllerMenuTest, MenuSizingAndScrollArrows) { EXPECT_CGFLOAT_EQ(expectedWidth, menuWidth); // Add a wider bookmark and make sure the button widths match. - model.AddURL(folder, folder->GetChildCount(), L"A really, really long name", + model.AddURL(folder, folder->GetChildCount(), + ASCIIToUTF16("A really, really long name"), GURL("http://www.google.com/a")); EXPECT_LT(menuWidth, NSWidth([folderMenu frame])); EXPECT_LT(buttonWidth, NSWidth([button frame])); @@ -1172,7 +1176,8 @@ TEST_F(BookmarkBarFolderControllerMenuTest, MenuSizingAndScrollArrows) { menuHeight = NSHeight([folderMenu frame]); NSUInteger tripWire = 0; // Prevent a runaway. while (![folderController scrollable] && ++tripWire < 100) { - model.AddURL(folder, folder->GetChildCount(), L"B", GURL("http://b.com/")); + model.AddURL(folder, folder->GetChildCount(), ASCIIToUTF16("B"), + GURL("http://b.com/")); oldMenuHeight = menuHeight; menuHeight = NSHeight([folderMenu frame]); } @@ -1199,9 +1204,9 @@ TEST_F(BookmarkBarFolderControllerMenuTest, HoverThenDeleteBookmark) { const BookmarkNode* root = model.GetBookmarkBarNode(); const BookmarkNode* folder = model.AddGroup(root, root->GetChildCount(), - L"BIG"); + ASCIIToUTF16("BIG")); for (int i = 0; i < kLotsOfNodesCount; i++) - model.AddURL(folder, folder->GetChildCount(), L"kid", + model.AddURL(folder, folder->GetChildCount(), ASCIIToUTF16("kid"), GURL("http://kid.com/smile")); // Pop open the new folder window and hover one of its kids. diff --git a/chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm index ffe036d..7dd01d9 100644 --- a/chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,6 +6,7 @@ #include "base/basictypes.h" #include "base/scoped_nsobject.h" +#include "base/utf_string_conversions.h" #import "chrome/browser/cocoa/bookmark_bubble_controller.h" #include "chrome/browser/cocoa/browser_test_helper.h" #include "chrome/browser/cocoa/browser_window_controller.h" @@ -105,7 +106,7 @@ TEST_F(BookmarkBubbleControllerTest, TestBubbleWindow) { BookmarkModel* model = GetBookmarkModel(); const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(), 0, - L"Bookie markie title", + ASCIIToUTF16("Bookie markie title"), GURL("http://www.google.com")); BookmarkBubbleController* controller = ControllerForNode(node); EXPECT_TRUE(controller); @@ -120,7 +121,7 @@ TEST_F(BookmarkBubbleControllerTest, TestClosingParentWindow) { BookmarkModel* model = GetBookmarkModel(); const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(), 0, - L"Bookie markie title", + ASCIIToUTF16("Bookie markie title"), GURL("http://www.google.com")); BookmarkBubbleController* controller = ControllerForNode(node); EXPECT_TRUE(controller); @@ -138,22 +139,25 @@ TEST_F(BookmarkBubbleControllerTest, TestFillInFolder) { EXPECT_TRUE(model); const BookmarkNode* bookmarkBarNode = model->GetBookmarkBarNode(); EXPECT_TRUE(bookmarkBarNode); - const BookmarkNode* node1 = model->AddGroup(bookmarkBarNode, 0, L"one"); + const BookmarkNode* node1 = model->AddGroup(bookmarkBarNode, 0, + ASCIIToUTF16("one")); EXPECT_TRUE(node1); - const BookmarkNode* node2 = model->AddGroup(bookmarkBarNode, 1, L"two"); + const BookmarkNode* node2 = model->AddGroup(bookmarkBarNode, 1, + ASCIIToUTF16("two")); EXPECT_TRUE(node2); - const BookmarkNode* node3 = model->AddGroup(bookmarkBarNode, 2, L"three"); + const BookmarkNode* node3 = model->AddGroup(bookmarkBarNode, 2, + ASCIIToUTF16("three")); EXPECT_TRUE(node3); - const BookmarkNode* node4 = model->AddGroup(node2, 0, L"sub"); + const BookmarkNode* node4 = model->AddGroup(node2, 0, ASCIIToUTF16("sub")); EXPECT_TRUE(node4); - const BookmarkNode* node5 = - model->AddURL(node1, 0, L"title1", GURL("http://www.google.com")); + const BookmarkNode* node5 = model->AddURL(node1, 0, ASCIIToUTF16("title1"), + GURL("http://www.google.com")); EXPECT_TRUE(node5); - const BookmarkNode* node6 = - model->AddURL(node3, 0, L"title2", GURL("http://www.google.com")); + const BookmarkNode* node6 = model->AddURL(node3, 0, ASCIIToUTF16("title2"), + GURL("http://www.google.com")); EXPECT_TRUE(node6); - const BookmarkNode* node7 = - model->AddURL(node4, 0, L"title3", GURL("http://www.google.com/reader")); + const BookmarkNode* node7 = model->AddURL(node4, 0, ASCIIToUTF16("title3"), + GURL("http://www.google.com/reader")); EXPECT_TRUE(node7); BookmarkBubbleController* controller = ControllerForNode(node4); @@ -176,14 +180,17 @@ TEST_F(BookmarkBubbleControllerTest, TestFolderWithBlankName) { EXPECT_TRUE(model); const BookmarkNode* bookmarkBarNode = model->GetBookmarkBarNode(); EXPECT_TRUE(bookmarkBarNode); - const BookmarkNode* node1 = model->AddGroup(bookmarkBarNode, 0, L"one"); + const BookmarkNode* node1 = model->AddGroup(bookmarkBarNode, 0, + ASCIIToUTF16("one")); EXPECT_TRUE(node1); - const BookmarkNode* node2 = model->AddGroup(bookmarkBarNode, 1, L""); + const BookmarkNode* node2 = model->AddGroup(bookmarkBarNode, 1, + ASCIIToUTF16("")); EXPECT_TRUE(node2); - const BookmarkNode* node3 = model->AddGroup(bookmarkBarNode, 2, L"three"); + const BookmarkNode* node3 = model->AddGroup(bookmarkBarNode, 2, + ASCIIToUTF16("three")); EXPECT_TRUE(node3); - const BookmarkNode* node2_1 = - model->AddURL(node2, 0, L"title1", GURL("http://www.google.com")); + const BookmarkNode* node2_1 = model->AddURL(node2, 0, ASCIIToUTF16("title1"), + GURL("http://www.google.com")); EXPECT_TRUE(node2_1); BookmarkBubbleController* controller = ControllerForNode(node1); @@ -210,7 +217,7 @@ TEST_F(BookmarkBubbleControllerTest, TestEdit) { BookmarkModel* model = GetBookmarkModel(); const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(), 0, - L"Bookie markie title", + ASCIIToUTF16("Bookie markie title"), GURL("http://www.google.com")); BookmarkBubbleController* controller = ControllerForNode(node); EXPECT_TRUE(controller); @@ -226,10 +233,9 @@ TEST_F(BookmarkBubbleControllerTest, TestEdit) { // Also confirm pulse notifications get sent. TEST_F(BookmarkBubbleControllerTest, TestClose) { BookmarkModel* model = GetBookmarkModel(); - const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(), - 0, - L"Bookie markie title", - GURL("http://www.google.com")); + const BookmarkNode* node = model->AddURL( + model->GetBookmarkBarNode(), 0, ASCIIToUTF16("Bookie markie title"), + GURL("http://www.google.com")); EXPECT_EQ(edits_, 0); scoped_nsobject<BookmarkPulseObserver> observer([[BookmarkPulseObserver alloc] @@ -253,11 +259,13 @@ TEST_F(BookmarkBubbleControllerTest, TestUserEdit) { EXPECT_TRUE(bookmarkBarNode); const BookmarkNode* node = model->AddURL(bookmarkBarNode, 0, - L"short-title", + ASCIIToUTF16("short-title"), GURL("http://www.google.com")); - const BookmarkNode* grandma = model->AddGroup(bookmarkBarNode, 0, L"grandma"); + const BookmarkNode* grandma = model->AddGroup(bookmarkBarNode, 0, + ASCIIToUTF16("grandma")); EXPECT_TRUE(grandma); - const BookmarkNode* grandpa = model->AddGroup(bookmarkBarNode, 0, L"grandpa"); + const BookmarkNode* grandpa = model->AddGroup(bookmarkBarNode, 0, + ASCIIToUTF16("grandpa")); EXPECT_TRUE(grandpa); BookmarkBubbleController* controller = ControllerForNode(node); @@ -268,8 +276,8 @@ TEST_F(BookmarkBubbleControllerTest, TestUserEdit) { [controller edit:controller]; // Make sure bookmark has changed - EXPECT_EQ(node->GetTitle(), L"oops"); - EXPECT_EQ(node->GetParent()->GetTitle(), L"grandma"); + EXPECT_EQ(node->GetTitleAsString16(), ASCIIToUTF16("oops")); + EXPECT_EQ(node->GetParent()->GetTitleAsString16(), ASCIIToUTF16("grandma")); } // Confirm happiness with parent nodes that have the same name. @@ -281,14 +289,15 @@ TEST_F(BookmarkBubbleControllerTest, TestNewParentSameName) { for (int i=0; i<2; i++) { const BookmarkNode* node = model->AddURL(bookmarkBarNode, 0, - L"short-title", + ASCIIToUTF16("short-title"), GURL("http://www.google.com")); EXPECT_TRUE(node); - const BookmarkNode* group = model->AddGroup(bookmarkBarNode, 0, L"NAME"); + const BookmarkNode* group = model->AddGroup(bookmarkBarNode, 0, + ASCIIToUTF16("NAME")); EXPECT_TRUE(group); - group = model->AddGroup(bookmarkBarNode, 0, L"NAME"); + group = model->AddGroup(bookmarkBarNode, 0, ASCIIToUTF16("NAME")); EXPECT_TRUE(group); - group = model->AddGroup(bookmarkBarNode, 0, L"NAME"); + group = model->AddGroup(bookmarkBarNode, 0, ASCIIToUTF16("NAME")); EXPECT_TRUE(group); BookmarkBubbleController* controller = ControllerForNode(node); EXPECT_TRUE(controller); @@ -308,9 +317,11 @@ TEST_F(BookmarkBubbleControllerTest, TestDuplicateNodeNames) { BookmarkModel* model = GetBookmarkModel(); const BookmarkNode* bookmarkBarNode = model->GetBookmarkBarNode(); EXPECT_TRUE(bookmarkBarNode); - const BookmarkNode* node1 = model->AddGroup(bookmarkBarNode, 0, L"NAME"); + const BookmarkNode* node1 = model->AddGroup(bookmarkBarNode, 0, + ASCIIToUTF16("NAME")); EXPECT_TRUE(node1); - const BookmarkNode* node2 = model->AddGroup(bookmarkBarNode, 0, L"NAME"); + const BookmarkNode* node2 = model->AddGroup(bookmarkBarNode, 0, + ASCIIToUTF16("NAME")); EXPECT_TRUE(node2); BookmarkBubbleController* controller = ControllerForNode(bookmarkBarNode); EXPECT_TRUE(controller); @@ -332,7 +343,7 @@ TEST_F(BookmarkBubbleControllerTest, TestRemove) { GURL gurl("http://www.google.com"); const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(), 0, - L"Bookie markie title", + ASCIIToUTF16("Bookie markie title"), gurl); BookmarkBubbleController* controller = ControllerForNode(node); EXPECT_TRUE(controller); @@ -348,7 +359,7 @@ TEST_F(BookmarkBubbleControllerTest, PopUpSelectionChanged) { BookmarkModel* model = GetBookmarkModel(); GURL gurl("http://www.google.com"); const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(), - 0, L"super-title", + 0, ASCIIToUTF16("super-title"), gurl); BookmarkBubbleController* controller = ControllerForNode(node); EXPECT_TRUE(controller); @@ -368,7 +379,7 @@ TEST_F(BookmarkBubbleControllerTest, EscapeRemovesNewBookmark) { GURL gurl("http://www.google.com"); const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(), 0, - L"Bookie markie title", + ASCIIToUTF16("Bookie markie title"), gurl); BookmarkBubbleController* controller = [[BookmarkBubbleController alloc] @@ -390,7 +401,7 @@ TEST_F(BookmarkBubbleControllerTest, EscapeDoesntTouchExistingBookmark) { GURL gurl("http://www.google.com"); const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(), 0, - L"Bookie markie title", + ASCIIToUTF16("Bookie markie title"), gurl); BookmarkBubbleController* controller = ControllerForNode(node); EXPECT_TRUE(controller); @@ -406,13 +417,17 @@ TEST_F(BookmarkBubbleControllerTest, TestMenuIndentation) { EXPECT_TRUE(model); const BookmarkNode* bookmarkBarNode = model->GetBookmarkBarNode(); EXPECT_TRUE(bookmarkBarNode); - const BookmarkNode* node1 = model->AddGroup(bookmarkBarNode, 0, L"one"); + const BookmarkNode* node1 = model->AddGroup(bookmarkBarNode, 0, + ASCIIToUTF16("one")); EXPECT_TRUE(node1); - const BookmarkNode* node2 = model->AddGroup(bookmarkBarNode, 1, L"two"); + const BookmarkNode* node2 = model->AddGroup(bookmarkBarNode, 1, + ASCIIToUTF16("two")); EXPECT_TRUE(node2); - const BookmarkNode* node2_1 = model->AddGroup(node2, 0, L"two dot one"); + const BookmarkNode* node2_1 = model->AddGroup(node2, 0, + ASCIIToUTF16("two dot one")); EXPECT_TRUE(node2_1); - const BookmarkNode* node3 = model->AddGroup(bookmarkBarNode, 2, L"three"); + const BookmarkNode* node3 = model->AddGroup(bookmarkBarNode, 2, + ASCIIToUTF16("three")); EXPECT_TRUE(node3); BookmarkBubbleController* controller = ControllerForNode(node1); @@ -435,7 +450,7 @@ TEST_F(BookmarkBubbleControllerTest, BubbleGoesAwayOnNewTab) { BookmarkModel* model = GetBookmarkModel(); const BookmarkNode* node = model->AddURL(model->GetBookmarkBarNode(), 0, - L"Bookie markie title", + ASCIIToUTF16("Bookie markie title"), GURL("http://www.google.com")); EXPECT_EQ(edits_, 0); diff --git a/chrome/browser/cocoa/bookmark_editor_base_controller.mm b/chrome/browser/cocoa/bookmark_editor_base_controller.mm index af88ea7..a431c20 100644 --- a/chrome/browser/cocoa/bookmark_editor_base_controller.mm +++ b/chrome/browser/cocoa/bookmark_editor_base_controller.mm @@ -463,7 +463,7 @@ class BookmarkEditorBaseControllerBridge : public BookmarkModelObserver { BookmarkModel* model = [self bookmarkModel]; const BookmarkNode* newFolder = model->AddGroup(parentNode, i, - base::SysNSStringToWide([subFolderInfo folderName])); + base::SysNSStringToUTF16([subFolderInfo folderName])); // Update our dictionary with the actual folder node just created. [subFolderInfo setFolderNode:newFolder]; [subFolderInfo setNewFolder:NO]; diff --git a/chrome/browser/cocoa/bookmark_editor_base_controller_unittest.mm b/chrome/browser/cocoa/bookmark_editor_base_controller_unittest.mm index 2550aec..363461b 100644 --- a/chrome/browser/cocoa/bookmark_editor_base_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_editor_base_controller_unittest.mm @@ -7,6 +7,7 @@ #include "app/l10n_util_mac.h" #include "base/scoped_nsobject.h" #include "base/sys_string_conversions.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_model.h" #import "chrome/browser/cocoa/bookmark_editor_controller.h" #include "chrome/browser/cocoa/browser_test_helper.h" @@ -39,28 +40,28 @@ class BookmarkEditorBaseControllerTest : public CocoaTest { // b-4 BookmarkModel& model(*(browser_helper_.profile()->GetBookmarkModel())); const BookmarkNode* root = model.GetBookmarkBarNode(); - group_a_ = model.AddGroup(root, 0, L"a"); - model.AddURL(group_a_, 0, L"a-0", GURL("http://a-0.com")); - model.AddURL(group_a_, 1, L"a-1", GURL("http://a-1.com")); - model.AddURL(group_a_, 2, L"a-2", GURL("http://a-2.com")); - - group_b_ = model.AddGroup(root, 1, L"b"); - group_b_0_ = model.AddGroup(group_b_, 0, L"b-0"); - model.AddURL(group_b_0_, 0, L"bb-0", GURL("http://bb-0.com")); - model.AddURL(group_b_, 1, L"b-1", GURL("http://b-1.com")); - model.AddURL(group_b_, 2, L"b-2", GURL("http://b-2.com")); - group_b_3_ = model.AddGroup(group_b_, 3, L"b-3"); - model.AddURL(group_b_3_, 0, L"b-30", GURL("http://b-30.com")); - model.AddURL(group_b_3_, 1, L"b-31", GURL("http://b-31.com")); - model.AddURL(group_b_, 4, L"b-4", GURL("http://b-4.com")); - - group_c_ = model.AddGroup(root, 2, L"c"); - model.AddURL(group_c_, 0, L"c-0", GURL("http://c-0.com")); - model.AddURL(group_c_, 1, L"c-1", GURL("http://c-1.com")); - model.AddURL(group_c_, 2, L"c-2", GURL("http://c-2.com")); - model.AddURL(group_c_, 3, L"c-3", GURL("http://c-3.com")); - - model.AddURL(root, 3, L"d", GURL("http://d-0.com")); + group_a_ = model.AddGroup(root, 0, ASCIIToUTF16("a")); + model.AddURL(group_a_, 0, ASCIIToUTF16("a-0"), GURL("http://a-0.com")); + model.AddURL(group_a_, 1, ASCIIToUTF16("a-1"), GURL("http://a-1.com")); + model.AddURL(group_a_, 2, ASCIIToUTF16("a-2"), GURL("http://a-2.com")); + + group_b_ = model.AddGroup(root, 1, ASCIIToUTF16("b")); + group_b_0_ = model.AddGroup(group_b_, 0, ASCIIToUTF16("b-0")); + model.AddURL(group_b_0_, 0, ASCIIToUTF16("bb-0"), GURL("http://bb-0.com")); + model.AddURL(group_b_, 1, ASCIIToUTF16("b-1"), GURL("http://b-1.com")); + model.AddURL(group_b_, 2, ASCIIToUTF16("b-2"), GURL("http://b-2.com")); + group_b_3_ = model.AddGroup(group_b_, 3, ASCIIToUTF16("b-3")); + model.AddURL(group_b_3_, 0, ASCIIToUTF16("b-30"), GURL("http://b-30.com")); + model.AddURL(group_b_3_, 1, ASCIIToUTF16("b-31"), GURL("http://b-31.com")); + model.AddURL(group_b_, 4, ASCIIToUTF16("b-4"), GURL("http://b-4.com")); + + group_c_ = model.AddGroup(root, 2, ASCIIToUTF16("c")); + model.AddURL(group_c_, 0, ASCIIToUTF16("c-0"), GURL("http://c-0.com")); + model.AddURL(group_c_, 1, ASCIIToUTF16("c-1"), GURL("http://c-1.com")); + model.AddURL(group_c_, 2, ASCIIToUTF16("c-2"), GURL("http://c-2.com")); + model.AddURL(group_c_, 3, ASCIIToUTF16("c-3"), GURL("http://c-3.com")); + + model.AddURL(root, 3, ASCIIToUTF16("d"), GURL("http://d-0.com")); } virtual BookmarkEditorBaseController* CreateController() { @@ -207,7 +208,8 @@ TEST_F(BookmarkEditorBaseControllerTest, FolderAdded) { const BookmarkNode* root = model.GetBookmarkBarNode(); // Add a group node to the model, and verify it can be selected in the tree: - const BookmarkNode* group_added = model.AddGroup(root, 0, L"added"); + const BookmarkNode* group_added = model.AddGroup(root, 0, + ASCIIToUTF16("added")); [controller_ selectTestNodeInBrowser:group_added]; EXPECT_EQ(group_added, [controller_ selectedNode]); diff --git a/chrome/browser/cocoa/bookmark_editor_controller_unittest.mm b/chrome/browser/cocoa/bookmark_editor_controller_unittest.mm index 57b583c..87f8210 100644 --- a/chrome/browser/cocoa/bookmark_editor_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_editor_controller_unittest.mm @@ -4,7 +4,9 @@ #import <Cocoa/Cocoa.h> +#include "base/string16.h" #include "base/sys_string_conversions.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_model.h" #import "chrome/browser/cocoa/bookmark_editor_controller.h" #include "chrome/browser/cocoa/browser_test_helper.h" @@ -19,7 +21,7 @@ class BookmarkEditorControllerTest : public CocoaTest { const BookmarkNode* default_node_; const BookmarkNode* default_parent_; const char* default_name_; - std::wstring default_title_; + string16 default_title_; BookmarkEditorController* controller_; virtual void SetUp() { @@ -27,7 +29,7 @@ class BookmarkEditorControllerTest : public CocoaTest { BookmarkModel* model = browser_helper_.profile()->GetBookmarkModel(); default_parent_ = model->GetBookmarkBarNode(); default_name_ = "http://www.zim-bop-a-dee.com/"; - default_title_ = L"ooh title"; + default_title_ = ASCIIToUTF16("ooh title"); const BookmarkNode* default_node = model->AddURL(default_parent_, 0, default_title_, GURL(default_name_)); @@ -50,7 +52,7 @@ TEST_F(BookmarkEditorControllerTest, NoEdit) { [controller_ cancel:nil]; ASSERT_EQ(default_parent_->GetChildCount(), 1); const BookmarkNode* child = default_parent_->GetChild(0); - EXPECT_EQ(child->GetTitle(), default_title_); + EXPECT_EQ(child->GetTitleAsString16(), default_title_); EXPECT_EQ(child->GetURL(), GURL(default_name_)); } @@ -70,7 +72,7 @@ TEST_F(BookmarkEditorControllerTest, EditURL) { [controller_ ok:nil]; ASSERT_EQ(default_parent_->GetChildCount(), 1); const BookmarkNode* child = default_parent_->GetChild(0); - EXPECT_EQ(child->GetTitle(), default_title_); + EXPECT_EQ(child->GetTitleAsString16(), default_title_); EXPECT_EQ(child->GetURL(), GURL("http://yellow-sneakers.com/")); } @@ -163,7 +165,7 @@ TEST_F(BookmarkEditorControllerNoNodeTest, NoNodeNoTree) { class BookmarkEditorControllerYesNodeTest : public CocoaTest { public: BrowserTestHelper browser_helper_; - std::wstring default_title_; + string16 default_title_; const char* url_name_; BookmarkEditorController* controller_; @@ -171,7 +173,7 @@ class BookmarkEditorControllerYesNodeTest : public CocoaTest { CocoaTest::SetUp(); BookmarkModel* model = browser_helper_.profile()->GetBookmarkModel(); const BookmarkNode* parent = model->GetBookmarkBarNode(); - default_title_ = L"wooh title"; + default_title_ = ASCIIToUTF16("wooh title"); url_name_ = "http://www.zoom-baby-doo-da.com/"; const BookmarkNode* node = model->AddURL(parent, 0, default_title_, GURL(url_name_)); @@ -192,7 +194,7 @@ class BookmarkEditorControllerYesNodeTest : public CocoaTest { }; TEST_F(BookmarkEditorControllerYesNodeTest, YesNodeShowTree) { - EXPECT_NSEQ(base::SysWideToNSString(default_title_), + EXPECT_NSEQ(base::SysUTF16ToNSString(default_title_), [controller_ displayName]); EXPECT_NSEQ([NSString stringWithCString:url_name_ encoding:NSUTF8StringEncoding], @@ -226,35 +228,36 @@ class BookmarkEditorControllerTreeTest : public CocoaTest { // b-2 BookmarkModel& model(*(browser_helper_.profile()->GetBookmarkModel())); const BookmarkNode* root = model.GetBookmarkBarNode(); - group_a_ = model.AddGroup(root, 0, L"a"); - model.AddURL(group_a_, 0, L"a-0", GURL("http://a-0.com")); - model.AddURL(group_a_, 1, L"a-1", GURL("http://a-1.com")); - model.AddURL(group_a_, 2, L"a-2", GURL("http://a-2.com")); - - group_b_ = model.AddGroup(root, 1, L"b"); - model.AddURL(group_b_, 0, L"b-0", GURL("http://b-0.com")); - group_bb_ = model.AddGroup(group_b_, 1, L"bb"); - model.AddURL(group_bb_, 0, L"bb-0", GURL("http://bb-0.com")); - model.AddURL(group_bb_, 1, L"bb-1", GURL("http://bb-1.com")); - model.AddURL(group_bb_, 2, L"bb-2", GURL("http://bb-2.com")); + group_a_ = model.AddGroup(root, 0, ASCIIToUTF16("a")); + model.AddURL(group_a_, 0, ASCIIToUTF16("a-0"), GURL("http://a-0.com")); + model.AddURL(group_a_, 1, ASCIIToUTF16("a-1"), GURL("http://a-1.com")); + model.AddURL(group_a_, 2, ASCIIToUTF16("a-2"), GURL("http://a-2.com")); + + group_b_ = model.AddGroup(root, 1, ASCIIToUTF16("b")); + model.AddURL(group_b_, 0, ASCIIToUTF16("b-0"), GURL("http://b-0.com")); + group_bb_ = model.AddGroup(group_b_, 1, ASCIIToUTF16("bb")); + model.AddURL(group_bb_, 0, ASCIIToUTF16("bb-0"), GURL("http://bb-0.com")); + model.AddURL(group_bb_, 1, ASCIIToUTF16("bb-1"), GURL("http://bb-1.com")); + model.AddURL(group_bb_, 2, ASCIIToUTF16("bb-2"), GURL("http://bb-2.com")); // To find it later, this bookmark name must always have a URL // of http://bb-3.com or https://bb-3.com bb3_url_1_ = GURL("http://bb-3.com"); bb3_url_2_ = GURL("https://bb-3.com"); - bookmark_bb_3_ = model.AddURL(group_bb_, 3, L"bb-3", bb3_url_1_); + bookmark_bb_3_ = model.AddURL(group_bb_, 3, ASCIIToUTF16("bb-3"), + bb3_url_1_); - model.AddURL(group_bb_, 4, L"bb-4", GURL("http://bb-4.com")); - model.AddURL(group_b_, 2, L"b-1", GURL("http://b-2.com")); - model.AddURL(group_b_, 3, L"b-2", GURL("http://b-3.com")); + model.AddURL(group_bb_, 4, ASCIIToUTF16("bb-4"), GURL("http://bb-4.com")); + model.AddURL(group_b_, 2, ASCIIToUTF16("b-1"), GURL("http://b-2.com")); + model.AddURL(group_b_, 3, ASCIIToUTF16("b-2"), GURL("http://b-3.com")); - group_c_ = model.AddGroup(root, 2, L"c"); - model.AddURL(group_c_, 0, L"c-0", GURL("http://c-0.com")); - model.AddURL(group_c_, 1, L"c-1", GURL("http://c-1.com")); - model.AddURL(group_c_, 2, L"c-2", GURL("http://c-2.com")); - model.AddURL(group_c_, 3, L"c-3", GURL("http://c-3.com")); + group_c_ = model.AddGroup(root, 2, ASCIIToUTF16("c")); + model.AddURL(group_c_, 0, ASCIIToUTF16("c-0"), GURL("http://c-0.com")); + model.AddURL(group_c_, 1, ASCIIToUTF16("c-1"), GURL("http://c-1.com")); + model.AddURL(group_c_, 2, ASCIIToUTF16("c-2"), GURL("http://c-2.com")); + model.AddURL(group_c_, 3, ASCIIToUTF16("c-3"), GURL("http://c-3.com")); - model.AddURL(root, 3, L"d", GURL("http://d-0.com")); + model.AddURL(root, 3, ASCIIToUTF16("d"), GURL("http://d-0.com")); } virtual BookmarkEditorController* CreateController() { diff --git a/chrome/browser/cocoa/bookmark_menu_bridge_unittest.mm b/chrome/browser/cocoa/bookmark_menu_bridge_unittest.mm index 4f275eb..56590ff 100644 --- a/chrome/browser/cocoa/bookmark_menu_bridge_unittest.mm +++ b/chrome/browser/cocoa/bookmark_menu_bridge_unittest.mm @@ -1,10 +1,13 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #import <AppKit/AppKit.h> + #import "base/scoped_nsobject.h" +#include "base/string16.h" #include "base/string_util.h" +#include "base/utf_string_conversions.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/browser.h" @@ -86,8 +89,7 @@ TEST_F(BookmarkMenuBridgeTest, TestBookmarkMenuAutoSeparator) { // menu contents plus a new separator and the new bookmark. const BookmarkNode* parent = model->GetBookmarkBarNode(); const char* url = "http://www.zim-bop-a-dee.com/"; - std::wstring title(L"Bookmark"); - model->AddURL(parent, 0, title, GURL(url)); + model->AddURL(parent, 0, ASCIIToUTF16("Bookmark"), GURL(url)); bridge_->UpdateMenu(menu); EXPECT_EQ(4, [menu numberOfItems]); // Remove the new bookmark and reload and we should have 2 items again @@ -139,8 +141,7 @@ TEST_F(BookmarkMenuBridgeTest, TestInvalidation) { const BookmarkNode* parent = model->GetBookmarkBarNode(); const char* url = "http://www.zim-bop-a-dee.com/"; - std::wstring title(L"Bookmark"); - model->AddURL(parent, 0, title, GURL(url)); + model->AddURL(parent, 0, ASCIIToUTF16("Bookmark"), GURL(url)); EXPECT_FALSE(menu_is_valid()); bridge_->UpdateMenu(bridge_->menu_); @@ -150,7 +151,7 @@ TEST_F(BookmarkMenuBridgeTest, TestInvalidation) { // Test that AddNodeToMenu() properly adds bookmark nodes as menus, // including the recursive case. TEST_F(BookmarkMenuBridgeTest, TestAddNodeToMenu) { - std::wstring empty; + string16 empty; NSMenu* menu = bridge_->menu_.get(); BookmarkModel* model = bridge_->GetBookmarkModel(); @@ -166,11 +167,11 @@ TEST_F(BookmarkMenuBridgeTest, TestAddNodeToMenu) { // 3 nodes; middle one has a child, last one has a HUGE URL // Set their titles to be the same as the URLs const BookmarkNode* node = NULL; - model->AddURL(root, 0, ASCIIToWide(short_url), GURL(short_url)); + model->AddURL(root, 0, ASCIIToUTF16(short_url), GURL(short_url)); bridge_->UpdateMenu(menu); int prev_count = [menu numberOfItems] - 1; // "extras" added at this point node = model->AddGroup(root, 1, empty); - model->AddURL(root, 2, ASCIIToWide(long_url), GURL(long_url)); + model->AddURL(root, 2, ASCIIToUTF16(long_url), GURL(long_url)); // And the submenu fo the middle one model->AddURL(node, 0, empty, GURL("http://sub")); @@ -225,7 +226,7 @@ TEST_F(BookmarkMenuBridgeTest, TestAddNodeToMenu) { // Makes sure our internal map of BookmarkNode to NSMenuItem works. TEST_F(BookmarkMenuBridgeTest, TestGetMenuItemForNode) { - std::wstring empty; + string16 empty; NSMenu* menu = bridge_->menu_.get(); BookmarkModel* model = bridge_->GetBookmarkModel(); @@ -233,11 +234,11 @@ TEST_F(BookmarkMenuBridgeTest, TestGetMenuItemForNode) { const BookmarkNode* root = model->AddGroup(bookmark_bar, 0, empty); EXPECT_TRUE(model && root); - model->AddURL(root, 0, ASCIIToWide("Test Item"), GURL("http://test")); + model->AddURL(root, 0, ASCIIToUTF16("Test Item"), GURL("http://test")); AddNodeToMenu(bridge_.get(), root, menu); EXPECT_TRUE(MenuItemForNode(bridge_.get(), root->GetChild(0))); - model->AddURL(root, 1, ASCIIToWide("Test 2"), GURL("http://second-test")); + model->AddURL(root, 1, ASCIIToUTF16("Test 2"), GURL("http://second-test")); AddNodeToMenu(bridge_.get(), root, menu); EXPECT_TRUE(MenuItemForNode(bridge_.get(), root->GetChild(0))); EXPECT_TRUE(MenuItemForNode(bridge_.get(), root->GetChild(1))); @@ -257,7 +258,6 @@ TEST_F(BookmarkMenuBridgeTest, TestGetMenuItemForNode) { // Test that Loaded() adds both the bookmark bar nodes and the "other" nodes. TEST_F(BookmarkMenuBridgeTest, TestAddNodeToOther) { - std::wstring empty; NSMenu* menu = bridge_->menu_.get(); BookmarkModel* model = bridge_->GetBookmarkModel(); @@ -265,7 +265,7 @@ TEST_F(BookmarkMenuBridgeTest, TestAddNodeToOther) { EXPECT_TRUE(model && root); const char* short_url = "http://foo/"; - model->AddURL(root, 0, ASCIIToWide(short_url), GURL(short_url)); + model->AddURL(root, 0, ASCIIToUTF16(short_url), GURL(short_url)); bridge_->UpdateMenu(menu); ASSERT_GT([menu numberOfItems], 0); @@ -277,7 +277,6 @@ TEST_F(BookmarkMenuBridgeTest, TestAddNodeToOther) { } TEST_F(BookmarkMenuBridgeTest, TestFavIconLoading) { - std::wstring empty; NSMenu* menu = bridge_->menu_; BookmarkModel* model = bridge_->GetBookmarkModel(); @@ -285,7 +284,7 @@ TEST_F(BookmarkMenuBridgeTest, TestFavIconLoading) { EXPECT_TRUE(model && root); const BookmarkNode* node = - model->AddURL(root, 0, ASCIIToWide("Test Item"), + model->AddURL(root, 0, ASCIIToUTF16("Test Item"), GURL("http://favicon-test")); bridge_->UpdateMenu(menu); NSMenuItem* item = [menu itemWithTitle:@"Test Item"]; @@ -302,13 +301,13 @@ TEST_F(BookmarkMenuBridgeTest, TestChangeTitle) { EXPECT_TRUE(model && root); const BookmarkNode* node = - model->AddURL(root, 0, L"Test Item", + model->AddURL(root, 0, ASCIIToUTF16("Test Item"), GURL("http://title-test")); bridge_->UpdateMenu(menu); NSMenuItem* item = [menu itemWithTitle:@"Test Item"]; EXPECT_TRUE([item image]); - model->SetTitle(node, L"New Title"); + model->SetTitle(node, ASCIIToUTF16("New Title")); item = [menu itemWithTitle:@"Test Item"]; EXPECT_FALSE(item); diff --git a/chrome/browser/cocoa/bookmark_name_folder_controller.mm b/chrome/browser/cocoa/bookmark_name_folder_controller.mm index 108d87a..57b9116 100644 --- a/chrome/browser/cocoa/bookmark_name_folder_controller.mm +++ b/chrome/browser/cocoa/bookmark_name_folder_controller.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -94,7 +94,7 @@ } else { model->AddGroup(parent_, newIndex_, - base::SysNSStringToWide(name)); + base::SysNSStringToUTF16(name)); } [NSApp endSheet:[self window]]; } diff --git a/chrome/browser/cocoa/bookmark_name_folder_controller_unittest.mm b/chrome/browser/cocoa/bookmark_name_folder_controller_unittest.mm index 56654a1..9419b8f 100644 --- a/chrome/browser/cocoa/bookmark_name_folder_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_name_folder_controller_unittest.mm @@ -1,10 +1,11 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #import <Cocoa/Cocoa.h> #include "base/scoped_nsobject.h" +#include "base/utf_string_conversions.h" #import "chrome/browser/cocoa/bookmark_name_folder_controller.h" #include "chrome/browser/cocoa/browser_test_helper.h" #import "chrome/browser/cocoa/cocoa_test_helper.h" @@ -45,7 +46,7 @@ TEST_F(BookmarkNameFolderControllerTest, AddNew) { [controller ok:nil]; EXPECT_EQ(1, parent->GetChildCount()); EXPECT_TRUE(parent->GetChild(0)->is_folder()); - EXPECT_EQ(L"Bozo", parent->GetChild(0)->GetTitle()); + EXPECT_EQ(ASCIIToUTF16("Bozo"), parent->GetChild(0)->GetTitleAsString16()); } // Add new but specify a sibling. @@ -54,8 +55,10 @@ TEST_F(BookmarkNameFolderControllerTest, AddNewWithSibling) { const BookmarkNode* parent = model->GetBookmarkBarNode(); // Add 2 nodes. We will place the new folder in the middle of these. - model->AddURL(parent, 0, L"title 1", GURL("http://www.google.com")); - model->AddURL(parent, 1, L"title 3", GURL("http://www.google.com")); + model->AddURL(parent, 0, ASCIIToUTF16("title 1"), + GURL("http://www.google.com")); + model->AddURL(parent, 1, ASCIIToUTF16("title 3"), + GURL("http://www.google.com")); EXPECT_EQ(2, parent->GetChildCount()); scoped_nsobject<BookmarkNameFolderController> @@ -73,7 +76,7 @@ TEST_F(BookmarkNameFolderControllerTest, AddNewWithSibling) { // Confirm we now have 3, and that the new one is in the middle. EXPECT_EQ(3, parent->GetChildCount()); EXPECT_TRUE(parent->GetChild(1)->is_folder()); - EXPECT_EQ(L"middle", parent->GetChild(1)->GetTitle()); + EXPECT_EQ(ASCIIToUTF16("middle"), parent->GetChild(1)->GetTitleAsString16()); } // Make sure we are allowed to create a folder named "New Folder". @@ -123,7 +126,7 @@ TEST_F(BookmarkNameFolderControllerTest, Rename) { const BookmarkNode* parent = model->GetBookmarkBarNode(); const BookmarkNode* folder = model->AddGroup(parent, parent->GetChildCount(), - L"group"); + ASCIIToUTF16("group")); // Rename the folder by creating a controller that originates from // the node. @@ -139,7 +142,7 @@ TEST_F(BookmarkNameFolderControllerTest, Rename) { [controller ok:nil]; EXPECT_EQ(1, parent->GetChildCount()); EXPECT_TRUE(parent->GetChild(0)->is_folder()); - EXPECT_EQ(L"Zobo", parent->GetChild(0)->GetTitle()); + EXPECT_EQ(ASCIIToUTF16("Zobo"), parent->GetChild(0)->GetTitleAsString16()); } TEST_F(BookmarkNameFolderControllerTest, EditAndConfirmOKButton) { |
