Commit 8e51b713 authored by Bo Majewski's avatar Bo Majewski Committed by Commit Bot

Files app: Fixes icons for files shown in Audio folder

Adds .opus as a know extension for OGG files. Browser would return
*.opus files as recent audio files, but file manager would not
set the correct icon on them.

Bug: 1067093
Change-Id: Ie14f06245004f96e6e86ba61353d0a3d7b584d09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2215389
Commit-Queue: Bo Majewski <majewski@chromium.org>
Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772148}
parent e49594aa
...@@ -225,7 +225,7 @@ FileType.types = [ ...@@ -225,7 +225,7 @@ FileType.types = [
type: 'audio', type: 'audio',
name: 'AUDIO_FILE_TYPE', name: 'AUDIO_FILE_TYPE',
subtype: 'OGG', subtype: 'OGG',
pattern: /\.og(a|g)$/i, pattern: /\.o(g(a|g)|pus)$/i,
mimePattern: /audio\/ogg/i mimePattern: /audio\/ogg/i
}, },
{ {
......
...@@ -37,3 +37,31 @@ function testDownloadsIcon() { ...@@ -37,3 +37,31 @@ function testDownloadsIcon() {
assertEquals('folder', FileType.getIcon(downloads, mimetype, driveRoot)); assertEquals('folder', FileType.getIcon(downloads, mimetype, driveRoot));
assertEquals('folder', FileType.getIcon(downloads, mimetype, androidRoot)); assertEquals('folder', FileType.getIcon(downloads, mimetype, androidRoot));
} }
function testGetTypeForName() {
const testItems = [
// Simple cases: file name only.
{name: '/foo.amr', want: {type: 'audio', subtype: 'AMR'}},
{name: '/foo.flac', want: {type: 'audio', subtype: 'FLAC'}},
{name: '/foo.mp3', want: {type: 'audio', subtype: 'MP3'}},
{name: '/foo.m4a', want: {type: 'audio', subtype: 'MPEG'}},
{name: '/foo.oga', want: {type: 'audio', subtype: 'OGG'}},
{name: '/foo.ogg', want: {type: 'audio', subtype: 'OGG'}},
{name: '/foo.opus', want: {type: 'audio', subtype: 'OGG'}},
{name: '/foo.wav', want: {type: 'audio', subtype: 'WAV'}},
// Complex cases, directory and file name.
{name: '/dir.mp3/foo.amr', want: {type: 'audio', subtype: 'AMR'}},
{name: '/dir.ogg/foo.flac', want: {type: 'audio', subtype: 'FLAC'}},
{name: '/dir/flac/foo.mp3', want: {type: 'audio', subtype: 'MP3'}},
{name: '/dir_amr/foo.m4a', want: {type: 'audio', subtype: 'MPEG'}},
{name: '/amr/foo.oga', want: {type: 'audio', subtype: 'OGG'}},
{name: '/wav/dir/foo.ogg', want: {type: 'audio', subtype: 'OGG'}},
{name: '/mp3/amr/foo.opus', want: {type: 'audio', subtype: 'OGG'}},
{name: '/dir/foo.wav', want: {type: 'audio', subtype: 'WAV'}},
];
for (const item of testItems) {
const got = FileType.getTypeForName(item.name);
assertEquals(item.want.type, got.type);
assertEquals(item.want.subtype, got.subtype);
}
}
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