Commit bf012524 authored by sky@chromium.org's avatar sky@chromium.org

Moves responsibility of invoking OnNativeWidgetCreated to DesktopRootWindowHost

I had centralized this in DesktopNativeWidgetAura, but it needs to be
in the DesktopRootWindowHost implementations as it may be invoked
during construction so that state can be set up. Otherwise we may
crash if during init state isn't set up.

I added test for coverage.

BUG=313780
TEST=covered by unit test
R=ben@chromium.org

Review URL: https://codereview.chromium.org/49303007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233012 0039d316-1c4b-4281-b951-d872f2087c98
parent aa3dd499
......@@ -780,6 +780,7 @@
'view_model_utils_unittest.cc',
'view_unittest.cc',
'widget/desktop_aura/desktop_native_widget_aura_unittest.cc',
'widget/desktop_aura/desktop_root_window_host_win_unittest.cc',
'widget/desktop_aura/desktop_screen_x11_unittest.cc',
'widget/desktop_aura/desktop_screen_position_client_unittest.cc',
'widget/native_widget_aura_unittest.cc',
......
......@@ -364,8 +364,6 @@ void DesktopNativeWidgetAura::InitNativeWidget(
desktop_root_window_host_->OnRootWindowCreated(root_window_.get(), params);
native_widget_delegate_->OnNativeWidgetCreated(true);
UpdateWindowTransparency();
capture_client_.reset(new DesktopCaptureClient(root_window_.get()));
......
......@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/aura/root_window.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/widget.h"
namespace views {
......
......@@ -687,6 +687,8 @@ void DesktopRootWindowHostWin::HandleCreate() {
// TODO(beng): moar
NOTIMPLEMENTED();
native_widget_delegate_->OnNativeWidgetCreated(true);
// 1. Window property association
// 2. MouseWheel.
}
......
// Copyright 2013 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 "ui/views/widget/desktop_aura/desktop_root_window_host_win.h"
#include "ui/aura/root_window.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/widget.h"
namespace views {
typedef ViewsTestBase DesktopRootWindowHostWinTest;
namespace {
// See description above SaveFocusOnDeactivateFromHandleCreate.
class TestDesktopRootWindowHostWin : public DesktopRootWindowHostWin {
public:
TestDesktopRootWindowHostWin(
internal::NativeWidgetDelegate* native_widget_delegate,
DesktopNativeWidgetAura* desktop_native_widget_aura)
: DesktopRootWindowHostWin(native_widget_delegate,
desktop_native_widget_aura) {}
virtual ~TestDesktopRootWindowHostWin() {}
// DesktopRootWindowHostWin overrides:
virtual void HandleCreate() OVERRIDE {
DesktopRootWindowHostWin::HandleCreate();
SaveFocusOnDeactivate();
}
private:
DISALLOW_COPY_AND_ASSIGN(TestDesktopRootWindowHostWin);
};
} // namespace
// Verifies if SaveFocusOnDeactivate() is invoked from
// DesktopRootWindowHostWin::HandleCreate we don't crash.
TEST_F(DesktopRootWindowHostWinTest, SaveFocusOnDeactivateFromHandleCreate) {
Widget widget;
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(0, 0, 200, 200);
params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
DesktopNativeWidgetAura* desktop_native_widget_aura =
new DesktopNativeWidgetAura(&widget);
params.native_widget = desktop_native_widget_aura;
params.desktop_root_window_host = new TestDesktopRootWindowHostWin(
&widget, desktop_native_widget_aura);
widget.Init(params);
}
} // namespace views
......@@ -240,6 +240,8 @@ void DesktopRootWindowHostX11::OnRootWindowCreated(
x11_window_move_client_.reset(new X11DesktopWindowMoveClient);
aura::client::SetWindowMoveClient(root_window_,
x11_window_move_client_.get());
native_widget_delegate_->OnNativeWidgetCreated(true);
}
scoped_ptr<corewm::Tooltip> DesktopRootWindowHostX11::CreateTooltip() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment