| OLD | NEW |
| 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/constrained_window/constrained_window_sheet_con
troller.h" | 5 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con
troller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/mac/sdk_forward_declarations.h" |
| 9 #include "base/macros.h" | 10 #include "base/macros.h" |
| 10 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" | 12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" |
| 12 #import "testing/gtest_mac.h" | 13 #import "testing/gtest_mac.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 const int kSystemSheetReturnCode = 77; | 17 const int kSystemSheetReturnCode = 77; |
| 17 | 18 |
| 18 } // namespace | 19 } // namespace |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 149 |
| 149 [controller hideSheet]; | 150 [controller hideSheet]; |
| 150 CustomConstrainedWindowSheet* sheet = | 151 CustomConstrainedWindowSheet* sheet = |
| 151 [sheets_ objectAtIndex:[tab_views_ indexOfObject:active_tab_view_]]; | 152 [sheets_ objectAtIndex:[tab_views_ indexOfObject:active_tab_view_]]; |
| 152 EXPECT_TRUE(sheet); | 153 EXPECT_TRUE(sheet); |
| 153 [controller showSheet:sheet forParentView:active_tab_view_]; | 154 [controller showSheet:sheet forParentView:active_tab_view_]; |
| 154 } | 155 } |
| 155 | 156 |
| 156 NSRect GetViewFrameInScreenCoordinates(NSView* view) { | 157 NSRect GetViewFrameInScreenCoordinates(NSView* view) { |
| 157 NSRect rect = [view convertRect:[view bounds] toView:nil]; | 158 NSRect rect = [view convertRect:[view bounds] toView:nil]; |
| 158 rect.origin = [[view window] convertBaseToScreen:rect.origin]; | 159 rect = [[view window] convertRectToScreen:rect]; |
| 159 return rect; | 160 return rect; |
| 160 } | 161 } |
| 161 | 162 |
| 162 void VerifySheetXPosition(NSRect sheet_frame, NSView* parent_view) { | 163 void VerifySheetXPosition(NSRect sheet_frame, NSView* parent_view) { |
| 163 NSRect parent_frame = GetViewFrameInScreenCoordinates(parent_view); | 164 NSRect parent_frame = GetViewFrameInScreenCoordinates(parent_view); |
| 164 CGFloat expected_x = NSMinX(parent_frame) + | 165 CGFloat expected_x = NSMinX(parent_frame) + |
| 165 (NSWidth(parent_frame) - NSWidth(sheet_frame)) / 2.0; | 166 (NSWidth(parent_frame) - NSWidth(sheet_frame)) / 2.0; |
| 166 EXPECT_EQ(expected_x, NSMinX(sheet_frame)); | 167 EXPECT_EQ(expected_x, NSMinX(sheet_frame)); |
| 167 } | 168 } |
| 168 | 169 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 [system_sheet setAlert:alert]; | 307 [system_sheet setAlert:alert]; |
| 307 | 308 |
| 308 EXPECT_FALSE([[alert window] isVisible]); | 309 EXPECT_FALSE([[alert window] isVisible]); |
| 309 [controller_ showSheet:system_sheet forParentView:active_tab_view_]; | 310 [controller_ showSheet:system_sheet forParentView:active_tab_view_]; |
| 310 EXPECT_TRUE([[alert window] isVisible]); | 311 EXPECT_TRUE([[alert window] isVisible]); |
| 311 | 312 |
| 312 [controller_ closeSheet:system_sheet]; | 313 [controller_ closeSheet:system_sheet]; |
| 313 EXPECT_FALSE([[alert window] isVisible]); | 314 EXPECT_FALSE([[alert window] isVisible]); |
| 314 EXPECT_EQ(kSystemSheetReturnCode, [system_sheet returnCode]); | 315 EXPECT_EQ(kSystemSheetReturnCode, [system_sheet returnCode]); |
| 315 } | 316 } |
| OLD | NEW |