File indexing completed on 2024-12-22 04:10:30
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kis_store_limits_test.h" 0008 #include <simpletest.h> 0009 0010 #include "kis_debug.h" 0011 0012 #include "kis_image_config.h" 0013 #include "tiles3/swap/kis_tile_data_swapper_p.h" 0014 0015 void KisStoreLimitsTest::testLimits() 0016 { 0017 KisImageConfig config(false); 0018 config.setMemoryHardLimitPercent(50); 0019 config.setMemorySoftLimitPercent(25); 0020 config.setMemoryPoolLimitPercent(10); 0021 0022 int emergencyThreshold = MiB_TO_METRIC(config.tilesHardLimit()); 0023 0024 int hardLimitThreshold = emergencyThreshold - (emergencyThreshold / 8); 0025 int hardLimit = hardLimitThreshold - (hardLimitThreshold / 8); 0026 0027 int softLimitThreshold = qBound(0, MiB_TO_METRIC(config.tilesSoftLimit()), hardLimitThreshold); 0028 int softLimit = softLimitThreshold - softLimitThreshold / 8; 0029 0030 KisStoreLimits limits; 0031 0032 QCOMPARE(limits.emergencyThreshold(), emergencyThreshold); 0033 QCOMPARE(limits.hardLimitThreshold(), hardLimitThreshold); 0034 QCOMPARE(limits.hardLimit(), hardLimit); 0035 QCOMPARE(limits.softLimitThreshold(), softLimitThreshold); 0036 QCOMPARE(limits.softLimit(), softLimit); 0037 } 0038 0039 SIMPLE_TEST_MAIN(KisStoreLimitsTest) 0040