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

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

Issue 1895203004: Update sundry BubbleDelegateView references to BubbleDialogDelegateView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: relative ps Created 4 years, 8 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 #include "ui/views/bubble/bubble_dialog_delegate.h"
26 #import "ui/views/cocoa/bridged_native_widget.h" 26 #import "ui/views/cocoa/bridged_native_widget.h"
27 #import "ui/views/cocoa/native_widget_mac_nswindow.h" 27 #import "ui/views/cocoa/native_widget_mac_nswindow.h"
28 #include "ui/views/controls/button/label_button.h" 28 #include "ui/views/controls/button/label_button.h"
29 #include "ui/views/controls/label.h" 29 #include "ui/views/controls/label.h"
30 #include "ui/views/controls/native/native_view_host.h" 30 #include "ui/views/controls/native/native_view_host.h"
31 #include "ui/views/native_cursor.h" 31 #include "ui/views/native_cursor.h"
32 #include "ui/views/test/native_widget_factory.h" 32 #include "ui/views/test/native_widget_factory.h"
33 #include "ui/views/test/test_widget_observer.h" 33 #include "ui/views/test/test_widget_observer.h"
34 #include "ui/views/test/widget_test.h" 34 #include "ui/views/test/widget_test.h"
35 #include "ui/views/widget/native_widget_mac.h" 35 #include "ui/views/widget/native_widget_mac.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 gfx::NativeView view() const { return view_.get(); } 229 gfx::NativeView view() const { return view_.get(); }
230 NativeViewHost* host() const { return host_.get(); } 230 NativeViewHost* host() const { return host_.get(); }
231 231
232 private: 232 private:
233 base::scoped_nsobject<NSView> view_; 233 base::scoped_nsobject<NSView> view_;
234 std::unique_ptr<NativeViewHost> host_; 234 std::unique_ptr<NativeViewHost> host_;
235 235
236 DISALLOW_COPY_AND_ASSIGN(NativeHostHolder); 236 DISALLOW_COPY_AND_ASSIGN(NativeHostHolder);
237 }; 237 };
238 238
239 class SimpleBubbleView : public BubbleDialogDelegateView {
msw 2016/04/19 18:14:55 Why do we need this subclass?
Evan Stade 2016/04/19 21:51:31 the ctor is protected. I'll add a comment.
240 public:
241 SimpleBubbleView() {}
242 ~SimpleBubbleView() override {}
243
244 private:
245 DISALLOW_COPY_AND_ASSIGN(SimpleBubbleView);
246 };
247
239 // Test visibility states triggered externally. 248 // Test visibility states triggered externally.
240 TEST_F(NativeWidgetMacTest, HideAndShowExternally) { 249 TEST_F(NativeWidgetMacTest, HideAndShowExternally) {
241 Widget* widget = CreateTopLevelPlatformWidget(); 250 Widget* widget = CreateTopLevelPlatformWidget();
242 NSWindow* ns_window = widget->GetNativeWindow(); 251 NSWindow* ns_window = widget->GetNativeWindow();
243 WidgetChangeObserver observer(widget); 252 WidgetChangeObserver observer(widget);
244 253
245 // Should initially be hidden. 254 // Should initially be hidden.
246 EXPECT_FALSE(widget->IsVisible()); 255 EXPECT_FALSE(widget->IsVisible());
247 EXPECT_FALSE([ns_window isVisible]); 256 EXPECT_FALSE([ns_window isVisible]);
248 EXPECT_EQ(0, observer.gained_visible_count()); 257 EXPECT_EQ(0, observer.gained_visible_count());
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 1077
1069 // Create a dialog widget (also TYPE_WINDOW), but with a DialogDelegate. 1078 // Create a dialog widget (also TYPE_WINDOW), but with a DialogDelegate.
1070 Widget* dialog_widget = views::DialogDelegate::CreateDialogWidget( 1079 Widget* dialog_widget = views::DialogDelegate::CreateDialogWidget(
1071 new ModalDialogDelegate(ui::MODAL_TYPE_CHILD), nullptr, 1080 new ModalDialogDelegate(ui::MODAL_TYPE_CHILD), nullptr,
1072 regular_widget->GetNativeView()); 1081 regular_widget->GetNativeView());
1073 EXPECT_TRUE([dialog_widget->GetNativeWindow() canBecomeKeyWindow]); 1082 EXPECT_TRUE([dialog_widget->GetNativeWindow() canBecomeKeyWindow]);
1074 // Dialogs shouldn't take main status away from their parent. 1083 // Dialogs shouldn't take main status away from their parent.
1075 EXPECT_FALSE([dialog_widget->GetNativeWindow() canBecomeMainWindow]); 1084 EXPECT_FALSE([dialog_widget->GetNativeWindow() canBecomeMainWindow]);
1076 1085
1077 // Create a bubble widget with a parent: also shouldn't get main. 1086 // Create a bubble widget with a parent: also shouldn't get main.
1078 BubbleDelegateView* bubble_view = new BubbleDelegateView(); 1087 BubbleDialogDelegateView* bubble_view = new SimpleBubbleView();
1079 bubble_view->set_parent_window(regular_widget->GetNativeView()); 1088 bubble_view->set_parent_window(regular_widget->GetNativeView());
1080 Widget* bubble_widget = BubbleDelegateView::CreateBubble(bubble_view); 1089 Widget* bubble_widget = BubbleDialogDelegateView::CreateBubble(bubble_view);
1081 EXPECT_TRUE([bubble_widget->GetNativeWindow() canBecomeKeyWindow]); 1090 EXPECT_TRUE([bubble_widget->GetNativeWindow() canBecomeKeyWindow]);
1082 EXPECT_FALSE([bubble_widget->GetNativeWindow() canBecomeMainWindow]); 1091 EXPECT_FALSE([bubble_widget->GetNativeWindow() canBecomeMainWindow]);
1083 1092
1084 // But a bubble without a parent should still be able to become main. 1093 // But a bubble without a parent should still be able to become main.
1085 Widget* toplevel_bubble_widget = 1094 Widget* toplevel_bubble_widget =
1086 BubbleDelegateView::CreateBubble(new BubbleDelegateView()); 1095 BubbleDialogDelegateView::CreateBubble(new SimpleBubbleView());
1087 EXPECT_TRUE([toplevel_bubble_widget->GetNativeWindow() canBecomeKeyWindow]); 1096 EXPECT_TRUE([toplevel_bubble_widget->GetNativeWindow() canBecomeKeyWindow]);
1088 EXPECT_TRUE([toplevel_bubble_widget->GetNativeWindow() canBecomeMainWindow]); 1097 EXPECT_TRUE([toplevel_bubble_widget->GetNativeWindow() canBecomeMainWindow]);
1089 1098
1090 toplevel_bubble_widget->CloseNow(); 1099 toplevel_bubble_widget->CloseNow();
1091 regular_widget->CloseNow(); 1100 regular_widget->CloseNow();
1092 } 1101 }
1093 1102
1094 NSData* WindowContentsAsTIFF(NSWindow* window) { 1103 NSData* WindowContentsAsTIFF(NSWindow* window) {
1095 NSView* frame_view = [[window contentView] superview]; 1104 NSView* frame_view = [[window contentView] superview];
1096 EXPECT_TRUE(frame_view); 1105 EXPECT_TRUE(frame_view);
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 lastDirtyRect_ = dirtyRect; 1508 lastDirtyRect_ = dirtyRect;
1500 } 1509 }
1501 1510
1502 @end 1511 @end
1503 1512
1504 @implementation FocusableTestNSView 1513 @implementation FocusableTestNSView
1505 - (BOOL)acceptsFirstResponder { 1514 - (BOOL)acceptsFirstResponder {
1506 return YES; 1515 return YES;
1507 } 1516 }
1508 @end 1517 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698