Chromium Code Reviews| 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 #include "base/scoped_nsobject.h" | 5 #include "base/scoped_nsobject.h" |
| 6 #include "base/scoped_nsautorelease_pool.h" | 6 #include "base/scoped_nsautorelease_pool.h" |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/cocoa/browser_test_helper.h" | 9 #include "chrome/browser/cocoa/browser_test_helper.h" |
| 10 #include "chrome/browser/cocoa/browser_window_controller.h" | 10 #include "chrome/browser/cocoa/browser_window_controller.h" |
| 11 #include "chrome/browser/cocoa/cocoa_test_helper.h" | 11 #include "chrome/browser/cocoa/cocoa_test_helper.h" |
| 12 #include "chrome/browser/cocoa/find_bar_bridge.h" | |
| 12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/common/pref_service.h" | 14 #include "chrome/common/pref_service.h" |
| 14 #include "chrome/test/testing_browser_process.h" | 15 #include "chrome/test/testing_browser_process.h" |
| 15 #include "chrome/test/testing_profile.h" | 16 #include "chrome/test/testing_profile.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 @interface BrowserWindowController (JustForTesting) | 19 @interface BrowserWindowController (JustForTesting) |
| 19 // Already defined in BWC. | 20 // Already defined in BWC. |
| 20 - (void)saveWindowPositionToPrefs:(PrefService*)prefs; | 21 - (void)saveWindowPositionToPrefs:(PrefService*)prefs; |
| 21 - (void)layoutSubviews; | 22 - (void)layoutSubviews; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 36 } | 37 } |
| 37 | 38 |
| 38 - (NSView*)toolbarView { | 39 - (NSView*)toolbarView { |
| 39 return [toolbarController_ view]; | 40 return [toolbarController_ view]; |
| 40 } | 41 } |
| 41 | 42 |
| 42 - (NSView*)bookmarkView { | 43 - (NSView*)bookmarkView { |
| 43 return [bookmarkBarController_ view]; | 44 return [bookmarkBarController_ view]; |
| 44 } | 45 } |
| 45 | 46 |
| 47 - (NSView*)findBarView { | |
| 48 return [findBarCocoaController_ view]; | |
| 49 } | |
| 50 | |
| 46 - (BOOL)bookmarkBarVisible { | 51 - (BOOL)bookmarkBarVisible { |
| 47 return [bookmarkBarController_ isVisible]; | 52 return [bookmarkBarController_ isVisible]; |
| 48 } | 53 } |
| 49 | 54 |
| 50 - (NSView*)extensionShelfView { | 55 - (NSView*)extensionShelfView { |
| 51 return [extensionShelfController_ view]; | 56 return [extensionShelfController_ view]; |
| 52 } | 57 } |
| 53 @end | 58 @end |
| 54 | 59 |
| 55 class BrowserWindowControllerTest : public testing::Test { | 60 class BrowserWindowControllerTest : public testing::Test { |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 [window setFrame:testFrame display:NO]; | 434 [window setFrame:testFrame display:NO]; |
| 430 zoomFrame = [controller_ windowWillUseStandardFrame:window | 435 zoomFrame = [controller_ windowWillUseStandardFrame:window |
| 431 defaultFrame:screenFrame]; | 436 defaultFrame:screenFrame]; |
| 432 // Use the actual width of the window frame, since it's subject to rounding. | 437 // Use the actual width of the window frame, since it's subject to rounding. |
| 433 EXPECT_EQ([window frame].size.width, zoomFrame.size.width); | 438 EXPECT_EQ([window frame].size.width, zoomFrame.size.width); |
| 434 EXPECT_EQ(screenFrame.size.height, zoomFrame.size.height); | 439 EXPECT_EQ(screenFrame.size.height, zoomFrame.size.height); |
| 435 EXPECT_EQ(testFrame.origin.x, zoomFrame.origin.x); | 440 EXPECT_EQ(testFrame.origin.x, zoomFrame.origin.x); |
| 436 EXPECT_EQ(screenFrame.origin.y, zoomFrame.origin.y); | 441 EXPECT_EQ(screenFrame.origin.y, zoomFrame.origin.y); |
| 437 } | 442 } |
| 438 | 443 |
| 444 TEST_F(BrowserWindowControllerTest, TestFindBarOnTop) { | |
|
John Grabowski
2009/10/07 04:56:50
jrg <3 erg
| |
| 445 FindBarBridge bridge; | |
| 446 [controller_.get() addFindBar:bridge.find_bar_cocoa_controller()]; | |
| 447 | |
| 448 // Test that the Z-order of the find bar is on top of everything. | |
| 449 NSArray* subviews = [[[controller_.get() window] contentView] subviews]; | |
| 450 NSUInteger findBar_index = | |
| 451 [subviews indexOfObject:[controller_.get() findBarView]]; | |
| 452 EXPECT_NE(NSNotFound, findBar_index); | |
| 453 NSUInteger toolbar_index = | |
| 454 [subviews indexOfObject:[controller_.get() toolbarView]]; | |
| 455 EXPECT_NE(NSNotFound, toolbar_index); | |
| 456 NSUInteger bookmark_index = | |
| 457 [subviews indexOfObject:[controller_.get() bookmarkView]]; | |
| 458 EXPECT_NE(NSNotFound, bookmark_index); | |
| 459 | |
| 460 EXPECT_GT(findBar_index, toolbar_index); | |
| 461 EXPECT_GT(findBar_index, bookmark_index); | |
| 462 } | |
| 463 | |
| 439 | 464 |
| 440 /* TODO(???): test other methods of BrowserWindowController */ | 465 /* TODO(???): test other methods of BrowserWindowController */ |
| OLD | NEW |