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

Side by Side Diff: ui/views/cocoa/bridged_native_widget_interactive_uitest.mm

Issue 1782773002: MacViews: Fix ViewTest.HandleAccelerator by faking window activation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Faked activations for everyone! Created 4 years, 9 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/cocoa/bridged_native_widget.h" 5 #import "ui/views/cocoa/bridged_native_widget.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #import "base/mac/mac_util.h" 9 #import "base/mac/mac_util.h"
10 #import "base/mac/sdk_forward_declarations.h" 10 #import "base/mac/sdk_forward_declarations.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "ui/base/hit_test.h" 12 #include "ui/base/hit_test.h"
13 #import "ui/base/test/nswindow_fullscreen_notification_waiter.h" 13 #import "ui/base/test/nswindow_fullscreen_notification_waiter.h"
14 #include "ui/base/test/ui_controls.h"
14 #import "ui/base/test/windowed_nsnotification_observer.h" 15 #import "ui/base/test/windowed_nsnotification_observer.h"
15 #import "ui/events/test/cocoa_test_event_utils.h" 16 #import "ui/events/test/cocoa_test_event_utils.h"
16 #include "ui/views/test/widget_test.h" 17 #include "ui/views/test/widget_test.h"
17 #include "ui/views/widget/native_widget_mac.h" 18 #include "ui/views/widget/native_widget_mac.h"
18 #include "ui/views/window/native_frame_view.h" 19 #include "ui/views/window/native_frame_view.h"
19 20
20 namespace views { 21 namespace views {
21 namespace test { 22 namespace test {
22 namespace { 23 namespace {
23 24
24 // Provide a resizable Widget by default. Starting in 10.11, OSX doesn't 25 // Provide a resizable Widget by default. Starting in 10.11, OSX doesn't
25 // correctly restore the window size when coming out of fullscreen if the window 26 // correctly restore the window size when coming out of fullscreen if the window
26 // is not user-sizable. 27 // is not user-sizable.
27 class ResizableDelegateView : public WidgetDelegateView { 28 class ResizableDelegateView : public WidgetDelegateView {
28 public: 29 public:
29 ResizableDelegateView() {} 30 ResizableDelegateView() {}
30 31
31 // WidgetDelgate: 32 // WidgetDelgate:
32 bool CanResize() const override { return true; } 33 bool CanResize() const override { return true; }
33 34
34 private: 35 private:
35 DISALLOW_COPY_AND_ASSIGN(ResizableDelegateView); 36 DISALLOW_COPY_AND_ASSIGN(ResizableDelegateView);
36 }; 37 };
37 38
38 } // namespace 39 } // namespace
39 40
40 class BridgedNativeWidgetUITest : public test::WidgetTest { 41 class BridgedNativeWidgetUITest : public test::WidgetTest {
41 public: 42 public:
42 BridgedNativeWidgetUITest() {} 43 BridgedNativeWidgetUITest() {
44 // TODO(tapted): Remove this when these are absorbed into Chrome's
45 // interactive_ui_tests target. See http://crbug.com/403679.
46 ui_controls::EnableUIControls();
47 }
43 48
44 // testing::Test: 49 // testing::Test:
45 void SetUp() override { 50 void SetUp() override {
46 WidgetTest::SetUp(); 51 WidgetTest::SetUp();
47 Widget::InitParams init_params = 52 Widget::InitParams init_params =
48 CreateParams(Widget::InitParams::TYPE_WINDOW); 53 CreateParams(Widget::InitParams::TYPE_WINDOW);
49 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 54 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
50 init_params.bounds = gfx::Rect(100, 100, 300, 200); 55 init_params.bounds = gfx::Rect(100, 100, 300, 200);
51 init_params.delegate = new ResizableDelegateView; 56 init_params.delegate = new ResizableDelegateView;
52 widget_.reset(new Widget); 57 widget_.reset(new Widget);
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 NSEvent* mouse_up = cocoa_test_event_utils::MouseEventAtPointInWindow( 486 NSEvent* mouse_up = cocoa_test_event_utils::MouseEventAtPointInWindow(
482 NSMakePoint(30, 30), NSLeftMouseUp, window, 0); 487 NSMakePoint(30, 30), NSLeftMouseUp, window, 0);
483 CGEventPost(kCGSessionEventTap, [mouse_up CGEvent]); 488 CGEventPost(kCGSessionEventTap, [mouse_up CGEvent]);
484 WaitForEvent(NSLeftMouseUpMask); 489 WaitForEvent(NSLeftMouseUpMask);
485 EXPECT_EQ(120, [window frame].origin.x); 490 EXPECT_EQ(120, [window frame].origin.x);
486 } 491 }
487 } 492 }
488 493
489 } // namespace test 494 } // namespace test
490 } // namespace views 495 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_delegate_unittest.cc ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698