Commit 63af8d5f authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

Gallery: closure-compile image_editor/image_encoder_unittest.js

The shared, unittest_util.js optionally overwrites some vars specified
by externs that may or may not exist in the unit test. Suppress the
warnings around these.

Bug: 867700, 860355
Change-Id: I461ed7921e7d454869d8e64de8c0eeeb626e4af7
Reviewed-on: https://chromium-review.googlesource.com/1154774Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580043}
parent 6a18a9c5
...@@ -18,6 +18,7 @@ js_type_check("closure_compile") { ...@@ -18,6 +18,7 @@ js_type_check("closure_compile") {
":metrics_events", ":metrics_events",
":mock_entry", ":mock_entry",
":progress_center_common", ":progress_center_common",
":unittest_util",
":util", ":util",
":volume_manager_common", ":volume_manager_common",
] ]
...@@ -89,6 +90,12 @@ js_library("mock_entry") { ...@@ -89,6 +90,12 @@ js_library("mock_entry") {
js_library("progress_center_common") { js_library("progress_center_common") {
} }
js_library("unittest_util") {
deps = [
"//ui/webui/resources/js:webui_resource_test",
]
}
js_library("util") { js_library("util") {
deps = [ deps = [
":files_app_entry_types", ":files_app_entry_types",
......
...@@ -95,7 +95,7 @@ function assertFileEntryPathsEqual(expectedPaths, fileEntries) { ...@@ -95,7 +95,7 @@ function assertFileEntryPathsEqual(expectedPaths, fileEntries) {
* @constructor * @constructor
*/ */
function TestCallRecorder() { function TestCallRecorder() {
/** @private {!Array<!Argument>} */ /** @private {!Array<!Arguments>} */
this.calls_ = []; this.calls_ = [];
/** /**
...@@ -188,7 +188,7 @@ MockAPIEvent.prototype.dispatch = function(var_args) { ...@@ -188,7 +188,7 @@ MockAPIEvent.prototype.dispatch = function(var_args) {
/** /**
* Stubs the chrome.storage API. * Stubs the chrome.storage API.
* @construct * @constructor
* @struct * @struct
*/ */
function MockChromeStorageAPI() { function MockChromeStorageAPI() {
...@@ -196,7 +196,9 @@ function MockChromeStorageAPI() { ...@@ -196,7 +196,9 @@ function MockChromeStorageAPI() {
this.state = {}; this.state = {};
window.chrome = window.chrome || {}; window.chrome = window.chrome || {};
/** @suppress {const} */
window.chrome.runtime = window.chrome.runtime || {}; // For lastError. window.chrome.runtime = window.chrome.runtime || {}; // For lastError.
/** @suppress {checkTypes} */
window.chrome.storage = { window.chrome.storage = {
local: { local: {
get: this.get_.bind(this), get: this.get_.bind(this),
...@@ -241,9 +243,11 @@ MockChromeStorageAPI.prototype.set_ = function(values, opt_callback) { ...@@ -241,9 +243,11 @@ MockChromeStorageAPI.prototype.set_ = function(values, opt_callback) {
function MockCommandLinePrivate() { function MockCommandLinePrivate() {
this.flags_ = {}; this.flags_ = {};
if (!chrome) { if (!chrome) {
/** @suppress {const|checkTypes} */
chrome = {}; chrome = {};
} }
if (!chrome.commandLinePrivate) { if (!chrome.commandLinePrivate) {
/** @suppress {checkTypes} */
chrome.commandLinePrivate = {}; chrome.commandLinePrivate = {};
} }
chrome.commandLinePrivate.hasSwitch = function(name, callback) { chrome.commandLinePrivate.hasSwitch = function(name, callback) {
......
...@@ -17,6 +17,7 @@ js_type_check("closure_compile") { ...@@ -17,6 +17,7 @@ js_type_check("closure_compile") {
":image_editor_prompt", ":image_editor_prompt",
":image_editor_toolbar", ":image_editor_toolbar",
":image_encoder", ":image_encoder",
":image_encoder_unittest",
":image_loader", ":image_loader",
":image_resize", ":image_resize",
":image_transform", ":image_transform",
...@@ -41,6 +42,7 @@ js_library("closure_compile_externs") { ...@@ -41,6 +42,7 @@ js_library("closure_compile_externs") {
"../../../externs/background/volume_manager_factory.js", "../../../externs/background/volume_manager_factory.js",
"../../../externs/entry_location.js", "../../../externs/entry_location.js",
"../../../externs/exif_entry.js", "../../../externs/exif_entry.js",
"../../../externs/metadata_worker_window.js",
"../../../externs/paper_elements.js", "../../../externs/paper_elements.js",
"../../../externs/platform.js", "../../../externs/platform.js",
"../../../externs/volume_info.js", "../../../externs/volume_info.js",
...@@ -132,6 +134,14 @@ js_library("image_encoder") { ...@@ -132,6 +134,14 @@ js_library("image_encoder") {
] ]
} }
js_library("image_encoder_unittest") {
deps = [
":image_encoder",
"../../../file_manager/common/js:unittest_util",
"../../../file_manager/foreground/js/metadata:metadata_parser",
]
}
js_library("image_loader") { js_library("image_loader") {
deps = [ deps = [
":image_util", ":image_util",
......
...@@ -83,12 +83,13 @@ function testWebpImage(callback) { ...@@ -83,12 +83,13 @@ function testWebpImage(callback) {
function testWithBrokenMetadata() { function testWithBrokenMetadata() {
var canvas = getSampleCanvas(); var canvas = getSampleCanvas();
var metadata = { var metadata = /** @type {!MetadataItem} */ ({
// No mimetype field. // No mimetype field.
}; });
// An exception should be thrown if metadata is broken. // An exception should be thrown if metadata is broken.
const quality = 0.5;
assertThrows(function() { assertThrows(function() {
var encoder = ImageEncoder.encodeMetadata(metadata, canvas); var encoder = ImageEncoder.encodeMetadata(metadata, canvas, quality);
}); });
} }
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
/** /**
* Creates a sample canvas. * Creates a sample canvas.
* @return {HTMLCanvasElement} * @return {!HTMLCanvasElement}
*/ */
function getSampleCanvas() { function getSampleCanvas() {
var canvas = var canvas =
/** @type {HTMLCanvasElement} */ (document.createElement('canvas')); assertInstanceof(document.createElement('canvas'), HTMLCanvasElement);
canvas.width = 1920; canvas.width = 1920;
canvas.height = 1080; canvas.height = 1080;
......
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