window_watcher_unittest.cc revision eb525c5499e34cc9c4b825d6d9e75bb07cc06ace
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
3// found in the LICENSE file.
4
5#include "ash/shell/window_watcher.h"
6
7#include "ash/shell.h"
8#include "ash/shell_delegate.h"
9#include "ash/shell/shell_delegate_impl.h"
10#include "ash/system/user/login_status.h"
11#include "ash/test/ash_test_base.h"
12#include "ui/aura/root_window.h"
13
14namespace ash {
15
16typedef test::AshTestBase WindowWatcherTest;
17
18// This test verifies that shell can be torn down without causing failures
19// bug http://code.google.com/p/chromium/issues/detail?id=130332
20TEST_F(WindowWatcherTest, ShellDeleteInstance) {
21  scoped_ptr<ash::shell::WindowWatcher> window_watcher;
22  Shell::DeleteInstance();
23
24  shell::ShellDelegateImpl* delegate = new ash::shell::ShellDelegateImpl;
25  Shell::CreateInstance(delegate);
26  Shell::GetPrimaryRootWindow()->ShowRootWindow();
27  Shell::GetInstance()->CreateLauncher();
28  Shell::GetInstance()->UpdateAfterLoginStatusChange(
29      user::LOGGED_IN_USER);
30
31  window_watcher.reset(new ash::shell::WindowWatcher);
32
33  delegate->SetWatcher(window_watcher.get());
34  Shell::GetPrimaryRootWindow()->Hide();
35  window_watcher.reset();
36  delegate->SetWatcher(NULL);
37}
38
39}  // namespace ash
40