File indexing completed on 2025-01-26 04:57:20

0001 /*
0002    SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "backoffmodemanagertest.h"
0008 #include "../backoffmodemanager.h"
0009 #include <QStandardPaths>
0010 #include <QTest>
0011 BackOffModeManagerTest::BackOffModeManagerTest(QObject *parent)
0012     : QObject(parent)
0013 {
0014     QStandardPaths::setTestModeEnabled(true);
0015 }
0016 
0017 BackOffModeManagerTest::~BackOffModeManagerTest() = default;
0018 
0019 void BackOffModeManagerTest::shouldHaveDefaultValue()
0020 {
0021     WebEngineViewer::BackOffModeManager manager;
0022     QVERIFY(!manager.isInBackOffMode());
0023     QCOMPARE(manager.numberOfHttpFailed(), 0);
0024 }
0025 
0026 void BackOffModeManagerTest::shouldStartBackOffMode()
0027 {
0028     WebEngineViewer::BackOffModeManager manager;
0029     manager.startOffMode();
0030     QVERIFY(manager.isInBackOffMode());
0031 }
0032 
0033 void BackOffModeManagerTest::shouldIncreaseBackOff()
0034 {
0035     WebEngineViewer::BackOffModeManager manager;
0036     for (int i = 0; i < 5; ++i) {
0037         manager.startOffMode();
0038     }
0039     QCOMPARE(manager.numberOfHttpFailed(), 5);
0040 }
0041 
0042 QTEST_GUILESS_MAIN(BackOffModeManagerTest)
0043 
0044 #include "moc_backoffmodemanagertest.cpp"