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

Unified Diff: chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm

Issue 299573002: [Mac] Improve modal sheet positioning during window resizing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm b/chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm
index 562155abd4de55f9e43a5926214e5d49bb2bcd11..93e6b8e52823c9fabc80f28803e2f2da24fb10c9 100644
--- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm
@@ -136,6 +136,11 @@ class ConstrainedWindowSheetControllerTest : public CocoaTest {
EXPECT_EQ(expected_x, NSMinX(sheet_frame));
}
+ CGFloat GetSheetYOffset(NSRect sheet_frame, NSView* parent_view) {
+ return NSMaxY(sheet_frame) -
+ NSMaxY(GetViewFrameInScreenCoordinates(parent_view));
+ }
+
base::scoped_nsobject<NSWindow> sheet_window_;
base::scoped_nsobject<CustomConstrainedWindowSheet> sheet_;
base::scoped_nsobject<ConstrainedWindowSheetController> controller_;
@@ -254,6 +259,31 @@ TEST_F(ConstrainedWindowSheetControllerTest, ResizeHiddenSheet) {
EXPECT_EQ(NSHeight(new_inactive_frame), NSHeight(new_active_frame));
}
+// Test resizing parent window keeps the sheet anchored.
+TEST_F(ConstrainedWindowSheetControllerTest, ResizeParentWindow) {
+ [controller_ showSheet:sheet_ forParentView:active_tab_view_];
+ CGFloat sheet_offset =
+ GetSheetYOffset([sheet_window_ frame], active_tab_view_);
+
+ // Test 3x3 different parent window sizes.
+ CGFloat insets[] = {-10, 0, 10};
+ NSRect old_frame = [test_window() frame];
+
+ for (size_t x = 0; x < sizeof(insets) / sizeof(CGFloat); x++) {
+ for (size_t y = 0; y < sizeof(insets) / sizeof(CGFloat); y++) {
+ NSRect resized_frame = NSInsetRect(old_frame, insets[x], insets[y]);
+ [test_window() setFrame:resized_frame display:YES];
+ NSRect sheet_frame = [sheet_window_ frame];
+
+ // Y pos should track parent view's position.
+ EXPECT_EQ(sheet_offset, GetSheetYOffset(sheet_frame, active_tab_view_));
+
+ // X pos should be centered on parent view.
+ VerifySheetXPosition(sheet_frame, active_tab_view_);
+ }
+ }
+}
+
// Test system sheets.
TEST_F(ConstrainedWindowSheetControllerTest, SystemSheet) {
base::scoped_nsobject<ConstrainedWindowSystemSheetTest> system_sheet(
« no previous file with comments | « chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698