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