• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/macros.h>
20 #include <shared/send_message.h>
21 
22 #include "chre_api/chre.h"
23 
24 /*
25  * Test to check expected functionality of host awake/suspend APIs.
26  */
27 namespace general_test {
28 
HostAwakeSuspendTest()29 HostAwakeSuspendTest::HostAwakeSuspendTest() : Test(CHRE_API_VERSION_1_2) {}
30 
setUp(uint32_t messageSize,const void *)31 void HostAwakeSuspendTest::setUp(uint32_t messageSize,
32                                  const void * /* message */) {
33   if (messageSize != 0) {
34     EXPECT_FAIL_RETURN("Expected 0 byte message, got more bytes:",
35                        &messageSize);
36   } else {
37     // Invoke to verify that this API is implemented
38     chreConfigureHostSleepStateEvents(true /* enable */);
39 
40     // Assume that GTS tests are performed under USB connection,
41     // in which the host should be awake.
42     if (!chreIsHostAwake()) {
43       EXPECT_FAIL_RETURN("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