CompositionEngineTest.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright 2018 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <compositionengine/impl/CompositionEngine.h>
  17. #include <gtest/gtest.h>
  18. #include <renderengine/mock/RenderEngine.h>
  19. #include "MockHWComposer.h"
  20. namespace android::compositionengine {
  21. namespace {
  22. using ::testing::StrictMock;
  23. class CompositionEngineTest : public testing::Test {
  24. public:
  25. ~CompositionEngineTest() override;
  26. mock::HWComposer* mHwc = new StrictMock<mock::HWComposer>();
  27. renderengine::mock::RenderEngine* mRenderEngine =
  28. new StrictMock<renderengine::mock::RenderEngine>();
  29. impl::CompositionEngine mEngine;
  30. };
  31. CompositionEngineTest::~CompositionEngineTest() = default;
  32. TEST_F(CompositionEngineTest, canInstantiateCompositionEngine) {
  33. auto engine = impl::createCompositionEngine();
  34. EXPECT_TRUE(engine.get() != nullptr);
  35. }
  36. TEST_F(CompositionEngineTest, canSetHWComposer) {
  37. mEngine.setHwComposer(std::unique_ptr<android::HWComposer>(mHwc));
  38. EXPECT_EQ(mHwc, &mEngine.getHwComposer());
  39. }
  40. TEST_F(CompositionEngineTest, canSetRenderEngine) {
  41. mEngine.setRenderEngine(std::unique_ptr<renderengine::RenderEngine>(mRenderEngine));
  42. EXPECT_EQ(mRenderEngine, &mEngine.getRenderEngine());
  43. }
  44. } // namespace
  45. } // namespace android::compositionengine