| Index: ui/views/widget/native_widget_aura_unittest.cc
|
| diff --git a/ui/views/widget/native_widget_aura_unittest.cc b/ui/views/widget/native_widget_aura_unittest.cc
|
| index c53ce4d5186fb733f6ddf30cbbd747f8f1fbef64..8fc19733d311b073619bebb4103ca4add5445796 100644
|
| --- a/ui/views/widget/native_widget_aura_unittest.cc
|
| +++ b/ui/views/widget/native_widget_aura_unittest.cc
|
| @@ -100,30 +100,39 @@ TEST_F(NativeWidgetAuraTest, CenterWindowSmallParentNotAtOrigin) {
|
| widget->CloseNow();
|
| }
|
|
|
| +class TestLayoutManagerBase : public aura::LayoutManager {
|
| + public:
|
| + TestLayoutManagerBase() {}
|
| + virtual ~TestLayoutManagerBase() {}
|
| +
|
| + // aura::LayoutManager:
|
| + virtual void OnWindowResized() OVERRIDE {}
|
| + virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE {}
|
| + virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {}
|
| + virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {}
|
| + virtual void OnChildWindowVisibilityChanged(aura::Window* child,
|
| + bool visible) OVERRIDE {}
|
| + virtual void SetChildBounds(aura::Window* child,
|
| + const gfx::Rect& requested_bounds) OVERRIDE {}
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(TestLayoutManagerBase);
|
| +};
|
| +
|
| // Used by ShowMaximizedDoesntBounceAround. See it for details.
|
| -class TestLayoutManager : public aura::LayoutManager {
|
| +class MaximizeLayoutManager : public TestLayoutManagerBase {
|
| public:
|
| - TestLayoutManager() {}
|
| + MaximizeLayoutManager() {}
|
| + virtual ~MaximizeLayoutManager() {}
|
|
|
| - virtual void OnWindowResized() OVERRIDE {
|
| - }
|
| + private:
|
| + // aura::LayoutManager:
|
| virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE {
|
| // This simulates what happens when adding a maximized window.
|
| SetChildBoundsDirect(child, gfx::Rect(0, 0, 300, 300));
|
| }
|
| - virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {
|
| - }
|
| - virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {
|
| - }
|
| - virtual void OnChildWindowVisibilityChanged(aura::Window* child,
|
| - bool visible) OVERRIDE {
|
| - }
|
| - virtual void SetChildBounds(aura::Window* child,
|
| - const gfx::Rect& requested_bounds) OVERRIDE {
|
| - }
|
|
|
| - private:
|
| - DISALLOW_COPY_AND_ASSIGN(TestLayoutManager);
|
| + DISALLOW_COPY_AND_ASSIGN(MaximizeLayoutManager);
|
| };
|
|
|
| // This simulates BrowserView, which creates a custom RootView so that
|
| @@ -160,7 +169,7 @@ class TestWidget : public views::Widget {
|
| // leads to noticable flashes.
|
| TEST_F(NativeWidgetAuraTest, ShowMaximizedDoesntBounceAround) {
|
| root_window()->SetBounds(gfx::Rect(0, 0, 640, 480));
|
| - root_window()->SetLayoutManager(new TestLayoutManager);
|
| + root_window()->SetLayoutManager(new MaximizeLayoutManager);
|
| scoped_ptr<TestWidget> widget(new TestWidget());
|
| Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
|
| params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
|
| @@ -173,6 +182,70 @@ TEST_F(NativeWidgetAuraTest, ShowMaximizedDoesntBounceAround) {
|
| widget->CloseNow();
|
| }
|
|
|
| +class PropertyTestLayoutManager : public TestLayoutManagerBase {
|
| + public:
|
| + PropertyTestLayoutManager() : added_(false) {}
|
| + virtual ~PropertyTestLayoutManager() {}
|
| +
|
| + bool added() const { return added_; }
|
| +
|
| + private:
|
| + // aura::LayoutManager:
|
| + virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE {
|
| + EXPECT_TRUE(child->GetProperty(aura::client::kCanMaximizeKey));
|
| + EXPECT_TRUE(child->GetProperty(aura::client::kCanResizeKey));
|
| + added_ = true;
|
| + }
|
| +
|
| + bool added_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(PropertyTestLayoutManager);
|
| +};
|
| +
|
| +class PropertyTestWidgetDelegate : public views::WidgetDelegate {
|
| + public:
|
| + explicit PropertyTestWidgetDelegate(Widget* widget) : widget_(widget) {}
|
| + virtual ~PropertyTestWidgetDelegate() {}
|
| +
|
| + private:
|
| + // views::WidgetDelegate:
|
| + virtual bool CanMaximize() const OVERRIDE {
|
| + return true;
|
| + }
|
| + virtual bool CanResize() const OVERRIDE {
|
| + return true;
|
| + }
|
| + virtual void DeleteDelegate() OVERRIDE {
|
| + delete this;
|
| + }
|
| + virtual Widget* GetWidget() OVERRIDE {
|
| + return widget_;
|
| + }
|
| + virtual const Widget* GetWidget() const OVERRIDE {
|
| + return widget_;
|
| + }
|
| +
|
| + Widget* widget_;
|
| + DISALLOW_COPY_AND_ASSIGN(PropertyTestWidgetDelegate);
|
| +};
|
| +
|
| +// Verifies that the kCanMaximizeKey/kCanReizeKey have the correct
|
| +// value when added to the layout manager.
|
| +TEST_F(NativeWidgetAuraTest, TestPropertiesWhenAddedToLayout) {
|
| + root_window()->SetBounds(gfx::Rect(0, 0, 640, 480));
|
| + PropertyTestLayoutManager* layout_manager = new PropertyTestLayoutManager();
|
| + root_window()->SetLayoutManager(layout_manager);
|
| + scoped_ptr<TestWidget> widget(new TestWidget());
|
| + Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
|
| + params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
|
| + params.delegate = new PropertyTestWidgetDelegate(widget.get());
|
| + params.parent = NULL;
|
| + params.context = root_window();
|
| + widget->Init(params);
|
| + EXPECT_TRUE(layout_manager->added());
|
| + widget->CloseNow();
|
| +}
|
| +
|
| TEST_F(NativeWidgetAuraTest, GetClientAreaScreenBounds) {
|
| // Create a widget.
|
| Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
|
| @@ -190,8 +263,6 @@ TEST_F(NativeWidgetAuraTest, GetClientAreaScreenBounds) {
|
| EXPECT_EQ(400, client_bounds.height());
|
| }
|
|
|
| -namespace {
|
| -
|
| // View subclass that tracks whether it has gotten a gesture event.
|
| class GestureTrackingView : public views::View {
|
| public:
|
| @@ -227,8 +298,6 @@ class GestureTrackingView : public views::View {
|
| DISALLOW_COPY_AND_ASSIGN(GestureTrackingView);
|
| };
|
|
|
| -} // namespace
|
| -
|
| // Verifies a capture isn't set on touch press and that the view that gets
|
| // the press gets the release.
|
| TEST_F(NativeWidgetAuraTest, DontCaptureOnGesture) {
|
|
|