• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mcallegari / qlcplus / 13215211607

08 Feb 2025 11:29AM UTC coverage: 31.507% (+0.02%) from 31.492%
13215211607

push

github

mcallegari
engine: fix test units

4 of 4 new or added lines in 1 file covered. (100.0%)

196 existing lines in 2 files now uncovered.

14157 of 44933 relevant lines covered (31.51%)

26901.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.59
/engine/src/rgbscriptscache.cpp
1
/*
2
  Q Light Controller Plus
3
  rgbscriptscache.cpp
4

5
  Copyright (c) David Garyga
6

7
  Licensed under the Apache License, Version 2.0 (the "License");
8
  you may not use this file except in compliance with the License.
9
  You may obtain a copy of the License at
10

11
      http://www.apache.org/licenses/LICENSE-2.0.txt
12

13
  Unless required by applicable law or agreed to in writing, software
14
  distributed under the License is distributed on an "AS IS" BASIS,
15
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
  See the License for the specific language governing permissions and
17
  limitations under the License.
18
*/
19

20
#include <QDebug>
21
#include <QDir>
22

23
#include "rgbscriptscache.h"
24
#ifdef QT_QML_LIB
25
  #include "rgbscriptv4.h"
26
#else
27
  #include "rgbscript.h"
28
#endif
29
#include "qlcconfig.h"
30
#include "qlcfile.h"
31

32
RGBScriptsCache::RGBScriptsCache(Doc* doc)
177✔
33
    : m_doc(doc)
177✔
34
{
35
}
177✔
36

37
QStringList RGBScriptsCache::names() const
4✔
38
{
39
    return m_scriptsMap.keys();
4✔
40
}
41

42
RGBScript const& RGBScriptsCache::script(QString name) const
61✔
43
{
44
    RGBScript *mScript = new RGBScript(m_doc);
61✔
45
    QString filename = m_scriptsMap.value(name);
122✔
46
    if (filename.isEmpty())
61✔
47
    {
48
        return *mScript;
49
    }
50
    else
51
    {
52
        mScript->load(filename);
58✔
53
        return *mScript;
54
    }
55
}
56

57
bool RGBScriptsCache::load(const QDir& dir)
4✔
58
{
59
    qDebug() << "Loading RGB scripts in " << dir.path() << "...";
60

61
    if (dir.exists() == false || dir.isReadable() == false)
4✔
UNCOV
62
        return false;
×
63

64
    foreach (QString file, dir.entryList())
348✔
65
    {
66
        if (!file.endsWith(".js", Qt::CaseInsensitive))
170✔
67
        {
68
            qDebug() << "    " << file << " skipped (special file or does not end on *.js)";
69
            continue;
14✔
70
        }
71
        QFile absFile(dir.absoluteFilePath(file));
312✔
72
        QString absFilename = absFile.fileName();
312✔
73

74
        if (m_scriptsMap.value(absFilename).isEmpty())
156✔
75
        {
76
            if (!absFile.open(QIODevice::ReadOnly | QIODevice::Text))
156✔
UNCOV
77
                return false;
×
78

79
            QTextStream in(&absFile);
312✔
80
            QString line = in.readLine();
312✔
81
            while (!line.isNull())
4,436✔
82
            {
83
                QStringList tokens = line.split("=");
8,872✔
84
                if (tokens.length() == 2 && tokens[0].simplified() == "algo.name")
4,932✔
85
                {
86
                    QString algoName = tokens[1].simplified().remove('"');
468✔
87
                    algoName.remove(';');
156✔
88
                    m_scriptsMap.insert(algoName, absFilename);
156✔
89
                    qDebug() << "    " << algoName << "script loaded";
90
                    break;
91
                }
92
                line = in.readLine();
4,280✔
93
            }
94
            absFile.close();
156✔
95
        }
96
        else
97
        {
98
            qDebug() << "    " << file << " already known";
99
        }
100
    }
101
    return true;
4✔
102
}
103

104
QDir RGBScriptsCache::systemScriptsDirectory()
1✔
105
{
106
    return QLCFile::systemDirectory(QString(RGBSCRIPTDIR), QString(".js"));
1✔
107
}
108

109
QDir RGBScriptsCache::userScriptsDirectory()
1✔
110
{
111
    return QLCFile::userDirectory(QString(USERRGBSCRIPTDIR), QString(RGBSCRIPTDIR),
2✔
112
            QStringList() << QString("*%1").arg(".js"));
3✔
113
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc