Commit 29b0747b authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Move media view volumes above shortcuts

This change is following: go/filesapp-2018-mocks

Bug: 846587
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: I066b3670ef0c06bc2b170ecd8991b6940fdac637
Reviewed-on: https://chromium-review.googlesource.com/1137804Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575199}
parent 2dffee07
...@@ -467,15 +467,16 @@ NavigationListModel.prototype.flatNavigationItems_ = function() { ...@@ -467,15 +467,16 @@ NavigationListModel.prototype.flatNavigationItems_ = function() {
* Reorder navigation items and nest some within "Downloads" * Reorder navigation items and nest some within "Downloads"
* which will be displayed as "My-Files". Desired order: * which will be displayed as "My-Files". Desired order:
* 1. Recents. * 1. Recents.
* 2. Shortcuts. * 2. Media Views (Images, Videos and Audio).
* 3. "My-Files" (grouping), actually Downloads volume. * 3. Shortcuts.
* 3.1. Downloads * 4. "My-Files" (grouping), actually Downloads volume.
* 3.2. Play files (android volume) (if enabled). * 4.1. Downloads
* 3.3. Linux files (crostini volume or fake item) (if enabled). * 4.2. Play files (android volume) (if enabled).
* 4. Other volumes (MTP, ARCHIVE, REMOVABLE). * 4.3. Linux files (crostini volume or fake item) (if enabled).
* 5. Drive volumes. * 5. Other volumes (MTP, ARCHIVE, REMOVABLE).
* 6. Other FSP (File System Provider) (when mounted). * 6. Drive volumes.
* 7. Add new services if (it exists). * 7. Other FSP (File System Provider) (when mounted).
* 8. Add new services if (it exists).
* @private * @private
*/ */
NavigationListModel.prototype.orderAndNestItems_ = function() { NavigationListModel.prototype.orderAndNestItems_ = function() {
...@@ -536,6 +537,14 @@ NavigationListModel.prototype.orderAndNestItems_ = function() { ...@@ -536,6 +537,14 @@ NavigationListModel.prototype.orderAndNestItems_ = function() {
if (this.recentModelItem_) if (this.recentModelItem_)
this.navigationItems_.push(this.recentModelItem_); this.navigationItems_.push(this.recentModelItem_);
// Media View (Images, Videos and Audio).
for (const mediaView of getVolumes(
VolumeManagerCommon.VolumeType.MEDIA_VIEW)) {
this.navigationItems_.push(mediaView);
mediaView.section = NavigationSection.TOP;
}
// Shortcuts.
for (const shortcut of this.shortcutList_) for (const shortcut of this.shortcutList_)
this.navigationItems_.push(shortcut); this.navigationItems_.push(shortcut);
...@@ -603,7 +612,6 @@ NavigationListModel.prototype.orderAndNestItems_ = function() { ...@@ -603,7 +612,6 @@ NavigationListModel.prototype.orderAndNestItems_ = function() {
// section. // section.
const otherVolumes = const otherVolumes =
[].concat( [].concat(
getVolumes(VolumeManagerCommon.VolumeType.MEDIA_VIEW),
getVolumes(VolumeManagerCommon.VolumeType.REMOVABLE), getVolumes(VolumeManagerCommon.VolumeType.REMOVABLE),
getVolumes(VolumeManagerCommon.VolumeType.ARCHIVE), getVolumes(VolumeManagerCommon.VolumeType.ARCHIVE),
getVolumes(VolumeManagerCommon.VolumeType.MTP)) getVolumes(VolumeManagerCommon.VolumeType.MTP))
......
...@@ -198,22 +198,34 @@ function testOrderAndNestItems() { ...@@ -198,22 +198,34 @@ function testOrderAndNestItems() {
volumeManager.volumeInfoList.push( volumeManager.volumeInfoList.push(
MockVolumeManagerWrapper.createMockVolumeInfo( MockVolumeManagerWrapper.createMockVolumeInfo(
VolumeManagerCommon.VolumeType.ANDROID_FILES, 'android_files:droid')); VolumeManagerCommon.VolumeType.ANDROID_FILES, 'android_files:droid'));
volumeManager.volumeInfoList.push(
MockVolumeManagerWrapper.createMockVolumeInfo(
VolumeManagerCommon.VolumeType.MEDIA_VIEW, 'media_view:images_root'));
volumeManager.volumeInfoList.push(
MockVolumeManagerWrapper.createMockVolumeInfo(
VolumeManagerCommon.VolumeType.MEDIA_VIEW, 'media_view:videos_root'));
volumeManager.volumeInfoList.push(
MockVolumeManagerWrapper.createMockVolumeInfo(
VolumeManagerCommon.VolumeType.MEDIA_VIEW, 'media_view:audio_root'));
// Navigation items built above: // Navigation items built above:
// 1. fake-entry://recent // 1. fake-entry://recent
// 2. /root/shortcut // 2. media_view:images_root
// 3. /root/shortcut2 // 3. media_view:videos_root
// 4. My-Files // 4. media_view:audio_root
// 5. /root/shortcut
// 6. /root/shortcut2
// 7. My-Files
// -> Downloads // -> Downloads
// -> Play Files // -> Play Files
// -> Linux Files // -> Linux Files
// 5. removable:hoge // 8. removable:hoge
// 6. archive:a-zip // 9. archive:a-rar - mounted as archive
// 7. removable:fuga // 10. removable:fuga
// 8. mtp:a-phone // 11. mtp:a-phone
// 9. Drive - from setup() // 12. Drive - from setup()
// 10. provided:prov1 // 13. provided:prov1
// 11. provided:prov2 // 14. provided:prov2
// Constructor already calls orderAndNestItems_. // Constructor already calls orderAndNestItems_.
const model = new NavigationListModel( const model = new NavigationListModel(
...@@ -221,54 +233,67 @@ function testOrderAndNestItems() { ...@@ -221,54 +233,67 @@ function testOrderAndNestItems() {
// Check items order and that MTP/Archive/Removable respect the original // Check items order and that MTP/Archive/Removable respect the original
// order. // order.
assertEquals(11, model.length); assertEquals(14, model.length);
assertEquals('recent-label', model.item(0).label); assertEquals('recent-label', model.item(0).label);
assertEquals('shortcut', model.item(1).label);
assertEquals('shortcut2', model.item(2).label); assertEquals('media_view:images_root', model.item(1).label);
assertEquals('My Files', model.item(3).label); assertEquals('media_view:videos_root', model.item(2).label);
assertEquals('removable:hoge', model.item(4).label); assertEquals('media_view:audio_root', model.item(3).label);
assertEquals('archive:a-zip', model.item(5).label);
assertEquals('removable:fuga', model.item(6).label); assertEquals('shortcut', model.item(4).label);
assertEquals('mtp:a-phone', model.item(7).label); assertEquals('shortcut2', model.item(5).label);
assertEquals('My Drive', model.item(8).label); assertEquals('My Files', model.item(6).label);
assertEquals('provided:prov1', model.item(9).label); assertEquals('removable:hoge', model.item(7).label);
assertEquals('provided:prov2', model.item(10).label); assertEquals('archive:a-zip', model.item(8).label);
assertEquals('removable:fuga', model.item(9).label);
assertEquals('mtp:a-phone', model.item(10).label);
assertEquals('My Drive', model.item(11).label);
assertEquals('provided:prov1', model.item(12).label);
assertEquals('provided:prov2', model.item(13).label);
// Check NavigationSection, which defaults to TOP. // Check NavigationSection, which defaults to TOP.
// recent-label. // recent-label.
assertEquals(NavigationSection.TOP, model.item(0).section); assertEquals(NavigationSection.TOP, model.item(0).section);
// shortcut. // Media View.
// Images.
assertEquals(NavigationSection.TOP, model.item(1).section); assertEquals(NavigationSection.TOP, model.item(1).section);
// shortcut2. // Videos.
assertEquals(NavigationSection.TOP, model.item(2).section); assertEquals(NavigationSection.TOP, model.item(2).section);
// Audio.
assertEquals(NavigationSection.TOP, model.item(3).section);
// shortcut.
assertEquals(NavigationSection.TOP, model.item(4).section);
// shortcut2.
assertEquals(NavigationSection.TOP, model.item(5).section);
// My Files. // My Files.
assertEquals(NavigationSection.MY_FILES, model.item(3).section); assertEquals(NavigationSection.MY_FILES, model.item(6).section);
// MTP/Archive/Removable are grouped together. // MTP/Archive/Removable are grouped together.
// removable:hoge. // removable:hoge.
assertEquals(NavigationSection.REMOVABLE, model.item(4).section); assertEquals(NavigationSection.REMOVABLE, model.item(7).section);
// archive:a-zip. // archive:a-zip.
assertEquals(NavigationSection.REMOVABLE, model.item(5).section); assertEquals(NavigationSection.REMOVABLE, model.item(8).section);
// removable:fuga. // removable:fuga.
assertEquals(NavigationSection.REMOVABLE, model.item(6).section); assertEquals(NavigationSection.REMOVABLE, model.item(9).section);
// mtp:a-phone. // mtp:a-phone.
assertEquals(NavigationSection.REMOVABLE, model.item(7).section); assertEquals(NavigationSection.REMOVABLE, model.item(10).section);
// Drive and FSP are grouped together. // Drive and FSP are grouped together.
// My Drive. // My Drive.
assertEquals(NavigationSection.CLOUD, model.item(8).section); assertEquals(NavigationSection.CLOUD, model.item(11).section);
// provided:prov1. // provided:prov1.
assertEquals(NavigationSection.CLOUD, model.item(9).section); assertEquals(NavigationSection.CLOUD, model.item(12).section);
// provided:prov2. // provided:prov2.
assertEquals(NavigationSection.CLOUD, model.item(10).section); assertEquals(NavigationSection.CLOUD, model.item(13).section);
const myFilesModel = model.item(3); const myFilesModel = model.item(6);
// Re-order again. // Re-order again.
model.orderAndNestItems_(); model.orderAndNestItems_();
// Check if My Files continues on the same position. // Check if My Files continues on the same position.
assertEquals(NavigationSection.MY_FILES, model.item(3).section); assertEquals(NavigationSection.MY_FILES, model.item(6).section);
// Check if My Files model is still the same instance, because DirectoryTree // Check if My Files model is still the same instance, because DirectoryTree
// expects it to be the same instance to be able to find it on the tree. // expects it to be the same instance to be able to find it on the tree.
assertEquals(myFilesModel, model.item(3)); assertEquals(myFilesModel, model.item(6));
} }
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