~nick-dedekind/unity8/indicator.submenu-reinit

« back to all changes in this revision

Viewing changes to tests/plugins/Unity/resultstest.cpp

  • Committer: Nick Dedekind
  • Date: 2013-10-16 13:24:10 UTC
  • mfrom: (229.1.237 trunk)
  • Revision ID: nicholas.dedekind@gmail.com-20131016132410-ezos8if9y1oanv5x
merged with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "resultstest.h"
25
25
#include "categoryresults.h"
 
26
#include "variantutils.h"
26
27
 
27
28
static DeeModel* createBackendModel()
28
29
{
193
194
    QCOMPARE(transformedIcon, result);
194
195
}
195
196
 
 
197
void ResultsTest::testMetadataOverride_data()
 
198
{
 
199
    QTest::addColumn<QString>("uri");
 
200
    QTest::addColumn<QVariantHash>("result");
 
201
 
 
202
    QVariantHash expected_result;
 
203
    QVariantHash inner_hash;
 
204
 
 
205
    expected_result = QVariantHash();
 
206
    expected_result["scope-id"] = QVariant::fromValue(QString("applications.scope"));
 
207
    expected_result["content"] = QVariant::fromValue(QVariantHash());
 
208
 
 
209
    QTest::newRow("single scope") << "subscope:applications.scope" << expected_result;
 
210
 
 
211
    expected_result = QVariantHash();
 
212
    expected_result["scope-id"] = QVariant::fromValue(QString("applications.scope"));
 
213
    inner_hash = QVariantHash();
 
214
    inner_hash["foo"] = QVariant::fromValue(QString("bar"));
 
215
    inner_hash["qoo"] = QVariant::fromValue(QString("baz"));
 
216
    expected_result["content"] = QVariant::fromValue(inner_hash);
 
217
 
 
218
    QTest::newRow("single scope with data") << "subscope:applications.scope?foo=bar&qoo=baz" << expected_result;
 
219
 
 
220
    expected_result = QVariantHash();
 
221
    inner_hash = QVariantHash();
 
222
    inner_hash["scope-id"] = QVariant::fromValue(QString("applications-local.scope"));
 
223
    inner_hash["content"] = QVariant::fromValue(QVariantHash());
 
224
    expected_result["scope-id"] = QVariant::fromValue(QString("applications.scope"));
 
225
    expected_result["content"] = QVariant::fromValue(inner_hash);
 
226
    QTest::newRow("master scope") << "subscope:applications.scope/applications-local.scope" << expected_result;
 
227
 
 
228
    expected_result = QVariantHash();
 
229
    expected_result["foo"] = QVariant::fromValue(QString("baz"));
 
230
    expected_result["qoo"] = QVariant::fromValue(QString("baz"));
 
231
    inner_hash = QVariantHash();
 
232
    inner_hash["scope-id"] = QVariant::fromValue(QString("applications-local.scope"));
 
233
    inner_hash["content"] = QVariant::fromValue(expected_result);
 
234
    expected_result = QVariantHash();
 
235
    expected_result["scope-id"] = QVariant::fromValue(QString("applications.scope"));
 
236
    expected_result["content"] = QVariant::fromValue(inner_hash);
 
237
    QTest::newRow("nested with data") << "subscope:applications.scope/applications-local.scope?foo=baz&qoo=baz" << expected_result;
 
238
}
 
239
 
 
240
void ResultsTest::testMetadataOverride()
 
241
{
 
242
    QFETCH(QString, uri);
 
243
    QFETCH(QVariantHash, result);
 
244
 
 
245
    QCOMPARE(subscopeUriToMetadataHash(uri), result);
 
246
}
 
247
 
196
248
QTEST_MAIN(ResultsTest)