| 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_nsautorelease_pool.h" | 10 #import "base/mac/scoped_nsautorelease_pool.h" |
| (...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 EXPECT_EQ(1, [window invalidateShadowCount]); | 1372 EXPECT_EQ(1, [window invalidateShadowCount]); |
| 1373 | 1373 |
| 1374 test_api.SimulateFrameSwap(gfx::Size(123, 456)); | 1374 test_api.SimulateFrameSwap(gfx::Size(123, 456)); |
| 1375 EXPECT_EQ(2, [window invalidateShadowCount]); | 1375 EXPECT_EQ(2, [window invalidateShadowCount]); |
| 1376 test_api.SimulateFrameSwap(gfx::Size(123, 456)); | 1376 test_api.SimulateFrameSwap(gfx::Size(123, 456)); |
| 1377 EXPECT_EQ(2, [window invalidateShadowCount]); | 1377 EXPECT_EQ(2, [window invalidateShadowCount]); |
| 1378 | 1378 |
| 1379 widget->CloseNow(); | 1379 widget->CloseNow(); |
| 1380 } | 1380 } |
| 1381 | 1381 |
| 1382 // Test that the contentView opacity corresponds to the window type. |
| 1383 TEST_F(NativeWidgetMacTest, ContentOpacity) { |
| 1384 NativeWidgetMacTestWindow* window; |
| 1385 Widget::InitParams init_params = |
| 1386 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 1387 |
| 1388 EXPECT_EQ(init_params.opacity, Widget::InitParams::INFER_OPACITY); |
| 1389 Widget* widget = CreateWidgetWithTestWindow(init_params, &window); |
| 1390 |
| 1391 // Infer should default to opaque on Mac. |
| 1392 EXPECT_TRUE([[window contentView] isOpaque]); |
| 1393 widget->CloseNow(); |
| 1394 |
| 1395 init_params.opacity = Widget::InitParams::TRANSLUCENT_WINDOW; |
| 1396 widget = CreateWidgetWithTestWindow(init_params, &window); |
| 1397 EXPECT_FALSE([[window contentView] isOpaque]); |
| 1398 widget->CloseNow(); |
| 1399 |
| 1400 // Test opaque explicitly. |
| 1401 init_params.opacity = Widget::InitParams::OPAQUE_WINDOW; |
| 1402 widget = CreateWidgetWithTestWindow(init_params, &window); |
| 1403 EXPECT_TRUE([[window contentView] isOpaque]); |
| 1404 widget->CloseNow(); |
| 1405 } |
| 1406 |
| 1382 // Test the expected result of GetWorkAreaBoundsInScreen(). | 1407 // Test the expected result of GetWorkAreaBoundsInScreen(). |
| 1383 TEST_F(NativeWidgetMacTest, GetWorkAreaBoundsInScreen) { | 1408 TEST_F(NativeWidgetMacTest, GetWorkAreaBoundsInScreen) { |
| 1384 Widget widget; | 1409 Widget widget; |
| 1385 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); | 1410 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); |
| 1386 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 1411 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 1387 | 1412 |
| 1388 // This is relative to the top-left of the primary screen, so unless the bot's | 1413 // This is relative to the top-left of the primary screen, so unless the bot's |
| 1389 // display is smaller than 400x300, the window will be wholly contained there. | 1414 // display is smaller than 400x300, the window will be wholly contained there. |
| 1390 params.bounds = gfx::Rect(100, 100, 300, 200); | 1415 params.bounds = gfx::Rect(100, 100, 300, 200); |
| 1391 widget.Init(params); | 1416 widget.Init(params); |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1757 | 1782 |
| 1758 - (void)dealloc { | 1783 - (void)dealloc { |
| 1759 if (deallocFlag_) { | 1784 if (deallocFlag_) { |
| 1760 DCHECK(!*deallocFlag_); | 1785 DCHECK(!*deallocFlag_); |
| 1761 *deallocFlag_ = true; | 1786 *deallocFlag_ = true; |
| 1762 } | 1787 } |
| 1763 [super dealloc]; | 1788 [super dealloc]; |
| 1764 } | 1789 } |
| 1765 | 1790 |
| 1766 @end | 1791 @end |
| OLD | NEW |