Commit 90258074 authored by Jérémie Boulic's avatar Jérémie Boulic Committed by Commit Bot

Audio Player: convert last dependencies in //ui/.../common/js/

In //ui/file_manager/file_manager/common/js:
- file_type.js
- file_type_unittest.js
- lru_cache.js
- lru_cache_unittest.js

Bug: 1133186
Change-Id: Id2b0dc75b4bc18969e6e7b862d0c9282baa0ba06
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521886
Auto-Submit: Jeremie Boulic <jboulic@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825703}
parent 6c9f35c4
...@@ -94,7 +94,6 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileOperationManagerTest) { ...@@ -94,7 +94,6 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileOperationManagerTest) {
RunTestURL("background/js/file_operation_manager_unittest_gen.html"); RunTestURL("background/js/file_operation_manager_unittest_gen.html");
} }
// TODO(crbug.com/1146484): Test is flaky.
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesAppEntryTypes) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesAppEntryTypes) {
RunTestURL("common/js/files_app_entry_types_unittest.m_gen.html"); RunTestURL("common/js/files_app_entry_types_unittest.m_gen.html");
} }
...@@ -149,7 +148,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileTypeFiltersController) { ...@@ -149,7 +148,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileTypeFiltersController) {
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileType) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileType) {
RunTestURL("common/js/file_type_unittest_gen.html"); RunTestURL("common/js/file_type_unittest.m_gen.html");
} }
IN_PROC_BROWSER_TEST_F(CanvasFileManagerJsTest, ImageOrientation) { IN_PROC_BROWSER_TEST_F(CanvasFileManagerJsTest, ImageOrientation) {
...@@ -177,7 +176,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ListThumbnailLoader) { ...@@ -177,7 +176,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ListThumbnailLoader) {
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, LRUCacheTest) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, LRUCacheTest) {
RunTestURL("common/js/lru_cache_unittest_gen.html"); RunTestURL("common/js/lru_cache_unittest.m_gen.html");
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, MediaImportHandlerTest) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, MediaImportHandlerTest) {
......
...@@ -42,7 +42,9 @@ js_type_check("closure_compile_jsmodules") { ...@@ -42,7 +42,9 @@ js_type_check("closure_compile_jsmodules") {
uses_js_modules = true uses_js_modules = true
deps = [ deps = [
":async_util.m", ":async_util.m",
":file_type.m",
":files_app_entry_types.m", ":files_app_entry_types.m",
":lru_cache.m",
":metrics.m", ":metrics.m",
":metrics_base.m", ":metrics_base.m",
":mock_entry.m", ":mock_entry.m",
...@@ -104,11 +106,25 @@ js_library("file_type") { ...@@ -104,11 +106,25 @@ js_library("file_type") {
] ]
} }
js_unittest("file_type_unittest") { js_library("file_type.m") {
sources =
[ "$root_gen_dir/ui/file_manager/file_manager/common/js/file_type.m.js" ]
deps = [ deps = [
":file_type", ":files_app_entry_types.m",
":mock_entry", "//ui/file_manager/base/js:volume_manager_types.m",
"//ui/file_manager/base/js:test_error_reporting", "//ui/file_manager/externs:files_app_entry_interfaces.m",
"//ui/webui/resources/js:assert.m",
]
extra_deps = [ ":modulize" ]
}
js_unittest("file_type_unittest.m") {
deps = [
":file_type.m",
":mock_entry.m",
"//chrome/test/data/webui:chai_assert",
"//ui/file_manager/base/js:volume_manager_types.m",
] ]
} }
...@@ -150,10 +166,17 @@ js_unittest("importer_common_unittest") { ...@@ -150,10 +166,17 @@ js_unittest("importer_common_unittest") {
js_library("lru_cache") { js_library("lru_cache") {
} }
js_unittest("lru_cache_unittest") { js_library("lru_cache.m") {
sources =
[ "$root_gen_dir/ui/file_manager/file_manager/common/js/lru_cache.m.js" ]
extra_deps = [ ":modulize" ]
}
js_unittest("lru_cache_unittest.m") {
deps = [ deps = [
":lru_cache", ":lru_cache.m",
"//ui/webui/resources/js:webui_resource_test", "//chrome/test/data/webui:chai_assert",
] ]
} }
...@@ -282,7 +305,9 @@ js_unittest("util_unittest.m") { ...@@ -282,7 +305,9 @@ js_unittest("util_unittest.m") {
js_test_gen_html("js_test_gen_html_modules") { js_test_gen_html("js_test_gen_html_modules") {
js_module = true js_module = true
deps = [ deps = [
":file_type_unittest.m",
":files_app_entry_types_unittest.m", ":files_app_entry_types_unittest.m",
":lru_cache_unittest.m",
":util_unittest.m", ":util_unittest.m",
] ]
...@@ -296,17 +321,15 @@ js_test_gen_html("js_test_gen_html_modules") { ...@@ -296,17 +321,15 @@ js_test_gen_html("js_test_gen_html_modules") {
} }
js_test_gen_html("js_test_gen_html") { js_test_gen_html("js_test_gen_html") {
deps = [ deps = [ ":importer_common_unittest" ]
":file_type_unittest",
":importer_common_unittest",
":lru_cache_unittest",
]
} }
js_modulizer("modulize") { js_modulizer("modulize") {
input_files = [ input_files = [
"async_util.js", "async_util.js",
"file_type.js",
"files_app_entry_types.js", "files_app_entry_types.js",
"lru_cache.js",
"metrics.js", "metrics.js",
"metrics_base.js", "metrics_base.js",
"mock_entry.js", "mock_entry.js",
......
...@@ -2,10 +2,17 @@ ...@@ -2,10 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// clang-format off
// #import * as wrappedVolumeManagerCommon from '../../../base/js/volume_manager_types.m.js'; const {VolumeManagerCommon} = wrappedVolumeManagerCommon;
// #import {FilesAppEntry} from '../../../externs/files_app_entry_interfaces.m.js';
// #import {VolumeEntry} from './files_app_entry_types.m.js';
// #import {assert} from 'chrome://resources/js/assert.m.js';
// clang-format on
/** /**
* Namespace object for file type utility functions. * Namespace object for file type utility functions.
*/ */
function FileType() {} /* #export */ function FileType() {}
/** /**
* @typedef {{ * @typedef {{
...@@ -499,7 +506,7 @@ FileType.getType = (entry, opt_mimeType) => { ...@@ -499,7 +506,7 @@ FileType.getType = (entry, opt_mimeType) => {
name: '', name: '',
type: 'partition', type: 'partition',
subtype: subtype:
/** @type {VolumeEntry}*/ (entry).volumeInfo.diskFileSystemType, assert(/** @type {VolumeEntry}*/ (entry).volumeInfo.diskFileSystemType),
icon: '', icon: '',
}; };
} }
......
...@@ -2,13 +2,17 @@ ...@@ -2,13 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
'use strict'; import {FileType} from './file_type.m.js';
import {MockFileSystem} from './mock_entry.m.js';
import * as wrappedVolumeManagerCommon from '../../../base/js/volume_manager_types.m.js';
const {VolumeManagerCommon} = wrappedVolumeManagerCommon;
import {assertEquals} from 'chrome://test/chai_assert.js';
/* /*
* Tests that Downloads icon is customized within Downloads root, but not in * Tests that Downloads icon is customized within Downloads root, but not in
* others. * others.
*/ */
function testDownloadsIcon() { export function testDownloadsIcon() {
const fileSystem = new MockFileSystem('fake-fs'); const fileSystem = new MockFileSystem('fake-fs');
const filenames = [ const filenames = [
'/folder/', '/folder/',
...@@ -38,7 +42,7 @@ function testDownloadsIcon() { ...@@ -38,7 +42,7 @@ function testDownloadsIcon() {
assertEquals('folder', FileType.getIcon(downloads, mimetype, androidRoot)); assertEquals('folder', FileType.getIcon(downloads, mimetype, androidRoot));
} }
function testGetTypeForName() { export function testGetTypeForName() {
const testItems = [ const testItems = [
// Simple cases: file name only. // Simple cases: file name only.
{name: '/foo.amr', want: {type: 'audio', subtype: 'AMR'}}, {name: '/foo.amr', want: {type: 'audio', subtype: 'AMR'}},
......
...@@ -84,7 +84,7 @@ class LRUCacheList { ...@@ -84,7 +84,7 @@ class LRUCacheList {
* Cache management class implementing LRU algorithm. * Cache management class implementing LRU algorithm.
* @template T * @template T
*/ */
class LRUCache { /* #export */ class LRUCache {
/** /**
* @param {number} maxSize Maximum total size of items this cache can hold. * @param {number} maxSize Maximum total size of items this cache can hold.
* When items are put without specifying their sizes, their sizes are * When items are put without specifying their sizes, their sizes are
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
function testLRUCache() { import {assertEquals, assertTrue} from 'chrome://test/chai_assert.js';
import {LRUCache} from './lru_cache.m.js';
export function testLRUCache() {
const cache = new LRUCache(3); const cache = new LRUCache(3);
// Querying by non-existent key will get null. // Querying by non-existent key will get null.
...@@ -72,7 +75,7 @@ function testLRUCache() { ...@@ -72,7 +75,7 @@ function testLRUCache() {
assertEquals(0, cache.size()); assertEquals(0, cache.size());
} }
function testLRUCacheWithIndividualSizes() { export function testLRUCacheWithIndividualSizes() {
const cache = new LRUCache(10); const cache = new LRUCache(10);
// Querying by non-existent key will get null. // Querying by non-existent key will get null.
...@@ -137,7 +140,7 @@ function generateRandom3letters(generator) { ...@@ -137,7 +140,7 @@ function generateRandom3letters(generator) {
return res; return res;
} }
function testSizeCalculationByRandomInput() { export function testSizeCalculationByRandomInput() {
const cache = new LRUCache(10000); const cache = new LRUCache(10000);
// We need fixed random number sequence to avoid test flakiness, so // We need fixed random number sequence to avoid test flakiness, so
...@@ -166,7 +169,7 @@ function testSizeCalculationByRandomInput() { ...@@ -166,7 +169,7 @@ function testSizeCalculationByRandomInput() {
assertEquals(0, cache.size()); assertEquals(0, cache.size());
} }
function testSetMaxSize() { export function testSetMaxSize() {
const cache = new LRUCache(10); const cache = new LRUCache(10);
cache.put('a', 'valueA'); cache.put('a', 'valueA');
cache.put('b', 'valueB'); cache.put('b', 'valueB');
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* @suppress {uselessCode} Temporary suppress because of the line exporting. * @suppress {uselessCode} Temporary suppress because of the line exporting.
*/ */
// eslint-disable-next-line no-var // eslint-disable-next-line no-var
var metrics; // Needs to be defined in each window which uses metrics. var metrics; // Needs to be defined in each window which uses metrics.
const metricsBase = {}; const metricsBase = {};
......
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