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 #include <general_test/wwan_capabilities_test.h>
17 
18 #include <chre.h>
19 
20 #include <shared/send_message.h>
21 
22 namespace general_test {
23 
WwanCapabilitiesTest()24 WwanCapabilitiesTest::WwanCapabilitiesTest()
25     : Test(CHRE_API_VERSION_1_1) {
26 }
27 
setUp(uint32_t messageSize,const void *)28 void WwanCapabilitiesTest::setUp(uint32_t messageSize,
29                                  const void * /* message */) {
30   if (messageSize != 0) {
31     nanoapp_testing::sendFatalFailureToHost(
32         "Expected 0 byte message, got more bytes:", &messageSize);
33   } else {
34     uint32_t allCapabilities = CHRE_WWAN_CAPABILITIES_NONE;
35 
36     if (mApiVersion >= CHRE_API_VERSION_1_1) {
37       allCapabilities |= CHRE_WWAN_GET_CELL_INFO;
38     }
39 
40     // Call the new API
41     uint32_t capabilities = chreWwanGetCapabilities();
42 
43     // Clear out known capabilities, any remaining are unknown
44     if ((capabilities & ~allCapabilities) != 0) {
45       if (mApiVersion > CHRE_API_VERSION_1_2) {
46         nanoapp_testing::sendFatalFailureToHost(
47             "New version with unknown capabilities encountered:",
48             &capabilities);
49       } else {
50         nanoapp_testing::sendFatalFailureToHost(
51             "Received unexpected capabilities:", &capabilities);
52       }
53     } else {
54       nanoapp_testing::sendSuccessToHost();
55     }
56   }
57 }
58 
handleEvent(uint32_t,uint16_t eventType,const void *)59 void WwanCapabilitiesTest::handleEvent(uint32_t /* senderInstanceId */,
60                                        uint16_t eventType,
61                                        const void * /* eventData */) {
62   unexpectedEvent(eventType);
63 }
64 
65 } // namespace general_test
66