blob: 670a592db2f18958dc8266ccdd08860d119d1376 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
#include <QtBluetooth/qlowenergyservice.h>
/*
* This is a very simple test despite the complexity of QLowEnergyService.
* It mostly aims to test the static API behaviors of the class. The connection
* orientated elements are test by the test for QLowEnergyController as it
* is impossible to test the two classes separately from each other.
*/
class tst_QLowEnergyService : public QObject
{
Q_OBJECT
private slots:
void tst_flags();
};
void tst_QLowEnergyService::tst_flags()
{
QLowEnergyService::ServiceTypes flag1(QLowEnergyService::PrimaryService);
QLowEnergyService::ServiceTypes flag2(QLowEnergyService::IncludedService);
QLowEnergyService::ServiceTypes result;
// test QFlags &operator|=(QFlags f)
result = flag1 | flag2;
QVERIFY(result.testFlag(QLowEnergyService::PrimaryService));
QVERIFY(result.testFlag(QLowEnergyService::IncludedService));
// test QFlags &operator|=(Enum f)
result = flag1 | QLowEnergyService::IncludedService;
QVERIFY(result.testFlag(QLowEnergyService::PrimaryService));
QVERIFY(result.testFlag(QLowEnergyService::IncludedService));
// test Q_DECLARE_OPERATORS_FOR_FLAGS(QLowEnergyService::ServiceTypes)
result = QLowEnergyService::IncludedService | flag1;
QVERIFY(result.testFlag(QLowEnergyService::PrimaryService));
QVERIFY(result.testFlag(QLowEnergyService::IncludedService));
}
QTEST_MAIN(tst_QLowEnergyService)
#include "tst_qlowenergyservice.moc"
|