1 // Copyright (C) 2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) 2 // This Source Code Form is subject to the terms of the Mozilla Public 3 // License, v. 2.0. If a copy of the MPL was not distributed with this 4 // file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 6 #ifndef E2E_PROFILE_04_TEST_CLIENT_HPP_ 7 #define E2E_PROFILE_04_TEST_CLIENT_HPP_ 8 9 #include <gtest/gtest.h> 10 11 #include <vsomeip/vsomeip.hpp> 12 13 #include <thread> 14 #include <mutex> 15 #include <condition_variable> 16 #include <atomic> 17 18 class e2e_profile_04_test_client { 19 public: 20 e2e_profile_04_test_client(); 21 22 bool init(); 23 void start(); 24 void stop(); 25 26 void on_state(vsomeip::state_type_e _state); 27 void on_availability(vsomeip::service_t _service, 28 vsomeip::instance_t _instance, bool _is_available); 29 void on_message(const std::shared_ptr<vsomeip::message> &_response); 30 31 void run(); 32 void join_sender_thread(); 33 34 private: 35 void shutdown_service(); 36 37 std::shared_ptr<vsomeip::application> app_; 38 39 std::mutex mutex_; 40 std::condition_variable condition_; 41 bool is_available_; 42 43 std::thread sender_; 44 45 std::atomic<uint32_t> received_; 46 }; 47 48 #endif // E2E_PROFILE_04_TEST_CLIENT_HPP_ 49