Commit 96bdb21d authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Audio Player: Generate JS modules for //ui/file_manager/.../metadata/*

First batch of files in metadata that Audio Player depends on:
- metadata_provider.m.js
- image_orientation_unittest.m.js
- image_orientation.js
- metadata_request.js

Note on the image_orientation_unittest:
assertArrayEquals() andassertDeepEquals() now check for the type, so
changed to use Uint8ClampedArray in the expected value.

Bug: 1133186
Change-Id: Icbf9d58039eaa94d732c62c29f9bef08dbd39390
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2503767
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarJeremie Boulic <jboulic@chromium.org>
Commit-Queue: Jeremie Boulic <jboulic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822033}
parent 429fb750
...@@ -152,7 +152,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileType) { ...@@ -152,7 +152,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileType) {
} }
IN_PROC_BROWSER_TEST_F(CanvasFileManagerJsTest, ImageOrientation) { IN_PROC_BROWSER_TEST_F(CanvasFileManagerJsTest, ImageOrientation) {
RunTestURL("foreground/js/metadata/image_orientation_unittest_gen.html"); RunTestURL("foreground/js/metadata/image_orientation_unittest.m_gen.html");
} }
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImportControllerTest) { IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImportControllerTest) {
......
...@@ -64,6 +64,7 @@ group("unit_test_data") { ...@@ -64,6 +64,7 @@ group("unit_test_data") {
"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",
"file_manager/foreground/js/metadata:js_test_gen_html_modules",
"file_manager/foreground/js/ui:js_test_gen_html", "file_manager/foreground/js/ui:js_test_gen_html",
"gallery/js:js_test_gen_html", "gallery/js:js_test_gen_html",
"gallery/js/image_editor:js_test_gen_html", "gallery/js/image_editor:js_test_gen_html",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
import("//third_party/closure_compiler/js_unit_tests.gni") import("//third_party/closure_compiler/js_unit_tests.gni")
import("//ui/file_manager/base/gn/js_test_gen_html.gni") import("//ui/file_manager/base/gn/js_test_gen_html.gni")
import("//ui/webui/resources/tools/js_modulizer.gni")
# TODO(tapted): This entire folder should move to //ui/file_manager/base. # TODO(tapted): This entire folder should move to //ui/file_manager/base.
visibility = [ "//ui/file_manager/*" ] visibility = [ "//ui/file_manager/*" ]
...@@ -13,10 +14,22 @@ group("closure_compile") { ...@@ -13,10 +14,22 @@ group("closure_compile") {
testonly = true testonly = true
deps = [ deps = [
":closure_compile_module", ":closure_compile_module",
":closure_jsmodules",
":js_test_gen_html_modules_type_check_auto",
":js_test_gen_html_type_check_auto", ":js_test_gen_html_type_check_auto",
] ]
} }
js_type_check("closure_jsmodules") {
uses_js_modules = true
deps = [
":image_orientation.m",
":metadata_item.m",
":metadata_provider.m",
":metadata_request.m",
]
}
js_type_check("closure_compile_module") { js_type_check("closure_compile_module") {
deps = [ deps = [
":byte_reader", ":byte_reader",
...@@ -128,10 +141,17 @@ js_library("id3_parser") { ...@@ -128,10 +141,17 @@ js_library("id3_parser") {
js_library("image_orientation") { js_library("image_orientation") {
} }
js_unittest("image_orientation_unittest") { js_library("image_orientation.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/js/metadata/image_orientation.m.js" ]
deps = []
extra_deps = [ ":modulize" ]
}
js_unittest("image_orientation_unittest.m") {
deps = [ deps = [
":image_orientation", ":image_orientation.m",
"//ui/webui/resources/js:webui_resource_test", "//chrome/test/data/webui:chai_assert",
] ]
} }
...@@ -187,6 +207,13 @@ js_library("metadata_dispatcher") { ...@@ -187,6 +207,13 @@ js_library("metadata_dispatcher") {
js_library("metadata_item") { js_library("metadata_item") {
} }
js_library("metadata_item.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/js/metadata/metadata_item.m.js" ]
deps = []
extra_deps = [ ":modulize" ]
}
js_library("metadata_model") { js_library("metadata_model") {
deps = [ deps = [
":content_metadata_provider", ":content_metadata_provider",
...@@ -220,9 +247,27 @@ js_library("metadata_provider") { ...@@ -220,9 +247,27 @@ js_library("metadata_provider") {
] ]
} }
js_library("metadata_provider.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/js/metadata/metadata_provider.m.js" ]
deps = [
":metadata_item.m",
":metadata_request.m",
"//ui/webui/resources/js:assert.m",
]
extra_deps = [ ":modulize" ]
}
js_library("metadata_request") { js_library("metadata_request") {
} }
js_library("metadata_request.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/foreground/js/metadata/metadata_request.m.js" ]
deps = []
extra_deps = [ ":modulize" ]
}
js_library("mock_metadata") { js_library("mock_metadata") {
deps = [ ":metadata_model" ] deps = [ ":metadata_model" ]
} }
...@@ -260,13 +305,23 @@ js_unittest("thumbnail_model_unittest") { ...@@ -260,13 +305,23 @@ js_unittest("thumbnail_model_unittest") {
] ]
} }
js_test_gen_html("js_test_gen_html_modules") {
deps = [ ":image_orientation_unittest.m" ]
js_module = true
closure_flags = strict_error_checking_closure_args + [
"js_module_root=./gen/ui/file_manager/file_manager/foreground/js/metadata",
"js_module_root=../../ui/file_manager/file_manager/foreground/js/metadata",
"browser_resolver_prefix_replacements=\"chrome://test/=./\"",
]
}
js_test_gen_html("js_test_gen_html") { js_test_gen_html("js_test_gen_html") {
deps = [ deps = [
":content_metadata_provider_unittest", ":content_metadata_provider_unittest",
":exif_parser_unittest", ":exif_parser_unittest",
":external_metadata_provider_unittest", ":external_metadata_provider_unittest",
":file_system_metadata_provider_unittest", ":file_system_metadata_provider_unittest",
":image_orientation_unittest",
":metadata_cache_item_unittest", ":metadata_cache_item_unittest",
":metadata_cache_set_unittest", ":metadata_cache_set_unittest",
":metadata_model_unittest", ":metadata_model_unittest",
...@@ -275,3 +330,12 @@ js_test_gen_html("js_test_gen_html") { ...@@ -275,3 +330,12 @@ js_test_gen_html("js_test_gen_html") {
] ]
mocks = [ "metadata_dispatcher_mock_deps.js" ] mocks = [ "metadata_dispatcher_mock_deps.js" ]
} }
js_modulizer("modulize") {
input_files = [
"metadata_item.js",
"metadata_request.js",
"image_orientation.js",
"metadata_provider.js",
]
}
...@@ -13,7 +13,7 @@ let ImageTransformParam; ...@@ -13,7 +13,7 @@ let ImageTransformParam;
* Class representing image orientation. * Class representing image orientation.
* @final * @final
*/ */
class ImageOrientation { /* #export */ class ImageOrientation {
/** /**
* The constructor takes 2x2 matrix value that cancels the image orientation: * The constructor takes 2x2 matrix value that cancels the image orientation:
* |a, c| * |a, c|
......
...@@ -2,7 +2,11 @@ ...@@ -2,7 +2,11 @@
// 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 testGetSizeAfterCancelling() { import {assertDeepEquals, assertEquals, assertTrue} from 'chrome://test/chai_assert.js';
import {ImageOrientation} from './image_orientation.m.js';
export function testGetSizeAfterCancelling() {
// Crockwise 90 degrees image orientation. // Crockwise 90 degrees image orientation.
const orientation = new ImageOrientation(0, 1, 1, 0); const orientation = new ImageOrientation(0, 1, 1, 0);
...@@ -12,7 +16,7 @@ function testGetSizeAfterCancelling() { ...@@ -12,7 +16,7 @@ function testGetSizeAfterCancelling() {
assertEquals(100, size.height); assertEquals(100, size.height);
} }
function testCancelImageOrientation() { export function testCancelImageOrientation() {
// Crockwise 90 degrees image orientation. // Crockwise 90 degrees image orientation.
const orientation = new ImageOrientation(0, 1, 1, 0); const orientation = new ImageOrientation(0, 1, 1, 0);
...@@ -39,7 +43,9 @@ function testCancelImageOrientation() { ...@@ -39,7 +43,9 @@ function testCancelImageOrientation() {
orientation.cancelImageOrientation(destinationContext, 2, 1); orientation.cancelImageOrientation(destinationContext, 2, 1);
destinationContext.drawImage(canvas, 0, 0); destinationContext.drawImage(canvas, 0, 0);
const destinationImageData = destinationContext.getImageData(0, 0, 1, 2); const destinationImageData = destinationContext.getImageData(0, 0, 1, 2);
assertArrayEquals([255, 0, 0, 100, 0, 0, 0, 100], destinationImageData.data); assertDeepEquals(
new Uint8ClampedArray([255, 0, 0, 100, 0, 0, 0, 100]),
destinationImageData.data);
} }
function assertImageOrientationEquals(expected, actual, message) { function assertImageOrientationEquals(expected, actual, message) {
...@@ -49,7 +55,7 @@ function assertImageOrientationEquals(expected, actual, message) { ...@@ -49,7 +55,7 @@ function assertImageOrientationEquals(expected, actual, message) {
assertEquals(expected.d, actual.d, message); assertEquals(expected.d, actual.d, message);
} }
function testFromRotationAndScale() { export function testFromRotationAndScale() {
const rotate270 = {scaleX: 1, scaleY: 1, rotate90: -1}; const rotate270 = {scaleX: 1, scaleY: 1, rotate90: -1};
const rotate90 = {scaleX: 1, scaleY: 1, rotate90: 1}; const rotate90 = {scaleX: 1, scaleY: 1, rotate90: 1};
const flipX = {scaleX: -1, scaleY: 1, rotate90: 0}; const flipX = {scaleX: -1, scaleY: 1, rotate90: 0};
......
...@@ -16,7 +16,7 @@ let ImageTransformation; ...@@ -16,7 +16,7 @@ let ImageTransformation;
* @unrestricted to allow access for properties via '.' or '[]', useful for * @unrestricted to allow access for properties via '.' or '[]', useful for
* computed properties. * computed properties.
*/ */
class MetadataItem { /* #export */ class MetadataItem {
constructor() { constructor() {
/** /**
* Size of the file. -1 for directory. * Size of the file. -1 for directory.
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +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.
// #import {assert} from 'chrome://resources/js/assert.m.js';
// #import {MetadataRequest} from './metadata_request.m.js';
// #import {MetadataItem} from './metadata_item.m.js';
/** /**
* @abstract * @abstract
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// 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.
class MetadataRequest { /* #export */ class MetadataRequest {
/** /**
* @param {!Entry} entry Entry * @param {!Entry} entry Entry
* @param {!Array<string>} names Property name list to be requested. * @param {!Array<string>} names Property name list to be requested.
......
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