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 <future> 8 9 #include <vsomeip/vsomeip.hpp> 10 #include <vsomeip/internal/logger.hpp> 11 12 class application_test_daemon { 13 public: application_test_daemon()14 application_test_daemon() : 15 app_(vsomeip::runtime::get()->create_application("daemon")) { 16 if (!app_->init()) { 17 ADD_FAILURE() << "Couldn't initialize application"; 18 return; 19 } 20 std::promise<bool> its_promise; 21 application_thread_ = std::thread([&](){ 22 its_promise.set_value(true); 23 app_->start(); 24 }); 25 EXPECT_TRUE(its_promise.get_future().get()); 26 std::this_thread::sleep_for(std::chrono::milliseconds(100)); 27 VSOMEIP_INFO << "Daemon starting"; 28 } 29 ~application_test_daemon()30 ~application_test_daemon() { 31 application_thread_.join(); 32 } 33 stop()34 void stop() { 35 VSOMEIP_INFO << "Daemon stopping"; 36 app_->stop(); 37 } 38 39 private: 40 std::shared_ptr<vsomeip::application> app_; 41 std::thread application_thread_; 42 }; 43