~ubuntu-branches/ubuntu/oneiric/phonon/oneiric-201108111512

« back to all changes in this revision

Viewing changes to phonon/tests/mrltest.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Romain Perier
  • Date: 2011-03-29 18:52:38 UTC
  • mfrom: (0.5.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110329185238-zsdke31jv37427js
Tags: 4:4.7.0really4.5.0-0ubuntu1
* New upstream release, LP: #750480
* Create new package libphonon4-designer for the Qt4 Designer plugin
* Add libqzeitgeist to build dependencies
* debian/libphononexperimental4.install:
  Change library name to libphononexperimental4.so.4.*
* Update symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  This file is part of the KDE project
 
2
    Copyright (C) 2011 Harald Sitter <sitter@kde.org>
 
3
 
 
4
    This library is free software; you can redistribute it and/or
 
5
    modify it under the terms of the GNU Lesser General Public
 
6
    License as published by the Free Software Foundation; either
 
7
    version 2.1 of the License, or (at your option) version 3, or any
 
8
    later version accepted by the membership of KDE e.V. (or its
 
9
    successor approved by the membership of KDE e.V.), Nokia Corporation
 
10
    (or its successors, if any) and the KDE Free Qt Foundation, which shall
 
11
    act as a proxy defined in Section 6 of version 3 of the license.
 
12
 
 
13
    This library is distributed in the hope that it will be useful,
 
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
    Lesser General Public License for more details.
 
17
 
 
18
    You should have received a copy of the GNU Lesser General Public
 
19
    License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
20
*/
 
21
 
 
22
#include "../mrl.h"
 
23
 
 
24
#include <QtCore/QDebug>
 
25
#include <QtTest/QTest>
 
26
 
 
27
class MrlTest : public QObject
 
28
{
 
29
    Q_OBJECT
 
30
private Q_SLOTS:
 
31
    void initTestCase();
 
32
 
 
33
    void testDCtor();
 
34
    void testCCtor();
 
35
    void testQUrlCtor();
 
36
    void testQStringCtor();
 
37
    void testAssignment();
 
38
#ifndef QT_NO_URL_CAST_FROM_STRING
 
39
    void testQStringAssingment();
 
40
#endif
 
41
 
 
42
    void testLocalEncodingWithoutScheme();
 
43
    void testLocalEncodingWithScheme();
 
44
    void testUrlEncoding();
 
45
 
 
46
    void testImplicitSharing();
 
47
 
 
48
    void cleanupTestCase();
 
49
};
 
50
 
 
51
using namespace Phonon;
 
52
 
 
53
void MrlTest::initTestCase()
 
54
{
 
55
}
 
56
 
 
57
void MrlTest::testDCtor()
 
58
{
 
59
    Mrl mrl;
 
60
    QCOMPARE(mrl.isValid(), false);
 
61
    QCOMPARE(mrl.toString(), QString());
 
62
}
 
63
 
 
64
void MrlTest::testCCtor()
 
65
{
 
66
    Mrl mrl(QString("/usr/share/sounds/KDE_Beep.ogg"));
 
67
 
 
68
    Mrl newMrl(mrl);
 
69
 
 
70
    QCOMPARE(newMrl.isValid(), mrl.isValid());
 
71
    QCOMPARE(newMrl.toString(), mrl.toString());
 
72
}
 
73
 
 
74
void MrlTest::testQUrlCtor()
 
75
{
 
76
    QUrl qurl(QString("/usr/share/sounds/KDE_Beep.ogg"));
 
77
 
 
78
    Mrl mrl(qurl);
 
79
 
 
80
    QCOMPARE(mrl.isValid(), qurl.isValid());
 
81
    QCOMPARE(mrl.toString(), qurl.toString());
 
82
}
 
83
 
 
84
void MrlTest::testQStringCtor()
 
85
{
 
86
    QString url("/usr/share/sounds/KDE_Beep.ogg");
 
87
    QUrl qurl(url);
 
88
 
 
89
    Mrl mrl(url);
 
90
 
 
91
    QCOMPARE(mrl.isValid(), qurl.isValid());
 
92
    QCOMPARE(mrl.toString(), qurl.toString());
 
93
    QCOMPARE(mrl.toString(), url);
 
94
}
 
95
 
 
96
void MrlTest::testAssignment()
 
97
{
 
98
    Mrl mrl(QString("/usr/share/sounds/KDE_Beep.ogg"));
 
99
 
 
100
    Mrl newMrl = mrl;
 
101
 
 
102
    QCOMPARE(newMrl.isValid(), mrl.isValid());
 
103
    QCOMPARE(newMrl.toString(), mrl.toString());
 
104
}
 
105
 
 
106
#ifndef QT_NO_URL_CAST_FROM_STRING
 
107
void MrlTest::testQStringAssingment()
 
108
{
 
109
    QString filename("/usr/share/sounds/KDE_Beep.ogg");
 
110
 
 
111
    Mrl mrl;
 
112
    mrl = filename;
 
113
 
 
114
    QCOMPARE(mrl.toString(), filename);
 
115
}
 
116
#endif
 
117
 
 
118
void MrlTest::testLocalEncodingWithoutScheme()
 
119
{
 
120
    QString url("/home/test/Geräteüberhöhung.mp3");
 
121
    Mrl mrl(url);
 
122
    QUrl qurl(url);
 
123
    qurl.setScheme(QString("file://"));
 
124
 
 
125
    qDebug() << "MRL: " << mrl.toEncoded();
 
126
    qDebug() << "QURL: " << qurl.toEncoded();
 
127
 
 
128
    QEXPECT_FAIL("", "QUrl produces expected bogus encoded", Continue);
 
129
    QCOMPARE(mrl.toEncoded(), qurl.toEncoded());
 
130
    QCOMPARE(mrl.toEncoded(), QByteArray("file:///home/test/Ger%C3%A4te%C3%BCberh%C3%B6hung.mp3"));
 
131
}
 
132
 
 
133
void MrlTest::testLocalEncodingWithScheme()
 
134
{
 
135
    QString url("file:///home/test/Geräteüberhöhung.mp3");
 
136
    Mrl mrl(url);
 
137
    QUrl qurl(url);
 
138
 
 
139
    QEXPECT_FAIL("", "QUrl produces expected bogus encoded", Continue);
 
140
    QCOMPARE(mrl.toEncoded(), qurl.toEncoded());
 
141
    QCOMPARE(mrl.toEncoded(), QByteArray("file:///home/test/Ger%C3%A4te%C3%BCberh%C3%B6hung.mp3"));
 
142
}
 
143
 
 
144
void MrlTest::testUrlEncoding()
 
145
{
 
146
    QString url("http://user@häst.eu/a/b/c/d/Geräteüberhöhung.mp3");
 
147
    Mrl mrl(url);
 
148
    QUrl qurl(url);
 
149
 
 
150
    QCOMPARE(mrl.toEncoded(), qurl.toEncoded());
 
151
}
 
152
 
 
153
void MrlTest::testImplicitSharing()
 
154
{
 
155
    QString url("/usr/share/sounds/KDE_Beep.ogg");
 
156
    QUrl qurl(QString("/usr/share/sounds/KDE_Beep.ogg"));
 
157
    Mrl mrl(qurl);
 
158
 
 
159
    mrl.setHost(QString("randomhost.com"));
 
160
    mrl.setScheme(QString("http"));
 
161
 
 
162
    QCOMPARE(mrl.toString(), QString("http://randomhost.com/usr/share/sounds/KDE_Beep.ogg"));
 
163
    QCOMPARE(qurl.toString(), url);
 
164
}
 
165
 
 
166
void MrlTest::cleanupTestCase()
 
167
{
 
168
}
 
169
 
 
170
QTEST_APPLESS_MAIN(MrlTest)
 
171
 
 
172
#include "mrltest.moc"