From 1f91b5c4fbff0ab1d2a8dd308c7ce00b92e40a40 Mon Sep 17 00:00:00 2001 From: Raine Makelainen Date: Thu, 17 Oct 2019 14:22:54 +0300 Subject: [PATCH] [nemo-systemsettings] Cleanup hardcoded nemo user. Fixes JB#47605 --- src/diskusage.cpp | 10 +++++----- tests/ut_diskusage.cpp | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/diskusage.cpp b/src/diskusage.cpp index 87f0a7e..c008954 100644 --- a/src/diskusage.cpp +++ b/src/diskusage.cpp @@ -98,8 +98,8 @@ QVariantMap DiskUsageWorker::calculate(QStringList paths) // Sort keys in reverse order (so child directories come before their // parents, and the calculation is done correctly, no child directory // subtracted once too often), for example: - // 1. a0 = size(/home/nemo/foo/) - // 2. b0 = size(/home/nemo/) + // 1. a0 = size(/home//foo/) + // 2. b0 = size(/home//) // 3. c0 = size(/) // // This will calculate the following changes in the nested for loop below: @@ -113,9 +113,9 @@ QVariantMap DiskUsageWorker::calculate(QStringList paths) // 3. c' = c2 = c1 - b1 = (c0 - a0) - (b0 - a0) = c0 - a0 - b0 + a0 = c0 - b0 // // Or with paths: - // 1. output(/home/nemo/foo/) = size(/home/nemo/foo/) - // 2. output(/home/nemo/) = size(/home/nemo/) - size(/home/nemo/foo/) - // 3. output(/) = size(/) - size(/home/nemo/) + // 1. output(/home//foo/) = size(/home//foo/) + // 2. output(/home//) = size(/home//) - size(/home//foo/) + // 3. output(/) = size(/) - size(/home//) QStringList keys; foreach (const QString &key, usage.uniqueKeys()) { keys << expandedPaths.value(key, key); diff --git a/tests/ut_diskusage.cpp b/tests/ut_diskusage.cpp index b4f6df6..27e1813 100644 --- a/tests/ut_diskusage.cpp +++ b/tests/ut_diskusage.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2015 Jolla Ltd. - * Contact: Thomas Perl + * Copyright (c) 2015 - 2019 Jolla Ltd. + * Copyright (c) 2019 Open Mobile Platform LLC. * * You may use this file under the terms of the BSD license as follows: * @@ -37,7 +37,7 @@ #include "ut_diskusage.h" #include - +#include static QVariantMap g_mocked_file_size; static QVariantMap g_mocked_rpm_size; @@ -131,37 +131,37 @@ void Ut_DiskUsage::testSubtractNestedSubdirectory() { g_mocked_file_size["/"] = MB(1000); g_mocked_file_size["/home/"] = MB(300); - g_mocked_file_size["/home/nemo/"] = MB(150); - g_mocked_file_size["/home/nemo/Documents/"] = MB(70); + g_mocked_file_size[QDir::homePath()] = MB(150); + g_mocked_file_size[QDir::homePath() + "/Documents/"] = MB(70); QVariantMap usage = DiskUsageWorker().calculate(QStringList() << - "/" << "/home/" << "/home/nemo/" << "/home/nemo/Documents/"); + "/" << "/home/" << QDir::homePath() << QDir::homePath() + "/Documents/"); UT_DISKUSAGE_EXPECT_SIZE("/", MB(1000) - MB(300)) UT_DISKUSAGE_EXPECT_SIZE("/home/", MB(300) - MB(150)) - UT_DISKUSAGE_EXPECT_SIZE("/home/nemo/", MB(150) - MB(70)) - UT_DISKUSAGE_EXPECT_SIZE("/home/nemo/Documents/", MB(70)) + UT_DISKUSAGE_EXPECT_SIZE(QDir::homePath(), MB(150) - MB(70)) + UT_DISKUSAGE_EXPECT_SIZE(QDir::homePath() + "/Documents/", MB(70)) } void Ut_DiskUsage::testSubtractNestedSubdirectoryMulti() { g_mocked_file_size["/"] = MB(1000); g_mocked_file_size["/home/"] = MB(300); - g_mocked_file_size["/home/nemo/"] = MB(150); - g_mocked_file_size["/home/nemo/Documents/"] = MB(70); + g_mocked_file_size[QDir::homePath()] = MB(150); + g_mocked_file_size[QDir::homePath() + "/Documents/"] = MB(70); g_mocked_file_size["/opt/"] = MB(100); g_mocked_file_size["/opt/foo/"] = MB(30); g_mocked_file_size["/opt/foo/bar/"] = MB(20); g_mocked_file_size["/opt/baz/"] = MB(10); QVariantMap usage = DiskUsageWorker().calculate(QStringList() << "/" << - "/home/" << "/home/nemo/" << "/home/nemo/Documents/" << + "/home/" << QDir::homePath() << QDir::homePath() + "/Documents/" << "/opt/" << "/opt/foo/" << "/opt/foo/bar/" << "/opt/baz/"); UT_DISKUSAGE_EXPECT_SIZE("/", MB(1000) - MB(300) - MB(100)) UT_DISKUSAGE_EXPECT_SIZE("/home/", MB(300) - MB(150)) - UT_DISKUSAGE_EXPECT_SIZE("/home/nemo/", MB(150) - MB(70)) - UT_DISKUSAGE_EXPECT_SIZE("/home/nemo/Documents/", MB(70)) + UT_DISKUSAGE_EXPECT_SIZE(QDir::homePath(), MB(150) - MB(70)) + UT_DISKUSAGE_EXPECT_SIZE(QDir::homePath() + "/Documents/", MB(70)) UT_DISKUSAGE_EXPECT_SIZE("/opt/", MB(100) - MB(30) - MB(10)) UT_DISKUSAGE_EXPECT_SIZE("/opt/foo/", MB(30) - MB(20)) UT_DISKUSAGE_EXPECT_SIZE("/opt/foo/bar/", MB(20))