GCC Code Coverage Report


Directory: ./
File: src/client/selection_device_p.h
Date: 2024-01-22 17:25:27
Exec Total Coverage
Lines: 19 19 100.0%
Branches: 8 14 57.1%

Line Branch Exec Source
1 /*
2 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
3 SPDX-FileCopyrightText: 2021 Francesco Sorrentino <francesco.sorr@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only
6 */
7 #pragma once
8
9 #include <QObject>
10
11 namespace Wrapland::Client
12 {
13
14 template<typename PrivateDevice, typename WlDevice, typename WlOffer>
15 44 void data_offer_callback(void* data, WlDevice* device, WlOffer* id)
16 {
17 44 auto priv = reinterpret_cast<PrivateDevice*>(data);
18
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 Q_ASSERT(priv->device == device);
19
20
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 Q_ASSERT(!priv->lastOffer);
21 using Offer = typename std::remove_pointer_t<decltype(priv->q)>::offer_type;
22
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 priv->lastOffer = new Offer(priv->q, id);
23
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 Q_ASSERT(priv->lastOffer->isValid());
24 44 }
25
26 template<typename PrivateDevice, typename WlDevice, typename WlOffer>
27 49 void selection_callback(void* data, WlDevice* device, WlOffer* id)
28 {
29 49 auto priv = reinterpret_cast<PrivateDevice*>(data);
30
1/2
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
49 Q_ASSERT(priv->device == device);
31
32
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 13 times.
49 if (!id) {
33 13 priv->selectionOffer.reset();
34 13 Q_EMIT priv->q->selectionOffered(nullptr);
35 13 return;
36 }
37
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 Q_ASSERT(*priv->lastOffer == id);
38 36 priv->selectionOffer.reset(priv->lastOffer);
39 36 priv->lastOffer = nullptr;
40 36 Q_EMIT priv->q->selectionOffered(priv->selectionOffer.get());
41 49 }
42
43 }
44