swift
testprocess.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
7 
8 #include <QCoreApplication>
9 #include <QTest>
10 
11 #include "test.h"
12 
13 #include "misc/processinfo.h"
14 
15 using namespace swift::misc;
16 
17 namespace MiscTest
18 {
20  class CTestProcess : public QObject
21  {
22  Q_OBJECT
23 
24  private slots:
26  void processInfo();
27  };
28 
29  void CTestProcess::processInfo()
30  {
31  CProcessInfo invalid;
32  QVERIFY2(!invalid.exists(), "Invalid process shall not exist");
33 
35  CProcessInfo current2(QCoreApplication::applicationPid());
36  CProcessInfo current3(QCoreApplication::applicationPid(), QCoreApplication::applicationName());
37  QVERIFY2(current1.exists(), "Current process shall exist");
38  QVERIFY2(current1 == current2, "Current process equals process with current PID");
39  QVERIFY2(current1 == current3, "Current process equals process with current PID and name");
40  }
41 } // namespace MiscTest
42 
45 
46 #include "testprocess.moc"
47 
Testing process tools.
Definition: testprocess.cpp:21
Value class identifying a process, with a PID and a name.
Definition: processinfo.h:22
bool exists() const
True if this object identifies a process that exists.
Definition: processinfo.h:37
static CProcessInfo currentProcess()
Return an object identifying the current process.
Definition: processinfo.h:34
Free functions in swift::misc.
SWIFTTEST_MAIN(MiscTest::CTestProcess)
main