diff options
25 files changed, 138 insertions, 119 deletions
diff --git a/ash/shell.cc b/ash/shell.cc index 651068f..52e25d1 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -270,7 +270,11 @@ internal::WorkspaceController* Shell::TestApi::workspace_controller() { // Shell, public: Shell::Shell(ShellDelegate* delegate) - : root_window_(new aura::RootWindow), + : root_filter_(new internal::RootWindowEventFilter), +#if !defined(OS_MACOSX) + nested_dispatcher_controller_(new NestedDispatcherController), + accelerator_controller_(new AcceleratorController), +#endif delegate_(delegate), audio_controller_(NULL), brightness_controller_(NULL), @@ -279,6 +283,8 @@ 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() { @@ -314,10 +320,7 @@ 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 @@ -353,18 +356,10 @@ void Shell::DeleteInstance() { // static aura::RootWindow* Shell::GetRootWindow() { - return GetInstance()->root_window_.get(); + return aura::RootWindow::GetInstance(); } 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 40d5e20..2413c4b 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -252,8 +252,6 @@ 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 a5dbccf..34611d3 100644 --- a/ash/shell/shell_main.cc +++ b/ash/shell/shell_main.cc @@ -268,6 +268,7 @@ 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 be7fd5e..8b0f23e 100644 --- a/ash/test/ash_test_base.cc +++ b/ash/test/ash_test_base.cc @@ -13,12 +13,18 @@ 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; @@ -26,9 +32,6 @@ 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); } @@ -37,10 +40,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 930dcf1c..6dd359a 100644 --- a/chrome/browser/chrome_browser_main_extra_parts_aura.cc +++ b/chrome/browser/chrome_browser_main_extra_parts_aura.cc @@ -77,5 +77,6 @@ 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 bea8cdd..c59f0c9 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::CreateInstance(NULL); + ash::Shell::GetRootWindow(); #endif browser::RegisterLocalState(&local_state_); @@ -112,7 +112,7 @@ void DesktopNotificationsTest::TearDown() { ui_manager_.reset(NULL); profile_.reset(NULL); #if defined(USE_AURA) - ash::Shell::DeleteInstance(); + aura::RootWindow::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 c6154fc..59e25a8 100644 --- a/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc +++ b/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc @@ -121,16 +121,15 @@ class AccessibilityEventRouterViewsTest virtual void SetUp() { views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); #if defined(USE_AURA) - root_window_.reset(new aura::RootWindow); + aura::RootWindow* root_window = aura::RootWindow::GetInstance(); test_stacking_client_.reset( - new aura::test::TestStackingClient(root_window_.get())); + new aura::test::TestStackingClient(root_window)); #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; @@ -166,7 +165,6 @@ 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 a17d34e..904d4f3 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -740,12 +740,6 @@ '../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 1b8fc00..a948f80 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) - root_window_.reset(new aura::RootWindow); + aura::RootWindow* root_window = aura::RootWindow::GetInstance(); test_activation_client_.reset( - new aura::test::TestActivationClient(root_window_.get())); + new aura::test::TestActivationClient(root_window)); test_stacking_client_.reset( - new aura::test::TestStackingClient(root_window_.get())); + new aura::test::TestStackingClient(root_window)); #endif } @@ -61,7 +61,7 @@ void BrowserWithTestWindowTest::TearDown() { #if defined(USE_AURA) test_activation_client_.reset(); test_stacking_client_.reset(); - root_window_.reset(); + aura::RootWindow::DeleteInstance(); #endif } diff --git a/chrome/test/base/browser_with_test_window_test.h b/chrome/test/base/browser_with_test_window_test.h index 294f72f..ce46819 100644 --- a/chrome/test/base/browser_with_test_window_test.h +++ b/chrome/test/base/browser_with_test_window_test.h @@ -18,7 +18,6 @@ class GURL; #if defined(USE_AURA) namespace aura { -class RootWindow; namespace test { class TestActivationClient; class TestStackingClient; @@ -125,7 +124,6 @@ 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 f9b052f..612d77f 100644 --- a/chrome/test/base/chrome_render_view_host_test_harness.cc +++ b/chrome/test/base/chrome_render_view_host_test_harness.cc @@ -33,6 +33,7 @@ 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 667397e..adc81b0 100644 --- a/chrome/test/base/ui_test_utils.cc +++ b/chrome/test/base/ui_test_utils.cc @@ -278,6 +278,7 @@ 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 de2bb32..b04ab49 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) && !defined(USE_AURA) +#if defined(OS_WIN) // 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,6 +87,7 @@ void ViewEventTestBase::SetUp() { #endif ui::CompositorTestSupport::Initialize(); #if defined(USE_AURA) + ash::Shell::GetRootWindow(); ash::Shell::CreateInstance(NULL); #endif window_ = views::Widget::CreateWindow(this); @@ -94,7 +95,7 @@ void ViewEventTestBase::SetUp() { void ViewEventTestBase::TearDown() { if (window_) { -#if defined(OS_WIN) && !defined(USE_AURA) +#if defined(OS_WIN) DestroyWindow(window_->GetNativeWindow()); #else window_->Close(); @@ -104,6 +105,7 @@ void ViewEventTestBase::TearDown() { } #if defined(USE_AURA) ash::Shell::DeleteInstance(); + aura::RootWindow::DeleteInstance(); aura::Env::DeleteInstance(); #endif ui::CompositorTestSupport::Terminate(); @@ -143,7 +145,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) && !defined(USE_AURA) +#if defined(OS_WIN) 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 d29c0ce..721de95 100644 --- a/content/browser/renderer_host/test_render_view_host.cc +++ b/content/browser/renderer_host/test_render_view_host.cc @@ -400,9 +400,8 @@ void RenderViewHostTestHarness::Reload() { void RenderViewHostTestHarness::SetUp() { #if defined(USE_AURA) - root_window_.reset(new aura::RootWindow); - test_stacking_client_.reset( - new aura::test::TestStackingClient(root_window_.get())); + aura::RootWindow* root_window = aura::RootWindow::GetInstance(); + test_stacking_client_.reset(new aura::test::TestStackingClient(root_window)); #endif SetContents(CreateTestTabContents()); } @@ -411,7 +410,6 @@ 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 029c748..dec9719 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -19,7 +19,6 @@ #if defined(USE_AURA) namespace aura { -class RootWindow; namespace test { class TestStackingClient; } @@ -375,7 +374,6 @@ 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 d6eccc2..48f2e8d 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(); - scoped_ptr<aura::RootWindow> root_window(new aura::RootWindow); + aura::RootWindow::GetInstance(); // 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); - root_window->ShowRootWindow(); + aura::RootWindow::GetInstance()->ShowRootWindow(); MessageLoopForUI::current()->Run(); ui::CompositorTestSupport::Terminate(); diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index 3c3ece6..aaec097 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -83,52 +83,19 @@ bool RootWindow::hide_host_cursor_ = false; //////////////////////////////////////////////////////////////////////////////// // RootWindow, public: -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 +RootWindow* RootWindow::GetInstance() { + if (!instance_) { + instance_ = new RootWindow; + instance_->Init(); + } + return instance_; } -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; +// static +void RootWindow::DeleteInstance() { + delete instance_; + instance_ = NULL; } void RootWindow::ShowRootWindow() { @@ -478,6 +445,53 @@ 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 983ec87..b04857d 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: - RootWindow(); - virtual ~RootWindow(); + static RootWindow* GetInstance(); + static void DeleteInstance(); static void set_use_fullscreen_host_window(bool use_fullscreen) { use_fullscreen_host_window_ = use_fullscreen; @@ -197,6 +197,9 @@ 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 a6c4e5a..342e114 100644 --- a/ui/aura/root_window_host_linux.cc +++ b/ui/aura/root_window_host_linux.cc @@ -305,6 +305,8 @@ 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; @@ -326,6 +328,8 @@ RootWindowHostLinux::~RootWindowHostLinux() { ui::GetXCursor(ui::kCursorClearXCursorCache); XFreeCursor(xdisplay_, invisible_cursor_); + + MessageLoopForUI::current()->RemoveDestructionObserver(this); } base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( @@ -620,6 +624,10 @@ 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 2ad9fe7..0d05b7b 100644 --- a/ui/aura/root_window_host_linux.h +++ b/ui/aura/root_window_host_linux.h @@ -17,7 +17,8 @@ namespace aura { -class RootWindowHostLinux : public RootWindowHost { +class RootWindowHostLinux : public RootWindowHost, + public MessageLoop::DestructionObserver { public: explicit RootWindowHostLinux(const gfx::Rect& bounds); virtual ~RootWindowHostLinux(); @@ -44,6 +45,9 @@ 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 a7399a8..5747b38 100644 --- a/ui/aura/test/aura_test_base.cc +++ b/ui/aura/test/aura_test_base.cc @@ -10,33 +10,34 @@ namespace aura { namespace test { -AuraTestBase::AuraTestBase() { +AuraTestBase::AuraTestBase() : root_window_(RootWindow::GetInstance()) { + helper_.InitRootWindow(root_window_); } 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 14bd3f9..7b2a134 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_.get(); } + RootWindow* root_window() { return root_window_; } private: AuraTestHelper helper_; - scoped_ptr<RootWindow> root_window_; + 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 f12c26b..693de93 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_.reset(new aura::RootWindow); + root_window_ = aura::RootWindow::GetInstance(); root_window_->SetProperty( aura::client::kRootWindowInputMethodKey, test_input_method_.get()); test_activation_client_.reset( - new aura::test::TestActivationClient(root_window_.get())); + new aura::test::TestActivationClient(root_window_)); test_stacking_client_.reset( - new aura::test::TestStackingClient(root_window_.get())); + new aura::test::TestStackingClient(root_window_)); #endif } @@ -108,7 +108,7 @@ void ViewsTestBase::TearDown() { #if defined(USE_AURA) test_stacking_client_.reset(); test_activation_client_.reset(); - root_window_.reset(); + aura::RootWindow::DeleteInstance(); #endif } diff --git a/ui/views/test/views_test_base.h b/ui/views/test/views_test_base.h index 635c24c..eebd9e2b 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 4196cf3..5561fda 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() {} + NativeWidgetAuraTest() : root_window_(NULL) {} virtual ~NativeWidgetAuraTest() {} // testing::Test overrides: virtual void SetUp() OVERRIDE { - root_window_.reset(new aura::RootWindow); + root_window_ = aura::RootWindow::GetInstance(); 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_.get())); + new aura::test::TestStackingClient(root_window_)); } virtual void TearDown() OVERRIDE { - message_loop_.RunAllPending(); test_stacking_client_.reset(); - root_window_.reset(); + aura::RootWindow::DeleteInstance(); + message_loop_.RunAllPending(); } protected: - aura::RootWindow* root_window() { return root_window_.get(); } + aura::RootWindow* root_window() { return root_window_; } private: MessageLoopForUI message_loop_; - scoped_ptr<aura::RootWindow> root_window_; + aura::RootWindow* root_window_; scoped_ptr<aura::test::TestStackingClient> test_stacking_client_; DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest); @@ -154,6 +154,7 @@ 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(); } |