OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_base.h" | 5 #include "ash/test/ash_test_base.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/display/display_controller.h" | 10 #include "ash/display/display_controller.h" |
11 #include "ash/display/display_manager.h" | 11 #include "ash/display/display_manager.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "ash/test/display_manager_test_api.h" | 13 #include "ash/test/display_manager_test_api.h" |
14 #include "ash/test/test_shell_delegate.h" | 14 #include "ash/test/test_shell_delegate.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "content/public/test/web_contents_tester.h" | 16 #include "content/public/test/web_contents_tester.h" |
| 17 #include "ui/aura/client/aura_constants.h" |
17 #include "ui/aura/env.h" | 18 #include "ui/aura/env.h" |
18 #include "ui/aura/root_window.h" | 19 #include "ui/aura/root_window.h" |
| 20 #include "ui/aura/test/test_window_delegate.h" |
| 21 #include "ui/aura/window_delegate.h" |
19 #include "ui/base/ime/text_input_test_support.h" | 22 #include "ui/base/ime/text_input_test_support.h" |
20 #include "ui/compositor/layer_animator.h" | 23 #include "ui/compositor/layer_animator.h" |
21 #include "ui/gfx/display.h" | 24 #include "ui/gfx/display.h" |
22 #include "ui/gfx/screen.h" | 25 #include "ui/gfx/screen.h" |
23 | 26 |
24 namespace ash { | 27 namespace ash { |
25 namespace test { | 28 namespace test { |
26 | 29 |
27 content::WebContents* AshTestViewsDelegate::CreateWebContents( | 30 content::WebContents* AshTestViewsDelegate::CreateWebContents( |
28 content::BrowserContext* browser_context, | 31 content::BrowserContext* browser_context, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 displays.push_back(display); | 74 displays.push_back(display); |
72 Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays); | 75 Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays); |
73 } | 76 } |
74 | 77 |
75 void AshTestBase::UpdateDisplay(const std::string& display_specs) { | 78 void AshTestBase::UpdateDisplay(const std::string& display_specs) { |
76 DisplayManagerTestApi display_manager_test_api( | 79 DisplayManagerTestApi display_manager_test_api( |
77 Shell::GetInstance()->display_manager()); | 80 Shell::GetInstance()->display_manager()); |
78 display_manager_test_api.UpdateDisplay(display_specs); | 81 display_manager_test_api.UpdateDisplay(display_specs); |
79 } | 82 } |
80 | 83 |
| 84 aura::Window* AshTestBase::CreateTestWindowInShellWithId(int id) { |
| 85 return CreateTestWindowInShellWithDelegate(NULL, id, gfx::Rect()); |
| 86 } |
| 87 |
| 88 aura::Window* AshTestBase::CreateTestWindowInShellWithBounds( |
| 89 const gfx::Rect& bounds) { |
| 90 return CreateTestWindowInShellWithDelegate(NULL, 0, bounds); |
| 91 } |
| 92 |
| 93 aura::Window* AshTestBase::CreateTestWindowInShell(SkColor color, |
| 94 int id, |
| 95 const gfx::Rect& bounds) { |
| 96 return CreateTestWindowInShellWithDelegate( |
| 97 new aura::test::ColorTestWindowDelegate(color), id, bounds); |
| 98 } |
| 99 |
| 100 aura::Window* AshTestBase::CreateTestWindowInShellWithDelegate( |
| 101 aura::WindowDelegate* delegate, |
| 102 int id, |
| 103 const gfx::Rect& bounds) { |
| 104 return CreateTestWindowInShellWithDelegateAndType( |
| 105 delegate, |
| 106 aura::client::WINDOW_TYPE_NORMAL, |
| 107 id, |
| 108 bounds); |
| 109 } |
| 110 |
| 111 aura::Window* AshTestBase::CreateTestWindowInShellWithDelegateAndType( |
| 112 aura::WindowDelegate* delegate, |
| 113 aura::client::WindowType type, |
| 114 int id, |
| 115 const gfx::Rect& bounds) { |
| 116 aura::Window* window = new aura::Window(delegate); |
| 117 window->set_id(id); |
| 118 window->SetType(type); |
| 119 window->Init(ui::LAYER_TEXTURED); |
| 120 window->SetBounds(bounds); |
| 121 window->Show(); |
| 122 SetDefaultParentByPrimaryRootWindow(window); |
| 123 window->SetProperty(aura::client::kCanMaximizeKey, true); |
| 124 return window; |
| 125 } |
| 126 |
| 127 void AshTestBase::SetDefaultParentByPrimaryRootWindow(aura::Window* window) { |
| 128 window->SetDefaultParentByRootWindow( |
| 129 Shell::GetPrimaryRootWindow(), gfx::Rect()); |
| 130 } |
| 131 |
81 void AshTestBase::RunAllPendingInMessageLoop() { | 132 void AshTestBase::RunAllPendingInMessageLoop() { |
82 #if !defined(OS_MACOSX) | 133 #if !defined(OS_MACOSX) |
83 DCHECK(MessageLoopForUI::current() == &message_loop_); | 134 DCHECK(MessageLoopForUI::current() == &message_loop_); |
84 base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher()); | 135 base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher()); |
85 run_loop.RunUntilIdle(); | 136 run_loop.RunUntilIdle(); |
86 #endif | 137 #endif |
87 } | 138 } |
88 | 139 |
89 void AshTestBase::SetSessionStarted(bool session_started) { | 140 void AshTestBase::SetSessionStarted(bool session_started) { |
90 test_shell_delegate_->SetSessionStarted(session_started); | 141 test_shell_delegate_->SetSessionStarted(session_started); |
91 } | 142 } |
92 | 143 |
93 void AshTestBase::SetUserLoggedIn(bool user_logged_in) { | 144 void AshTestBase::SetUserLoggedIn(bool user_logged_in) { |
94 test_shell_delegate_->SetUserLoggedIn(user_logged_in); | 145 test_shell_delegate_->SetUserLoggedIn(user_logged_in); |
95 } | 146 } |
96 | 147 |
97 void AshTestBase::SetCanLockScreen(bool can_lock_screen) { | 148 void AshTestBase::SetCanLockScreen(bool can_lock_screen) { |
98 test_shell_delegate_->SetCanLockScreen(can_lock_screen); | 149 test_shell_delegate_->SetCanLockScreen(can_lock_screen); |
99 } | 150 } |
100 | 151 |
101 } // namespace test | 152 } // namespace test |
102 } // namespace ash | 153 } // namespace ash |
OLD | NEW |