blob: b8df640c0f04a497a2b917f8e53fe827e278ee38 [file] [log] [blame]
Marin Shalamanov4a92f552021-03-29 18:38:27 +02001/*
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 "DisplayHardware/FramebufferSurface.h"
18
19#include <gmock/gmock.h>
20#include <gtest/gtest.h>
21
22namespace android {
23
24class FramebufferSurfaceTest : public testing::Test {
25public:
26 ui::Size limitSize(const ui::Size& size, const ui::Size maxSize) {
27 return FramebufferSurface::limitSizeInternal(size, maxSize);
28 }
29};
30
31TEST_F(FramebufferSurfaceTest, limitSize) {
32 const ui::Size kMaxSize(1920, 1080);
33 EXPECT_EQ(ui::Size(1920, 1080), limitSize({3840, 2160}, kMaxSize));
34 EXPECT_EQ(ui::Size(1920, 1080), limitSize({1920, 1080}, kMaxSize));
35 EXPECT_EQ(ui::Size(1920, 1012), limitSize({4096, 2160}, kMaxSize));
36 EXPECT_EQ(ui::Size(1080, 1080), limitSize({3840, 3840}, kMaxSize));
37 EXPECT_EQ(ui::Size(1280, 720), limitSize({1280, 720}, kMaxSize));
38}
39
40} // namespace android