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

Audio player: Convert dependencies in //ui/file_manager/image_loader/

In //ui/file_manager/image_loader:
- load_image_request.js
- image_loader_client.js
- image_loader_client_unittest.js

Bug: 1133186
Change-Id: Iaef19a8bcafc298d8e91cd398b92e3fc881dda6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2531335
Auto-Submit: Jeremie Boulic <jboulic@chromium.org>
Commit-Queue: Jeremie Boulic <jboulic@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826143}
parent 50d5488e
......@@ -12,7 +12,7 @@ class ImageLoaderJsTest : public FileManagerJsTestBase {
};
IN_PROC_BROWSER_TEST_F(ImageLoaderJsTest, ImageLoaderClientTest) {
RunTestURL("image_loader_client_unittest_gen.html");
RunTestURL("image_loader_client_unittest.m_gen.html");
}
IN_PROC_BROWSER_TEST_F(ImageLoaderJsTest, CacheTest) {
......
......@@ -69,6 +69,7 @@ group("unit_test_data") {
"gallery/js:js_test_gen_html",
"gallery/js/image_editor:js_test_gen_html",
"image_loader:js_test_gen_html",
"image_loader:js_test_gen_html_modules",
"video_player/js:js_test_gen_html",
]
}
......
......@@ -7,7 +7,7 @@
*
* @typedef {{scaleX: number, scaleY: number, rotate90: number}}
*/
let ImageTransformParam;
/* #export */ let ImageTransformParam;
/**
* Class representing image orientation.
......
......@@ -5,6 +5,15 @@
import("//third_party/closure_compiler/compile_js.gni")
import("//third_party/closure_compiler/js_unit_tests.gni")
import("//ui/file_manager/base/gn/js_test_gen_html.gni")
import("//ui/webui/resources/tools/js_modulizer.gni")
js_type_check("closure_compile_jsmodules") {
uses_js_modules = true
deps = [
":image_loader_client.m",
":load_image_request.m",
]
}
js_type_check("closure_compile_module") {
closure_flags = default_closure_args + [ "jscomp_error=strictCheckTypes" ]
......@@ -67,6 +76,17 @@ js_library("load_image_request") {
]
}
js_library("load_image_request.m") {
sources =
[ "$root_gen_dir/ui/file_manager/image_loader/load_image_request.m.js" ]
deps = [
"//ui/file_manager/file_manager/foreground/js/metadata:image_orientation.m",
"//ui/webui/resources/js:assert.m",
]
extra_deps = [ ":modulize" ]
}
js_library("image_loader_client") {
deps = [
":load_image_request",
......@@ -79,10 +99,28 @@ js_library("image_loader_client") {
]
}
js_unittest("image_loader_client_unittest") {
js_library("image_loader_client.m") {
sources =
[ "$root_gen_dir/ui/file_manager/image_loader/image_loader_client.m.js" ]
deps = [
":image_loader_client",
"//ui/file_manager/base/js:test_error_reporting",
":load_image_request.m",
"//ui/file_manager/file_manager/common/js:lru_cache.m",
]
externs_list = [
"$externs_path/chrome.js",
"$externs_path/chrome_extensions.js",
"$externs_path/metrics_private.js",
]
extra_deps = [ ":modulize" ]
}
js_unittest("image_loader_client_unittest.m") {
deps = [
":image_loader_client.m",
":load_image_request.m",
"//chrome/test/data/webui:chai_assert",
"//ui/file_manager/base/js:test_error_reporting.m",
]
}
......@@ -115,11 +153,22 @@ js_unittest("scheduler_unittest") {
]
}
js_test_gen_html("js_test_gen_html_modules") {
deps = [ ":image_loader_client_unittest.m" ]
js_module = true
closure_flags =
strict_error_checking_closure_args + [
"js_module_root=./gen/ui",
"js_module_root=../../ui",
"browser_resolver_prefix_replacements=\"chrome://test/=./\"",
]
}
js_test_gen_html("js_test_gen_html") {
closure_flags = default_closure_args + [ "jscomp_error=strictCheckTypes" ]
deps = [
":cache_unittest",
":image_loader_client_unittest",
":image_loader_unittest",
":scheduler_unittest",
]
......@@ -128,7 +177,16 @@ js_test_gen_html("js_test_gen_html") {
group("closure_compile") {
testonly = true
deps = [
":closure_compile_jsmodules",
":closure_compile_module",
":js_test_gen_html_modules_type_check_auto",
":js_test_gen_html_type_check_auto",
]
}
js_modulizer("modulize") {
input_files = [
"image_loader_client.js",
"load_image_request.js",
]
}
......@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
// #import {LRUCache} from '../file_manager/common/js/lru_cache.m.js';
// #import {LoadImageRequest, LoadImageResponse, LoadImageResponseStatus} from './load_image_request.m.js';
// clang-format on
/**
* Client used to connect to the remote ImageLoader extension. Client class runs
* in the extension, where the client.js is included (eg. Files app).
......@@ -12,7 +17,7 @@
*
* @constructor
*/
function ImageLoaderClient() {
/* #export */ function ImageLoaderClient() {
/**
* @type {number}
* @private
......
......@@ -2,10 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
import {assertFalse, assertTrue} from 'chrome://test/chai_assert.js';
import {reportPromise} from '../base/js/test_error_reporting.m.js';
import {ImageLoaderClient} from './image_loader_client.m.js';
import {LoadImageRequest, LoadImageResponse, LoadImageResponseStatus} from './load_image_request.m.js';
/** @suppress {const|checkTypes} */
function setUp() {
export function setUp() {
chrome.metricsPrivate = {
MetricTypeType:
{HISTOGRAM_LOG: 'histogram-log', HISTOGRAM_LINEAR: 'histogram-linear'},
......@@ -50,7 +53,7 @@ function loadAndCheckCacheUsed(client, url, cache) {
});
}
function testCache(callback) {
export function testCache(callback) {
const client = new ImageLoaderClient();
reportPromise(
loadAndCheckCacheUsed(client, 'http://example.com/image.jpg', true)
......@@ -65,7 +68,7 @@ function testCache(callback) {
callback);
}
function testNoCache(callback) {
export function testNoCache(callback) {
const client = new ImageLoaderClient();
reportPromise(
loadAndCheckCacheUsed(client, 'http://example.com/image.jpg', false)
......@@ -80,7 +83,7 @@ function testNoCache(callback) {
callback);
}
function testDataURLCache(callback) {
export function testDataURLCache(callback) {
const client = new ImageLoaderClient();
reportPromise(
loadAndCheckCacheUsed(client, 'data:URI', true)
......
......@@ -2,14 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
// clang-format off
// #import {assert} from 'chrome://resources/js/assert.m.js';
// #import {ImageOrientation, ImageTransformParam} from '../file_manager/foreground/js/metadata/image_orientation.m.js';
// clang-format on
/* #ignore */ 'use strict';
/**
* Response status.
*
* @enum {string}
*/
const LoadImageResponseStatus = {
/* #export */ const LoadImageResponseStatus = {
SUCCESS: 'success',
ERROR: 'error'
};
......@@ -20,7 +25,7 @@ const LoadImageResponseStatus = {
*
* @struct
*/
class LoadImageResponse {
/* #export */ class LoadImageResponse {
/**
* @param {!LoadImageResponseStatus} status
* @param {?number} taskId or null if fulfilled by the client-side cache.
......@@ -96,7 +101,7 @@ class LoadImageResponse {
*
* @struct
*/
class LoadImageRequest {
/* #export */ class LoadImageRequest {
constructor() {
// Parts that uniquely identify the request.
......
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