Commit 5bfe525b authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Files app: JS modules for common/js/files_app_types_unittest.m.js

Bug: 1133186
Change-Id: Iae372cb4fba850543fa62ea4ce9942f50bd82dea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2519234
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarJeremie Boulic <jboulic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823960}
parent 748ab90d
...@@ -95,7 +95,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileOperationManagerTest) { ...@@ -95,7 +95,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileOperationManagerTest) {
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesAppEntryTypes) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesAppEntryTypes) {
RunTestURL("common/js/files_app_entry_types_unittest_gen.html"); RunTestURL("common/js/files_app_entry_types_unittest.m_gen.html");
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesDisplayPanel) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FilesDisplayPanel) {
......
...@@ -61,6 +61,7 @@ group("unit_test_data") { ...@@ -61,6 +61,7 @@ group("unit_test_data") {
"base/js:js_test_gen_html", "base/js:js_test_gen_html",
"file_manager/background/js:js_test_gen_html", "file_manager/background/js:js_test_gen_html",
"file_manager/common/js:js_test_gen_html", "file_manager/common/js:js_test_gen_html",
"file_manager/common/js:js_test_gen_html_modules",
"file_manager/foreground/elements:js_test_gen_html", "file_manager/foreground/elements:js_test_gen_html",
"file_manager/foreground/js:js_test_gen_html", "file_manager/foreground/js:js_test_gen_html",
"file_manager/foreground/js/metadata:js_test_gen_html", "file_manager/foreground/js/metadata:js_test_gen_html",
......
...@@ -16,6 +16,7 @@ group("closure_compile") { ...@@ -16,6 +16,7 @@ group("closure_compile") {
deps = [ deps = [
":closure_compile_jsmodules", ":closure_compile_jsmodules",
":closure_compile_module", ":closure_compile_module",
":js_test_gen_html_modules_type_check_auto",
":js_test_gen_html_type_check_auto", ":js_test_gen_html_type_check_auto",
":test_support_type_check", ":test_support_type_check",
] ]
...@@ -65,12 +66,14 @@ js_library("files_app_entry_types") { ...@@ -65,12 +66,14 @@ js_library("files_app_entry_types") {
] ]
} }
js_unittest("files_app_entry_types_unittest") { js_unittest("files_app_entry_types_unittest.m") {
deps = [ deps = [
":files_app_entry_types", ":files_app_entry_types.m",
":mock_entry", ":mock_entry.m",
"//ui/file_manager/base/js:test_error_reporting", "//chrome/test/data/webui:chai_assert",
"//ui/file_manager/base/js:volume_manager_types", "//ui/file_manager/base/js:test_error_reporting.m",
"//ui/file_manager/externs:volume_info.m",
"//ui/webui/resources/js:assert.m",
] ]
} }
...@@ -240,10 +243,22 @@ js_library("util.m") { ...@@ -240,10 +243,22 @@ js_library("util.m") {
extra_deps = [ ":modulize" ] extra_deps = [ ":modulize" ]
} }
js_test_gen_html("js_test_gen_html_modules") {
js_module = true
deps = [ ":files_app_entry_types_unittest.m" ]
closure_flags =
strict_error_checking_closure_args + [
"js_module_root=./gen/ui",
"js_module_root=../../ui",
"browser_resolver_prefix_replacements=\"chrome://test/=./\"",
"hide_warnings_for=third_party/",
]
}
js_test_gen_html("js_test_gen_html") { js_test_gen_html("js_test_gen_html") {
deps = [ deps = [
":file_type_unittest", ":file_type_unittest",
":files_app_entry_types_unittest",
":importer_common_unittest", ":importer_common_unittest",
":lru_cache_unittest", ":lru_cache_unittest",
":util_unittest", ":util_unittest",
......
...@@ -2,7 +2,19 @@ ...@@ -2,7 +2,19 @@
// 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'; // clang-format off
import {assert} from 'chrome://resources/js/assert.m.js';
import {assertEquals, assertFalse, assertTrue} from 'chrome://test/chai_assert.js';
import * as wrappedVolumeManagerCommon from '../../../base/js/volume_manager_types.m.js';
const {VolumeManagerCommon} = wrappedVolumeManagerCommon;
import {MockFileSystem} from './mock_entry.m.js';
import {reportPromise, waitUntil} from '../../../base/js/test_error_reporting.m.js';
import {VolumeEntry, EntryList, StaticReader, CombinedReaders, FakeEntryImpl} from './files_app_entry_types.m.js';
import {VolumeInfo} from '../../../externs/volume_info.m.js';
// clang-format on
function notreached(error) { function notreached(error) {
assertTrue(false, 'NOTREACHED(): ' + (error.stack || error)); assertTrue(false, 'NOTREACHED(): ' + (error.stack || error));
...@@ -31,7 +43,7 @@ function fakeVolumeEntry(volumeType, displayRoot, additionalProperties) { ...@@ -31,7 +43,7 @@ function fakeVolumeEntry(volumeType, displayRoot, additionalProperties) {
} }
/** Test constructor and default public attributes. */ /** Test constructor and default public attributes. */
function testEntryList(testReportCallback) { export function testEntryList(testReportCallback) {
const entryList = const entryList =
new EntryList('My files', VolumeManagerCommon.RootType.MY_FILES); new EntryList('My files', VolumeManagerCommon.RootType.MY_FILES);
assertEquals('My files', entryList.label); assertEquals('My files', entryList.label);
...@@ -76,7 +88,7 @@ function testEntryList(testReportCallback) { ...@@ -76,7 +88,7 @@ function testEntryList(testReportCallback) {
} }
/** Tests method EntryList.getParent. */ /** Tests method EntryList.getParent. */
function testEntryListGetParent(testReportCallback) { export function testEntryListGetParent(testReportCallback) {
const entryList = const entryList =
new EntryList('My files', VolumeManagerCommon.RootType.MY_FILES); new EntryList('My files', VolumeManagerCommon.RootType.MY_FILES);
let callbackTriggered = false; let callbackTriggered = false;
...@@ -90,7 +102,7 @@ function testEntryListGetParent(testReportCallback) { ...@@ -90,7 +102,7 @@ function testEntryListGetParent(testReportCallback) {
} }
/** Tests method EntryList.addEntry. */ /** Tests method EntryList.addEntry. */
function testEntryListAddEntry() { export function testEntryListAddEntry() {
const entryList = const entryList =
new EntryList('My files', VolumeManagerCommon.RootType.MY_FILES); new EntryList('My files', VolumeManagerCommon.RootType.MY_FILES);
assertEquals(0, entryList.getUIChildren().length); assertEquals(0, entryList.getUIChildren().length);
...@@ -105,7 +117,7 @@ function testEntryListAddEntry() { ...@@ -105,7 +117,7 @@ function testEntryListAddEntry() {
* Tests EntryList's methods addEntry, findIndexByVolumeInfo, * Tests EntryList's methods addEntry, findIndexByVolumeInfo,
* removeByVolumeType, removeByRootType, removeChildEntry. * removeByVolumeType, removeByRootType, removeChildEntry.
*/ */
function testEntryFindIndex() { export function testEntryFindIndex() {
const entryList = const entryList =
new EntryList('My files', VolumeManagerCommon.RootType.MY_FILES); new EntryList('My files', VolumeManagerCommon.RootType.MY_FILES);
...@@ -153,7 +165,7 @@ function testEntryFindIndex() { ...@@ -153,7 +165,7 @@ function testEntryFindIndex() {
* removeByRootType, removeChildEntry. * removeByRootType, removeChildEntry.
* @suppress {accessControls} to be able to access private properties. * @suppress {accessControls} to be able to access private properties.
*/ */
function testVolumeEntryFindIndex() { export function testVolumeEntryFindIndex() {
const fakeRootEntry = createFakeDisplayRoot(); const fakeRootEntry = createFakeDisplayRoot();
const volumeEntry = const volumeEntry =
fakeVolumeEntry(VolumeManagerCommon.VolumeType.DOWNLOADS, fakeRootEntry); fakeVolumeEntry(VolumeManagerCommon.VolumeType.DOWNLOADS, fakeRootEntry);
...@@ -202,7 +214,7 @@ function testVolumeEntryFindIndex() { ...@@ -202,7 +214,7 @@ function testVolumeEntryFindIndex() {
} }
/** Tests method EntryList.getMetadata. */ /** Tests method EntryList.getMetadata. */
function testEntryListGetMetadata(testReportCallback) { export function testEntryListGetMetadata(testReportCallback) {
const entryList = const entryList =
new EntryList('My files', VolumeManagerCommon.RootType.MY_FILES); new EntryList('My files', VolumeManagerCommon.RootType.MY_FILES);
...@@ -225,7 +237,7 @@ function testEntryListGetMetadata(testReportCallback) { ...@@ -225,7 +237,7 @@ function testEntryListGetMetadata(testReportCallback) {
} }
/** Tests StaticReader.readEntries. */ /** Tests StaticReader.readEntries. */
function testStaticReader(testReportCallback) { export function testStaticReader(testReportCallback) {
const reader = new StaticReader(['file1', 'file2']); const reader = new StaticReader(['file1', 'file2']);
const testResults = []; const testResults = [];
// How many times the reader callback |accumulateResults| has been called? // How many times the reader callback |accumulateResults| has been called?
...@@ -256,7 +268,7 @@ function testStaticReader(testReportCallback) { ...@@ -256,7 +268,7 @@ function testStaticReader(testReportCallback) {
} }
/** Tests CombinedReader.readEntries. */ /** Tests CombinedReader.readEntries. */
function testCombinedReader(testReportCallback) { export function testCombinedReader(testReportCallback) {
const innerReaders = [ const innerReaders = [
new StaticReader(['file1']), new StaticReader(['file1']),
new StaticReader(['file2']), new StaticReader(['file2']),
...@@ -290,7 +302,7 @@ function testCombinedReader(testReportCallback) { ...@@ -290,7 +302,7 @@ function testCombinedReader(testReportCallback) {
testReportCallback); testReportCallback);
} }
function testCombinedReaderError(testReportCallback) { export function testCombinedReaderError(testReportCallback) {
const expectedError = new Error('a fake error'); const expectedError = new Error('a fake error');
const alwaysFailReader = { const alwaysFailReader = {
readEntries: (success, error) => { readEntries: (success, error) => {
...@@ -349,7 +361,7 @@ function createFakeDisplayRoot() { ...@@ -349,7 +361,7 @@ function createFakeDisplayRoot() {
/** /**
* Tests VolumeEntry constructor and default public attributes/getter/methods. * Tests VolumeEntry constructor and default public attributes/getter/methods.
*/ */
function testVolumeEntry() { export function testVolumeEntry() {
const fakeRootEntry = createFakeDisplayRoot(); const fakeRootEntry = createFakeDisplayRoot();
const volumeEntry = const volumeEntry =
fakeVolumeEntry(VolumeManagerCommon.VolumeType.DOWNLOADS, fakeRootEntry); fakeVolumeEntry(VolumeManagerCommon.VolumeType.DOWNLOADS, fakeRootEntry);
...@@ -366,7 +378,7 @@ function testVolumeEntry() { ...@@ -366,7 +378,7 @@ function testVolumeEntry() {
assertFalse(volumeEntry.isFile); assertFalse(volumeEntry.isFile);
} }
function testVolumeEntryCreateReader(testReportCallback) { export function testVolumeEntryCreateReader(testReportCallback) {
const fakeRootEntry = createFakeDisplayRoot(); const fakeRootEntry = createFakeDisplayRoot();
fakeRootEntry.createReader = () => new StaticReader(['file1']); fakeRootEntry.createReader = () => new StaticReader(['file1']);
const volumeEntry = const volumeEntry =
...@@ -402,7 +414,7 @@ function testVolumeEntryCreateReader(testReportCallback) { ...@@ -402,7 +414,7 @@ function testVolumeEntryCreateReader(testReportCallback) {
} }
/** Tests VolumeEntry createReader when root entry isn't resolved yet. */ /** Tests VolumeEntry createReader when root entry isn't resolved yet. */
function testVolumeEntryCreateReaderUnresolved(testReportCallback) { export function testVolumeEntryCreateReaderUnresolved(testReportCallback) {
// A VolumeInfo that doesn't resolve the display root. // A VolumeInfo that doesn't resolve the display root.
const fakeVolumeInfo = /** @type{!VolumeInfo} */ ({ const fakeVolumeInfo = /** @type{!VolumeInfo} */ ({
displayRoot: null, displayRoot: null,
...@@ -452,7 +464,7 @@ function testVolumeEntryCreateReaderUnresolved(testReportCallback) { ...@@ -452,7 +464,7 @@ function testVolumeEntryCreateReaderUnresolved(testReportCallback) {
/** /**
* Tests VolumeEntry getFile and getDirectory methods. * Tests VolumeEntry getFile and getDirectory methods.
*/ */
function testVolumeEntryGetDirectory(testReportCallback) { export function testVolumeEntryGetDirectory(testReportCallback) {
const root = createFakeDisplayRoot(); const root = createFakeDisplayRoot();
root.filesystem.populate(['/bla/', '/bla.txt']); root.filesystem.populate(['/bla/', '/bla.txt']);
...@@ -476,7 +488,7 @@ function testVolumeEntryGetDirectory(testReportCallback) { ...@@ -476,7 +488,7 @@ function testVolumeEntryGetDirectory(testReportCallback) {
/** /**
* Tests VolumeEntry which initially doesn't have displayRoot. * Tests VolumeEntry which initially doesn't have displayRoot.
*/ */
function testVolumeEntryDelayedDisplayRoot(testReportCallback) { export function testVolumeEntryDelayedDisplayRoot(testReportCallback) {
let callbackTriggered = false; let callbackTriggered = false;
const fakeRootEntry = createFakeDisplayRoot(); const fakeRootEntry = createFakeDisplayRoot();
...@@ -502,7 +514,7 @@ function testVolumeEntryDelayedDisplayRoot(testReportCallback) { ...@@ -502,7 +514,7 @@ function testVolumeEntryDelayedDisplayRoot(testReportCallback) {
} }
/** Tests VolumeEntry.getParent */ /** Tests VolumeEntry.getParent */
function testVolumeEntryGetParent(testReportCallback) { export function testVolumeEntryGetParent(testReportCallback) {
const volumeEntry = fakeVolumeEntry(null); const volumeEntry = fakeVolumeEntry(null);
let callbackTriggered = false; let callbackTriggered = false;
volumeEntry.getParent(parentEntry => { volumeEntry.getParent(parentEntry => {
...@@ -515,7 +527,7 @@ function testVolumeEntryGetParent(testReportCallback) { ...@@ -515,7 +527,7 @@ function testVolumeEntryGetParent(testReportCallback) {
} }
/** Tests VolumeEntry.getMetadata */ /** Tests VolumeEntry.getMetadata */
function testVolumeEntryGetMetadata(testReportCallback) { export function testVolumeEntryGetMetadata(testReportCallback) {
const volumeEntry = fakeVolumeEntry(null); const volumeEntry = fakeVolumeEntry(null);
let modificationTime = null; let modificationTime = null;
volumeEntry.getMetadata(metadata => { volumeEntry.getMetadata(metadata => {
...@@ -533,7 +545,7 @@ function testVolumeEntryGetMetadata(testReportCallback) { ...@@ -533,7 +545,7 @@ function testVolumeEntryGetMetadata(testReportCallback) {
/** /**
* Test EntryList.addEntry sets prefix on VolumeEntry. * Test EntryList.addEntry sets prefix on VolumeEntry.
*/ */
function testEntryListAddEntrySetsPrefix() { export function testEntryListAddEntrySetsPrefix() {
const volumeEntry = fakeVolumeEntry(null); const volumeEntry = fakeVolumeEntry(null);
const entryList = const entryList =
new EntryList('My files', VolumeManagerCommon.RootType.MY_FILES); new EntryList('My files', VolumeManagerCommon.RootType.MY_FILES);
...@@ -547,7 +559,7 @@ function testEntryListAddEntrySetsPrefix() { ...@@ -547,7 +559,7 @@ function testEntryListAddEntrySetsPrefix() {
/** /**
* Test FakeEntry, which is only static data. * Test FakeEntry, which is only static data.
*/ */
function testFakeEntry(testReportCallback) { export function testFakeEntry(testReportCallback) {
let fakeEntry = let fakeEntry =
new FakeEntryImpl('label', VolumeManagerCommon.RootType.CROSTINI); new FakeEntryImpl('label', VolumeManagerCommon.RootType.CROSTINI);
......
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