1 // Copyright (C) 2014-2017 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 #include <gtest/gtest.h> 7 #include "application_test_service.cpp" 8 #include "application_test_client.cpp" 9 #include "application_test_daemon.cpp" 10 TEST(someip_application_test_single_process,notify_increasing_counter)11TEST(someip_application_test_single_process, notify_increasing_counter) 12 { 13 // start application acting as daemon (rm_stub) 14 auto its_daemon = std::make_shared<application_test_daemon>(); 15 16 // start receiver service (rm_proxy) 17 application_test_service its_receiver(application_test::service); 18 19 // stop the daemon (rm_stub goes away) 20 its_daemon->stop(); 21 its_daemon.reset(); 22 // restart client which tries to communicate with service multiple times 23 // thus it will always be the new routing manager 24 for (int var = 0; var < 10; ++var) { 25 // every time the client is restarted it becomes the rm_stub again 26 application_test_client its_client(application_test::service); 27 if(var != 9) { 28 its_client.stop(false); 29 } else { 30 // for the last iteration we sleep to make sure the communication 31 // between the client and the service can be established 32 std::this_thread::sleep_for(std::chrono::milliseconds(2000)); 33 its_client.stop(true); 34 } 35 } 36 std::this_thread::sleep_for(std::chrono::milliseconds(100)); 37 its_receiver.on_shutdown_method_called(vsomeip::runtime::get()->create_message()); 38 } 39 40 41 #ifndef _WIN32 main(int argc,char ** argv)42int main(int argc, char** argv) 43 { 44 ::testing::InitGoogleTest(&argc, argv); 45 return RUN_ALL_TESTS(); 46 } 47 #endif 48