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

Side by Side Diff: ash/shell_unittest.cc

Issue 14295008: Add ash SessionStateDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ready for review. Created 7 years, 8 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 (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/shell.h" 5 #include "ash/shell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
11 #include "ash/desktop_background/desktop_background_widget_controller.h" 11 #include "ash/desktop_background/desktop_background_widget_controller.h"
12 #include "ash/launcher/launcher.h" 12 #include "ash/launcher/launcher.h"
13 #include "ash/root_window_controller.h" 13 #include "ash/root_window_controller.h"
14 #include "ash/session_state_delegate.h"
14 #include "ash/shelf/shelf_layout_manager.h" 15 #include "ash/shelf/shelf_layout_manager.h"
15 #include "ash/shelf/shelf_widget.h" 16 #include "ash/shelf/shelf_widget.h"
16 #include "ash/shell_delegate.h"
17 #include "ash/shell_window_ids.h" 17 #include "ash/shell_window_ids.h"
18 #include "ash/test/ash_test_base.h" 18 #include "ash/test/ash_test_base.h"
19 #include "ash/wm/root_window_layout_manager.h" 19 #include "ash/wm/root_window_layout_manager.h"
20 #include "ash/wm/window_util.h" 20 #include "ash/wm/window_util.h"
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 #include "ui/aura/client/aura_constants.h" 22 #include "ui/aura/client/aura_constants.h"
23 #include "ui/aura/root_window.h" 23 #include "ui/aura/root_window.h"
24 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
25 #include "ui/gfx/size.h" 25 #include "ui/gfx/size.h"
26 #include "ui/views/widget/widget.h" 26 #include "ui/views/widget/widget.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 views::Widget::InitParams::TYPE_WINDOW); 212 views::Widget::InitParams::TYPE_WINDOW);
213 213
214 // Create a normal window. 214 // Create a normal window.
215 views::Widget* widget = CreateTestWindow(widget_params); 215 views::Widget* widget = CreateTestWindow(widget_params);
216 widget->Show(); 216 widget->Show();
217 217
218 // It should be in default container. 218 // It should be in default container.
219 EXPECT_TRUE(GetDefaultContainer()->Contains( 219 EXPECT_TRUE(GetDefaultContainer()->Contains(
220 widget->GetNativeWindow()->parent())); 220 widget->GetNativeWindow()->parent()));
221 221
222 Shell::GetInstance()->delegate()->LockScreen(); 222 Shell::GetInstance()->session_state_delegate()->LockScreen();
223 // Create a LockScreen window. 223 // Create a LockScreen window.
224 views::Widget* lock_widget = CreateTestWindow(widget_params); 224 views::Widget* lock_widget = CreateTestWindow(widget_params);
225 ash::Shell::GetContainer( 225 ash::Shell::GetContainer(
226 Shell::GetPrimaryRootWindow(), 226 Shell::GetPrimaryRootWindow(),
227 ash::internal::kShellWindowId_LockScreenContainer)-> 227 ash::internal::kShellWindowId_LockScreenContainer)->
228 AddChild(lock_widget->GetNativeView()); 228 AddChild(lock_widget->GetNativeView());
229 lock_widget->Show(); 229 lock_widget->Show();
230 230
231 // It should be in LockScreen container. 231 // It should be in LockScreen container.
232 aura::Window* lock_screen = Shell::GetContainer( 232 aura::Window* lock_screen = Shell::GetContainer(
(...skipping 24 matching lines...) Expand all
257 ash::internal::kShellWindowId_SystemModalContainer); 257 ash::internal::kShellWindowId_SystemModalContainer);
258 EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent()); 258 EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent());
259 259
260 modal_widget->Close(); 260 modal_widget->Close();
261 lock_modal_widget->Close(); 261 lock_modal_widget->Close();
262 lock_widget->Close(); 262 lock_widget->Close();
263 widget->Close(); 263 widget->Close();
264 } 264 }
265 265
266 TEST_F(ShellTest, IsScreenLocked) { 266 TEST_F(ShellTest, IsScreenLocked) {
267 ash::Shell::GetInstance()->delegate()->LockScreen(); 267 SessionStateDelegate* delegate =
268 EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); 268 Shell::GetInstance()->session_state_delegate();
269 ash::Shell::GetInstance()->delegate()->UnlockScreen(); 269 delegate->LockScreen();
270 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); 270 EXPECT_TRUE(delegate->IsScreenLocked());
271 delegate->UnlockScreen();
272 EXPECT_FALSE(delegate->IsScreenLocked());
271 } 273 }
272 274
273 // Fails on Mac, see http://crbug.com/115662 275 // Fails on Mac, see http://crbug.com/115662
274 #if defined(OS_MACOSX) 276 #if defined(OS_MACOSX)
275 #define MAYBE_ManagedWindowModeBasics DISABLED_ManagedWindowModeBasics 277 #define MAYBE_ManagedWindowModeBasics DISABLED_ManagedWindowModeBasics
276 #else 278 #else
277 #define MAYBE_ManagedWindowModeBasics ManagedWindowModeBasics 279 #define MAYBE_ManagedWindowModeBasics ManagedWindowModeBasics
278 #endif 280 #endif
279 TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) { 281 TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) {
280 Shell* shell = Shell::GetInstance(); 282 Shell* shell = Shell::GetInstance();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 private: 414 private:
413 DISALLOW_COPY_AND_ASSIGN(ShellTest2); 415 DISALLOW_COPY_AND_ASSIGN(ShellTest2);
414 }; 416 };
415 417
416 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { 418 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) {
417 window_.reset(new aura::Window(NULL)); 419 window_.reset(new aura::Window(NULL));
418 window_->Init(ui::LAYER_NOT_DRAWN); 420 window_->Init(ui::LAYER_NOT_DRAWN);
419 } 421 }
420 422
421 } // namespace ash 423 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698