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

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

Issue 414123005: Move DesktopWindowTreeHostX11Test.Deactivate to interactive_ui_tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 5 #include <vector>
6 6
7 #include <X11/extensions/shape.h> 7 #include <X11/extensions/shape.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 // Get rid of X11 macros which conflict with gtest. 10 // Get rid of X11 macros which conflict with gtest.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 // The name of the hint to wait to get set or unset. 71 // The name of the hint to wait to get set or unset.
72 const char* hint_; 72 const char* hint_;
73 73
74 // Whether we are waiting for |hint| to be set or unset. 74 // Whether we are waiting for |hint| to be set or unset.
75 bool wait_till_set_; 75 bool wait_till_set_;
76 76
77 DISALLOW_COPY_AND_ASSIGN(WMStateWaiter); 77 DISALLOW_COPY_AND_ASSIGN(WMStateWaiter);
78 }; 78 };
79 79
80 // Blocks till |window| gets activated.
81 class ActivationWaiter : public X11PropertyChangeWaiter {
82 public:
83 explicit ActivationWaiter(XID window)
84 : X11PropertyChangeWaiter(ui::GetX11RootWindow(), "_NET_ACTIVE_WINDOW"),
85 window_(window) {
86 }
87
88 virtual ~ActivationWaiter() {
89 }
90
91 private:
92 // X11PropertyChangeWaiter:
93 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) OVERRIDE {
94 XID xid = 0;
95 ui::GetXIDProperty(ui::GetX11RootWindow(), "_NET_ACTIVE_WINDOW", &xid);
96 return xid != window_;
97 }
98
99 XID window_;
100
101 DISALLOW_COPY_AND_ASSIGN(ActivationWaiter);
102 };
103
104 // A NonClientFrameView with a window mask with the bottom right corner cut out. 80 // A NonClientFrameView with a window mask with the bottom right corner cut out.
105 class ShapedNonClientFrameView : public NonClientFrameView { 81 class ShapedNonClientFrameView : public NonClientFrameView {
106 public: 82 public:
107 explicit ShapedNonClientFrameView() { 83 explicit ShapedNonClientFrameView() {
108 } 84 }
109 85
110 virtual ~ShapedNonClientFrameView() { 86 virtual ~ShapedNonClientFrameView() {
111 } 87 }
112 88
113 // NonClientFrameView: 89 // NonClientFrameView:
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 XSendEvent(display, DefaultRootWindow(display), False, 438 XSendEvent(display, DefaultRootWindow(display), False,
463 SubstructureRedirectMask | SubstructureNotifyMask, 439 SubstructureRedirectMask | SubstructureNotifyMask,
464 &xevent); 440 &xevent);
465 441
466 WMStateWaiter waiter(xid, "_NET_WM_STATE_FOCUSED", true); 442 WMStateWaiter waiter(xid, "_NET_WM_STATE_FOCUSED", true);
467 waiter.Wait(); 443 waiter.Wait();
468 } 444 }
469 EXPECT_TRUE(widget.GetNativeWindow()->IsVisible()); 445 EXPECT_TRUE(widget.GetNativeWindow()->IsVisible());
470 } 446 }
471 447
472 // Test that calling Widget::Deactivate() sets the widget as inactive wrt to
473 // Chrome even if it not possible to deactivate the window wrt to the x server.
474 // This behavior is required by several interactive_ui_tests.
475 TEST_F(DesktopWindowTreeHostX11Test, Deactivate) {
476 scoped_ptr<Widget> widget(CreateWidget(NULL));
477
478 ActivationWaiter waiter(
479 widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget());
480 widget->Show();
481 widget->Activate();
482 waiter.Wait();
483
484 widget->Deactivate();
485 // Regardless of whether |widget|'s X11 window eventually gets deactivated,
486 // |widget|'s "active" state should change.
487 EXPECT_FALSE(widget->IsActive());
488
489 // |widget|'s X11 window should still be active. Reactivating |widget| should
490 // update the widget's "active" state.
491 // Note: Activating a widget whose X11 window is not active does not
492 // synchronously update the widget's "active" state.
493 widget->Activate();
494 EXPECT_TRUE(widget->IsActive());
495 }
496
497 } // namespace views 448 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698