| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "athena/test/athena_test_base.h" | 5 #include "athena/test/athena_test_base.h" |
| 6 | 6 |
| 7 #include "athena/test/athena_test_helper.h" | 7 #include "athena/test/athena_test_helper.h" |
| 8 #include "ui/compositor/test/context_factories_for_test.h" | 8 #include "ui/compositor/test/context_factories_for_test.h" |
| 9 | 9 |
| 10 #if defined(USE_X11) |
| 11 #include "ui/aura/window_tree_host_x11.h" |
| 12 #endif |
| 13 |
| 10 namespace athena { | 14 namespace athena { |
| 11 namespace test { | 15 namespace test { |
| 12 | 16 |
| 13 AthenaTestBase::AthenaTestBase() | 17 AthenaTestBase::AthenaTestBase() |
| 14 : setup_called_(false), teardown_called_(false) { | 18 : setup_called_(false), teardown_called_(false) { |
| 15 } | 19 } |
| 16 | 20 |
| 17 AthenaTestBase::~AthenaTestBase() { | 21 AthenaTestBase::~AthenaTestBase() { |
| 18 CHECK(setup_called_) | 22 CHECK(setup_called_) |
| 19 << "You have overridden SetUp but never called super class's SetUp"; | 23 << "You have overridden SetUp but never called super class's SetUp"; |
| 20 CHECK(teardown_called_) | 24 CHECK(teardown_called_) |
| 21 << "You have overridden TearDown but never called super class's TearDown"; | 25 << "You have overridden TearDown but never called super class's TearDown"; |
| 22 } | 26 } |
| 23 | 27 |
| 24 void AthenaTestBase::SetUp() { | 28 void AthenaTestBase::SetUp() { |
| 25 setup_called_ = true; | 29 setup_called_ = true; |
| 26 testing::Test::SetUp(); | 30 testing::Test::SetUp(); |
| 27 | 31 |
| 28 // The ContextFactory must exist before any Compositors are created. | 32 // The ContextFactory must exist before any Compositors are created. |
| 29 bool enable_pixel_output = false; | 33 bool enable_pixel_output = false; |
| 30 ui::ContextFactory* context_factory = | 34 ui::ContextFactory* context_factory = |
| 31 ui::InitializeContextFactoryForTests(enable_pixel_output); | 35 ui::InitializeContextFactoryForTests(enable_pixel_output); |
| 32 | 36 |
| 33 helper_.reset(new AthenaTestHelper(&message_loop_)); | 37 helper_.reset(new AthenaTestHelper(&message_loop_)); |
| 38 #if defined(USE_X11) |
| 39 aura::test::SetUseOverrideRedirectWindowByDefault(true); |
| 40 #endif |
| 34 helper_->SetUp(context_factory); | 41 helper_->SetUp(context_factory); |
| 35 } | 42 } |
| 36 | 43 |
| 37 void AthenaTestBase::TearDown() { | 44 void AthenaTestBase::TearDown() { |
| 38 teardown_called_ = true; | 45 teardown_called_ = true; |
| 39 | 46 |
| 40 // Flush the message loop because we have pending release tasks | 47 // Flush the message loop because we have pending release tasks |
| 41 // and these tasks if un-executed would upset Valgrind. | 48 // and these tasks if un-executed would upset Valgrind. |
| 42 RunAllPendingInMessageLoop(); | 49 RunAllPendingInMessageLoop(); |
| 43 | 50 |
| 44 helper_->TearDown(); | 51 helper_->TearDown(); |
| 45 ui::TerminateContextFactoryForTests(); | 52 ui::TerminateContextFactoryForTests(); |
| 46 testing::Test::TearDown(); | 53 testing::Test::TearDown(); |
| 47 } | 54 } |
| 48 | 55 |
| 49 void AthenaTestBase::RunAllPendingInMessageLoop() { | 56 void AthenaTestBase::RunAllPendingInMessageLoop() { |
| 50 helper_->RunAllPendingInMessageLoop(); | 57 helper_->RunAllPendingInMessageLoop(); |
| 51 } | 58 } |
| 52 | 59 |
| 53 } // namespace test | 60 } // namespace test |
| 54 } // namespace athena | 61 } // namespace athena |
| OLD | NEW |