summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-27 11:21:55 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-27 11:21:55 +0000
commitd23cc4cf8500248c536f2236fbf179143d7a7282 (patch)
tree925fb9e92680976dbdb259f4e74e37641ad20aba
parent6f381e25b81b8d775c5a99d355ff9af275776be5 (diff)
downloadchromium_src-d23cc4cf8500248c536f2236fbf179143d7a7282.zip
chromium_src-d23cc4cf8500248c536f2236fbf179143d7a7282.tar.gz
chromium_src-d23cc4cf8500248c536f2236fbf179143d7a7282.tar.bz2
Move DesktopWindowTreeHostX11Test.Deactivate to interactive_ui_tests
Hopefully the move will make DesktopWindowTreeHostX11Test.Deactivate no longer flaky. Only a single window can be active at a time. I suspect that this test sometimes fails when run in parallel with other tests BUG=396491 TEST=None Review URL: https://codereview.chromium.org/414123005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285834 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--build/filename_rules.gypi2
-rw-r--r--chrome/chrome_tests.gypi2
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc127
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc49
4 files changed, 130 insertions, 50 deletions
diff --git a/build/filename_rules.gypi b/build/filename_rules.gypi
index e225699..1bef75f 100644
--- a/build/filename_rules.gypi
+++ b/build/filename_rules.gypi
@@ -65,7 +65,7 @@
}],
['<(use_x11)!=1 or >(nacl_untrusted_build)==1', {
'sources/': [
- ['exclude', '_(x|x11)(_unittest)?\\.(h|cc)$'],
+ ['exclude', '_(x|x11)(_interactive_uitest|_unittest)?\\.(h|cc)$'],
['exclude', '(^|/)x11_[^/]*\\.(h|cc)$'],
['exclude', '(^|/)x11/'],
['exclude', '(^|/)x/'],
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index a5ddd61..7d7736b 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -50,6 +50,7 @@
'../ui/base/clipboard/clipboard_unittest.cc',
'../ui/views/controls/webview/webview_interactive_uitest.cc',
'../ui/views/corewm/desktop_capture_controller_unittest.cc',
+ '../ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc',
'../ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc',
'../ui/views/widget/widget_interactive_uitest.cc',
'browser/apps/app_browsertest_util.cc',
@@ -294,6 +295,7 @@
'test/data/chromeos/service_login.html',
],
'sources!': [
+ '../ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc',
'../ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc',
# chromeos does not use cross-platform panels
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc
new file mode 100644
index 0000000..1c14861
--- /dev/null
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc
@@ -0,0 +1,127 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <vector>
+
+#include <X11/Xlib.h>
+
+// Get rid of X11 macros which conflict with gtest.
+#undef Bool
+#undef None
+
+#include "base/memory/scoped_ptr.h"
+#include "base/path_service.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_tree_host.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_paths.h"
+#include "ui/base/x/x11_util.h"
+#include "ui/events/platform/x11/x11_event_source.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/x/x11_atom_cache.h"
+#include "ui/gl/gl_surface.h"
+#include "ui/views/test/views_test_base.h"
+#include "ui/views/test/x11_property_change_waiter.h"
+#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
+
+namespace views {
+
+namespace {
+
+// Blocks till |window| gets activated.
+class ActivationWaiter : public X11PropertyChangeWaiter {
+ public:
+ explicit ActivationWaiter(XID window)
+ : X11PropertyChangeWaiter(ui::GetX11RootWindow(), "_NET_ACTIVE_WINDOW"),
+ window_(window) {
+ }
+
+ virtual ~ActivationWaiter() {
+ }
+
+ private:
+ // X11PropertyChangeWaiter:
+ virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) OVERRIDE {
+ XID xid = 0;
+ ui::GetXIDProperty(ui::GetX11RootWindow(), "_NET_ACTIVE_WINDOW", &xid);
+ return xid != window_;
+ }
+
+ XID window_;
+
+ DISALLOW_COPY_AND_ASSIGN(ActivationWaiter);
+};
+
+// Creates a widget of size 100x100.
+scoped_ptr<Widget> CreateWidget() {
+ scoped_ptr<Widget> widget(new Widget);
+ Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
+ params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params.remove_standard_frame = true;
+ params.native_widget = new DesktopNativeWidgetAura(widget.get());
+ params.bounds = gfx::Rect(100, 100, 100, 100);
+ widget->Init(params);
+ return widget.Pass();
+}
+
+} // namespace
+
+class DesktopWindowTreeHostX11Test : public ViewsTestBase {
+ public:
+ DesktopWindowTreeHostX11Test() {
+ }
+ virtual ~DesktopWindowTreeHostX11Test() {
+ }
+
+ static void SetUpTestCase() {
+ gfx::GLSurface::InitializeOneOffForTests();
+ ui::RegisterPathProvider();
+ base::FilePath ui_test_pak_path;
+ ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
+ ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
+ }
+
+ virtual void SetUp() OVERRIDE {
+ ViewsTestBase::SetUp();
+
+ // Make X11 synchronous for our display connection. This does not force the
+ // window manager to behave synchronously.
+ XSynchronize(gfx::GetXDisplay(), True);
+ }
+
+ virtual void TearDown() OVERRIDE {
+ XSynchronize(gfx::GetXDisplay(), False);
+ ViewsTestBase::TearDown();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11Test);
+};
+
+// Test that calling Widget::Deactivate() sets the widget as inactive wrt to
+// Chrome even if it not possible to deactivate the window wrt to the x server.
+// This behavior is required by several interactive_ui_tests.
+TEST_F(DesktopWindowTreeHostX11Test, Deactivate) {
+ scoped_ptr<Widget> widget(CreateWidget());
+
+ ActivationWaiter waiter(
+ widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget());
+ widget->Show();
+ widget->Activate();
+ waiter.Wait();
+
+ widget->Deactivate();
+ // Regardless of whether |widget|'s X11 window eventually gets deactivated,
+ // |widget|'s "active" state should change.
+ EXPECT_FALSE(widget->IsActive());
+
+ // |widget|'s X11 window should still be active. Reactivating |widget| should
+ // update the widget's "active" state.
+ // Note: Activating a widget whose X11 window is not active does not
+ // synchronously update the widget's "active" state.
+ widget->Activate();
+ EXPECT_TRUE(widget->IsActive());
+}
+
+} // namespace views
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
index 17e597c..8a66c6e 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
@@ -77,30 +77,6 @@ class WMStateWaiter : public X11PropertyChangeWaiter {
DISALLOW_COPY_AND_ASSIGN(WMStateWaiter);
};
-// Blocks till |window| gets activated.
-class ActivationWaiter : public X11PropertyChangeWaiter {
- public:
- explicit ActivationWaiter(XID window)
- : X11PropertyChangeWaiter(ui::GetX11RootWindow(), "_NET_ACTIVE_WINDOW"),
- window_(window) {
- }
-
- virtual ~ActivationWaiter() {
- }
-
- private:
- // X11PropertyChangeWaiter:
- virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) OVERRIDE {
- XID xid = 0;
- ui::GetXIDProperty(ui::GetX11RootWindow(), "_NET_ACTIVE_WINDOW", &xid);
- return xid != window_;
- }
-
- XID window_;
-
- DISALLOW_COPY_AND_ASSIGN(ActivationWaiter);
-};
-
// A NonClientFrameView with a window mask with the bottom right corner cut out.
class ShapedNonClientFrameView : public NonClientFrameView {
public:
@@ -469,29 +445,4 @@ TEST_F(DesktopWindowTreeHostX11Test, ToggleMinimizePropogateToContentWindow) {
EXPECT_TRUE(widget.GetNativeWindow()->IsVisible());
}
-// Test that calling Widget::Deactivate() sets the widget as inactive wrt to
-// Chrome even if it not possible to deactivate the window wrt to the x server.
-// This behavior is required by several interactive_ui_tests.
-TEST_F(DesktopWindowTreeHostX11Test, Deactivate) {
- scoped_ptr<Widget> widget(CreateWidget(NULL));
-
- ActivationWaiter waiter(
- widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget());
- widget->Show();
- widget->Activate();
- waiter.Wait();
-
- widget->Deactivate();
- // Regardless of whether |widget|'s X11 window eventually gets deactivated,
- // |widget|'s "active" state should change.
- EXPECT_FALSE(widget->IsActive());
-
- // |widget|'s X11 window should still be active. Reactivating |widget| should
- // update the widget's "active" state.
- // Note: Activating a widget whose X11 window is not active does not
- // synchronously update the widget's "active" state.
- widget->Activate();
- EXPECT_TRUE(widget->IsActive());
-}
-
} // namespace views