summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/shell.cc21
-rw-r--r--ash/shell.h2
-rw-r--r--ash/shell/shell_main.cc1
-rw-r--r--ash/test/ash_test_base.cc13
-rw-r--r--chrome/browser/chrome_browser_main_extra_parts_aura.cc1
-rw-r--r--chrome/browser/notifications/desktop_notifications_unittest.cc4
-rw-r--r--chrome/browser/ui/views/accessibility_event_router_views_unittest.cc6
-rw-r--r--chrome/chrome_tests.gypi6
-rw-r--r--chrome/test/base/browser_with_test_window_test.cc8
-rw-r--r--chrome/test/base/browser_with_test_window_test.h2
-rw-r--r--chrome/test/base/chrome_render_view_host_test_harness.cc1
-rw-r--r--chrome/test/base/ui_test_utils.cc1
-rw-r--r--chrome/test/base/view_event_test_base.cc8
-rw-r--r--content/browser/renderer_host/test_render_view_host.cc6
-rw-r--r--content/browser/renderer_host/test_render_view_host.h2
-rw-r--r--ui/aura/demo/demo_main.cc4
-rw-r--r--ui/aura/root_window.cc102
-rw-r--r--ui/aura/root_window.h7
-rw-r--r--ui/aura/root_window_host_linux.cc8
-rw-r--r--ui/aura/root_window_host_linux.h6
-rw-r--r--ui/aura/test/aura_test_base.cc19
-rw-r--r--ui/aura/test/aura_test_base.h4
-rw-r--r--ui/views/test/views_test_base.cc8
-rw-r--r--ui/views/test/views_test_base.h2
-rw-r--r--ui/views/widget/native_widget_aura_unittest.cc15
25 files changed, 119 insertions, 138 deletions
diff --git a/ash/shell.cc b/ash/shell.cc
index 52e25d1..651068f 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -270,11 +270,7 @@ internal::WorkspaceController* Shell::TestApi::workspace_controller() {
// Shell, public:
Shell::Shell(ShellDelegate* delegate)
- : root_filter_(new internal::RootWindowEventFilter),
-#if !defined(OS_MACOSX)
- nested_dispatcher_controller_(new NestedDispatcherController),
- accelerator_controller_(new AcceleratorController),
-#endif
+ : root_window_(new aura::RootWindow),
delegate_(delegate),
audio_controller_(NULL),
brightness_controller_(NULL),
@@ -283,8 +279,6 @@ Shell::Shell(ShellDelegate* delegate)
desktop_background_mode_(BACKGROUND_IMAGE),
root_window_layout_(NULL),
status_widget_(NULL) {
- // Pass ownership of the filter to the root window.
- GetRootWindow()->SetEventFilter(root_filter_);
}
Shell::~Shell() {
@@ -320,7 +314,10 @@ Shell::~Shell() {
// These need a valid Shell instance to clean up properly, so explicitly
// delete them before invalidating the instance.
+ // Alphabetical.
+ activation_controller_.reset();
drag_drop_controller_.reset();
+ shadow_controller_.reset();
window_cycle_controller_.reset();
// Launcher widget has a InputMethodBridge that references to
@@ -356,10 +353,18 @@ void Shell::DeleteInstance() {
// static
aura::RootWindow* Shell::GetRootWindow() {
- return aura::RootWindow::GetInstance();
+ return GetInstance()->root_window_.get();
}
void Shell::Init() {
+ root_filter_ = new internal::RootWindowEventFilter;
+#if !defined(OS_MACOSX)
+ nested_dispatcher_controller_.reset(new NestedDispatcherController);
+ accelerator_controller_.reset(new AcceleratorController);
+#endif
+ // Pass ownership of the filter to the root window.
+ GetRootWindow()->SetEventFilter(root_filter_);
+
DCHECK(!GetRootWindowEventFilterCount());
// PartialScreenshotEventFilter must be the first one to capture key
diff --git a/ash/shell.h b/ash/shell.h
index 2413c4b..40d5e20 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -252,6 +252,8 @@ class ASH_EXPORT Shell {
// when the screen is initially created.
static bool initially_hide_cursor_;
+ scoped_ptr<aura::RootWindow> root_window_;
+
internal::RootWindowEventFilter* root_filter_; // not owned
std::vector<WindowAndBoundsPair> to_restore_;
diff --git a/ash/shell/shell_main.cc b/ash/shell/shell_main.cc
index 34611d3..a5dbccf 100644
--- a/ash/shell/shell_main.cc
+++ b/ash/shell/shell_main.cc
@@ -268,7 +268,6 @@ int main(int argc, char** argv) {
ash::Shell::DeleteInstance();
- aura::RootWindow::DeleteInstance();
aura::Env::DeleteInstance();
ui::CompositorTestSupport::Terminate();
diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc
index 8b0f23e..be7fd5e 100644
--- a/ash/test/ash_test_base.cc
+++ b/ash/test/ash_test_base.cc
@@ -13,18 +13,12 @@ namespace ash {
namespace test {
AshTestBase::AshTestBase() {
- helper_.InitRootWindow(Shell::GetRootWindow());
}
AshTestBase::~AshTestBase() {
- // Ensure that we don't use the previously-allocated static RootWindow object
- // later -- on Linux, it holds a reference to our message loop's X connection.
- aura::RootWindow::DeleteInstance();
}
void AshTestBase::SetUp() {
- helper_.SetUp();
-
// Creates Shell and hook with Desktop.
TestShellDelegate* delegate = new TestShellDelegate;
Shell::WindowMode window_mode = Shell::MODE_OVERLAPPING;
@@ -32,6 +26,9 @@ void AshTestBase::SetUp() {
delegate->SetOverrideWindowMode(window_mode);
ash::Shell::CreateInstance(delegate);
+ helper_.SetUp();
+ helper_.InitRootWindow(Shell::GetRootWindow());
+
// Disable animations during tests.
ui::LayerAnimator::set_disable_animations_for_test(true);
}
@@ -40,10 +37,10 @@ void AshTestBase::TearDown() {
// Flush the message loop to finish pending release tasks.
RunAllPendingInMessageLoop();
+ helper_.TearDown();
+
// Tear down the shell.
Shell::DeleteInstance();
-
- helper_.TearDown();
}
bool AshTestBase::GetOverrideWindowMode(Shell::WindowMode* window_mode) {
diff --git a/chrome/browser/chrome_browser_main_extra_parts_aura.cc b/chrome/browser/chrome_browser_main_extra_parts_aura.cc
index 6dd359a..930dcf1c 100644
--- a/chrome/browser/chrome_browser_main_extra_parts_aura.cc
+++ b/chrome/browser/chrome_browser_main_extra_parts_aura.cc
@@ -77,6 +77,5 @@ void ChromeBrowserMainExtraPartsAura::PostProfileInit() {
void ChromeBrowserMainExtraPartsAura::PostMainMessageLoopRun() {
ash::Shell::DeleteInstance();
- aura::RootWindow::DeleteInstance();
aura::Env::DeleteInstance();
}
diff --git a/chrome/browser/notifications/desktop_notifications_unittest.cc b/chrome/browser/notifications/desktop_notifications_unittest.cc
index c59f0c9..bea8cdd 100644
--- a/chrome/browser/notifications/desktop_notifications_unittest.cc
+++ b/chrome/browser/notifications/desktop_notifications_unittest.cc
@@ -95,7 +95,7 @@ void DesktopNotificationsTest::SetUp() {
WebKit::initialize(&webkit_platform_support_);
// MockBalloonCollection retrieves information about the screen on creation.
// So it is necessary to make sure the desktop gets created first.
- ash::Shell::GetRootWindow();
+ ash::Shell::CreateInstance(NULL);
#endif
browser::RegisterLocalState(&local_state_);
@@ -112,7 +112,7 @@ void DesktopNotificationsTest::TearDown() {
ui_manager_.reset(NULL);
profile_.reset(NULL);
#if defined(USE_AURA)
- aura::RootWindow::DeleteInstance();
+ ash::Shell::DeleteInstance();
aura::Env::DeleteInstance();
WebKit::shutdown();
#endif
diff --git a/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc b/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc
index 59e25a8..c6154fc 100644
--- a/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc
+++ b/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc
@@ -121,15 +121,16 @@ class AccessibilityEventRouterViewsTest
virtual void SetUp() {
views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate();
#if defined(USE_AURA)
- aura::RootWindow* root_window = aura::RootWindow::GetInstance();
+ root_window_.reset(new aura::RootWindow);
test_stacking_client_.reset(
- new aura::test::TestStackingClient(root_window));
+ new aura::test::TestStackingClient(root_window_.get()));
#endif
}
virtual void TearDown() {
#if defined(USE_AURA)
test_stacking_client_.reset();
+ root_window_.reset();
#endif
delete views::ViewsDelegate::views_delegate;
views::ViewsDelegate::views_delegate = NULL;
@@ -165,6 +166,7 @@ class AccessibilityEventRouterViewsTest
std::string last_control_name_;
std::string last_control_context_;
#if defined(USE_AURA)
+ scoped_ptr<aura::RootWindow> root_window_;
scoped_ptr<aura::test::TestStackingClient> test_stacking_client_;
#endif
};
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 904d4f3..a17d34e 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -740,6 +740,12 @@
'../base/allocator/allocator.gyp:allocator',
],
}],
+ ['use_aura==1', {
+ 'sources/': [
+ ['exclude', '^browser/accessibility/accessibility_win_browsertest.cc'],
+ ['exclude', '^browser/accessibility/browser_views_accessibility_browsertest.cc'],
+ ],
+ }],
],
'configurations': {
'Debug_Base': {
diff --git a/chrome/test/base/browser_with_test_window_test.cc b/chrome/test/base/browser_with_test_window_test.cc
index a948f80..1b8fc00 100644
--- a/chrome/test/base/browser_with_test_window_test.cc
+++ b/chrome/test/base/browser_with_test_window_test.cc
@@ -48,11 +48,11 @@ void BrowserWithTestWindowTest::SetUp() {
window_.reset(new TestBrowserWindow(browser()));
browser_->SetWindowForTesting(window_.get());
#if defined(USE_AURA)
- aura::RootWindow* root_window = aura::RootWindow::GetInstance();
+ root_window_.reset(new aura::RootWindow);
test_activation_client_.reset(
- new aura::test::TestActivationClient(root_window));
+ new aura::test::TestActivationClient(root_window_.get()));
test_stacking_client_.reset(
- new aura::test::TestStackingClient(root_window));
+ new aura::test::TestStackingClient(root_window_.get()));
#endif
}
@@ -61,7 +61,7 @@ void BrowserWithTestWindowTest::TearDown() {
#if defined(USE_AURA)
test_activation_client_.reset();
test_stacking_client_.reset();
- aura::RootWindow::DeleteInstance();
+ root_window_.reset();
#endif
}
diff --git a/chrome/test/base/browser_with_test_window_test.h b/chrome/test/base/browser_with_test_window_test.h
index ce46819..294f72f 100644
--- a/chrome/test/base/browser_with_test_window_test.h
+++ b/chrome/test/base/browser_with_test_window_test.h
@@ -18,6 +18,7 @@ class GURL;
#if defined(USE_AURA)
namespace aura {
+class RootWindow;
namespace test {
class TestActivationClient;
class TestStackingClient;
@@ -124,6 +125,7 @@ class BrowserWithTestWindowTest : public testing::Test {
TestRenderViewHostFactory rvh_factory_;
#if defined(USE_AURA)
+ scoped_ptr<aura::RootWindow> root_window_;
scoped_ptr<aura::test::TestActivationClient> test_activation_client_;
scoped_ptr<aura::test::TestStackingClient> test_stacking_client_;
#endif
diff --git a/chrome/test/base/chrome_render_view_host_test_harness.cc b/chrome/test/base/chrome_render_view_host_test_harness.cc
index 612d77f..f9b052f 100644
--- a/chrome/test/base/chrome_render_view_host_test_harness.cc
+++ b/chrome/test/base/chrome_render_view_host_test_harness.cc
@@ -33,7 +33,6 @@ void ChromeRenderViewHostTestHarness::TearDown() {
RenderViewHostTestHarness::TearDown();
#if defined(USE_AURA)
ash::Shell::DeleteInstance();
- aura::RootWindow::DeleteInstance();
aura::Env::DeleteInstance();
#endif
}
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index adc81b0..667397e 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -278,7 +278,6 @@ void RunMessageLoop() {
MessageLoop::ScopedNestableTaskAllower allow(loop);
if (ui_loop) {
#if defined(USE_AURA)
- ash::Shell::GetRootWindow()->ShowRootWindow();
ui_loop->Run();
#elif defined(TOOLKIT_VIEWS)
views::AcceleratorHandler handler;
diff --git a/chrome/test/base/view_event_test_base.cc b/chrome/test/base/view_event_test_base.cc
index b04ab49..de2bb32 100644
--- a/chrome/test/base/view_event_test_base.cc
+++ b/chrome/test/base/view_event_test_base.cc
@@ -68,7 +68,7 @@ ViewEventTestBase::ViewEventTestBase()
void ViewEventTestBase::Done() {
MessageLoop::current()->Quit();
-#if defined(OS_WIN)
+#if defined(OS_WIN) && !defined(USE_AURA)
// We need to post a message to tickle the Dispatcher getting called and
// exiting out of the nested loop. Without this the quit never runs.
PostMessage(window_->GetNativeWindow(), WM_USER, 0, 0);
@@ -87,7 +87,6 @@ void ViewEventTestBase::SetUp() {
#endif
ui::CompositorTestSupport::Initialize();
#if defined(USE_AURA)
- ash::Shell::GetRootWindow();
ash::Shell::CreateInstance(NULL);
#endif
window_ = views::Widget::CreateWindow(this);
@@ -95,7 +94,7 @@ void ViewEventTestBase::SetUp() {
void ViewEventTestBase::TearDown() {
if (window_) {
-#if defined(OS_WIN)
+#if defined(OS_WIN) && !defined(USE_AURA)
DestroyWindow(window_->GetNativeWindow());
#else
window_->Close();
@@ -105,7 +104,6 @@ void ViewEventTestBase::TearDown() {
}
#if defined(USE_AURA)
ash::Shell::DeleteInstance();
- aura::RootWindow::DeleteInstance();
aura::Env::DeleteInstance();
#endif
ui::CompositorTestSupport::Terminate();
@@ -145,7 +143,7 @@ void ViewEventTestBase::StartMessageLoopAndRunTest() {
window_->Show();
// Make sure the window is the foreground window, otherwise none of the
// mouse events are going to be targeted correctly.
-#if defined(OS_WIN)
+#if defined(OS_WIN) && !defined(USE_AURA)
SetForegroundWindow(window_->GetNativeWindow());
#endif
diff --git a/content/browser/renderer_host/test_render_view_host.cc b/content/browser/renderer_host/test_render_view_host.cc
index 721de95..d29c0ce 100644
--- a/content/browser/renderer_host/test_render_view_host.cc
+++ b/content/browser/renderer_host/test_render_view_host.cc
@@ -400,8 +400,9 @@ void RenderViewHostTestHarness::Reload() {
void RenderViewHostTestHarness::SetUp() {
#if defined(USE_AURA)
- aura::RootWindow* root_window = aura::RootWindow::GetInstance();
- test_stacking_client_.reset(new aura::test::TestStackingClient(root_window));
+ root_window_.reset(new aura::RootWindow);
+ test_stacking_client_.reset(
+ new aura::test::TestStackingClient(root_window_.get()));
#endif
SetContents(CreateTestTabContents());
}
@@ -410,6 +411,7 @@ void RenderViewHostTestHarness::TearDown() {
SetContents(NULL);
#if defined(USE_AURA)
test_stacking_client_.reset();
+ root_window_.reset();
#endif
// Make sure that we flush any messages related to TabContents destruction
diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h
index dec9719..029c748 100644
--- a/content/browser/renderer_host/test_render_view_host.h
+++ b/content/browser/renderer_host/test_render_view_host.h
@@ -19,6 +19,7 @@
#if defined(USE_AURA)
namespace aura {
+class RootWindow;
namespace test {
class TestStackingClient;
}
@@ -374,6 +375,7 @@ class RenderViewHostTestHarness : public testing::Test {
private:
scoped_ptr<TestTabContents> contents_;
#if defined(USE_AURA)
+ scoped_ptr<aura::RootWindow> root_window_;
scoped_ptr<aura::test::TestStackingClient> test_stacking_client_;
#endif
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc
index 48f2e8d..d6eccc2 100644
--- a/ui/aura/demo/demo_main.cc
+++ b/ui/aura/demo/demo_main.cc
@@ -88,7 +88,7 @@ int main(int argc, char** argv) {
MessageLoop message_loop(MessageLoop::TYPE_UI);
ui::CompositorTestSupport::Initialize();
- aura::RootWindow::GetInstance();
+ scoped_ptr<aura::RootWindow> root_window(new aura::RootWindow);
// Create a hierarchy of test windows.
DemoWindowDelegate window_delegate1(SK_ColorBLUE);
@@ -115,7 +115,7 @@ int main(int argc, char** argv) {
window3.Show();
window3.SetParent(&window2);
- aura::RootWindow::GetInstance()->ShowRootWindow();
+ root_window->ShowRootWindow();
MessageLoopForUI::current()->Run();
ui::CompositorTestSupport::Terminate();
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index aaec097..3c3ece6 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -83,19 +83,52 @@ bool RootWindow::hide_host_cursor_ = false;
////////////////////////////////////////////////////////////////////////////////
// RootWindow, public:
-// static
-RootWindow* RootWindow::GetInstance() {
- if (!instance_) {
- instance_ = new RootWindow;
- instance_->Init();
- }
- return instance_;
+RootWindow::RootWindow()
+ : Window(NULL),
+ host_(aura::RootWindowHost::Create(GetInitialHostWindowBounds())),
+ ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)),
+ mouse_button_flags_(0),
+ last_cursor_(kCursorNull),
+ cursor_shown_(true),
+ ALLOW_THIS_IN_INITIALIZER_LIST(screen_(new ScreenAura(this))),
+ capture_window_(NULL),
+ mouse_pressed_handler_(NULL),
+ mouse_moved_handler_(NULL),
+ focused_window_(NULL),
+ touch_event_handler_(NULL),
+ gesture_handler_(NULL),
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ gesture_recognizer_(GestureRecognizer::Create(this))),
+ synthesize_mouse_move_(false),
+ waiting_on_compositing_end_(false),
+ draw_on_compositing_end_(false) {
+ SetName("RootWindow");
+ gfx::Screen::SetInstance(screen_);
+ last_mouse_location_ = host_->QueryMouseLocation();
+
+ ui::Compositor::Initialize(false);
+ compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget(),
+ host_->GetSize()));
+ DCHECK(compositor_.get());
+ compositor_->AddObserver(this);
+ Init();
}
-// static
-void RootWindow::DeleteInstance() {
- delete instance_;
- instance_ = NULL;
+RootWindow::~RootWindow() {
+ compositor_->RemoveObserver(this);
+ // Make sure to destroy the compositor before terminating so that state is
+ // cleared and we don't hit asserts.
+ compositor_.reset();
+
+ // Tear down in reverse. Frees any references held by the host.
+ host_.reset(NULL);
+
+ // An observer may have been added by an animation on the RootWindow.
+ layer()->GetAnimator()->RemoveObserver(this);
+ ui::Compositor::Terminate();
+ if (instance_ == this)
+ instance_ = NULL;
}
void RootWindow::ShowRootWindow() {
@@ -445,53 +478,6 @@ void RootWindow::OnCompositingEnded(ui::Compositor*) {
////////////////////////////////////////////////////////////////////////////////
// RootWindow, private:
-RootWindow::RootWindow()
- : Window(NULL),
- host_(aura::RootWindowHost::Create(GetInitialHostWindowBounds())),
- ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)),
- ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)),
- mouse_button_flags_(0),
- last_cursor_(kCursorNull),
- cursor_shown_(true),
- ALLOW_THIS_IN_INITIALIZER_LIST(screen_(new ScreenAura(this))),
- capture_window_(NULL),
- mouse_pressed_handler_(NULL),
- mouse_moved_handler_(NULL),
- focused_window_(NULL),
- touch_event_handler_(NULL),
- gesture_handler_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- gesture_recognizer_(GestureRecognizer::Create(this))),
- synthesize_mouse_move_(false),
- waiting_on_compositing_end_(false),
- draw_on_compositing_end_(false) {
- SetName("RootWindow");
- gfx::Screen::SetInstance(screen_);
- last_mouse_location_ = host_->QueryMouseLocation();
-
- ui::Compositor::Initialize(false);
- compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget(),
- host_->GetSize()));
- DCHECK(compositor_.get());
- compositor_->AddObserver(this);
-}
-
-RootWindow::~RootWindow() {
- compositor_->RemoveObserver(this);
- // Make sure to destroy the compositor before terminating so that state is
- // cleared and we don't hit asserts.
- compositor_.reset();
-
- // Tear down in reverse. Frees any references held by the host.
- host_.reset(NULL);
-
- // An observer may have been added by an animation on the RootWindow.
- layer()->GetAnimator()->RemoveObserver(this);
- ui::Compositor::Terminate();
- if (instance_ == this)
- instance_ = NULL;
-}
-
void RootWindow::HandleMouseCaptureChanged(Window* old_capture_window) {
if (capture_window_)
host_->SetCapture();
diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h
index b04857d..983ec87 100644
--- a/ui/aura/root_window.h
+++ b/ui/aura/root_window.h
@@ -50,8 +50,8 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
public internal::FocusManager,
public ui::LayerAnimationObserver {
public:
- static RootWindow* GetInstance();
- static void DeleteInstance();
+ RootWindow();
+ virtual ~RootWindow();
static void set_use_fullscreen_host_window(bool use_fullscreen) {
use_fullscreen_host_window_ = use_fullscreen;
@@ -197,9 +197,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
private:
friend class Window;
- RootWindow();
- virtual ~RootWindow();
-
// Called whenever the mouse moves, tracks the current |mouse_moved_handler_|,
// sending exited and entered events as its value changes.
void HandleMouseMoved(const MouseEvent& event, Window* target);
diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc
index 342e114..a6c4e5a 100644
--- a/ui/aura/root_window_host_linux.cc
+++ b/ui/aura/root_window_host_linux.cc
@@ -305,8 +305,6 @@ RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds)
if (base::MessagePumpForUI::HasXInput2())
ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_);
- MessageLoopForUI::current()->AddDestructionObserver(this);
-
// Initialize invisible cursor.
char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
XColor black;
@@ -328,8 +326,6 @@ RootWindowHostLinux::~RootWindowHostLinux() {
ui::GetXCursor(ui::kCursorClearXCursorCache);
XFreeCursor(xdisplay_, invisible_cursor_);
-
- MessageLoopForUI::current()->RemoveDestructionObserver(this);
}
base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch(
@@ -624,10 +620,6 @@ void RootWindowHostLinux::PostNativeEvent(
XSendEvent(xdisplay_, xwindow_, False, 0, &xevent);
}
-void RootWindowHostLinux::WillDestroyCurrentMessageLoop() {
- aura::RootWindow::DeleteInstance();
-}
-
bool RootWindowHostLinux::IsWindowManagerPresent() {
// Per ICCCM 2.8, "Manager Selections", window managers should take ownership
// of WM_Sn selections (where n is a screen number).
diff --git a/ui/aura/root_window_host_linux.h b/ui/aura/root_window_host_linux.h
index 0d05b7b..2ad9fe7 100644
--- a/ui/aura/root_window_host_linux.h
+++ b/ui/aura/root_window_host_linux.h
@@ -17,8 +17,7 @@
namespace aura {
-class RootWindowHostLinux : public RootWindowHost,
- public MessageLoop::DestructionObserver {
+class RootWindowHostLinux : public RootWindowHost {
public:
explicit RootWindowHostLinux(const gfx::Rect& bounds);
virtual ~RootWindowHostLinux();
@@ -45,9 +44,6 @@ class RootWindowHostLinux : public RootWindowHost,
virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE;
- // MessageLoop::DestructionObserver Overrides.
- virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
-
// Returns true if there's an X window manager present... in most cases. Some
// window managers (notably, ion3) don't implement enough of ICCCM for us to
// detect that they're there.
diff --git a/ui/aura/test/aura_test_base.cc b/ui/aura/test/aura_test_base.cc
index 5747b38..a7399a8 100644
--- a/ui/aura/test/aura_test_base.cc
+++ b/ui/aura/test/aura_test_base.cc
@@ -10,34 +10,33 @@
namespace aura {
namespace test {
-AuraTestBase::AuraTestBase() : root_window_(RootWindow::GetInstance()) {
- helper_.InitRootWindow(root_window_);
+AuraTestBase::AuraTestBase() {
}
AuraTestBase::~AuraTestBase() {
- // Flush the message loop because we have pending release tasks
- // and these tasks if un-executed would upset Valgrind.
- helper_.RunAllPendingInMessageLoop(root_window_);
-
- // Ensure that we don't use the previously-allocated static RootWindow object
- // later -- on Linux, it holds a reference to our message loop's X connection.
- RootWindow::DeleteInstance();
}
void AuraTestBase::SetUp() {
testing::Test::SetUp();
+ root_window_.reset(new aura::RootWindow);
+ helper_.InitRootWindow(root_window());
helper_.SetUp();
stacking_client_.reset(new TestStackingClient(root_window()));
}
void AuraTestBase::TearDown() {
+ // Flush the message loop because we have pending release tasks
+ // and these tasks if un-executed would upset Valgrind.
+ RunAllPendingInMessageLoop();
+
stacking_client_.reset();
helper_.TearDown();
+ root_window_.reset();
testing::Test::TearDown();
}
void AuraTestBase::RunAllPendingInMessageLoop() {
- helper_.RunAllPendingInMessageLoop(root_window_);
+ helper_.RunAllPendingInMessageLoop(root_window());
}
} // namespace test
diff --git a/ui/aura/test/aura_test_base.h b/ui/aura/test/aura_test_base.h
index 7b2a134..14bd3f9 100644
--- a/ui/aura/test/aura_test_base.h
+++ b/ui/aura/test/aura_test_base.h
@@ -30,11 +30,11 @@ class AuraTestBase : public testing::Test {
protected:
void RunAllPendingInMessageLoop();
- RootWindow* root_window() { return root_window_; }
+ RootWindow* root_window() { return root_window_.get(); }
private:
AuraTestHelper helper_;
- RootWindow* root_window_;
+ scoped_ptr<RootWindow> root_window_;
scoped_ptr<TestStackingClient> stacking_client_;
DISALLOW_COPY_AND_ASSIGN(AuraTestBase);
diff --git a/ui/views/test/views_test_base.cc b/ui/views/test/views_test_base.cc
index 693de93..f12c26b 100644
--- a/ui/views/test/views_test_base.cc
+++ b/ui/views/test/views_test_base.cc
@@ -87,14 +87,14 @@ void ViewsTestBase::SetUp() {
if (!views_delegate_.get())
views_delegate_.reset(new TestViewsDelegate());
#if defined(USE_AURA)
- root_window_ = aura::RootWindow::GetInstance();
+ root_window_.reset(new aura::RootWindow);
root_window_->SetProperty(
aura::client::kRootWindowInputMethodKey,
test_input_method_.get());
test_activation_client_.reset(
- new aura::test::TestActivationClient(root_window_));
+ new aura::test::TestActivationClient(root_window_.get()));
test_stacking_client_.reset(
- new aura::test::TestStackingClient(root_window_));
+ new aura::test::TestStackingClient(root_window_.get()));
#endif
}
@@ -108,7 +108,7 @@ void ViewsTestBase::TearDown() {
#if defined(USE_AURA)
test_stacking_client_.reset();
test_activation_client_.reset();
- aura::RootWindow::DeleteInstance();
+ root_window_.reset();
#endif
}
diff --git a/ui/views/test/views_test_base.h b/ui/views/test/views_test_base.h
index eebd9e2b..635c24c 100644
--- a/ui/views/test/views_test_base.h
+++ b/ui/views/test/views_test_base.h
@@ -53,10 +53,10 @@ class ViewsTestBase : public testing::Test {
MessageLoopForUI message_loop_;
scoped_ptr<TestViewsDelegate> views_delegate_;
#if defined(USE_AURA)
+ scoped_ptr<aura::RootWindow> root_window_;
scoped_ptr<aura::test::TestActivationClient> test_activation_client_;
scoped_ptr<aura::test::TestStackingClient> test_stacking_client_;
scoped_ptr<ui::InputMethod> test_input_method_;
- aura::RootWindow* root_window_;
#endif
bool setup_called_;
bool teardown_called_;
diff --git a/ui/views/widget/native_widget_aura_unittest.cc b/ui/views/widget/native_widget_aura_unittest.cc
index 5561fda..4196cf3 100644
--- a/ui/views/widget/native_widget_aura_unittest.cc
+++ b/ui/views/widget/native_widget_aura_unittest.cc
@@ -28,29 +28,29 @@ NativeWidgetAura* Init(aura::Window* parent, Widget* widget) {
class NativeWidgetAuraTest : public testing::Test {
public:
- NativeWidgetAuraTest() : root_window_(NULL) {}
+ NativeWidgetAuraTest() {}
virtual ~NativeWidgetAuraTest() {}
// testing::Test overrides:
virtual void SetUp() OVERRIDE {
- root_window_ = aura::RootWindow::GetInstance();
+ root_window_.reset(new aura::RootWindow);
root_window_->SetBounds(gfx::Rect(0, 0, 640, 480));
root_window_->SetHostSize(gfx::Size(640, 480));
test_stacking_client_.reset(
- new aura::test::TestStackingClient(root_window_));
+ new aura::test::TestStackingClient(root_window_.get()));
}
virtual void TearDown() OVERRIDE {
- test_stacking_client_.reset();
- aura::RootWindow::DeleteInstance();
message_loop_.RunAllPending();
+ test_stacking_client_.reset();
+ root_window_.reset();
}
protected:
- aura::RootWindow* root_window() { return root_window_; }
+ aura::RootWindow* root_window() { return root_window_.get(); }
private:
MessageLoopForUI message_loop_;
- aura::RootWindow* root_window_;
+ scoped_ptr<aura::RootWindow> root_window_;
scoped_ptr<aura::test::TestStackingClient> test_stacking_client_;
DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest);
@@ -154,7 +154,6 @@ TEST_F(NativeWidgetAuraTest, ShowMaximizedDoesntBounceAround) {
params.show_state = ui::SHOW_STATE_MAXIMIZED;
params.bounds = gfx::Rect(10, 10, 100, 200);
widget->Init(params);
- aura::RootWindow::DeleteInstance();
EXPECT_FALSE(widget->did_size_change_more_than_once());
widget->CloseNow();
}