Commit 5b081495 authored by Omid Tourzan's avatar Omid Tourzan Committed by Commit Bot

[partition-as-single] Show device in nav tree for single partition.

Bug: 491043
Change-Id: I491dab8627493b91bf4b109707d03130b09c6c1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2402850
Commit-Queue: Omid Tourzan <oto@chromium.org>
Reviewed-by: default avatarAustin Tankiang <austinct@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809510}
parent 205df2b0
...@@ -696,7 +696,8 @@ class NavigationListModel extends cr.EventTarget { ...@@ -696,7 +696,8 @@ class NavigationListModel extends cr.EventTarget {
// Add REMOVABLE volumes and partitions. // Add REMOVABLE volumes and partitions.
const removableModels = new Map(); const removableModels = new Map();
for (const [devicePath, removableGroup] of groupRemovables().entries()) { for (const [devicePath, removableGroup] of groupRemovables().entries()) {
if (removableGroup.length == 1) { if (removableGroup.length == 1 &&
!util.isSinglePartitionFormatEnabled()) {
// Add unpartitioned removable device as a regular volume. // Add unpartitioned removable device as a regular volume.
this.navigationItems_.push(removableGroup[0]); this.navigationItems_.push(removableGroup[0]);
removableGroup[0].section = NavigationSection.REMOVABLE; removableGroup[0].section = NavigationSection.REMOVABLE;
......
...@@ -200,6 +200,14 @@ function testAddAndRemoveShortcuts() { ...@@ -200,6 +200,14 @@ function testAddAndRemoveShortcuts() {
(model.item(0)).label); (model.item(0)).label);
} }
/**
* Tests testAddAndRemoveVolumes test with SinglePartitionFormat flag is on.
*/
function testAddAndRemoveVolumesWhenSinglePartitionOn() {
window.loadTimeData.data_['FILES_SINGLE_PARTITION_FORMAT_ENABLED'] = true;
testAddAndRemoveVolumes();
}
/** /**
* Tests adding and removing volumes. * Tests adding and removing volumes.
*/ */
...@@ -229,9 +237,17 @@ function testAddAndRemoveVolumes() { ...@@ -229,9 +237,17 @@ function testAddAndRemoveVolumes() {
assertEquals( assertEquals(
'drive', /** @type {!NavigationModelVolumeItem} */ 'drive', /** @type {!NavigationModelVolumeItem} */
(model.item(2)).volumeInfo.volumeId); (model.item(2)).volumeInfo.volumeId);
assertEquals( if (util.isSinglePartitionFormatEnabled()) {
'removable:hoge', /** @type {!NavigationModelVolumeItem} */ const drive = model.item(3);
(model.item(3)).volumeInfo.volumeId); assertEquals('External Drive', drive.label);
assertEquals(
'removable:hoge', /** @type {!NavigationModelFakeItem} */
(drive).entry.getUIChildren()[0].volumeInfo.volumeId);
} else {
assertEquals(
'removable:hoge', /** @type {!NavigationModelVolumeItem} */
(model.item(3)).volumeInfo.volumeId);
}
// Mount removable volume 'fuga'. Not a partition, so set a different device // Mount removable volume 'fuga'. Not a partition, so set a different device
// path to 'hoge'. // path to 'hoge'.
...@@ -247,12 +263,25 @@ function testAddAndRemoveVolumes() { ...@@ -247,12 +263,25 @@ function testAddAndRemoveVolumes() {
assertEquals( assertEquals(
'drive', /** @type {!NavigationModelVolumeItem} */ 'drive', /** @type {!NavigationModelVolumeItem} */
(model.item(2)).volumeInfo.volumeId); (model.item(2)).volumeInfo.volumeId);
assertEquals( if (util.isSinglePartitionFormatEnabled()) {
'removable:hoge', /** @type {!NavigationModelVolumeItem} */ const drive1 = model.item(3);
(model.item(3)).volumeInfo.volumeId); const drive2 = model.item(4);
assertEquals( assertEquals('External Drive', drive1.label);
'removable:fuga', /** @type {!NavigationModelVolumeItem} */ assertEquals('External Drive', drive2.label);
(model.item(4)).volumeInfo.volumeId); assertEquals(
'removable:hoge', /** @type {!NavigationModelFakeItem} */
(drive1).entry.getUIChildren()[0].volumeInfo.volumeId);
assertEquals(
'removable:fuga', /** @type {!NavigationModelFakeItem} */
(drive2).entry.getUIChildren()[0].volumeInfo.volumeId);
} else {
assertEquals(
'removable:hoge', /** @type {!NavigationModelVolumeItem} */
(model.item(3)).volumeInfo.volumeId);
assertEquals(
'removable:fuga', /** @type {!NavigationModelVolumeItem} */
(model.item(4)).volumeInfo.volumeId);
}
// Create a shortcut on the 'hoge' volume. // Create a shortcut on the 'hoge' volume.
shortcutListModel.splice(1, 0, MockFileEntry.create(hoge, '/shortcut2')); shortcutListModel.splice(1, 0, MockFileEntry.create(hoge, '/shortcut2'));
...@@ -268,12 +297,25 @@ function testAddAndRemoveVolumes() { ...@@ -268,12 +297,25 @@ function testAddAndRemoveVolumes() {
assertEquals( assertEquals(
'drive', /** @type {!NavigationModelVolumeItem} */ 'drive', /** @type {!NavigationModelVolumeItem} */
(model.item(3)).volumeInfo.volumeId); (model.item(3)).volumeInfo.volumeId);
assertEquals( if (util.isSinglePartitionFormatEnabled()) {
'removable:hoge', /** @type {!NavigationModelVolumeItem} */ assertEquals('External Drive', model.item(4).label);
(model.item(4)).volumeInfo.volumeId); assertEquals('External Drive', model.item(5).label);
assertEquals( } else {
'removable:fuga', /** @type {!NavigationModelVolumeItem} */ assertEquals(
(model.item(5)).volumeInfo.volumeId); 'removable:hoge', /** @type {!NavigationModelVolumeItem} */
(model.item(4)).volumeInfo.volumeId);
assertEquals(
'removable:fuga', /** @type {!NavigationModelVolumeItem} */
(model.item(5)).volumeInfo.volumeId);
}
}
/**
* Tests testOrderAndNestItems test with SinglePartitionFormat flag is on.
*/
function testOrderAndNestItemsWhenSinglePartitionOn() {
window.loadTimeData.data_['FILES_SINGLE_PARTITION_FORMAT_ENABLED'] = true;
testOrderAndNestItems();
} }
/** /**
...@@ -379,8 +421,13 @@ function testOrderAndNestItems() { ...@@ -379,8 +421,13 @@ function testOrderAndNestItems() {
assertEquals('provided:prov1', model.item(9).label); assertEquals('provided:prov1', model.item(9).label);
assertEquals('provided:prov2', model.item(10).label); assertEquals('provided:prov2', model.item(10).label);
assertEquals('removable:hoge', model.item(11).label); if (util.isSinglePartitionFormatEnabled()) {
assertEquals('removable:fuga', model.item(12).label); assertEquals('External Drive', model.item(11).label);
assertEquals('External Drive', model.item(12).label);
} else {
assertEquals('removable:hoge', model.item(11).label);
assertEquals('removable:fuga', model.item(12).label);
}
assertEquals('archive:a-rar', model.item(13).label); assertEquals('archive:a-rar', model.item(13).label);
assertEquals('mtp:a-phone', model.item(14).label); assertEquals('mtp:a-phone', model.item(14).label);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment