window_watcher_unittest.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
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/test/ash_test_base.h"
11#include "ui/aura/root_window.h"
12
13namespace ash {
14
15typedef test::AshTestBase WindowWatcherTest;
16
17// This test verifies that shell can be torn down without causing failures
18// bug http://code.google.com/p/chromium/issues/detail?id=130332
19TEST_F(WindowWatcherTest, ShellDeleteInstance) {
20  scoped_ptr<ash::shell::WindowWatcher> window_watcher;
21  Shell::DeleteInstance();
22
23  shell::ShellDelegateImpl* delegate = new ash::shell::ShellDelegateImpl;
24  Shell::CreateInstance(delegate);
25
26  Shell::GetPrimaryRootWindow()->ShowRootWindow();
27  window_watcher.reset(new ash::shell::WindowWatcher);
28
29  delegate->SetWatcher(window_watcher.get());
30  Shell::GetPrimaryRootWindow()->Hide();
31  window_watcher.reset();
32  delegate->SetWatcher(NULL);
33}
34
35}  // namespace ash
36