Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
PIM GrantleeTheme
Commits
1f575869
Commit
1f575869
authored
Aug 07, 2021
by
Laurent Montel
😁
Browse files
Make sure to not generate file in source dir
parent
0e7b85ba
Pipeline
#73739
failed with stage
in 2 minutes and 39 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
autotest/CMakeLists.txt
View file @
1f575869
add_definitions
(
-DGRANTLEETHEME_DATA_DIR=
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/data"
)
add_definitions
(
-DGRANTLEETHEME_DATA_BUILD_DIR=
"
${
CMAKE_CURRENT_BINARY_DIR
}
/data"
)
ecm_add_test
(
grantleethemetest.cpp
NAME_PREFIX
"grantleetheme-"
LINK_LIBRARIES Qt::Test KF5::GrantleeTheme KF5::ConfigCore Qt::Gui KF5::ConfigWidgets
...
...
autotest/grantleethemetest.cpp
View file @
1f575869
...
...
@@ -96,6 +96,7 @@ bool GrantleeThemeTest::validateHtml(const QString &themePath, const QString &na
const
QString
htmlFileName
=
themePath
+
QStringLiteral
(
"/%1.out.html"
).
arg
(
name
);
QFile
outFile
(
outFileName
);
if
(
!
outFile
.
open
(
QIODevice
::
WriteOnly
))
{
qDebug
()
<<
"impossible to open "
<<
outFile
;
return
false
;
}
outFile
.
write
(
html
.
toUtf8
());
...
...
@@ -110,9 +111,9 @@ bool GrantleeThemeTest::validateHtml(const QString &themePath, const QString &na
return
result
==
0
;
}
bool
GrantleeThemeTest
::
compareHtml
(
const
QString
&
themePath
,
const
QString
&
name
)
bool
GrantleeThemeTest
::
compareHtml
(
const
QString
&
generatedTheme
,
const
QString
&
themePath
,
const
QString
&
name
)
{
const
QString
htmlFileName
=
themePath
+
QStringLiteral
(
"/%1.out.html"
).
arg
(
name
);
const
QString
htmlFileName
=
generatedTheme
+
QStringLiteral
(
"/%1.out.html"
).
arg
(
name
);
const
QString
referenceFileName
=
themePath
+
QStringLiteral
(
"/%1_expected.html"
).
arg
(
name
);
// get rid of system dependent or random paths
...
...
@@ -164,6 +165,8 @@ void GrantleeThemeTest::testRenderTemplate()
QFETCH
(
QString
,
templateBasename
);
const
QString
themePath
=
QStringLiteral
(
GRANTLEETHEME_DATA_DIR
"/themes/"
)
+
dirname
;
const
QString
themeBinaryPath
=
QStringLiteral
(
GRANTLEETHEME_DATA_BUILD_DIR
"/themes/"
)
+
dirname
;
QDir
().
mkpath
(
themeBinaryPath
);
QVariantHash
data
;
data
[
QStringLiteral
(
"icon"
)]
=
QStringLiteral
(
"kde"
);
...
...
@@ -186,11 +189,11 @@ void GrantleeThemeTest::testRenderTemplate()
if
(
isValid
)
{
const
QString
result
=
theme
.
render
(
templateBasename
+
QStringLiteral
(
".html"
),
data
);
QVERIFY
(
validateHtml
(
themePath
,
templateBasename
,
result
));
QVERIFY
(
compareHtml
(
themePath
,
templateBasename
));
QVERIFY
(
validateHtml
(
theme
Binary
Path
,
templateBasename
,
result
));
QVERIFY
(
compareHtml
(
themeBinaryPath
,
themePath
,
templateBasename
));
QFile
::
remove
(
themePath
+
QLatin1Char
(
'/'
)
+
templateBasename
+
QStringLiteral
(
".out"
));
QFile
::
remove
(
themePath
+
QLatin1Char
(
'/'
)
+
templateBasename
+
QStringLiteral
(
".out.html"
));
QFile
::
remove
(
theme
Binary
Path
+
QLatin1Char
(
'/'
)
+
templateBasename
+
QStringLiteral
(
".out"
));
QFile
::
remove
(
theme
Binary
Path
+
QLatin1Char
(
'/'
)
+
templateBasename
+
QStringLiteral
(
".out.html"
));
}
}
...
...
autotest/grantleethemetest.h
View file @
1f575869
...
...
@@ -25,6 +25,6 @@ private Q_SLOTS:
private:
bool
validateHtml
(
const
QString
&
path
,
const
QString
&
name
,
const
QString
&
html
);
bool
compareHtml
(
const
QString
&
path
,
const
QString
&
name
);
bool
compareHtml
(
const
QString
&
generatedTheme
,
const
QString
&
path
,
const
QString
&
name
);
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment