0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the test suite of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
|
|
43 |
#include <QtTest/QtTest>
|
|
44 |
#include <QtCore/QDir>
|
|
45 |
#include <QtCore/QFile>
|
|
46 |
#include <QtCore/QProcess>
|
|
47 |
|
|
48 |
class tst_MacPlist : public QObject
|
|
49 |
{
|
|
50 |
Q_OBJECT
|
|
51 |
public:
|
|
52 |
tst_MacPlist() {}
|
|
53 |
|
|
54 |
private slots:
|
|
55 |
#ifdef Q_OS_MAC
|
|
56 |
void test_plist_data();
|
|
57 |
void test_plist();
|
|
58 |
#endif
|
|
59 |
};
|
|
60 |
|
|
61 |
#ifdef Q_OS_MAC
|
|
62 |
void tst_MacPlist::test_plist_data()
|
|
63 |
{
|
|
64 |
QTest::addColumn<QString>("test_plist");
|
|
65 |
|
|
66 |
QTest::newRow("control") << QString::fromLatin1(
|
|
67 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
|
68 |
"<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">\n"
|
|
69 |
"<plist version=\"0.9\">\n"
|
|
70 |
"<dict>\n"
|
|
71 |
" <key>CFBundleIconFile</key>\n"
|
|
72 |
" <string></string>\n"
|
|
73 |
" <key>CFBundlePackageType</key>\n"
|
|
74 |
" <string>APPL</string>\n"
|
|
75 |
" <key>CFBundleGetInfoString</key>\n"
|
|
76 |
" <string>Created by Qt/QMake</string>\n"
|
|
77 |
" <key>CFBundleExecutable</key>\n"
|
|
78 |
" <string>app</string>\n"
|
|
79 |
" <key>CFBundleIdentifier</key>\n"
|
|
80 |
" <string>com.yourcompany.app</string>\n"
|
|
81 |
"</dict>\n"
|
|
82 |
"</plist>\n");
|
|
83 |
|
|
84 |
QTest::newRow("LSUIElement-as-string") << QString::fromLatin1(
|
|
85 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
|
86 |
"<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">\n"
|
|
87 |
"<plist version=\"0.9\">\n"
|
|
88 |
"<dict>\n"
|
|
89 |
" <key>CFBundleIconFile</key>\n"
|
|
90 |
" <string></string>\n"
|
|
91 |
" <key>CFBundlePackageType</key>\n"
|
|
92 |
" <string>APPL</string>\n"
|
|
93 |
" <key>CFBundleGetInfoString</key>\n"
|
|
94 |
" <string>Created by Qt/QMake</string>\n"
|
|
95 |
" <key>CFBundleExecutable</key>\n"
|
|
96 |
" <string>app</string>\n"
|
|
97 |
" <key>CFBundleIdentifier</key>\n"
|
|
98 |
" <string>com.yourcompany.app</string>\n"
|
|
99 |
" <key>LSUIElement</key>\n"
|
|
100 |
" <string>false</string>\n"
|
|
101 |
"</dict>\n"
|
|
102 |
"</plist>\n");
|
|
103 |
|
|
104 |
QTest::newRow("LSUIElement-as-bool") << QString::fromLatin1(
|
|
105 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
|
106 |
"<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">\n"
|
|
107 |
"<plist version=\"0.9\">\n"
|
|
108 |
"<dict>\n"
|
|
109 |
" <key>CFBundleIconFile</key>\n"
|
|
110 |
" <string></string>\n"
|
|
111 |
" <key>CFBundlePackageType</key>\n"
|
|
112 |
" <string>APPL</string>\n"
|
|
113 |
" <key>CFBundleGetInfoString</key>\n"
|
|
114 |
" <string>Created by Qt/QMake</string>\n"
|
|
115 |
" <key>CFBundleExecutable</key>\n"
|
|
116 |
" <string>app</string>\n"
|
|
117 |
" <key>CFBundleIdentifier</key>\n"
|
|
118 |
" <string>com.yourcompany.app</string>\n"
|
|
119 |
" <key>LSUIElement</key>\n"
|
|
120 |
" <false/>\n"
|
|
121 |
"</dict>\n"
|
|
122 |
"</plist>\n");
|
|
123 |
|
|
124 |
QTest::newRow("LSUIElement-as-int") << QString::fromLatin1(
|
|
125 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
|
126 |
"<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">\n"
|
|
127 |
"<plist version=\"0.9\">\n"
|
|
128 |
"<dict>\n"
|
|
129 |
" <key>CFBundleIconFile</key>\n"
|
|
130 |
" <string></string>\n"
|
|
131 |
" <key>CFBundlePackageType</key>\n"
|
|
132 |
" <string>APPL</string>\n"
|
|
133 |
" <key>CFBundleGetInfoString</key>\n"
|
|
134 |
" <string>Created by Qt/QMake</string>\n"
|
|
135 |
" <key>CFBundleExecutable</key>\n"
|
|
136 |
" <string>app</string>\n"
|
|
137 |
" <key>CFBundleIdentifier</key>\n"
|
|
138 |
" <string>com.yourcompany.app</string>\n"
|
|
139 |
" <key>LSUIElement</key>\n"
|
|
140 |
" <real>0</real>\n"
|
|
141 |
"</dict>\n"
|
|
142 |
"</plist>\n");
|
|
143 |
|
|
144 |
QTest::newRow("LSUIElement-as-garbage") << QString::fromLatin1(
|
|
145 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
|
146 |
"<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">\n"
|
|
147 |
"<plist version=\"0.9\">\n"
|
|
148 |
"<dict>\n"
|
|
149 |
" <key>CFBundleIconFile</key>\n"
|
|
150 |
" <string></string>\n"
|
|
151 |
" <key>CFBundlePackageType</key>\n"
|
|
152 |
" <string>APPL</string>\n"
|
|
153 |
" <key>CFBundleGetInfoString</key>\n"
|
|
154 |
" <string>Created by Qt/QMake</string>\n"
|
|
155 |
" <key>CFBundleExecutable</key>\n"
|
|
156 |
" <string>app</string>\n"
|
|
157 |
" <key>CFBundleIdentifier</key>\n"
|
|
158 |
" <string>com.yourcompany.app</string>\n"
|
|
159 |
" <key>LSUIElement</key>\n"
|
|
160 |
" <badkey>0</badkey>\n"
|
|
161 |
"</dict>\n"
|
|
162 |
"</plist>\n");
|
|
163 |
}
|
|
164 |
|
|
165 |
void tst_MacPlist::test_plist()
|
|
166 |
{
|
|
167 |
QFETCH(QString, test_plist);
|
|
168 |
|
|
169 |
QString infoPlist = QLatin1String("Info.plist");
|
|
170 |
QDir dir(QCoreApplication::applicationDirPath());
|
|
171 |
QVERIFY(dir.cdUp());
|
|
172 |
QVERIFY(dir.cdUp());
|
|
173 |
QVERIFY(dir.cdUp());
|
|
174 |
QVERIFY(dir.cd(QLatin1String("app")));
|
|
175 |
QVERIFY(dir.cd(QLatin1String("app.app")));
|
|
176 |
QVERIFY(dir.cd(QLatin1String("Contents")));
|
|
177 |
QVERIFY(dir.exists(infoPlist));
|
|
178 |
{
|
|
179 |
QFile file(dir.filePath(infoPlist));
|
|
180 |
QVERIFY(file.open(QIODevice::WriteOnly));
|
|
181 |
QByteArray ba = test_plist.toUtf8();
|
|
182 |
QCOMPARE(file.write(ba), qint64(ba.size()));
|
|
183 |
}
|
|
184 |
QVERIFY(dir.cd(QLatin1String("MacOS")));
|
|
185 |
QVERIFY(dir.exists(QLatin1String("app")));
|
|
186 |
QProcess process;
|
|
187 |
process.start(dir.filePath("app"));
|
|
188 |
QCOMPARE(process.waitForFinished(), true);
|
|
189 |
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
|
190 |
}
|
|
191 |
#endif
|
|
192 |
|
|
193 |
QTEST_MAIN(tst_MacPlist)
|
|
194 |
#include "tst_macplist.moc"
|