Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: ash/test/ash_test_impl_aura.cc

Issue 2391153002: Converts most of WorkspaceLayoutManager tests to use common code (Closed)
Patch Set: cleanup Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/test/ash_test_impl_aura.h" 5 #include "ash/test/ash_test_impl_aura.h"
6 6
7 #include "ash/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/test/ash_test.h" 8 #include "ash/common/test/ash_test.h"
9 #include "ash/display/display_manager.h" 9 #include "ash/display/display_manager.h"
10 #include "ash/screen_util.h" 10 #include "ash/screen_util.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
13 #include "ash/test/display_manager_test_api.h" 13 #include "ash/test/display_manager_test_api.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "ui/aura/test/test_window_delegate.h"
15 #include "ui/display/manager/display_layout.h" 16 #include "ui/display/manager/display_layout.h"
16 #include "ui/display/screen.h" 17 #include "ui/display/screen.h"
18 #include "ui/wm/core/window_util.h"
17 19
18 namespace ash { 20 namespace ash {
19 namespace { 21 namespace {
20 22
21 // AshTestBase is abstract as TestBody() is pure virtual (the various TEST 23 // AshTestBase is abstract as TestBody() is pure virtual (the various TEST
22 // macros have the implementation). In order to create AshTestBase we have to 24 // macros have the implementation). In order to create AshTestBase we have to
23 // subclass with an empty implementation of TestBody(). That's ok as the class 25 // subclass with an empty implementation of TestBody(). That's ok as the class
24 // isn't used as a normal test here. 26 // isn't used as a normal test here.
25 class AshTestBaseImpl : public test::AshTestBase { 27 class AshTestBaseImpl : public test::AshTestBase {
26 public: 28 public:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 61
60 std::unique_ptr<WindowOwner> AshTestImplAura::CreateTestWindow( 62 std::unique_ptr<WindowOwner> AshTestImplAura::CreateTestWindow(
61 const gfx::Rect& bounds_in_screen, 63 const gfx::Rect& bounds_in_screen,
62 ui::wm::WindowType type, 64 ui::wm::WindowType type,
63 int shell_window_id) { 65 int shell_window_id) {
64 return base::MakeUnique<WindowOwner>(WmWindowAura::Get( 66 return base::MakeUnique<WindowOwner>(WmWindowAura::Get(
65 ash_test_base_->CreateTestWindowInShellWithDelegateAndType( 67 ash_test_base_->CreateTestWindowInShellWithDelegateAndType(
66 nullptr, type, shell_window_id, bounds_in_screen))); 68 nullptr, type, shell_window_id, bounds_in_screen)));
67 } 69 }
68 70
71 std::unique_ptr<WindowOwner> AshTestImplAura::CreateToplevelTestWindow(
72 const gfx::Rect& bounds_in_screen,
73 int shell_window_id) {
74 aura::test::TestWindowDelegate* delegate =
75 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate();
76 return base::MakeUnique<WindowOwner>(WmWindowAura::Get(
77 ash_test_base_->CreateTestWindowInShellWithDelegateAndType(
78 delegate, ui::wm::WINDOW_TYPE_NORMAL, shell_window_id,
79 bounds_in_screen)));
80 }
81
69 display::Display AshTestImplAura::GetSecondaryDisplay() { 82 display::Display AshTestImplAura::GetSecondaryDisplay() {
70 return ScreenUtil::GetSecondaryDisplay(); 83 return ScreenUtil::GetSecondaryDisplay();
71 } 84 }
72 85
73 bool AshTestImplAura::SetSecondaryDisplayPlacement( 86 bool AshTestImplAura::SetSecondaryDisplayPlacement(
74 display::DisplayPlacement::Position position, 87 display::DisplayPlacement::Position position,
75 int offset) { 88 int offset) {
76 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( 89 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
77 test::CreateDisplayLayout(position, 0)); 90 test::CreateDisplayLayout(position, 0));
78 return true; 91 return true;
79 } 92 }
80 93
94 void AshTestImplAura::ConfigureWidgetInitParamsForDisplay(
95 WmWindow* window,
96 views::Widget::InitParams* init_params) {
97 init_params->context = WmWindowAura::GetAuraWindow(window);
98 }
99
100 void AshTestImplAura::AddTransientChild(WmWindow* parent, WmWindow* window) {
101 ::wm::AddTransientChild(WmWindowAura::GetAuraWindow(parent),
102 WmWindowAura::GetAuraWindow(window));
103 }
104
81 // static 105 // static
82 std::unique_ptr<AshTestImpl> AshTestImpl::Create() { 106 std::unique_ptr<AshTestImpl> AshTestImpl::Create() {
83 return base::MakeUnique<AshTestImplAura>(); 107 return base::MakeUnique<AshTestImplAura>();
84 } 108 }
85 109
110 // static
111 bool AshTest::IsMash() {
112 return false;
113 }
114
86 } // namespace ash 115 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698