OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 "athena/test/base/athena_test_base.h" | |
6 | |
7 #include "athena/env/public/athena_env.h" | |
8 #include "athena/test/base/athena_test_helper.h" | |
9 #include "ui/aura/test/event_generator_delegate_aura.h" | |
10 #include "ui/compositor/test/context_factories_for_test.h" | |
11 | |
12 #if defined(USE_X11) | |
13 #include "ui/aura/window_tree_host_x11.h" | |
14 #endif | |
15 | |
16 namespace athena { | |
17 namespace test { | |
18 | |
19 AthenaTestBase::AthenaTestBase() | |
20 : setup_called_(false), teardown_called_(false) { | |
21 } | |
22 | |
23 AthenaTestBase::~AthenaTestBase() { | |
24 CHECK(setup_called_) | |
25 << "You have overridden SetUp but never called super class's SetUp"; | |
26 CHECK(teardown_called_) | |
27 << "You have overridden TearDown but never called super class's TearDown"; | |
28 } | |
29 | |
30 void AthenaTestBase::SetUp() { | |
31 setup_called_ = true; | |
32 testing::Test::SetUp(); | |
33 | |
34 // The ContextFactory must exist before any Compositors are created. | |
35 bool enable_pixel_output = false; | |
36 ui::ContextFactory* context_factory = | |
37 ui::InitializeContextFactoryForTests(enable_pixel_output); | |
38 | |
39 helper_.reset(new AthenaTestHelper(&message_loop_)); | |
40 #if defined(USE_X11) | |
41 aura::test::SetUseOverrideRedirectWindowByDefault(true); | |
42 #endif | |
43 aura::test::InitializeAuraEventGeneratorDelegate(); | |
44 helper_->SetUp(context_factory); | |
45 } | |
46 | |
47 void AthenaTestBase::TearDown() { | |
48 AthenaEnv::Get()->OnTerminating(); | |
49 | |
50 teardown_called_ = true; | |
51 | |
52 // Flush the message loop because we have pending release tasks | |
53 // and these tasks if un-executed would upset Valgrind. | |
54 RunAllPendingInMessageLoop(); | |
55 | |
56 helper_->TearDown(); | |
57 ui::TerminateContextFactoryForTests(); | |
58 testing::Test::TearDown(); | |
59 } | |
60 | |
61 void AthenaTestBase::RunAllPendingInMessageLoop() { | |
62 helper_->RunAllPendingInMessageLoop(); | |
63 } | |
64 | |
65 } // namespace test | |
66 } // namespace athena | |
OLD | NEW |