mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Refactoring test
This commit is contained in:
41
Test/Applications/process/main.cpp
Normal file
41
Test/Applications/process/main.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "../../../../desktop-sdk/ChromiumBasedEditors/lib/src/cefwrapper/external_process.h"
|
||||
|
||||
class CProcessRunnerCallbackWork : public NSProcesses::CProcessRunnerCallback
|
||||
{
|
||||
public:
|
||||
CProcessRunnerCallbackWork(){}
|
||||
virtual ~CProcessRunnerCallbackWork(){}
|
||||
|
||||
virtual void process_callback(const int& id, const NSProcesses::StreamType& type, const std::string& message)
|
||||
{
|
||||
std::string type_out = "stop";
|
||||
switch (type)
|
||||
{
|
||||
case NSProcesses::StreamType::StdOut:
|
||||
type_out = "stdout";
|
||||
break;
|
||||
case NSProcesses::StreamType::StdErr:
|
||||
type_out = "stderr";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
std::cout << "[" << id << ", " << type_out << "] " << message << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
CProcessRunnerCallbackWork callback;
|
||||
NSProcesses::CProcessManager manager(&callback);
|
||||
|
||||
manager.Start("ping -c 4 google.com", {});
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
|
||||
manager.StopAll();
|
||||
|
||||
std::cout << "Hello World!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
18
Test/Applications/process/test.pro
Normal file
18
Test/Applications/process/test.pro
Normal file
@ -0,0 +1,18 @@
|
||||
TEMPLATE = app
|
||||
CONFIG += console c++17
|
||||
CONFIG -= app_bundle
|
||||
CONFIG -= qt
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
CONFIG += core_boost_libs
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/boost/boost.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel)
|
||||
|
||||
SOURCES += \
|
||||
main.cpp
|
||||
|
||||
DESTDIR = $$PWD/build
|
||||
Reference in New Issue
Block a user