From de53387756d8daa4c7b8cf77967d21a269a4ab62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 23 Sep 2024 13:12:41 -0700 Subject: [PATCH] PartitioningView: add test disk/partition data --- src/Views/PartitioningView.vala | 56 ++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/Views/PartitioningView.vala b/src/Views/PartitioningView.vala index 3b6b8d0d8..6d62b44e4 100644 --- a/src/Views/PartitioningView.vala +++ b/src/Views/PartitioningView.vala @@ -159,7 +159,11 @@ public class Installer.PartitioningView : AbstractInstallerView { InstallerDaemon.DiskInfo? disks = null; try { - disks = yield Daemon.get_default ().get_disks (true); + if (!Installer.App.test_mode) { + disks = yield Daemon.get_default ().get_disks (true); + } else { + disks = get_test_diskinfo (); + } } catch (Error e) { critical ("Unable to get disks: %s", e.message); load_stack.set_visible_child_name ("disk"); @@ -343,4 +347,54 @@ public class Installer.PartitioningView : AbstractInstallerView { array[index] = array[array.size - 1]; return array.remove_at (array.size - 1); } + + private InstallerDaemon.DiskInfo get_test_diskinfo () { + InstallerDaemon.Disk[] physical_disks = {}; + InstallerDaemon.Disk[] logical_disks = {}; + + InstallerDaemon.Partition[] partitions = {}; + + var usage_1 = Distinst.PartitionUsage () { + tag = 1, + value = 30312 + }; + + partitions += InstallerDaemon.Partition () { + device_path = "/dev/nvme0n1p1", + filesystem = InstallerDaemon.FileSystem.FAT32, + start_sector = 4096, + end_sector = 542966, + sectors_used = usage_1, + current_lvm_volume_group = "" + }; + + var usage_2 = Distinst.PartitionUsage () { + tag = 0, + value = 0 + }; + + partitions += InstallerDaemon.Partition () { + device_path = "/dev/nvme0n1p2", + filesystem = InstallerDaemon.FileSystem.LVM, + start_sector = 542968, + end_sector = 976769070, + sectors_used = usage_2, + current_lvm_volume_group = "data" + }; + + physical_disks += InstallerDaemon.Disk () { + name = "Samsung SSD 970 EVO 500GB", + device_path = "/dev/nvme0n1", + sectors = 976773168, + sector_size = 512, + rotational = false, + removable = false, + partitions = partitions + }; + + return InstallerDaemon.DiskInfo () { + physical_disks = physical_disks, + logical_disks = logical_disks + }; + } }