summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp4
-rw-r--r--tests/auto/other/android/android.pro11
-rw-r--r--tests/auto/other/android/testdata/assets/test.txt1
-rw-r--r--tests/auto/other/android/tst_android.cpp69
-rw-r--r--tests/auto/other/other.pro3
5 files changed, 85 insertions, 3 deletions
diff --git a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
index 2010c19bd4..6ff4c50c40 100644
--- a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
+++ b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
@@ -133,9 +133,7 @@ public:
virtual bool open(QIODevice::OpenMode openMode)
{
- if (m_assetFile)
- return openMode & QIODevice::ReadOnly;
- return false;
+ return m_assetFile != 0 && (openMode & QIODevice::WriteOnly) == 0;
}
virtual bool close()
diff --git a/tests/auto/other/android/android.pro b/tests/auto/other/android/android.pro
new file mode 100644
index 0000000000..60faf8050e
--- /dev/null
+++ b/tests/auto/other/android/android.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TARGET = tst_android
+QT = core testlib
+
+SOURCES += \
+ tst_android.cpp
+
+ANDROID_PACKAGE_SOURCE_DIR = $$PWD/testdata
+
+DISTFILES += \
+ testdata/assets/test.txt
diff --git a/tests/auto/other/android/testdata/assets/test.txt b/tests/auto/other/android/testdata/assets/test.txt
new file mode 100644
index 0000000000..61e2c47c25
--- /dev/null
+++ b/tests/auto/other/android/testdata/assets/test.txt
@@ -0,0 +1 @@
+FooBar \ No newline at end of file
diff --git a/tests/auto/other/android/tst_android.cpp b/tests/auto/other/android/tst_android.cpp
new file mode 100644
index 0000000000..245382ded3
--- /dev/null
+++ b/tests/auto/other/android/tst_android.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+class tst_Android : public QObject
+{
+Q_OBJECT
+private slots:
+ void assetsRead();
+ void assetsNotWritable();
+};
+
+void tst_Android::assetsRead()
+{
+ {
+ QFile file("assets:/test.txt");
+ QVERIFY(file.open(QIODevice::ReadOnly));
+ QCOMPARE(file.readAll(), QByteArray("FooBar"));
+ }
+
+ {
+ QFile file("assets:/test.txt");
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
+ QCOMPARE(file.readAll(), QByteArray("FooBar"));
+ }
+}
+
+void tst_Android::assetsNotWritable()
+{
+ QFile file("assets:/test.txt");
+ QVERIFY(!file.open(QIODevice::WriteOnly));
+ QVERIFY(!file.open(QIODevice::ReadWrite));
+ QVERIFY(!file.open(QIODevice::Append));
+}
+
+QTEST_MAIN(tst_Android)
+#include "tst_android.moc"
+
diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro
index 9f7d45e562..c5673727be 100644
--- a/tests/auto/other/other.pro
+++ b/tests/auto/other/other.pro
@@ -71,3 +71,6 @@ wince*|!contains(QT_CONFIG, accessibility): SUBDIRS -= qaccessibility
winrt: SUBDIRS -= \
qprocess_and_guieventloop
+
+android: SUBDIRS += \
+ android