OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/views/widget/native_widget_mac.h" | 5 #import "ui/views/widget/native_widget_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #import "base/mac/foundation_util.h" | 9 #import "base/mac/foundation_util.h" |
10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 NSRect expected = [[[NSScreen screens] firstObject] visibleFrame]; | 1082 NSRect expected = [[[NSScreen screens] firstObject] visibleFrame]; |
1083 NSRect actual = gfx::ScreenRectToNSRect(widget.GetWorkAreaBoundsInScreen()); | 1083 NSRect actual = gfx::ScreenRectToNSRect(widget.GetWorkAreaBoundsInScreen()); |
1084 EXPECT_FALSE(NSIsEmptyRect(actual)); | 1084 EXPECT_FALSE(NSIsEmptyRect(actual)); |
1085 EXPECT_NSEQ(expected, actual); | 1085 EXPECT_NSEQ(expected, actual); |
1086 | 1086 |
1087 [widget.GetNativeWindow() close]; | 1087 [widget.GetNativeWindow() close]; |
1088 actual = gfx::ScreenRectToNSRect(widget.GetWorkAreaBoundsInScreen()); | 1088 actual = gfx::ScreenRectToNSRect(widget.GetWorkAreaBoundsInScreen()); |
1089 EXPECT_TRUE(NSIsEmptyRect(actual)); | 1089 EXPECT_TRUE(NSIsEmptyRect(actual)); |
1090 } | 1090 } |
1091 | 1091 |
| 1092 // Test that Widget opacity can be changed. |
| 1093 TEST_F(NativeWidgetMacTest, ChangeOpacity) { |
| 1094 Widget* widget = CreateTopLevelPlatformWidget(); |
| 1095 NSWindow* ns_window = widget->GetNativeWindow(); |
| 1096 |
| 1097 CGFloat old_opacity = [ns_window alphaValue]; |
| 1098 widget->SetOpacity(0xAA); |
| 1099 EXPECT_NE(old_opacity, [ns_window alphaValue]); |
| 1100 EXPECT_DOUBLE_EQ(0xAA / 255.0, [ns_window alphaValue]); |
| 1101 |
| 1102 widget->CloseNow(); |
| 1103 } |
| 1104 |
1092 } // namespace test | 1105 } // namespace test |
1093 } // namespace views | 1106 } // namespace views |
1094 | 1107 |
1095 @implementation TestStopAnimationWaiter | 1108 @implementation TestStopAnimationWaiter |
1096 - (void)setWindowStateForEnd { | 1109 - (void)setWindowStateForEnd { |
1097 views::test::ScopedSwizzleWaiter::GetMethodAndMarkCalled()(self, _cmd); | 1110 views::test::ScopedSwizzleWaiter::GetMethodAndMarkCalled()(self, _cmd); |
1098 } | 1111 } |
1099 @end | 1112 @end |
1100 | 1113 |
1101 @implementation NativeWidgetMacTestWindow | 1114 @implementation NativeWidgetMacTestWindow |
1102 | 1115 |
1103 @synthesize invalidateShadowCount = invalidateShadowCount_; | 1116 @synthesize invalidateShadowCount = invalidateShadowCount_; |
1104 | 1117 |
1105 - (void)invalidateShadow { | 1118 - (void)invalidateShadow { |
1106 ++invalidateShadowCount_; | 1119 ++invalidateShadowCount_; |
1107 [super invalidateShadow]; | 1120 [super invalidateShadow]; |
1108 } | 1121 } |
1109 | 1122 |
1110 @end | 1123 @end |
OLD | NEW |