GCC Code Coverage Report


Directory: ./
File: backends/utils.cpp
Date: 2023-04-20 22:59:23
Exec Total Coverage
Lines: 21 37 56.8%
Branches: 23 42 54.8%

Line Branch Exec Source
1 /*************************************************************************************
2 * Copyright 2018 Daniel Vrátil <dvratil@kde.org> *
3 * *
4 * This library is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
8 * *
9 * This library is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with this library; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
17 *************************************************************************************/
18
19 #include "utils.h"
20
21 #include <QVector>
22
23 1631 Disman::Output::Type Utils::guessOutputType(const QString& type, const QString& name)
24 {
25 static const auto embedded = {QLatin1String("LVDS"),
26 QLatin1String("IDP"),
27 QLatin1String("EDP"),
28 QLatin1String("LCD"),
29
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1629 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
1631 QLatin1String("DSI")};
30
31
2/2
✓ Branch 2 taken 8155 times.
✓ Branch 3 taken 1631 times.
9786 for (const QLatin1String& pre : embedded) {
32
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8155 times.
8155 if (name.startsWith(pre, Qt::CaseInsensitive)) {
33 return Disman::Output::Panel;
34 }
35 }
36
37
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 if (type.contains(QLatin1String("VGA"))) {
38 return Disman::Output::VGA;
39
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 } else if (type.contains(QLatin1String("DVI"))) {
40 return Disman::Output::DVI;
41
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 } else if (type.contains(QLatin1String("DVI-I"))) {
42 return Disman::Output::DVII;
43
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 } else if (type.contains(QLatin1String("DVI-A"))) {
44 return Disman::Output::DVIA;
45
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 } else if (type.contains(QLatin1String("DVI-D"))) {
46 return Disman::Output::DVID;
47
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 } else if (type.contains(QLatin1String("HDMI"))) {
48 return Disman::Output::HDMI;
49
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 } else if (type.contains(QLatin1String("Panel"))) {
50 return Disman::Output::Panel;
51
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 } else if (type.contains(QLatin1String("TV-Composite"))) {
52 return Disman::Output::TVComposite;
53
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 } else if (type.contains(QLatin1String("TV-SVideo"))) {
54 return Disman::Output::TVSVideo;
55
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 } else if (type.contains(QLatin1String("TV-Component"))) {
56 return Disman::Output::TVComponent;
57
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 } else if (type.contains(QLatin1String("TV-SCART"))) {
58 return Disman::Output::TVSCART;
59
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 } else if (type.contains(QLatin1String("TV-C4"))) {
60 return Disman::Output::TVC4;
61
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 } else if (type.contains(QLatin1String("TV"))) {
62 return Disman::Output::TV;
63 1631 } else if (type.contains(QLatin1String("DisplayPort"))
64
3/6
✓ Branch 0 taken 1631 times.
✗ Branch 1 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1631 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1631 times.
1631 || type.startsWith(QLatin1String("DP"))) {
65 return Disman::Output::DisplayPort;
66
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1631 times.
1631 } else if (type.contains(QLatin1String("unknown"))) {
67 return Disman::Output::Unknown;
68 } else {
69 1631 return Disman::Output::Unknown;
70 }
71 }
72