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

Unified Diff: ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc

Issue 264713007: Add unittests for X11TopmostWindowFinder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/views.gyp ('k') | ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc
diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc b/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc
index 30632c7b713f9037ace12608e5038462849174e6..c9e7159a53facba056369d1844fd96320e3684d1 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc
@@ -5,20 +5,14 @@
#include "ui/views/widget/desktop_aura/desktop_screen_x11.h"
#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/run_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
-#include "ui/aura/window_tree_host.h"
#include "ui/base/hit_test.h"
#include "ui/base/x/x11_util.h"
-#include "ui/events/platform/platform_event_dispatcher.h"
-#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/display_observer.h"
-#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
@@ -57,71 +51,6 @@ namespace views {
const int64 kFirstDisplay = 5321829;
const int64 kSecondDisplay = 928310;
-// Class which waits till the X11 window associated with the widget passed into
-// the constructor is activated. We cannot listen for the widget's activation
-// because the _NET_ACTIVE_WINDOW property is changed after the widget is
-// activated.
-class ActivationWaiter : public ui::PlatformEventDispatcher {
- public:
- explicit ActivationWaiter(views::Widget* widget)
- : x_root_window_(DefaultRootWindow(gfx::GetXDisplay())),
- widget_xid_(0),
- active_(false) {
- const char* kAtomToCache[] = {
- "_NET_ACTIVE_WINDOW",
- NULL
- };
- atom_cache_.reset(new ui::X11AtomCache(gfx::GetXDisplay(), kAtomToCache));
- widget_xid_ = widget->GetNativeWindow()->GetHost()->
- GetAcceleratedWidget();
- ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
- }
-
- virtual ~ActivationWaiter() {
- ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
- }
-
- // Blocks till |widget_xid_| becomes active.
- void Wait() {
- if (active_)
- return;
- base::RunLoop run_loop;
- quit_closure_ = run_loop.QuitClosure();
- run_loop.Run();
- }
-
- // ui::PlatformEventDispatcher:
- virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE {
- return event->type == PropertyNotify &&
- event->xproperty.window == x_root_window_;
- }
-
- virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE {
- ::Window xid;
- CHECK_EQ(PropertyNotify, event->type);
- CHECK_EQ(x_root_window_, event->xproperty.window);
-
- if (event->xproperty.atom == atom_cache_->GetAtom("_NET_ACTIVE_WINDOW") &&
- ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &xid) &&
- xid == widget_xid_) {
- active_ = true;
- if (!quit_closure_.is_null())
- quit_closure_.Run();
- }
- return ui::POST_DISPATCH_NONE;
- }
-
- private:
- scoped_ptr<ui::X11AtomCache> atom_cache_;
- ::Window x_root_window_;
- ::Window widget_xid_;
-
- bool active_;
- base::Closure quit_closure_;
-
- DISALLOW_COPY_AND_ASSIGN(ActivationWaiter);
-};
-
class DesktopScreenX11Test : public views::ViewsTestBase,
public gfx::DisplayObserver {
public:
@@ -312,46 +241,6 @@ TEST_F(DesktopScreenX11Test, GetPrimaryDisplay) {
EXPECT_EQ(kFirstDisplay, screen()->GetPrimaryDisplay().id());
}
-TEST_F(DesktopScreenX11Test, GetWindowAtScreenPoint) {
- if (!ui::WmSupportsHint(ui::GetAtom("_NET_ACTIVE_WINDOW")))
- return;
-
- Widget* window_one = BuildTopLevelDesktopWidget(gfx::Rect(110, 110, 10, 10),
- false);
- Widget* window_two = BuildTopLevelDesktopWidget(gfx::Rect(150, 150, 10, 10),
- false);
- Widget* window_three =
- BuildTopLevelDesktopWidget(gfx::Rect(115, 115, 20, 20), false);
-
- window_three->Show();
- window_two->Show();
- window_one->Show();
-
- // Make sure the internal state of DesktopWindowTreeHostX11 is set up
- // correctly.
- ASSERT_EQ(3u, DesktopWindowTreeHostX11::GetAllOpenWindows().size());
-
- EXPECT_EQ(window_one->GetNativeWindow(),
- screen()->GetWindowAtScreenPoint(gfx::Point(117, 117)));
- EXPECT_EQ(window_two->GetNativeWindow(),
- screen()->GetWindowAtScreenPoint(gfx::Point(155, 155)));
- EXPECT_EQ(NULL,
- screen()->GetWindowAtScreenPoint(gfx::Point(200, 200)));
-
- // Bring the third window in front. It overlaps with the first window.
- // Hit-testing on the intersecting region should give the third window.
- ActivationWaiter activation_waiter(window_three);
- window_three->Activate();
- activation_waiter.Wait();
-
- EXPECT_EQ(window_three->GetNativeWindow(),
- screen()->GetWindowAtScreenPoint(gfx::Point(117, 117)));
-
- window_one->CloseNow();
- window_two->CloseNow();
- window_three->CloseNow();
-}
-
TEST_F(DesktopScreenX11Test, GetDisplayNearestWindow) {
// Set up a two monitor situation.
std::vector<gfx::Display> displays;
« no previous file with comments | « ui/views/views.gyp ('k') | ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698