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