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

Side by Side Diff: ui/views/widget/native_widget_mac_unittest.mm

Issue 1614663002: MacViews: Bubbles and dialogs behave more like sheets wrt main status (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix crash - much nicer anyway :) Created 4 years, 11 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 unified diff | Download patch
OLDNEW
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"
11 #import "base/mac/scoped_objc_class_swizzler.h" 11 #import "base/mac/scoped_objc_class_swizzler.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/test/test_timeouts.h" 16 #include "base/test/test_timeouts.h"
17 #import "testing/gtest_mac.h" 17 #import "testing/gtest_mac.h"
18 #include "third_party/skia/include/core/SkBitmap.h" 18 #include "third_party/skia/include/core/SkBitmap.h"
19 #include "third_party/skia/include/core/SkCanvas.h" 19 #include "third_party/skia/include/core/SkCanvas.h"
20 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" 20 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h"
21 #import "ui/base/cocoa/window_size_constants.h" 21 #import "ui/base/cocoa/window_size_constants.h"
22 #import "ui/events/test/cocoa_test_event_utils.h" 22 #import "ui/events/test/cocoa_test_event_utils.h"
23 #include "ui/events/test/event_generator.h" 23 #include "ui/events/test/event_generator.h"
24 #import "ui/gfx/mac/coordinate_conversion.h" 24 #import "ui/gfx/mac/coordinate_conversion.h"
25 #include "ui/views/bubble/bubble_delegate.h"
25 #import "ui/views/cocoa/bridged_native_widget.h" 26 #import "ui/views/cocoa/bridged_native_widget.h"
26 #import "ui/views/cocoa/native_widget_mac_nswindow.h" 27 #import "ui/views/cocoa/native_widget_mac_nswindow.h"
27 #include "ui/views/controls/button/label_button.h" 28 #include "ui/views/controls/button/label_button.h"
28 #include "ui/views/controls/label.h" 29 #include "ui/views/controls/label.h"
29 #include "ui/views/native_cursor.h" 30 #include "ui/views/native_cursor.h"
30 #include "ui/views/test/test_widget_observer.h" 31 #include "ui/views/test/test_widget_observer.h"
31 #include "ui/views/test/widget_test.h" 32 #include "ui/views/test/widget_test.h"
32 #include "ui/views/widget/native_widget_private.h" 33 #include "ui/views/widget/native_widget_private.h"
33 #include "ui/views/window/dialog_delegate.h" 34 #include "ui/views/window/dialog_delegate.h"
34 35
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 EXPECT_FALSE([regular_widget->GetNativeWindow() canBecomeMainWindow]); 932 EXPECT_FALSE([regular_widget->GetNativeWindow() canBecomeMainWindow]);
932 933
933 // Create a dialog widget (also TYPE_WINDOW), but with a DialogDelegate. 934 // Create a dialog widget (also TYPE_WINDOW), but with a DialogDelegate.
934 Widget* dialog_widget = views::DialogDelegate::CreateDialogWidget( 935 Widget* dialog_widget = views::DialogDelegate::CreateDialogWidget(
935 new ModalDialogDelegate(ui::MODAL_TYPE_CHILD), nullptr, 936 new ModalDialogDelegate(ui::MODAL_TYPE_CHILD), nullptr,
936 regular_widget->GetNativeView()); 937 regular_widget->GetNativeView());
937 EXPECT_TRUE([dialog_widget->GetNativeWindow() canBecomeKeyWindow]); 938 EXPECT_TRUE([dialog_widget->GetNativeWindow() canBecomeKeyWindow]);
938 // Dialogs shouldn't take main status away from their parent. 939 // Dialogs shouldn't take main status away from their parent.
939 EXPECT_FALSE([dialog_widget->GetNativeWindow() canBecomeMainWindow]); 940 EXPECT_FALSE([dialog_widget->GetNativeWindow() canBecomeMainWindow]);
940 941
942 // Create a bubble widget with a parent: also shouldn't get main.
943 BubbleDelegateView* bubble_view = new BubbleDelegateView();
944 bubble_view->set_parent_window(regular_widget->GetNativeView());
945 Widget* bubble_widget = BubbleDelegateView::CreateBubble(bubble_view);
946 EXPECT_TRUE([bubble_widget->GetNativeWindow() canBecomeKeyWindow]);
947 EXPECT_FALSE([bubble_widget->GetNativeWindow() canBecomeMainWindow]);
948
949 // But a bubble without a parent should still be able to become main.
950 Widget* toplevel_bubble_widget =
951 BubbleDelegateView::CreateBubble(new BubbleDelegateView());
952 EXPECT_TRUE([toplevel_bubble_widget->GetNativeWindow() canBecomeKeyWindow]);
953 EXPECT_TRUE([toplevel_bubble_widget->GetNativeWindow() canBecomeMainWindow]);
954
955 toplevel_bubble_widget->CloseNow();
941 regular_widget->CloseNow(); 956 regular_widget->CloseNow();
942 } 957 }
943 958
944 NSData* WindowContentsAsTIFF(NSWindow* window) { 959 NSData* WindowContentsAsTIFF(NSWindow* window) {
945 NSView* frame_view = [[window contentView] superview]; 960 NSView* frame_view = [[window contentView] superview];
946 EXPECT_TRUE(frame_view); 961 EXPECT_TRUE(frame_view);
947 962
948 // Inset to mask off left and right edges which vary in HighDPI. 963 // Inset to mask off left and right edges which vary in HighDPI.
949 NSRect bounds = NSInsetRect([frame_view bounds], 4, 0); 964 NSRect bounds = NSInsetRect([frame_view bounds], 4, 0);
950 965
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 @implementation NativeWidgetMacTestWindow 1116 @implementation NativeWidgetMacTestWindow
1102 1117
1103 @synthesize invalidateShadowCount = invalidateShadowCount_; 1118 @synthesize invalidateShadowCount = invalidateShadowCount_;
1104 1119
1105 - (void)invalidateShadow { 1120 - (void)invalidateShadow {
1106 ++invalidateShadowCount_; 1121 ++invalidateShadowCount_;
1107 [super invalidateShadow]; 1122 [super invalidateShadow];
1108 } 1123 }
1109 1124
1110 @end 1125 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698