Ady Abraham | d430202 | 2021-09-14 16:22:24 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 21 | namespace android::ui { |
| 22 | |
| 23 | using testing::Return; |
| 24 | |
| 25 | class MockFenceTest : public testing::Test { |
| 26 | public: |
| 27 | sp<Fence> getFenceForTesting() const { return mMockFence; } |
| 28 | |
| 29 | const mock::MockFence& getMockFence() const { return *mMockFence; } |
| 30 | |
| 31 | private: |
| 32 | sp<mock::MockFence> mMockFence = sp<mock::MockFence>::make(); |
| 33 | }; |
| 34 | |
| 35 | TEST_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 |