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

Side by Side Diff: chrome/browser/cocoa/bookmark_bar_controller_unittest.mm

Issue 336001: [Mac] Make bookmark bar a primitive drag destination. (Closed)
Patch Set: cleanup Created 11 years, 2 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
OLDNEW
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 #import "chrome/browser/cocoa/bookmark_bar_constants.h" 10 #import "chrome/browser/cocoa/bookmark_bar_constants.h"
10 #import "chrome/browser/cocoa/bookmark_bar_controller.h" 11 #import "chrome/browser/cocoa/bookmark_bar_controller.h"
11 #import "chrome/browser/cocoa/bookmark_bar_view.h" 12 #import "chrome/browser/cocoa/bookmark_bar_view.h"
12 #include "chrome/browser/cocoa/browser_test_helper.h" 13 #include "chrome/browser/cocoa/browser_test_helper.h"
13 #import "chrome/browser/cocoa/cocoa_test_helper.h" 14 #import "chrome/browser/cocoa/cocoa_test_helper.h"
14 #import "chrome/browser/cocoa/toolbar_compressable.h" 15 #import "chrome/browser/cocoa/toolbar_compressable.h"
15 #include "chrome/browser/cocoa/test_event_utils.h" 16 #include "chrome/browser/cocoa/test_event_utils.h"
16 #import "chrome/browser/cocoa/view_resizer_pong.h" 17 #import "chrome/browser/cocoa/view_resizer_pong.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 NSArray* buttons = [bar_ buttons]; 663 NSArray* buttons = [bar_ buttons];
663 EXPECT_GT([buttons count], 0u); 664 EXPECT_GT([buttons count], 0u);
664 for (NSButton* button in buttons) { 665 for (NSButton* button in buttons) {
665 EXPECT_FLOAT_EQ( 666 EXPECT_FLOAT_EQ(
666 bookmarks::kBookmarkBarHeight - 2 * 667 bookmarks::kBookmarkBarHeight - 2 *
667 bookmarks::kBookmarkVerticalPadding, 668 bookmarks::kBookmarkVerticalPadding,
668 [button frame].size.height); 669 [button frame].size.height);
669 } 670 }
670 } 671 }
671 672
673 TEST_F(BookmarkBarControllerTest, DropBookmarks) {
674 const char* urls[] = {
675 "http://qwantz.com",
676 "http://xkcd.com",
677 "javascript:alert('lolwut')"
678 };
679 std::wstring titles[] = {
680 std::wstring(L"Philosophoraptor"),
681 std::wstring(L"Can't draw"),
682 std::wstring(L"Inspiration")
683 };
684 EXPECT_EQ(arraysize(urls), arraysize(titles));
685
686 NSMutableArray* nsurls = [NSMutableArray arrayWithCapacity:0];
687 NSMutableArray* nstitles = [NSMutableArray arrayWithCapacity:0];
688 for (size_t i = 0; i < arraysize(urls); ++i) {
689 [nsurls addObject:[NSString stringWithCString:urls[i]]];
690 [nstitles addObject:base::SysWideToNSString(titles[i])];
691 }
692
693 BookmarkModel* model = helper_.profile()->GetBookmarkModel();
694 const BookmarkNode* parent = model->GetBookmarkBarNode();
695 [bar_ addURLs:nsurls withTitles:nstitles at:NSZeroPoint];
696 EXPECT_EQ(3, parent->GetChildCount());
697 for (int i = 0; i < parent->GetChildCount(); ++i) {
698 EXPECT_EQ(parent->GetChild(i)->GetURL(), GURL(urls[i]));
699 EXPECT_EQ(parent->GetChild(i)->GetTitle(), titles[i]);
700 }
701 }
702
703
672 // Cannot test these methods since they simply call a single static 704 // Cannot test these methods since they simply call a single static
673 // method, BookmarkEditor::Show(), which is impossible to mock. 705 // method, BookmarkEditor::Show(), which is impossible to mock.
674 // editBookmark:, addPage: 706 // editBookmark:, addPage:
675 707
676 708
677 } // namespace 709 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698