blob: df53d1988d9df9d168fbd36fc8920b6917d86c66 [file] [log] [blame]
Vishnu Nair8134c1a2023-10-17 22:55:49 -07001/*
2 * Copyright 2023 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#undef LOG_TAG
18#define LOG_TAG "CommitTest"
19
20#include <gmock/gmock.h>
21#include <gtest/gtest.h>
22
23#include <renderengine/mock/RenderEngine.h>
24#include "TestableSurfaceFlinger.h"
25
26namespace android {
27
28class CommitTest : public testing::Test {
29protected:
30 CommitTest() {
31 mFlinger.setupMockScheduler();
32 mFlinger.setupComposer(std::make_unique<Hwc2::mock::Composer>());
33 mFlinger.setupRenderEngine(std::unique_ptr<renderengine::RenderEngine>(mRenderEngine));
34 }
35 TestableSurfaceFlinger mFlinger;
36 renderengine::mock::RenderEngine* mRenderEngine = new renderengine::mock::RenderEngine();
37};
38
39namespace {
40
41TEST_F(CommitTest, noUpdatesDoesNotScheduleComposite) {
42 bool unused;
43 bool mustComposite = mFlinger.updateLayerSnapshots(VsyncId{1}, /*frameTimeNs=*/0,
44 /*transactionsFlushed=*/0, unused);
45 EXPECT_FALSE(mustComposite);
46}
47
48// Ensure that we handle eTransactionNeeded correctly
49TEST_F(CommitTest, eTransactionNeededFlagSchedulesComposite) {
50 // update display level color matrix
51 mFlinger.setDaltonizerType(ColorBlindnessType::Deuteranomaly);
52 bool unused;
53 bool mustComposite = mFlinger.updateLayerSnapshots(VsyncId{1}, /*frameTimeNs=*/0,
54 /*transactionsFlushed=*/0, unused);
55 EXPECT_TRUE(mustComposite);
56}
57
58} // namespace
59} // namespace android