blob: 6e520b1aeecdb955338610b75977d24c3d0a076e [file] [log] [blame]
Ady Abrahamd4302022021-09-14 16:22:24 -07001/*
2 * Copyright 2021 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 <ui/MockFence.h>
18
19#include <gtest/gtest.h>
20
21namespace android::ui {
22
23using testing::Return;
24
25class MockFenceTest : public testing::Test {
26public:
27 sp<Fence> getFenceForTesting() const { return mMockFence; }
28
29 const mock::MockFence& getMockFence() const { return *mMockFence; }
30
31private:
32 sp<mock::MockFence> mMockFence = sp<mock::MockFence>::make();
33};
34
35TEST_F(MockFenceTest, getSignalTime) {
36 sp<Fence> fence = getFenceForTesting();
37
38 EXPECT_CALL(getMockFence(), getSignalTime).WillOnce(Return(Fence::SIGNAL_TIME_PENDING));
39 EXPECT_EQ(Fence::SIGNAL_TIME_PENDING, fence->getSignalTime());
40
41 EXPECT_CALL(getMockFence(), getSignalTime).WillOnce(Return(1234));
42 EXPECT_EQ(1234, fence->getSignalTime());
43}
44
45} // namespace android::ui