1 /* 2 * Copyright (C) 2016 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 #ifndef _GTS_NANOAPPS_GENERAL_TEST_EVENT_BETWEEN_APPS_TEST_H_ 18 #define _GTS_NANOAPPS_GENERAL_TEST_EVENT_BETWEEN_APPS_TEST_H_ 19 20 #include <general_test/test.h> 21 #include <shared/macros.h> 22 #include <shared/send_message.h> 23 24 namespace general_test { 25 26 /** 27 * Send CHRE event to another nanoapp. 28 * 29 * Protocol: 30 * This is nanoapp app0. This test also involves nanoapp app1. 31 * All data to/from Host is in little endian. 32 * 33 * Host to app0: kEventBetweenApps0, no data 34 * app0 to Host: kContinue, 64-bit app ID, 32-bit instance ID 35 * Host to app0: kContinue, app1's 32-bit instance ID 36 * app0 to app1: kEventType, kMagic 37 */ 38 class EventBetweenApps0 : public Test { 39 public: 40 EventBetweenApps0(); 41 42 // Arbitrary as long as it's different from 43 // CHRE_EVENT_MESSAGE_FROM_HOST (which this value assures us). 44 static constexpr uint16_t kEventType = CHRE_EVENT_FIRST_USER_VALUE; 45 46 // NOTE: This is not constexpr, so we have storage for it. 47 static const uint32_t kMagic; 48 49 protected: 50 void handleEvent(uint32_t senderInstanceId, uint16_t eventType, 51 const void *eventData) override; 52 void setUp(uint32_t messageSize, const void *message) override; 53 54 private: 55 int mContinueCount; 56 }; 57 58 /** 59 * Receive CHRE event from another nanopp. 60 * 61 * Protocol: 62 * This is nanoapp app1. This test also involves nanoapp app0. 63 * All data to/from Host is in little endian. 64 * 65 * Host to app1: kEventBetweenApps1, no data 66 * app1 to Host: kContinue, 64-bit app ID, 32-bit instance ID 67 * [NOTE: Next two event can happen in any order] 68 * Host to app1: kContinue, app0's 32-bit instance ID 69 * app0 to app1: kEventType, EventBetweenApps1::kMagic 70 * app1 to Host: kSuccess, no data 71 */ 72 class EventBetweenApps1 : public Test { 73 public: 74 EventBetweenApps1(); 75 76 protected: 77 void handleEvent(uint32_t senderInstanceId, uint16_t eventType, 78 const void *eventData) override; 79 void setUp(uint32_t messageSize, const void *message) override; 80 81 private: 82 uint32_t mApp0InstanceId; 83 uint32_t mReceivedInstanceId; 84 }; 85 86 } // namespace general_test 87 88 #endif // _GTS_NANOAPPS_GENERAL_TEST_EVENT_BETWEEN_APPS_TEST_H_ 89