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

Side by Side Diff: ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc

Issue 678073003: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h" 5 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 #include <X11/extensions/shape.h> 9 #include <X11/extensions/shape.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 28 matching lines...) Expand all
39 39
40 // Waits till |window| is minimized. 40 // Waits till |window| is minimized.
41 class MinimizeWaiter : public X11PropertyChangeWaiter { 41 class MinimizeWaiter : public X11PropertyChangeWaiter {
42 public: 42 public:
43 explicit MinimizeWaiter(XID window) 43 explicit MinimizeWaiter(XID window)
44 : X11PropertyChangeWaiter(window, "_NET_WM_STATE") { 44 : X11PropertyChangeWaiter(window, "_NET_WM_STATE") {
45 const char* kAtomsToCache[] = { "_NET_WM_STATE_HIDDEN", NULL }; 45 const char* kAtomsToCache[] = { "_NET_WM_STATE_HIDDEN", NULL };
46 atom_cache_.reset(new ui::X11AtomCache(gfx::GetXDisplay(), kAtomsToCache)); 46 atom_cache_.reset(new ui::X11AtomCache(gfx::GetXDisplay(), kAtomsToCache));
47 } 47 }
48 48
49 virtual ~MinimizeWaiter() { 49 ~MinimizeWaiter() override {}
50 }
51 50
52 private: 51 private:
53 // X11PropertyChangeWaiter: 52 // X11PropertyChangeWaiter:
54 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) override { 53 bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) override {
55 std::vector<Atom> wm_states; 54 std::vector<Atom> wm_states;
56 if (ui::GetAtomArrayProperty(xwindow(), "_NET_WM_STATE", &wm_states)) { 55 if (ui::GetAtomArrayProperty(xwindow(), "_NET_WM_STATE", &wm_states)) {
57 std::vector<Atom>::iterator it = std::find( 56 std::vector<Atom>::iterator it = std::find(
58 wm_states.begin(), 57 wm_states.begin(),
59 wm_states.end(), 58 wm_states.end(),
60 atom_cache_->GetAtom("_NET_WM_STATE_HIDDEN")); 59 atom_cache_->GetAtom("_NET_WM_STATE_HIDDEN"));
61 return it == wm_states.end(); 60 return it == wm_states.end();
62 } 61 }
63 return true; 62 return true;
64 } 63 }
65 64
66 scoped_ptr<ui::X11AtomCache> atom_cache_; 65 scoped_ptr<ui::X11AtomCache> atom_cache_;
67 66
68 DISALLOW_COPY_AND_ASSIGN(MinimizeWaiter); 67 DISALLOW_COPY_AND_ASSIGN(MinimizeWaiter);
69 }; 68 };
70 69
71 // Waits till |_NET_CLIENT_LIST_STACKING| is updated to include 70 // Waits till |_NET_CLIENT_LIST_STACKING| is updated to include
72 // |expected_windows|. 71 // |expected_windows|.
73 class StackingClientListWaiter : public X11PropertyChangeWaiter { 72 class StackingClientListWaiter : public X11PropertyChangeWaiter {
74 public: 73 public:
75 StackingClientListWaiter(XID* expected_windows, size_t count) 74 StackingClientListWaiter(XID* expected_windows, size_t count)
76 : X11PropertyChangeWaiter(ui::GetX11RootWindow(), 75 : X11PropertyChangeWaiter(ui::GetX11RootWindow(),
77 "_NET_CLIENT_LIST_STACKING"), 76 "_NET_CLIENT_LIST_STACKING"),
78 expected_windows_(expected_windows, expected_windows + count) { 77 expected_windows_(expected_windows, expected_windows + count) {
79 } 78 }
80 79
81 virtual ~StackingClientListWaiter() { 80 ~StackingClientListWaiter() override {}
82 }
83 81
84 // X11PropertyChangeWaiter: 82 // X11PropertyChangeWaiter:
85 virtual void Wait() override { 83 void Wait() override {
86 // StackingClientListWaiter may be created after 84 // StackingClientListWaiter may be created after
87 // _NET_CLIENT_LIST_STACKING already contains |expected_windows|. 85 // _NET_CLIENT_LIST_STACKING already contains |expected_windows|.
88 if (!ShouldKeepOnWaiting(NULL)) 86 if (!ShouldKeepOnWaiting(NULL))
89 return; 87 return;
90 88
91 X11PropertyChangeWaiter::Wait(); 89 X11PropertyChangeWaiter::Wait();
92 } 90 }
93 91
94 private: 92 private:
95 // X11PropertyChangeWaiter: 93 // X11PropertyChangeWaiter:
96 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) override { 94 bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) override {
97 std::vector<XID> stack; 95 std::vector<XID> stack;
98 ui::GetXWindowStack(ui::GetX11RootWindow(), &stack); 96 ui::GetXWindowStack(ui::GetX11RootWindow(), &stack);
99 for (size_t i = 0; i < expected_windows_.size(); ++i) { 97 for (size_t i = 0; i < expected_windows_.size(); ++i) {
100 std::vector<XID>::iterator it = std::find( 98 std::vector<XID>::iterator it = std::find(
101 stack.begin(), stack.end(), expected_windows_[i]); 99 stack.begin(), stack.end(), expected_windows_[i]);
102 if (it == stack.end()) 100 if (it == stack.end())
103 return true; 101 return true;
104 } 102 }
105 return false; 103 return false;
106 } 104 }
107 105
108 std::vector<XID> expected_windows_; 106 std::vector<XID> expected_windows_;
109 107
110 DISALLOW_COPY_AND_ASSIGN(StackingClientListWaiter); 108 DISALLOW_COPY_AND_ASSIGN(StackingClientListWaiter);
111 }; 109 };
112 110
113 } // namespace 111 } // namespace
114 112
115 class X11TopmostWindowFinderTest : public ViewsTestBase { 113 class X11TopmostWindowFinderTest : public ViewsTestBase {
116 public: 114 public:
117 X11TopmostWindowFinderTest() { 115 X11TopmostWindowFinderTest() {
118 } 116 }
119 117
120 virtual ~X11TopmostWindowFinderTest() { 118 ~X11TopmostWindowFinderTest() override {}
121 }
122 119
123 // Creates and shows a Widget with |bounds|. The caller takes ownership of 120 // Creates and shows a Widget with |bounds|. The caller takes ownership of
124 // the returned widget. 121 // the returned widget.
125 scoped_ptr<Widget> CreateAndShowWidget(const gfx::Rect& bounds) { 122 scoped_ptr<Widget> CreateAndShowWidget(const gfx::Rect& bounds) {
126 scoped_ptr<Widget> toplevel(new Widget); 123 scoped_ptr<Widget> toplevel(new Widget);
127 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); 124 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
128 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 125 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
129 params.native_widget = new DesktopNativeWidgetAura(toplevel.get()); 126 params.native_widget = new DesktopNativeWidgetAura(toplevel.get());
130 params.bounds = bounds; 127 params.bounds = bounds;
131 params.remove_standard_frame = true; 128 params.remove_standard_frame = true;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 195
199 static void SetUpTestCase() { 196 static void SetUpTestCase() {
200 gfx::GLSurface::InitializeOneOffForTests(); 197 gfx::GLSurface::InitializeOneOffForTests();
201 ui::RegisterPathProvider(); 198 ui::RegisterPathProvider();
202 base::FilePath ui_test_pak_path; 199 base::FilePath ui_test_pak_path;
203 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); 200 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
204 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); 201 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
205 } 202 }
206 203
207 // ViewsTestBase: 204 // ViewsTestBase:
208 virtual void SetUp() override { 205 void SetUp() override {
209 ViewsTestBase::SetUp(); 206 ViewsTestBase::SetUp();
210 207
211 // Make X11 synchronous for our display connection. This does not force the 208 // Make X11 synchronous for our display connection. This does not force the
212 // window manager to behave synchronously. 209 // window manager to behave synchronously.
213 XSynchronize(xdisplay(), True); 210 XSynchronize(xdisplay(), True);
214 211
215 // Ensure that the X11DesktopHandler exists. The X11DesktopHandler is 212 // Ensure that the X11DesktopHandler exists. The X11DesktopHandler is
216 // necessary to properly track menu windows. 213 // necessary to properly track menu windows.
217 X11DesktopHandler::get(); 214 X11DesktopHandler::get();
218 } 215 }
219 216
220 virtual void TearDown() override { 217 void TearDown() override {
221 XSynchronize(xdisplay(), False); 218 XSynchronize(xdisplay(), False);
222 ViewsTestBase::TearDown(); 219 ViewsTestBase::TearDown();
223 } 220 }
224 221
225 private: 222 private:
226 DISALLOW_COPY_AND_ASSIGN(X11TopmostWindowFinderTest); 223 DISALLOW_COPY_AND_ASSIGN(X11TopmostWindowFinderTest);
227 }; 224 };
228 225
229 TEST_F(X11TopmostWindowFinderTest, Basic) { 226 TEST_F(X11TopmostWindowFinderTest, Basic) {
230 // Avoid positioning test windows at 0x0 because window managers often have a 227 // Avoid positioning test windows at 0x0 because window managers often have a
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 434
438 EXPECT_EQ(xid, FindTopmostXWindowAt(110, 110)); 435 EXPECT_EQ(xid, FindTopmostXWindowAt(110, 110));
439 EXPECT_EQ(menu_xid, FindTopmostXWindowAt(150, 120)); 436 EXPECT_EQ(menu_xid, FindTopmostXWindowAt(150, 120));
440 EXPECT_EQ(menu_xid, FindTopmostXWindowAt(210, 120)); 437 EXPECT_EQ(menu_xid, FindTopmostXWindowAt(210, 120));
441 438
442 XDestroyWindow(xdisplay(), xid); 439 XDestroyWindow(xdisplay(), xid);
443 XDestroyWindow(xdisplay(), menu_xid); 440 XDestroyWindow(xdisplay(), menu_xid);
444 } 441 }
445 442
446 } // namespace views 443 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/x11_topmost_window_finder.h ('k') | ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698