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