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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm

Issue 665933005: mac: Fix bug where finder window extends past bottom of screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase against top of tree. Comments from rsesek. Created 6 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller_private.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/cocoa/browser_window_controller.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
6 6
7 #import "base/mac/mac_util.h" 7 #import "base/mac/mac_util.h"
8 #include "base/mac/sdk_forward_declarations.h" 8 #include "base/mac/sdk_forward_declarations.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 22 matching lines...) Expand all
33 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 33 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
34 #include "chrome/browser/ui/extensions/application_launch.h" 34 #include "chrome/browser/ui/extensions/application_launch.h"
35 #include "chrome/browser/ui/find_bar/find_bar.h" 35 #include "chrome/browser/ui/find_bar/find_bar.h"
36 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 36 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
37 #include "chrome/browser/ui/tabs/tab_strip_model.h" 37 #include "chrome/browser/ui/tabs/tab_strip_model.h"
38 #include "chrome/test/base/in_process_browser_test.h" 38 #include "chrome/test/base/in_process_browser_test.h"
39 #include "chrome/test/base/testing_profile.h" 39 #include "chrome/test/base/testing_profile.h"
40 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
41 #include "content/public/test/test_utils.h" 41 #include "content/public/test/test_utils.h"
42 #import "testing/gtest_mac.h" 42 #import "testing/gtest_mac.h"
43 #import "third_party/ocmock/OCMock/OCMock.h"
43 #import "ui/base/cocoa/nsview_additions.h" 44 #import "ui/base/cocoa/nsview_additions.h"
44 #include "ui/gfx/animation/slide_animation.h" 45 #include "ui/gfx/animation/slide_animation.h"
45 46
46 namespace { 47 namespace {
47 48
49 // Creates a mock of an NSWindow that has the given |frame|.
50 id MockWindowWithFrame(NSRect frame) {
51 id window = [OCMockObject mockForClass:[NSWindow class]];
52 NSValue* window_frame =
53 [NSValue valueWithBytes:&frame objCType:@encode(NSRect)];
54 [[[window stub] andReturnValue:window_frame] frame];
55 return window;
56 }
57
48 void CreateProfileCallback(const base::Closure& quit_closure, 58 void CreateProfileCallback(const base::Closure& quit_closure,
49 Profile* profile, 59 Profile* profile,
50 Profile::CreateStatus status) { 60 Profile::CreateStatus status) {
51 EXPECT_TRUE(profile); 61 EXPECT_TRUE(profile);
52 EXPECT_NE(Profile::CREATE_STATUS_LOCAL_FAIL, status); 62 EXPECT_NE(Profile::CREATE_STATUS_LOCAL_FAIL, status);
53 EXPECT_NE(Profile::CREATE_STATUS_REMOTE_FAIL, status); 63 EXPECT_NE(Profile::CREATE_STATUS_REMOTE_FAIL, status);
54 // This will be called multiple times. Wait until the profile is initialized 64 // This will be called multiple times. Wait until the profile is initialized
55 // fully to quit the loop. 65 // fully to quit the loop.
56 if (status == Profile::CREATE_STATUS_INITIALIZED) 66 if (status == Profile::CREATE_STATUS_INITIALIZED)
57 quit_closure.Run(); 67 quit_closure.Run();
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 485
476 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, SheetPosition) { 486 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, SheetPosition) {
477 ASSERT_TRUE([controller() isKindOfClass:[BrowserWindowController class]]); 487 ASSERT_TRUE([controller() isKindOfClass:[BrowserWindowController class]]);
478 EXPECT_TRUE([controller() isTabbedWindow]); 488 EXPECT_TRUE([controller() isTabbedWindow]);
479 EXPECT_TRUE([controller() hasTabStrip]); 489 EXPECT_TRUE([controller() hasTabStrip]);
480 EXPECT_FALSE([controller() hasTitleBar]); 490 EXPECT_FALSE([controller() hasTitleBar]);
481 EXPECT_TRUE([controller() hasToolbar]); 491 EXPECT_TRUE([controller() hasToolbar]);
482 EXPECT_FALSE([controller() isBookmarkBarVisible]); 492 EXPECT_FALSE([controller() isBookmarkBarVisible]);
483 493
484 NSRect defaultAlertFrame = NSMakeRect(0, 0, 300, 200); 494 NSRect defaultAlertFrame = NSMakeRect(0, 0, 300, 200);
495 id sheet = MockWindowWithFrame(defaultAlertFrame);
485 NSWindow* window = browser()->window()->GetNativeWindow(); 496 NSWindow* window = browser()->window()->GetNativeWindow();
486 NSRect alertFrame = [controller() window:window 497 NSRect alertFrame = [controller() window:window
487 willPositionSheet:nil 498 willPositionSheet:nil
488 usingRect:defaultAlertFrame]; 499 usingRect:defaultAlertFrame];
489 NSRect toolbarFrame = [[[controller() toolbarController] view] frame]; 500 NSRect toolbarFrame = [[[controller() toolbarController] view] frame];
490 EXPECT_EQ(NSMinY(alertFrame), NSMinY(toolbarFrame)); 501 EXPECT_EQ(NSMinY(alertFrame), NSMinY(toolbarFrame));
491 502
492 // Open sheet with normal browser window, persistent bookmark bar. 503 // Open sheet with normal browser window, persistent bookmark bar.
493 chrome::ToggleBookmarkBarWhenVisible(browser()->profile()); 504 chrome::ToggleBookmarkBarWhenVisible(browser()->profile());
494 EXPECT_TRUE([controller() isBookmarkBarVisible]); 505 EXPECT_TRUE([controller() isBookmarkBarVisible]);
495 alertFrame = [controller() window:window 506 alertFrame = [controller() window:window
496 willPositionSheet:nil 507 willPositionSheet:sheet
497 usingRect:defaultAlertFrame]; 508 usingRect:defaultAlertFrame];
498 NSRect bookmarkBarFrame = [[[controller() bookmarkBarController] view] frame]; 509 NSRect bookmarkBarFrame = [[[controller() bookmarkBarController] view] frame];
499 EXPECT_EQ(NSMinY(alertFrame), NSMinY(bookmarkBarFrame)); 510 EXPECT_EQ(NSMinY(alertFrame), NSMinY(bookmarkBarFrame));
500 511
512 // If the sheet is too large, it should be positioned at the top of the
513 // window.
514 defaultAlertFrame = NSMakeRect(0, 0, 300, 2000);
515 sheet = MockWindowWithFrame(defaultAlertFrame);
516 alertFrame = [controller() window:window
517 willPositionSheet:sheet
518 usingRect:defaultAlertFrame];
519 EXPECT_EQ(NSMinY(alertFrame), NSHeight([window frame]));
520
521 // Reset the sheet's size.
522 defaultAlertFrame = NSMakeRect(0, 0, 300, 200);
523 sheet = MockWindowWithFrame(defaultAlertFrame);
524
501 // Make sure the profile does not have the bookmark visible so that 525 // Make sure the profile does not have the bookmark visible so that
502 // we'll create the shortcut window without the bookmark bar. 526 // we'll create the shortcut window without the bookmark bar.
503 chrome::ToggleBookmarkBarWhenVisible(browser()->profile()); 527 chrome::ToggleBookmarkBarWhenVisible(browser()->profile());
504 // Open application mode window. 528 // Open application mode window.
505 OpenAppShortcutWindow(browser()->profile(), GURL("about:blank")); 529 OpenAppShortcutWindow(browser()->profile(), GURL("about:blank"));
506 Browser* popup_browser = BrowserList::GetInstance( 530 Browser* popup_browser = BrowserList::GetInstance(
507 chrome::GetActiveDesktop())->GetLastActive(); 531 chrome::GetActiveDesktop())->GetLastActive();
508 NSWindow* popupWindow = popup_browser->window()->GetNativeWindow(); 532 NSWindow* popupWindow = popup_browser->window()->GetNativeWindow();
509 BrowserWindowController* popupController = 533 BrowserWindowController* popupController =
510 [BrowserWindowController browserWindowControllerForWindow:popupWindow]; 534 [BrowserWindowController browserWindowControllerForWindow:popupWindow];
511 ASSERT_TRUE([popupController isKindOfClass:[BrowserWindowController class]]); 535 ASSERT_TRUE([popupController isKindOfClass:[BrowserWindowController class]]);
512 EXPECT_FALSE([popupController isTabbedWindow]); 536 EXPECT_FALSE([popupController isTabbedWindow]);
513 EXPECT_FALSE([popupController hasTabStrip]); 537 EXPECT_FALSE([popupController hasTabStrip]);
514 EXPECT_TRUE([popupController hasTitleBar]); 538 EXPECT_TRUE([popupController hasTitleBar]);
515 EXPECT_FALSE([popupController isBookmarkBarVisible]); 539 EXPECT_FALSE([popupController isBookmarkBarVisible]);
516 EXPECT_FALSE([popupController hasToolbar]); 540 EXPECT_FALSE([popupController hasToolbar]);
517 541
518 // Open sheet in an application window. 542 // Open sheet in an application window.
519 [popupController showWindow:nil]; 543 [popupController showWindow:nil];
520 alertFrame = [popupController window:popupWindow 544 alertFrame = [popupController window:popupWindow
521 willPositionSheet:nil 545 willPositionSheet:sheet
522 usingRect:defaultAlertFrame]; 546 usingRect:defaultAlertFrame];
523 EXPECT_EQ(NSMinY(alertFrame), 547 EXPECT_EQ(NSMinY(alertFrame),
524 NSHeight([[popupWindow contentView] frame]) - 548 NSHeight([[popupWindow contentView] frame]) -
525 defaultAlertFrame.size.height); 549 defaultAlertFrame.size.height);
526 550
527 // Close the application window. 551 // Close the application window.
528 popup_browser->tab_strip_model()->CloseSelectedTabs(); 552 popup_browser->tab_strip_model()->CloseSelectedTabs();
529 [popupController close]; 553 [popupController close];
530 } 554 }
531 555
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 VerifyWindowControlsZOrder(); 628 VerifyWindowControlsZOrder();
605 [controller() removeOverlay]; 629 [controller() removeOverlay];
606 VerifyWindowControlsZOrder(); 630 VerifyWindowControlsZOrder();
607 631
608 // Toggle immersive fullscreen, then verify z order. In immersive fullscreen, 632 // Toggle immersive fullscreen, then verify z order. In immersive fullscreen,
609 // there are no window controls. 633 // there are no window controls.
610 [controller() enterImmersiveFullscreen]; 634 [controller() enterImmersiveFullscreen];
611 [controller() exitImmersiveFullscreen]; 635 [controller() exitImmersiveFullscreen];
612 VerifyWindowControlsZOrder(); 636 VerifyWindowControlsZOrder();
613 } 637 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller_private.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698