Changeset View
Standalone View
autotests/unit/file/resulttest.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * <one line to give the library's name and an idea of what it does.> | ||||
bruns: ^_^ | |||||
3 | * Copyright (C) 2018 Alexander Stippich <a.stippich@gmx.net> | ||||
4 | * | ||||
5 | * This library is free software; you can redistribute it and/or | ||||
6 | * modify it under the terms of the GNU Lesser General Public | ||||
7 | * License as published by the Free Software Foundation; either | ||||
8 | * version 2.1 of the License, or (at your option) any later version. | ||||
9 | * | ||||
10 | * This library is distributed in the hope that it will be useful, | ||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
13 | * Lesser General Public License for more details. | ||||
14 | * | ||||
15 | * You should have received a copy of the GNU Lesser General Public | ||||
16 | * License along with this library; if not, write to the Free Software | ||||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||
18 | * | ||||
19 | */ | ||||
20 | | ||||
21 | #include "document.h" | ||||
22 | #include "extractor/result.h" | ||||
23 | | ||||
24 | #include <KFileMetaData/Properties> | ||||
25 | | ||||
26 | #include <QTest> | ||||
27 | | ||||
28 | using namespace Baloo; | ||||
29 | | ||||
30 | class ResultTest : public QObject | ||||
31 | { | ||||
32 | Q_OBJECT | ||||
33 | | ||||
34 | private Q_SLOTS: | ||||
35 | void testStringMerging() | ||||
36 | { | ||||
37 | Document doc; | ||||
38 | | ||||
39 | Result result(QStringLiteral("test"),QStringLiteral("audo/mpeg3"),KFileMetaData::ExtractionResult::ExtractEverything); | ||||
bruns: Spaces and linebreaks ... | |||||
40 | result.setDocument(doc); | ||||
No need to reset the default constructed Baloo::Document with a default constructed one. bruns: No need to reset the default constructed `Baloo::Document` with a default constructed one. | |||||
Actually it is. The TermGenerators are otherwise only initialized with nullptr, and consequently will crash. That is something that should be fixed (separately). astippich: Actually it is. The TermGenerators are otherwise only initialized with nullptr, and… | |||||
bruns: D17315 | |||||
41 | | ||||
42 | result.add(KFileMetaData::Property::Artist, QVariant(QStringLiteral("artist1"))); | ||||
43 | result.add(KFileMetaData::Property::Artist, QVariant(QStringLiteral("artist2"))); | ||||
44 | | ||||
45 | result.finish(); | ||||
46 | auto properties = result.map(); | ||||
47 | auto artist = properties.find(QString::number(KFileMetaData::Property::Artist)); | ||||
48 | QCOMPARE(artist->type(), QVariant::List); | ||||
49 | QCOMPARE(artist->toStringList().join(", "), QStringLiteral("artist1, artist2")); | ||||
50 | } | ||||
51 | }; | ||||
52 | | ||||
53 | QTEST_MAIN(ResultTest) | ||||
54 | | ||||
55 | #include "resulttest.moc" | ||||
This looks wrong to me ... bruns: This looks wrong to me ...
How many items do you get when you append "keyword3" first and… | |||||
It's the same. The properties will get merged regardless of their form if the QVariantMap already contains an item with the same key, see https://phabricator.kde.org/source/baloo/browse/master/src/file/extractor/result.cpp$52 so this works as currently intended. astippich: It's the same. The properties will get merged regardless of their form if the QVariantMap… |
^_^