blob: 6972b909cf6c10f626ba10238a4475045bfde850 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/test/ash_test_base.h"
#include <vector>
#include "ash/shell.h"
#include "ash/test/test_shell_delegate.h"
#include "ui/aura/env.h"
#include "ui/aura/monitor_manager.h"
#include "ui/aura/root_window.h"
#include "ui/gfx/compositor/layer_animator.h"
#include "ui/gfx/monitor.h"
#include "ui/gfx/screen.h"
namespace ash {
namespace test {
AshTestBase::AshTestBase() {
}
AshTestBase::~AshTestBase() {
}
void AshTestBase::SetUp() {
// Creates Shell and hook with Desktop.
TestShellDelegate* delegate = new TestShellDelegate;
ash::Shell::CreateInstance(delegate);
helper_.SetUp();
helper_.InitRootWindow(Shell::GetRootWindow());
// Disable animations during tests.
ui::LayerAnimator::set_disable_animations_for_test(true);
}
void AshTestBase::TearDown() {
// Flush the message loop to finish pending release tasks.
RunAllPendingInMessageLoop();
helper_.TearDown();
// Tear down the shell.
Shell::DeleteInstance();
}
void AshTestBase::ChangeMonitorConfig(float scale,
const gfx::Rect& bounds_in_pixel) {
gfx::Monitor monitor = gfx::Monitor(gfx::Screen::GetPrimaryMonitor().id());
monitor.SetScaleAndBounds(scale, bounds_in_pixel);
std::vector<gfx::Monitor> monitors;
monitors.push_back(monitor);
aura::Env::GetInstance()->monitor_manager()->OnNativeMonitorsChanged(
monitors);
}
void AshTestBase::RunAllPendingInMessageLoop() {
helper_.RunAllPendingInMessageLoop(Shell::GetRootWindow());
}
} // namespace test
} // namespace ash
|