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