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