| 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 "ash/test/ash_test_impl_aura.h" | |
| 6 | |
| 7 #include "ash/mus/test/ash_test_impl_mus.h" | |
| 8 #include "ash/public/cpp/config.h" | |
| 9 #include "ash/screen_util.h" | |
| 10 #include "ash/shell.h" | |
| 11 #include "ash/test/ash_test.h" | |
| 12 #include "ash/test/ash_test_base.h" | |
| 13 #include "ash/test/ash_test_helper.h" | |
| 14 #include "ash/wm_window.h" | |
| 15 #include "base/memory/ptr_util.h" | |
| 16 #include "ui/aura/test/test_window_delegate.h" | |
| 17 #include "ui/display/display_layout.h" | |
| 18 #include "ui/display/manager/display_manager.h" | |
| 19 #include "ui/display/screen.h" | |
| 20 #include "ui/display/test/display_manager_test_api.h" | |
| 21 #include "ui/wm/core/window_util.h" | |
| 22 | |
| 23 namespace ash { | |
| 24 namespace { | |
| 25 | |
| 26 // AshTestBase is abstract as TestBody() is pure virtual (the various TEST | |
| 27 // macros have the implementation). In order to create AshTestBase we have to | |
| 28 // subclass with an empty implementation of TestBody(). That's ok as the class | |
| 29 // isn't used as a normal test here. | |
| 30 class AshTestBaseImpl : public test::AshTestBase { | |
| 31 public: | |
| 32 AshTestBaseImpl() {} | |
| 33 ~AshTestBaseImpl() override {} | |
| 34 | |
| 35 // AshTestBase: | |
| 36 void TestBody() override {} | |
| 37 | |
| 38 private: | |
| 39 DISALLOW_COPY_AND_ASSIGN(AshTestBaseImpl); | |
| 40 }; | |
| 41 | |
| 42 } // namespace | |
| 43 | |
| 44 AshTestImplAura::AshTestImplAura() | |
| 45 : ash_test_base_(base::MakeUnique<AshTestBaseImpl>()) {} | |
| 46 | |
| 47 AshTestImplAura::~AshTestImplAura() {} | |
| 48 | |
| 49 void AshTestImplAura::SetUp() { | |
| 50 ash_test_base_->SetUp(); | |
| 51 } | |
| 52 | |
| 53 void AshTestImplAura::TearDown() { | |
| 54 ash_test_base_->TearDown(); | |
| 55 } | |
| 56 | |
| 57 void AshTestImplAura::UpdateDisplay(const std::string& display_spec) { | |
| 58 ash_test_base_->UpdateDisplay(display_spec); | |
| 59 } | |
| 60 | |
| 61 std::unique_ptr<WindowOwner> AshTestImplAura::CreateTestWindow( | |
| 62 const gfx::Rect& bounds_in_screen, | |
| 63 ui::wm::WindowType type, | |
| 64 int shell_window_id) { | |
| 65 return base::MakeUnique<WindowOwner>( | |
| 66 WmWindow::Get(ash_test_base_->CreateTestWindowInShellWithDelegateAndType( | |
| 67 nullptr, type, shell_window_id, bounds_in_screen))); | |
| 68 } | |
| 69 | |
| 70 std::unique_ptr<WindowOwner> AshTestImplAura::CreateToplevelTestWindow( | |
| 71 const gfx::Rect& bounds_in_screen, | |
| 72 int shell_window_id) { | |
| 73 aura::test::TestWindowDelegate* delegate = | |
| 74 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(); | |
| 75 return base::MakeUnique<WindowOwner>( | |
| 76 WmWindow::Get(ash_test_base_->CreateTestWindowInShellWithDelegateAndType( | |
| 77 delegate, ui::wm::WINDOW_TYPE_NORMAL, shell_window_id, | |
| 78 bounds_in_screen))); | |
| 79 } | |
| 80 | |
| 81 display::Display AshTestImplAura::GetSecondaryDisplay() { | |
| 82 return Shell::Get()->display_manager()->GetSecondaryDisplay(); | |
| 83 } | |
| 84 | |
| 85 bool AshTestImplAura::SetSecondaryDisplayPlacement( | |
| 86 display::DisplayPlacement::Position position, | |
| 87 int offset) { | |
| 88 Shell::Get()->display_manager()->SetLayoutForCurrentDisplays( | |
| 89 display::test::CreateDisplayLayout(Shell::Get()->display_manager(), | |
| 90 position, 0)); | |
| 91 return true; | |
| 92 } | |
| 93 | |
| 94 void AshTestImplAura::ConfigureWidgetInitParamsForDisplay( | |
| 95 WmWindow* window, | |
| 96 views::Widget::InitParams* init_params) { | |
| 97 init_params->context = WmWindow::GetAuraWindow(window); | |
| 98 } | |
| 99 | |
| 100 void AshTestImplAura::AddTransientChild(WmWindow* parent, WmWindow* window) { | |
| 101 ::wm::AddTransientChild(WmWindow::GetAuraWindow(parent), | |
| 102 WmWindow::GetAuraWindow(window)); | |
| 103 } | |
| 104 | |
| 105 // static | |
| 106 std::unique_ptr<AshTestImpl> AshTestImpl::Create() { | |
| 107 if (test::AshTestHelper::config() == Config::CLASSIC) | |
| 108 return base::MakeUnique<AshTestImplAura>(); | |
| 109 | |
| 110 return base::MakeUnique<mus::AshTestImplMus>(); | |
| 111 } | |
| 112 | |
| 113 } // namespace ash | |
| OLD | NEW |