Warning, /pim/kube/views/log/tests/tst_logview.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * Copyright 2017 Christian Mollekopf <mollekopf@kolabsys.com>
0003 *
0004 * This program is free software; you can redistribute it and/or modify
0005 * it under the terms of the GNU Library General Public License as
0006 * published by the Free Software Foundation; either version 2, or
0007 * (at your option) any later version.
0008 *
0009 * This program is distributed in the hope that it will be useful,
0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0012 * GNU Library General Public License for more details
0013 *
0014 * You should have received a copy of the GNU Library General Public
0015 * License along with this program; if not, write to the
0016 * Free Software Foundation, Inc.,
0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018 */
0019
0020 import QtQuick 2.7
0021 import QtTest 1.0
0022 import org.kube.framework 1.0 as Kube
0023 import org.kube.test 1.0
0024 import "../qml"
0025
0026 ViewTestCase {
0027 id: logviewTestcase
0028 name: "LogView"
0029
0030 View {
0031 id: logView
0032 }
0033
0034 function test_logview() {
0035 var listModel = findChild(logView, "logModel");
0036 verify(listModel)
0037 compare(listModel.rowCount(), 0)
0038 //ignore progress
0039 Kube.Fabric.postMessage(Kube.Messages.progressNotification, {})
0040 compare(listModel.rowCount(), 0)
0041
0042 Kube.Fabric.postMessage(Kube.Messages.notification, {type: Kube.Notifications.info, message: "foobar", resource: "resource"})
0043 tryVerify(function(){ return listModel.rowCount() == 1})
0044 compare(logView.pendingError, false)
0045
0046 Kube.Fabric.postMessage(Kube.Messages.notification, {"type": Kube.Notifications.error, message: "foobar", resource: "resource"})
0047 tryVerify(function(){ return listModel.rowCount() == 2})
0048 compare(logView.pendingError, true)
0049
0050 //FIXME test the model contents again
0051 //Yes, this is ridiculous
0052 // compare(listModel.data(listModel.index(0, 0), Kube.LogModel.Type), Kube.Notifications.error)
0053 // compare(listModel.get(0).errors.rowCount(), 1)
0054 // compare(listModel.get(0).errors.get(0).message, "foobar")
0055 // compare(listModel.get(0).errors.get(0).resource, "resource")
0056
0057 Kube.Fabric.postMessage(Kube.Messages.notification, {"type": Kube.Notifications.error, "subtype": "merge", message: "merge1", resource: "resource1"})
0058 tryVerify(function(){ return listModel.rowCount() == 3})
0059
0060 //FIXME this test no longer works because async
0061 Kube.Fabric.postMessage(Kube.Messages.notification, {"type": Kube.Notifications.error, "subtype": "merge", message: "merge2", resource: "resource2"})
0062 compare(listModel.rowCount(), 3)
0063
0064 // compare(listModel.get(0).errors.rowCount(), 2)
0065 // compare(listModel.get(0).errors.get(0).message, "merge2")
0066 // compare(listModel.get(0).errors.get(0).resource, "resource2")
0067 }
0068 }