1 /*
2 * Copyright (C) 2018 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 <general_test/host_awake_suspend_test.h>
18
19 #include <chre.h>
20 #include <shared/send_message.h>
21
22 /*
23 * Test to check expected functionality of host awake/suspend APIs.
24 */
25 namespace general_test {
26
HostAwakeSuspendTest()27 HostAwakeSuspendTest::HostAwakeSuspendTest() : Test(CHRE_API_VERSION_1_2) {}
28
setUp(uint32_t messageSize,const void *)29 void HostAwakeSuspendTest::setUp(uint32_t messageSize,
30 const void * /* message */) {
31 if (messageSize != 0) {
32 nanoapp_testing::sendFatalFailureToHost(
33 "Expected 0 byte message, got more bytes:", &messageSize);
34 } else {
35 // Invoke to verify that this API is implemented
36 chreConfigureHostSleepStateEvents(true /* enable */);
37
38 // Assume that GTS tests are performed under USB connection,
39 // in which the host should be awake.
40 if (!chreIsHostAwake()) {
41 nanoapp_testing::sendFatalFailureToHost(
42 "Host must be awake during testing");
43 }
44
45 nanoapp_testing::sendSuccessToHost();
46 }
47 }
48
handleEvent(uint32_t,uint16_t eventType,const void *)49 void HostAwakeSuspendTest::handleEvent(uint32_t /* senderInstanceId */,
50 uint16_t eventType,
51 const void * /* eventData */) {
52 unexpectedEvent(eventType);
53 }
54
55 } // namespace general_test
56