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) {
RunTestURL("background/js/file_operation_manager_unittest_gen.html");
}
// TODO(crbug.com/1146484): Test is flaky.
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesAppEntryTypes) {
RunTestURL("common/js/files_app_entry_types_unittest.m_gen.html");
}
......@@ -149,7 +148,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileTypeFiltersController) {
}
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) {
......@@ -177,7 +176,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ListThumbnailLoader) {
}
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) {
......
......@@ -42,7 +42,9 @@ js_type_check("closure_compile_jsmodules") {
uses_js_modules = true
deps = [
":async_util.m",
":file_type.m",
":files_app_entry_types.m",
":lru_cache.m",
":metrics.m",
":metrics_base.m",
":mock_entry.m",
......@@ -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 = [
":file_type",
":mock_entry",
"//ui/file_manager/base/js:test_error_reporting",
":files_app_entry_types.m",
"//ui/file_manager/base/js:volume_manager_types.m",
"//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") {
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 = [
":lru_cache",
"//ui/webui/resources/js:webui_resource_test",
":lru_cache.m",
"//chrome/test/data/webui:chai_assert",
]
}
......@@ -282,7 +305,9 @@ js_unittest("util_unittest.m") {
js_test_gen_html("js_test_gen_html_modules") {
js_module = true
deps = [
":file_type_unittest.m",
":files_app_entry_types_unittest.m",
":lru_cache_unittest.m",
":util_unittest.m",
]
......@@ -296,17 +321,15 @@ js_test_gen_html("js_test_gen_html_modules") {
}
js_test_gen_html("js_test_gen_html") {
deps = [
":file_type_unittest",
":importer_common_unittest",
":lru_cache_unittest",
]
deps = [ ":importer_common_unittest" ]
}
js_modulizer("modulize") {
input_files = [
"async_util.js",
"file_type.js",
"files_app_entry_types.js",
"lru_cache.js",
"metrics.js",
"metrics_base.js",
"mock_entry.js",
......
......@@ -2,10 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// 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.
*/
function FileType() {}
/* #export */ function FileType() {}
/**
* @typedef {{
......@@ -499,7 +506,7 @@ FileType.getType = (entry, opt_mimeType) => {
name: '',
type: 'partition',
subtype:
/** @type {VolumeEntry}*/ (entry).volumeInfo.diskFileSystemType,
assert(/** @type {VolumeEntry}*/ (entry).volumeInfo.diskFileSystemType),
icon: '',
};
}
......
......@@ -2,13 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// 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
* others.
*/
function testDownloadsIcon() {
export function testDownloadsIcon() {
const fileSystem = new MockFileSystem('fake-fs');
const filenames = [
'/folder/',
......@@ -38,7 +42,7 @@ function testDownloadsIcon() {
assertEquals('folder', FileType.getIcon(downloads, mimetype, androidRoot));
}
function testGetTypeForName() {
export function testGetTypeForName() {
const testItems = [
// Simple cases: file name only.
{name: '/foo.amr', want: {type: 'audio', subtype: 'AMR'}},
......
......@@ -84,7 +84,7 @@ class LRUCacheList {
* Cache management class implementing LRU algorithm.
* @template T
*/
class LRUCache {
/* #export */ class LRUCache {
/**
* @param {number} maxSize Maximum total size of items this cache can hold.
* When items are put without specifying their sizes, their sizes are
......
......@@ -2,7 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// 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);
// Querying by non-existent key will get null.
......@@ -72,7 +75,7 @@ function testLRUCache() {
assertEquals(0, cache.size());
}
function testLRUCacheWithIndividualSizes() {
export function testLRUCacheWithIndividualSizes() {
const cache = new LRUCache(10);
// Querying by non-existent key will get null.
......@@ -137,7 +140,7 @@ function generateRandom3letters(generator) {
return res;
}
function testSizeCalculationByRandomInput() {
export function testSizeCalculationByRandomInput() {
const cache = new LRUCache(10000);
// We need fixed random number sequence to avoid test flakiness, so
......@@ -166,7 +169,7 @@ function testSizeCalculationByRandomInput() {
assertEquals(0, cache.size());
}
function testSetMaxSize() {
export function testSetMaxSize() {
const cache = new LRUCache(10);
cache.put('a', 'valueA');
cache.put('b', 'valueB');
......
......@@ -10,7 +10,7 @@
* @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.
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