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/gnss_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
GnssCapabilitiesTest()25 GnssCapabilitiesTest::GnssCapabilitiesTest() : Test(CHRE_API_VERSION_1_1) {}
26
setUp(uint32_t messageSize,const void *)27 void GnssCapabilitiesTest::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_GNSS_CAPABILITIES_NONE;
34
35 if (mApiVersion >= CHRE_API_VERSION_1_1) {
36 allCapabilities |=
37 CHRE_GNSS_CAPABILITIES_LOCATION | CHRE_GNSS_CAPABILITIES_MEASUREMENTS;
38 }
39 if (mApiVersion >= CHRE_API_VERSION_1_2) {
40 allCapabilities |=
41 CHRE_GNSS_CAPABILITIES_GNSS_ENGINE_BASED_PASSIVE_LISTENER;
42 }
43
44 // Call the new API
45 uint32_t capabilities = chreGnssGetCapabilities();
46
47 // Clear out known capabilities, any remaining are unknown
48 if ((capabilities & ~allCapabilities) != 0) {
49 if (mApiVersion > CHRE_API_VERSION_1_2) {
50 EXPECT_FAIL_RETURN("New version with unknown capabilities encountered:",
51 &capabilities);
52 } else {
53 EXPECT_FAIL_RETURN("Received unexpected capabilities:", &capabilities);
54 }
55 } else {
56 nanoapp_testing::sendSuccessToHost();
57 }
58 }
59 }
60
handleEvent(uint32_t,uint16_t eventType,const void *)61 void GnssCapabilitiesTest::handleEvent(uint32_t /* senderInstanceId */,
62 uint16_t eventType,
63 const void * /* eventData */) {
64 unexpectedEvent(eventType);
65 }
66
67 } // namespace general_test
68