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

Side by Side Diff: ui/views/test/test_platform_native_widget.h

Issue 2488393003: Changes views_aura_mus_unittests to create DesktopNativeWidgetAura (Closed)
Patch Set: git add Created 4 years, 1 month 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_VIEWS_TEST_TEST_PLATFORM_NATIVE_WIDGET_H_
6 #define UI_VIEWS_TEST_TEST_PLATFORM_NATIVE_WIDGET_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "ui/views/view.h"
11
12 namespace views {
13 namespace internal {
14 class NativeWidgetDelegate;
15 }
16 namespace test {
17
18 // NativeWidget implementation that adds the following:
19 // . capture can be mocked.
20 // . a boolean is set when the NativeWiget is destroyed.
msw 2016/11/11 00:29:24 nit: NativeWidget
sky 2016/11/11 01:09:13 Done.
21 // Don't create directly, instead go through functions in
22 // native_widget_factory.h that create the appropriate platform specific
23 // implementation.
24 template <typename PlatformNativeWidget>
25 class TestPlatformNativeWidget : public PlatformNativeWidget {
26 public:
27 TestPlatformNativeWidget(internal::NativeWidgetDelegate* delegate,
28 bool mock_capture,
29 bool* destroyed)
30 : PlatformNativeWidget(delegate),
31 mouse_capture_(false),
32 mock_capture_(mock_capture),
33 destroyed_(destroyed) {}
34
35 ~TestPlatformNativeWidget() override {
36 if (destroyed_)
37 *destroyed_ = true;
38 }
39
40 // PlatformNativeWidget:
41 void SetCapture() override {
42 if (mock_capture_)
43 mouse_capture_ = true;
44 else
45 PlatformNativeWidget::SetCapture();
46 }
47
48 void ReleaseCapture() override {
49 if (mock_capture_) {
50 if (mouse_capture_)
51 this->delegate()->OnMouseCaptureLost();
52 mouse_capture_ = false;
53 } else {
54 PlatformNativeWidget::ReleaseCapture();
55 }
56 }
57
58 bool HasCapture() const override {
59 return mock_capture_ ? mouse_capture_ : PlatformNativeWidget::HasCapture();
60 }
61
62 private:
63 bool mouse_capture_;
64 const bool mock_capture_;
65 bool* destroyed_;
66
67 DISALLOW_COPY_AND_ASSIGN(TestPlatformNativeWidget);
68 };
69
70 } // namespace test
71 } // namespace views
72
73 #endif // UI_VIEWS_TEST_TEST_PLATFORM_NATIVE_WIDGET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698