| OLD | NEW | 
| (Empty) |  | 
 |   1 // Copyright 2016 The Chromium Authors. All rights reserved. | 
 |   2 // Use of this source code is governed by a BSD-style license that can be | 
 |   3 // found in the LICENSE file. | 
 |   4  | 
 |   5 #include "ui/views/mus/desktop_window_tree_host_mus.h" | 
 |   6  | 
 |   7 #include "base/memory/ptr_util.h" | 
 |   8 #include "ui/aura/window.h" | 
 |   9 #include "ui/views/test/views_test_base.h" | 
 |  10 #include "ui/views/widget/widget.h" | 
 |  11 #include "ui/views/widget/widget_delegate.h" | 
 |  12  | 
 |  13 namespace views { | 
 |  14  | 
 |  15 class DesktopWindowTreeHostMusTest : public ViewsTestBase { | 
 |  16  public: | 
 |  17   DesktopWindowTreeHostMusTest() {} | 
 |  18   ~DesktopWindowTreeHostMusTest() override {} | 
 |  19  | 
 |  20   // Creates a test widget. Takes ownership of |delegate|. | 
 |  21   std::unique_ptr<Widget> CreateWidget(WidgetDelegate* delegate) { | 
 |  22     std::unique_ptr<Widget> widget = base::MakeUnique<Widget>(); | 
 |  23     Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); | 
 |  24     params.delegate = delegate; | 
 |  25     params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 
 |  26     params.bounds = gfx::Rect(0, 1, 111, 123); | 
 |  27     widget->Init(params); | 
 |  28     return widget; | 
 |  29   } | 
 |  30  | 
 |  31  private: | 
 |  32   DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostMusTest); | 
 |  33 }; | 
 |  34  | 
 |  35 TEST_F(DesktopWindowTreeHostMusTest, Visibility) { | 
 |  36   std::unique_ptr<Widget> widget(CreateWidget(nullptr)); | 
 |  37   EXPECT_FALSE(widget->IsVisible()); | 
 |  38   EXPECT_FALSE(widget->GetNativeView()->IsVisible()); | 
 |  39   // It's important the parent is also hidden as this value is sent to the | 
 |  40   // server. | 
 |  41   EXPECT_FALSE(widget->GetNativeView()->parent()->IsVisible()); | 
 |  42   widget->Show(); | 
 |  43   EXPECT_TRUE(widget->IsVisible()); | 
 |  44   EXPECT_TRUE(widget->GetNativeView()->IsVisible()); | 
 |  45   EXPECT_TRUE(widget->GetNativeView()->parent()->IsVisible()); | 
 |  46   widget->Hide(); | 
 |  47   EXPECT_FALSE(widget->IsVisible()); | 
 |  48   EXPECT_FALSE(widget->GetNativeView()->IsVisible()); | 
 |  49   EXPECT_FALSE(widget->GetNativeView()->parent()->IsVisible()); | 
 |  50 } | 
 |  51  | 
 |  52 }  // namespace views | 
| OLD | NEW |