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()
28 : Test(CHRE_API_VERSION_1_2) {
29 }
30
setUp(uint32_t messageSize,const void *)31 void HostAwakeSuspendTest::setUp(
32 uint32_t messageSize, const void * /* message */) {
33 if (messageSize != 0) {
34 nanoapp_testing::sendFatalFailureToHost(
35 "Expected 0 byte message, got more bytes:", &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 nanoapp_testing::sendFatalFailureToHost(
44 "Host must be awake during testing");
45 }
46
47 nanoapp_testing::sendSuccessToHost();
48 }
49 }
50
handleEvent(uint32_t,uint16_t eventType,const void *)51 void HostAwakeSuspendTest::handleEvent(uint32_t /* senderInstanceId */,
52 uint16_t eventType,
53 const void * /* eventData */) {
54 unexpectedEvent(eventType);
55 }
56
57 } // namespace general_test
58