• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 <composer-vts/2.1/TestCommandReader.h>
18 
19 #include <gtest/gtest.h>
20 
21 namespace android {
22 namespace hardware {
23 namespace graphics {
24 namespace composer {
25 namespace V2_1 {
26 namespace vts {
27 
parse()28 void TestCommandReader::parse() {
29     mErrors.clear();
30     mCompositionChanges.clear();
31     while (!isEmpty()) {
32         IComposerClient::Command command;
33         uint16_t length;
34         ASSERT_TRUE(beginCommand(&command, &length));
35 
36         switch (command) {
37             case IComposerClient::Command::SELECT_DISPLAY:
38                 ASSERT_EQ(2, length);
39                 read64();  // display
40                 break;
41             case IComposerClient::Command::SET_ERROR: {
42                 ASSERT_EQ(2, length);
43                 auto loc = read();
44                 auto err = readSigned();
45                 std::pair<uint32_t, uint32_t> error(loc, err);
46                 mErrors.push_back(error);
47             } break;
48             case IComposerClient::Command::SET_CHANGED_COMPOSITION_TYPES:
49                 ASSERT_EQ(0, length % 3);
50                 for (uint16_t count = 0; count < length / 3; ++count) {
51                     uint64_t layerId = read64();
52                     uint32_t composition = read();
53 
54                     std::pair<uint64_t, uint32_t> compositionChange(layerId, composition);
55                     mCompositionChanges.push_back(compositionChange);
56                 }
57                 break;
58             case IComposerClient::Command::SET_DISPLAY_REQUESTS:
59                 ASSERT_EQ(1, length % 3);
60                 read();  // displayRequests, ignored for now
61                 for (uint16_t count = 0; count < (length - 1) / 3; ++count) {
62                     read64();  // layer
63                     // silently eat requests to clear the client target, since we won't be testing
64                     // client composition anyway
65                     ASSERT_EQ(1u, read());
66                 }
67                 break;
68             case IComposerClient::Command::SET_PRESENT_FENCE:
69                 ASSERT_EQ(1, length);
70                 close(readFence());
71                 break;
72             case IComposerClient::Command::SET_RELEASE_FENCES:
73                 ASSERT_EQ(0, length % 3);
74                 for (uint16_t count = 0; count < length / 3; ++count) {
75                     read64();
76                     close(readFence());
77                 }
78                 break;
79             default:
80                 GTEST_FAIL() << "unexpected return command " << std::hex
81                              << static_cast<int>(command);
82                 break;
83         }
84 
85         endCommand();
86     }
87 }
88 
89 }  // namespace vts
90 }  // namespace V2_1
91 }  // namespace composer
92 }  // namespace graphics
93 }  // namespace hardware
94 }  // namespace android
95