OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/scoped_nsobject.h" | 8 #include "base/scoped_nsobject.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #import "chrome/browser/cocoa/bookmark_bar_constants.h" | 10 #import "chrome/browser/cocoa/bookmark_bar_constants.h" |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
669 [button frame].size.height); | 669 [button frame].size.height); |
670 } | 670 } |
671 } | 671 } |
672 | 672 |
673 TEST_F(BookmarkBarControllerTest, DropBookmarks) { | 673 TEST_F(BookmarkBarControllerTest, DropBookmarks) { |
674 const char* urls[] = { | 674 const char* urls[] = { |
675 "http://qwantz.com", | 675 "http://qwantz.com", |
676 "http://xkcd.com", | 676 "http://xkcd.com", |
677 "javascript:alert('lolwut')" | 677 "javascript:alert('lolwut')" |
678 }; | 678 }; |
679 std::wstring titles[] = { | 679 std::wstring titles[] = { |
Mark Mentovai
2009/10/24 18:46:21
Does this even need to be std::wstring? You can m
Nico
2009/10/24 18:51:33
GetTitle() below returns a wstring, and the GURL c
| |
680 std::wstring(L"Philosophoraptor"), | 680 std::wstring(L"Philosophoraptor"), |
681 std::wstring(L"Can't draw"), | 681 std::wstring(L"Can't draw"), |
682 std::wstring(L"Inspiration") | 682 std::wstring(L"Inspiration") |
683 }; | 683 }; |
684 EXPECT_EQ(arraysize(urls), arraysize(titles)); | 684 EXPECT_EQ(arraysize(urls), arraysize(titles)); |
685 | 685 |
686 NSMutableArray* nsurls = [NSMutableArray arrayWithCapacity:0]; | 686 NSMutableArray* nsurls = [NSMutableArray arrayWithCapacity:0]; |
687 NSMutableArray* nstitles = [NSMutableArray arrayWithCapacity:0]; | 687 NSMutableArray* nstitles = [NSMutableArray arrayWithCapacity:0]; |
688 for (size_t i = 0; i < arraysize(urls); ++i) { | 688 for (size_t i = 0; i < arraysize(urls); ++i) { |
689 [nsurls addObject:[NSString stringWithCString:urls[i]]]; | 689 [nsurls addObject:base::SysUTF8ToNSString(urls[i])]; |
690 [nstitles addObject:base::SysWideToNSString(titles[i])]; | 690 [nstitles addObject:base::SysWideToNSString(titles[i])]; |
691 } | 691 } |
692 | 692 |
693 BookmarkModel* model = helper_.profile()->GetBookmarkModel(); | 693 BookmarkModel* model = helper_.profile()->GetBookmarkModel(); |
694 const BookmarkNode* parent = model->GetBookmarkBarNode(); | 694 const BookmarkNode* parent = model->GetBookmarkBarNode(); |
695 [bar_ addURLs:nsurls withTitles:nstitles at:NSZeroPoint]; | 695 [bar_ addURLs:nsurls withTitles:nstitles at:NSZeroPoint]; |
696 EXPECT_EQ(3, parent->GetChildCount()); | 696 EXPECT_EQ(3, parent->GetChildCount()); |
697 for (int i = 0; i < parent->GetChildCount(); ++i) { | 697 for (int i = 0; i < parent->GetChildCount(); ++i) { |
698 EXPECT_EQ(parent->GetChild(i)->GetURL(), GURL(urls[i])); | 698 EXPECT_EQ(parent->GetChild(i)->GetURL(), GURL(urls[i])); |
699 EXPECT_EQ(parent->GetChild(i)->GetTitle(), titles[i]); | 699 EXPECT_EQ(parent->GetChild(i)->GetTitle(), titles[i]); |
700 } | 700 } |
701 } | 701 } |
702 | 702 |
703 | 703 |
704 // Cannot test these methods since they simply call a single static | 704 // Cannot test these methods since they simply call a single static |
705 // method, BookmarkEditor::Show(), which is impossible to mock. | 705 // method, BookmarkEditor::Show(), which is impossible to mock. |
706 // editBookmark:, addPage: | 706 // editBookmark:, addPage: |
707 | 707 |
708 | 708 |
709 } // namespace | 709 } // namespace |
OLD | NEW |