Index: athena/test/athena_test_base.cc |
diff --git a/athena/test/athena_test_base.cc b/athena/test/athena_test_base.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d1f6260369d2575acf4106689d3d30b27374455e |
--- /dev/null |
+++ b/athena/test/athena_test_base.cc |
@@ -0,0 +1,54 @@ |
+// Copyright 2014 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 "athena/test/athena_test_base.h" |
+ |
+#include "athena/test/athena_test_helper.h" |
+#include "ui/compositor/test/context_factories_for_test.h" |
+ |
+namespace athena { |
+namespace test { |
+ |
+AthenaTestBase::AthenaTestBase() |
+ : setup_called_(false), teardown_called_(false) { |
+} |
+ |
+AthenaTestBase::~AthenaTestBase() { |
+ CHECK(setup_called_) |
+ << "You have overridden SetUp but never called super class's SetUp"; |
+ CHECK(teardown_called_) |
+ << "You have overridden TearDown but never called super class's TearDown"; |
+} |
+ |
+void AthenaTestBase::SetUp() { |
+ setup_called_ = true; |
+ testing::Test::SetUp(); |
+ |
+ // The ContextFactory must exist before any Compositors are created. |
+ bool enable_pixel_output = false; |
+ ui::ContextFactory* context_factory = |
+ ui::InitializeContextFactoryForTests(enable_pixel_output); |
+ |
+ helper_.reset(new AthenaTestHelper(&message_loop_)); |
+ helper_->SetUp(context_factory); |
+} |
+ |
+void AthenaTestBase::TearDown() { |
+ teardown_called_ = true; |
+ |
+ // Flush the message loop because we have pending release tasks |
+ // and these tasks if un-executed would upset Valgrind. |
+ RunAllPendingInMessageLoop(); |
+ |
+ helper_->TearDown(); |
+ ui::TerminateContextFactoryForTests(); |
+ testing::Test::TearDown(); |
+} |
+ |
+void AthenaTestBase::RunAllPendingInMessageLoop() { |
+ helper_->RunAllPendingInMessageLoop(); |
+} |
+ |
+} // namespace test |
+} // namespace athena |