| Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 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 |  | 
|  | 17 | #include <compositionengine/impl/CompositionEngine.h> | 
|  | 18 | #include <gtest/gtest.h> | 
| Lloyd Pique | b97e04f | 2018-10-18 17:07:05 -0700 | [diff] [blame] | 19 | #include <renderengine/mock/RenderEngine.h> | 
| Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 20 |  | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 21 | #include "MockHWComposer.h" | 
|  | 22 |  | 
| Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 23 | namespace android::compositionengine { | 
|  | 24 | namespace { | 
|  | 25 |  | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 26 | using ::testing::StrictMock; | 
|  | 27 |  | 
| Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 28 | class CompositionEngineTest : public testing::Test { | 
|  | 29 | public: | 
|  | 30 | ~CompositionEngineTest() override; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 31 | mock::HWComposer* mHwc = new StrictMock<mock::HWComposer>(); | 
| Lloyd Pique | b97e04f | 2018-10-18 17:07:05 -0700 | [diff] [blame] | 32 | renderengine::mock::RenderEngine* mRenderEngine = | 
|  | 33 | new StrictMock<renderengine::mock::RenderEngine>(); | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 34 | impl::CompositionEngine mEngine; | 
| Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 35 | }; | 
|  | 36 |  | 
|  | 37 | CompositionEngineTest::~CompositionEngineTest() = default; | 
|  | 38 |  | 
|  | 39 | TEST_F(CompositionEngineTest, canInstantiateCompositionEngine) { | 
|  | 40 | auto engine = impl::createCompositionEngine(); | 
|  | 41 | EXPECT_TRUE(engine.get() != nullptr); | 
|  | 42 | } | 
|  | 43 |  | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 44 | TEST_F(CompositionEngineTest, canSetHWComposer) { | 
|  | 45 | mEngine.setHwComposer(std::unique_ptr<android::HWComposer>(mHwc)); | 
|  | 46 |  | 
|  | 47 | EXPECT_EQ(mHwc, &mEngine.getHwComposer()); | 
|  | 48 | } | 
|  | 49 |  | 
| Lloyd Pique | b97e04f | 2018-10-18 17:07:05 -0700 | [diff] [blame] | 50 | TEST_F(CompositionEngineTest, canSetRenderEngine) { | 
|  | 51 | mEngine.setRenderEngine(std::unique_ptr<renderengine::RenderEngine>(mRenderEngine)); | 
|  | 52 |  | 
|  | 53 | EXPECT_EQ(mRenderEngine, &mEngine.getRenderEngine()); | 
|  | 54 | } | 
|  | 55 |  | 
| Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 56 | } // namespace | 
|  | 57 | } // namespace android::compositionengine |