• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 "SurfaceFlingerGetDisplayStatsTest"
19 
20 #include <gmock/gmock.h>
21 #include <gtest/gtest.h>
22 #include <ui/DisplayStatInfo.h>
23 
24 #include "CommitAndCompositeTest.h"
25 
26 namespace android {
27 namespace {
28 
29 struct SurfaceFlingerGetDisplayStatsTest : CommitAndCompositeTest {};
30 
31 // TODO (b/277364366): Clients should be updated to pass in the display they want.
TEST_F(SurfaceFlingerGetDisplayStatsTest,nullptrSucceeds)32 TEST_F(SurfaceFlingerGetDisplayStatsTest, nullptrSucceeds) {
33     DisplayStatInfo info;
34     status_t status = mFlinger.getDisplayStats(nullptr, &info);
35     EXPECT_EQ(status, NO_ERROR);
36 }
37 
TEST_F(SurfaceFlingerGetDisplayStatsTest,explicitToken)38 TEST_F(SurfaceFlingerGetDisplayStatsTest, explicitToken) {
39     DisplayStatInfo info;
40     status_t status = mFlinger.getDisplayStats(mDisplay->getDisplayToken().promote(), &info);
41     EXPECT_EQ(status, NO_ERROR);
42 }
43 
TEST_F(SurfaceFlingerGetDisplayStatsTest,invalidToken)44 TEST_F(SurfaceFlingerGetDisplayStatsTest, invalidToken) {
45     static const std::string kDisplayName("fakeDisplay");
46     sp<IBinder> displayToken = mFlinger.createVirtualDisplay(kDisplayName, false /*isSecure*/);
47     DisplayStatInfo info;
48     status_t status = mFlinger.getDisplayStats(displayToken, &info);
49     EXPECT_EQ(status, NAME_NOT_FOUND);
50 }
51 
52 } // namespace
53 } // namespace android
54