Skip to content

Commit

Permalink
PartitioningView: add test disk/partition data
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Sep 23, 2024
1 parent 595e771 commit de53387
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion src/Views/PartitioningView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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
};
}
}

0 comments on commit de53387

Please sign in to comment.