OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/mac/mac_util.h" | 5 #include "base/mac/mac_util.h" |
6 #include "base/memory/scoped_nsobject.h" | 6 #include "base/memory/scoped_nsobject.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/sync/sync_ui_util.h" | 10 #include "chrome/browser/sync/sync_ui_util.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 } | 46 } |
47 | 47 |
48 - (NSView*)findBarView { | 48 - (NSView*)findBarView { |
49 return [findBarCocoaController_ view]; | 49 return [findBarCocoaController_ view]; |
50 } | 50 } |
51 | 51 |
52 - (NSSplitView*)devToolsView { | 52 - (NSSplitView*)devToolsView { |
53 return static_cast<NSSplitView*>([devToolsController_ view]); | 53 return static_cast<NSSplitView*>([devToolsController_ view]); |
54 } | 54 } |
55 | 55 |
56 - (NSView*)sidebarView { | |
57 return [sidebarController_ view]; | |
58 } | |
59 | |
60 - (BOOL)bookmarkBarVisible { | 56 - (BOOL)bookmarkBarVisible { |
61 return [bookmarkBarController_ isVisible]; | 57 return [bookmarkBarController_ isVisible]; |
62 } | 58 } |
63 @end | 59 @end |
64 | 60 |
65 class BrowserWindowControllerTest : public CocoaProfileTest { | 61 class BrowserWindowControllerTest : public CocoaProfileTest { |
66 public: | 62 public: |
67 virtual void SetUp() { | 63 virtual void SetUp() { |
68 CocoaProfileTest::SetUp(); | 64 CocoaProfileTest::SetUp(); |
69 ASSERT_TRUE(browser()); | 65 ASSERT_TRUE(browser()); |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 [subviews indexOfObject:[controller_ toolbarView]]; | 598 [subviews indexOfObject:[controller_ toolbarView]]; |
603 EXPECT_NE(NSNotFound, toolbar_index); | 599 EXPECT_NE(NSNotFound, toolbar_index); |
604 NSUInteger bookmark_index = | 600 NSUInteger bookmark_index = |
605 [subviews indexOfObject:[controller_ bookmarkView]]; | 601 [subviews indexOfObject:[controller_ bookmarkView]]; |
606 EXPECT_NE(NSNotFound, bookmark_index); | 602 EXPECT_NE(NSNotFound, bookmark_index); |
607 | 603 |
608 EXPECT_GT(findBar_index, toolbar_index); | 604 EXPECT_GT(findBar_index, toolbar_index); |
609 EXPECT_GT(findBar_index, bookmark_index); | 605 EXPECT_GT(findBar_index, bookmark_index); |
610 } | 606 } |
611 | 607 |
612 // Tests that the sidebar view and devtools view are both non-opaque. | |
613 TEST_F(BrowserWindowControllerTest, TestSplitViewsAreNotOpaque) { | |
614 // Add a subview to the sidebar view to mimic what happens when a tab is added | |
615 // to the window. NSSplitView only marks itself as non-opaque when one of its | |
616 // subviews is non-opaque, so the test will not pass without this subview. | |
617 scoped_nsobject<NSView> view( | |
618 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 10, 10)]); | |
619 [[controller_ sidebarView] addSubview:view]; | |
620 | |
621 EXPECT_FALSE([[controller_ tabContentArea] isOpaque]); | |
622 EXPECT_FALSE([[controller_ devToolsView] isOpaque]); | |
623 EXPECT_FALSE([[controller_ sidebarView] isOpaque]); | |
624 } | |
625 | |
626 // Tests that status bubble's base frame does move when devTools are docked. | 608 // Tests that status bubble's base frame does move when devTools are docked. |
627 TEST_F(BrowserWindowControllerTest, TestStatusBubblePositioning) { | 609 TEST_F(BrowserWindowControllerTest, TestStatusBubblePositioning) { |
628 ASSERT_EQ(1U, [[[controller_ devToolsView] subviews] count]); | 610 ASSERT_EQ(1U, [[[controller_ devToolsView] subviews] count]); |
629 | 611 |
630 NSPoint bubbleOrigin = [controller_ statusBubbleBaseFrame].origin; | 612 NSPoint bubbleOrigin = [controller_ statusBubbleBaseFrame].origin; |
631 | 613 |
632 // Add a fake subview to devToolsView to emulate docked devTools. | 614 // Add a fake subview to devToolsView to emulate docked devTools. |
633 scoped_nsobject<NSView> view( | 615 scoped_nsobject<NSView> view( |
634 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 10, 10)]); | 616 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 10, 10)]); |
635 [[controller_ devToolsView] addSubview:view]; | 617 [[controller_ devToolsView] addSubview:view]; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 testFullscreenWindow_.reset( | 712 testFullscreenWindow_.reset( |
731 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) | 713 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) |
732 styleMask:NSBorderlessWindowMask | 714 styleMask:NSBorderlessWindowMask |
733 backing:NSBackingStoreBuffered | 715 backing:NSBackingStoreBuffered |
734 defer:NO]); | 716 defer:NO]); |
735 return testFullscreenWindow_.get(); | 717 return testFullscreenWindow_.get(); |
736 } | 718 } |
737 @end | 719 @end |
738 | 720 |
739 /* TODO(???): test other methods of BrowserWindowController */ | 721 /* TODO(???): test other methods of BrowserWindowController */ |
OLD | NEW |