-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathtestnetworksettings.cpp
More file actions
56 lines (44 loc) 路 1.57 KB
/
Copy pathtestnetworksettings.cpp
File metadata and controls
56 lines (44 loc) 路 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: CC0-1.0
*
* This software is in the public domain, furnished "as is", without technical
* support, and with no warranty, express or implied, as to its usefulness for
* any purpose.
*/
#include <QtTest>
#include "account.h"
#include "testhelper.h"
#include "foldermantestutils.h"
#include "logger.h"
#include "networksettings.h"
using namespace OCC;
class TestNetworkSettings : public QObject
{
Q_OBJECT
FolderManTestHelper helper;
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void test_whenAccountIsLoggedOut_doesNotCrash()
{
// Create an account that is not registered in AccountManager
// This simulates a logged-out account scenario
auto account = Account::create();
account->setUrl(QUrl(QStringLiteral("https://example.com")));
account->setDavUser(QStringLiteral("testuser"));
// Create NetworkSettings with this account
// When proxy settings are changed, saveProxySettings() will try to
// get accountState from AccountManager, which will return nullptr
// This test ensures the app doesn't crash in that scenario
NetworkSettings settings(account);
// The test passes if we reach here without crashing
QVERIFY(true);
}
};
QTEST_MAIN(TestNetworkSettings)
#include "testnetworksettings.moc"