blob: e57b2d64cba05a10ad5cae7950d2d27baa2c47f5 (
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) 2011 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 "ui/views/test/views_test_base.h"
#if defined(OS_WIN)
#include <ole2.h>
#endif
#if defined(USE_AURA)
#include "ui/aura/root_window.h"
#include "ui/aura/test/test_stacking_client.h"
#endif
namespace views {
ViewsTestBase::ViewsTestBase()
: setup_called_(false),
teardown_called_(false) {
#if defined(OS_WIN)
OleInitialize(NULL);
#endif
#if defined(USE_AURA)
new aura::test::TestStackingClient;
#endif
}
ViewsTestBase::~ViewsTestBase() {
#if defined(OS_WIN)
OleUninitialize();
#endif
CHECK(setup_called_)
<< "You have overridden SetUp but never called super class's SetUp";
CHECK(teardown_called_)
<< "You have overrideen TearDown but never called super class's TearDown";
}
void ViewsTestBase::SetUp() {
testing::Test::SetUp();
setup_called_ = true;
if (!views_delegate_.get())
views_delegate_.reset(new TestViewsDelegate());
}
void ViewsTestBase::TearDown() {
// Flush the message loop because we have pending release tasks
// and these tasks if un-executed would upset Valgrind.
RunPendingMessages();
teardown_called_ = true;
views_delegate_.reset();
testing::Test::TearDown();
}
void ViewsTestBase::RunPendingMessages() {
#if defined(USE_AURA)
message_loop_.RunAllPendingWithDispatcher(
aura::RootWindow::GetInstance()->GetDispatcher());
#else
message_loop_.RunAllPending();
#endif
}
} // namespace views
|