Skip to content

Commit

Permalink
Merge branch 'jb52902' into 'master'
Browse files Browse the repository at this point in the history
Fix basename handling and unit tests

See merge request mer-core/nemo-qml-plugin-filemanager!40
  • Loading branch information
llewelld committed Feb 2, 2021
2 parents e39eb8a + 11eede5 commit dcf0c65
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
10 changes: 6 additions & 4 deletions src/plugin/statfileinfo.cpp
Expand Up @@ -110,10 +110,12 @@ void StatFileInfo::refresh()
m_extension = mimeDatabase.suffixForFileName(m_fileName);
m_baseName = m_fileInfo.fileName();

if (m_baseName.lastIndexOf(m_extension) == 1) {
m_extension.clear();
} else {
m_baseName.chop(m_extension.length() + 1);
if (!m_extension.isEmpty()) {
if (m_baseName.lastIndexOf(m_extension) < 1) {
m_extension.clear();
} else {
m_baseName.chop(m_extension.length() + 1);
}
}

m_archiveInfo.setFile(m_fileName);
Expand Down
2 changes: 1 addition & 1 deletion tests/auto/auto.pro
Expand Up @@ -3,7 +3,7 @@ include (../common.pri)
TEMPLATE = aux

QML_FILES = tst_*.qml
OTHER_FILES += $${QML_FILES}
OTHER_FILES += $${QML_FILES} folder/* folder/subfolder/*

target.files = $${QML_FILES} folder hiddenfolder protectedfolder
target.path = $$[QT_INSTALL_LIBS]/$${PACKAGENAME}-tests/auto
Expand Down
4 changes: 3 additions & 1 deletion tests/auto/tst_fileengine.qml
Expand Up @@ -157,11 +157,13 @@ Item {
compare(fileModel.count, 2)
compare(repeater.itemAt(1).fileName, name)

fileCountSpy.clear()

// delete the folder
FileEngine.deleteFiles([ fileModel.fileNameAt(1) ], nonprivileged)

// wait for the deletion to finish
workerDoneSpy.wait()
fileCountSpy.wait()
wait(0)
compare(fileModel.count, 1)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/auto/tst_filemodel.qml
Expand Up @@ -69,7 +69,7 @@ Item {
{fileName: "c", baseName: "c", extension: "", mimeType: "text/plain", size: 4, isDir: false},
{fileName: "subfolder", baseName: "subfolder", extension: "", mimeType: "inode/directory", size: 4096, isDir: true},
{fileName: ".hidden.xml", baseName: ".hidden", extension: "xml", mimeType: "application/xml", size: 52, isDir: false},
{fileName: ".tarball.tar.bz2", baseName: ".tarball.tar", extension: "bz2", mimeType: "application/x-bzip-compressed-tar", size: 109, isDir: false},
{fileName: ".tarball.tar.bz2", baseName: ".tarball", extension: "tar.bz2", mimeType: "application/x-bzip-compressed-tar", size: 109, isDir: false},
{fileName: ".hidden", baseName: ".hidden", extension: "", mimeType: "text/plain", size: 6, isDir: false}
]

Expand Down
3 changes: 2 additions & 1 deletion tests/tests.pro
Expand Up @@ -6,7 +6,8 @@ SUBDIRS = auto \

OTHER_FILES += tests.xml.template

system(sed -e s/@PACKAGENAME@/$${PACKAGENAME}/g -e s/@LIBDIR@/$$[QT_INSTALL_LIBS]/g tests.xml.template > tests.xml)
LIBDIR = $$[QT_INSTALL_LIBS]
system(sed -e s/@PACKAGENAME@/$${PACKAGENAME}/g -e s/@LIBDIR@/$$re_escape($$replace(LIBDIR, /, \/))/g tests.xml.template > tests.xml)

xml.path = /usr/share/$${PACKAGENAME}-tests
xml.files = tests.xml
Expand Down
16 changes: 8 additions & 8 deletions tests/tests.xml.template
Expand Up @@ -3,36 +3,36 @@
<suite name="@PACKAGENAME@-tests" domain="Middleware">
<set name="@PACKAGENAME@-qml" feature="@PACKAGENAME@">
<case name="FileModel">
<step>cd @LIBDIR@@PACKAGENAME@-tests/auto &amp;&amp; @LIBDIR@/qt5/bin/qmltestrunner -input tst_filemodel.qml</step>
<step>cd @LIBDIR@/@PACKAGENAME@-tests/auto &amp;&amp; @LIBDIR@/qt5/bin/qmltestrunner -input tst_filemodel.qml</step>
</case>
<case name="FileEngine">
<step>cd @LIBDIR@@PACKAGENAME@-tests/auto &amp;&amp; @LIBDIR@/qt5/bin/qmltestrunner -input tst_fileengine.qml</step>
<step>cd @LIBDIR@/@PACKAGENAME@-tests/auto &amp;&amp; @LIBDIR@/qt5/bin/qmltestrunner -input tst_fileengine.qml</step>
</case>
</set>
<set name="@PACKAGENAME@-diskusage" description="ut_diskusage" feature="@PACKAGENAME@">
<case name="testSimple" description="Test basic functionality"
type="Functional" level="Component" timeout="600">
<step expected_result="0">@LIBDIR@@PACKAGENAME@-tests/ut_diskusage testSimple</step>
<step expected_result="0">@LIBDIR@/@PACKAGENAME@-tests/ut_diskusage testSimple</step>
</case>
<case name="testSubtractApkdFromRoot" description="Test if subtracting :apkd: from / works"
type="Functional" level="Component" timeout="600">
<step expected_result="0">@LIBDIR@@PACKAGENAME@-tests/ut_diskusage testSubtractApkdFromRoot</step>
<step expected_result="0">@LIBDIR@/@PACKAGENAME@-tests/ut_diskusage testSubtractApkdFromRoot</step>
</case>
<case name="testSubtractRPMFromRoot" description="Test if subtracting :rpm: from / works"
type="Functional" level="Component" timeout="600">
<step expected_result="0">@LIBDIR@@PACKAGENAME@-tests/ut_diskusage testSubtractRPMFromRoot</step>
<step expected_result="0">@LIBDIR@/@PACKAGENAME@-tests/ut_diskusage testSubtractRPMFromRoot</step>
</case>
<case name="testSubtractSubdirectory" description="Test if subtracting a subdirectory works"
type="Functional" level="Component" timeout="600">
<step expected_result="0">@LIBDIR@@PACKAGENAME@-tests/ut_diskusage testSubtractSubdirectory</step>
<step expected_result="0">@LIBDIR@/@PACKAGENAME@-tests/ut_diskusage testSubtractSubdirectory</step>
</case>
<case name="testSubtractNestedSubdirectory" description="Test if subtracting nested subdirectories works"
type="Functional" level="Component" timeout="600">
<step expected_result="0">@LIBDIR@@PACKAGENAME@-tests/ut_diskusage testSubtractNestedSubdirectory</step>
<step expected_result="0">@LIBDIR@/@PACKAGENAME@-tests/ut_diskusage testSubtractNestedSubdirectory</step>
</case>
<case name="testSubtractNestedSubdirectoryMulti" description="Test if subtracting nested and sibling subdirectories works"
type="Functional" level="Component" timeout="600">
<step expected_result="0">@LIBDIR@@PACKAGENAME@-tests/ut_diskusage testSubtractNestedSubdirectoryMulti</step>
<step expected_result="0">@LIBDIR@/@PACKAGENAME@-tests/ut_diskusage testSubtractNestedSubdirectoryMulti</step>
</case>
</set>
</suite>
Expand Down

0 comments on commit dcf0c65

Please sign in to comment.