Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -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 <gtest/gtest.h> |
| 18 | |
| 19 | #include <renderengine/RenderEngine.h> |
| 20 | #include <ui/PixelFormat.h> |
| 21 | |
| 22 | namespace android { |
| 23 | |
| 24 | class RenderEngineTest : public ::testing::Test { |
| 25 | public: |
| 26 | RenderEngineTest() { |
| 27 | // Initialize with some sane defaults. |
| 28 | // TODO(alecmouri): This should probably be the same instance used by |
| 29 | // SurfaceFlinger eventually. |
| 30 | mRE = renderengine::RenderEngine::create(static_cast<int32_t>(ui::PixelFormat::RGBA_8888), |
| 31 | 0); |
| 32 | } |
| 33 | |
| 34 | status_t drawEmptyLayers() { |
| 35 | renderengine::DisplaySettings settings; |
| 36 | std::vector<renderengine::LayerSettings> layers; |
| 37 | // Meaningless buffer since we don't do any drawing |
| 38 | sp<GraphicBuffer> buffer = new GraphicBuffer(); |
| 39 | base::unique_fd fence; |
| 40 | return mRE->drawLayers(settings, layers, buffer->getNativeBuffer(), &fence); |
| 41 | } |
| 42 | |
| 43 | private: |
| 44 | std::unique_ptr<renderengine::RenderEngine> mRE; |
| 45 | }; |
| 46 | |
| 47 | TEST_F(RenderEngineTest, drawLayers_noLayersToDraw_works) { |
| 48 | status_t result = drawEmptyLayers(); |
| 49 | ASSERT_EQ(NO_ERROR, result); |
| 50 | } |
| 51 | |
| 52 | } // namespace android |