musicbrainztest-severaldiscs.cpp 4.8 KB
Newer Older
1
/*
2
    SPDX-FileCopyrightText: 2006 Richard Lärkäng <nouseforaname@home.se>
3

4
    SPDX-License-Identifier: LGPL-2.0-or-later
5
6
7
8
9
10
11
*/

#include "musicbrainztest-severaldiscs.h"
#include "libkcddb/client.h"
#include "libkcddb/cache.h"
#include "libkcddb/lookup.h"
#include "config-musicbrainz.h"
Yuri Chornoivan's avatar
Yuri Chornoivan committed
12
#include <QTest>
13

14
15
16
17
18
19
static void setEnvironment()
{
    qputenv("LANG", "C.UTF-8");
    qputenv("LANGUAGE", "C.UTF-8");
}

20
21
22
23
void MusicBrainzTestSeveralDiscs::testLookup()
{
  using namespace KCDDB;

24
#ifndef HAVE_MUSICBRAINZ5
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  QSKIP("This test requires libmusicbrainz", SkipAll);
#endif

  Client c;
  c.config().setCacheLookupEnabled(false);
  c.config().setFreedbLookupEnabled(false);
  c.config().setMusicBrainzLookupEnabled(true);

  TrackOffsetList list;

  list <<
    150 <<
    17272 <<
    36395 <<
    47954 <<
    63638 <<
    77928 <<
    95029 <<
    112094 <<
    130540 <<
    145938 <<
    160463 <<
    180364 <<
    195549 <<
    203821 <<
    222410 <<
    230367 <<
    249241 <<
    273944 <<
    287584 <<
    309904 <<
    325124;

  Result r = c.lookup(list);

  QVERIFY(r == Success);

62
  qDebug() << "Client::lookup gave : " << resultToString(r);
63
64
65

  CDInfoList response = c.lookupResponse();

66
  qDebug() << "Client::lookup returned : " << response.count() << " entries";
67
68
69

  QVERIFY(response.count() > 0);

Yuri Chornoivan's avatar
Yuri Chornoivan committed
70
  // See https://musicbrainz.org/release/4e0655b5-22fc-496e-9c14-2ee1a6027b45 for changes (disc 2)
71
72
73
  CDInfo i(response.first());
  QCOMPARE(i.numberOfTracks(),20);

74
75
  QCOMPARE(i.get(Artist).toString(),QString::fromUtf8("Billy Bragg"));
  QCOMPARE(i.get(Title).toString(),QString::fromUtf8("Must I Paint You a Picture? The Essential Billy Bragg (disc 2)"));
76
  // genre not really supported for musicbrainz
77
  QCOMPARE(i.get(Genre).toString(),QString());
78
  QCOMPARE(i.get(Year).toInt(),2003);
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
  QCOMPARE(i.track(0).get(Title).toString(),QString::fromUtf8("Sexuality"));
  QCOMPARE(i.track(1).get(Title).toString(),QString::fromUtf8("Cindy of 1000 Lives"));
  QCOMPARE(i.track(2).get(Title).toString(),QString::fromUtf8("Moving the Goalposts"));
  QCOMPARE(i.track(3).get(Title).toString(),QString::fromUtf8("Tank Park Salute"));
  QCOMPARE(i.track(4).get(Title).toString(),QString::fromUtf8("You Woke Up My Neighbourhood"));
  QCOMPARE(i.track(5).get(Title).toString(),QString::fromUtf8("Accident Waiting to Happen (Red Stars version)"));
  QCOMPARE(i.track(6).get(Title).toString(),QString::fromUtf8("Sulk"));
  QCOMPARE(i.track(7).get(Title).toString(),QString::fromUtf8("Upfield"));
  QCOMPARE(i.track(8).get(Title).toString(),QString::fromUtf8("The Fourteenth of February"));
  QCOMPARE(i.track(9).get(Title).toString(),QString::fromUtf8("Brickbat"));
  QCOMPARE(i.track(10).get(Title).toString(),QString::fromUtf8("The Space Race Is Over"));
  QCOMPARE(i.track(11).get(Title).toString(),QString::fromUtf8("The Boy Done Good"));
  QCOMPARE(i.track(12).get(Title).toString(),QString::fromUtf8("Ingrid Bergman"));
  QCOMPARE(i.track(13).get(Title).toString(),QString::fromUtf8("Way Over Yonder in the Minor Key"));
  QCOMPARE(i.track(14).get(Title).toString(),QString::fromUtf8("My Flying Saucer"));
  QCOMPARE(i.track(15).get(Title).toString(),QString::fromUtf8("All You Fascists Bound to Lose (Blokes version)"));
  QCOMPARE(i.track(16).get(Title).toString(),QString::fromUtf8("NPWA"));
  QCOMPARE(i.track(17).get(Title).toString(),QString::fromUtf8("St. Monday"));
97
  QCOMPARE(i.track(18).get(Title).toString(),QString::fromUtf8("Somedays I See the Point"));
98
  QCOMPARE(i.track(19).get(Title).toString(),QString::fromUtf8("Take Down the Union Jack (Band version)"));
99
  for (int j=0; j < 12; j++)
100
    QCOMPARE(i.track(j).get(Artist).toString(),QString::fromUtf8("Billy Bragg"));
101
  for (int j=12; j < 15; j++)
102
    QCOMPARE(i.track(j).get(Artist).toString(),QString::fromUtf8("Billy Bragg & Wilco"));
103
  for (int j=15; j < 20; j++)
104
    QCOMPARE(i.track(j).get(Artist).toString(),QString::fromUtf8("Billy Bragg and The Blokes"));
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
  // comments not supported in a simple way
  for (int j=0; j < 19; j++)
    QCOMPARE(i.track(j).get(Comment).toString(),QString());

  // Make sure it's the same when loaded from the cache again
  c.config().setCacheLookupEnabled(true);
  c.config().setFreedbLookupEnabled(false);
  c.config().setMusicBrainzLookupEnabled(false);

  c.lookup(list);

  response = c.lookupResponse();
  QVERIFY(response.count() > 0);

  CDInfo cacheInfo(response.first());
  QCOMPARE(i.get(Artist).toString(),cacheInfo.get(Artist).toString());
  QCOMPARE(i.get(Title).toString(),cacheInfo.get(Title).toString());
  QCOMPARE(i.get(Year).toInt(),cacheInfo.get(Year).toInt());
  for (int j=0; j < 19; j++)
  {
    QCOMPARE(i.track(j).get(Title).toString(),cacheInfo.track(j).get(Title).toString());
    QCOMPARE(i.track(j).get(Comment).toString(),cacheInfo.track(j).get(Comment).toString());
  }
}

130
131
Q_COREAPP_STARTUP_FUNCTION(setEnvironment)

132
QTEST_GUILESS_MAIN(MusicBrainzTestSeveralDiscs)