Commit a2bbe9de authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

Closure compile all file_manager/image_loader unittests.

This was making refactoring for https://crbug.com/879958 difficult.

Closure-compile existing unit_tests for the image_loader extension, and
delete the handcrafted unittest.html files.

Bug: 860355
Change-Id: I0d99d0383eb8fe48813d9142a14ce9af28da2dc5
Reviewed-on: https://chromium-review.googlesource.com/1207784Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589377}
parent f46bf54d
...@@ -11,18 +11,17 @@ class ImageLoaderJsTest : public FileManagerJsTestBase { ...@@ -11,18 +11,17 @@ class ImageLoaderJsTest : public FileManagerJsTestBase {
}; };
IN_PROC_BROWSER_TEST_F(ImageLoaderJsTest, ImageLoaderClientTest) { IN_PROC_BROWSER_TEST_F(ImageLoaderJsTest, ImageLoaderClientTest) {
RunTest(base::FilePath(FILE_PATH_LITERAL( RunGeneratedTest("/image_loader_client_unittest.html");
"image_loader_client_unittest.html")));
} }
IN_PROC_BROWSER_TEST_F(ImageLoaderJsTest, CacheTest) { IN_PROC_BROWSER_TEST_F(ImageLoaderJsTest, CacheTest) {
RunTest(base::FilePath(FILE_PATH_LITERAL("cache_unittest.html"))); RunGeneratedTest("/cache_unittest.html");
} }
IN_PROC_BROWSER_TEST_F(ImageLoaderJsTest, ImageLoaderTest) { IN_PROC_BROWSER_TEST_F(ImageLoaderJsTest, ImageLoaderTest) {
RunTest(base::FilePath(FILE_PATH_LITERAL("image_loader_unittest.html"))); RunGeneratedTest("/image_loader_unittest.html");
} }
IN_PROC_BROWSER_TEST_F(ImageLoaderJsTest, PiexLoaderTest) { IN_PROC_BROWSER_TEST_F(ImageLoaderJsTest, PiexLoaderTest) {
RunTest(base::FilePath(FILE_PATH_LITERAL("piex_loader_unittest.html"))); RunGeneratedTest("/piex_loader_unittest.html");
} }
...@@ -52,5 +52,6 @@ group("unit_test_data") { ...@@ -52,5 +52,6 @@ group("unit_test_data") {
deps = [ deps = [
"gallery/js:unit_tests", "gallery/js:unit_tests",
"gallery/js/image_editor:unit_tests", "gallery/js/image_editor:unit_tests",
"image_loader:unit_tests",
] ]
} }
...@@ -61,6 +61,8 @@ js_library("metrics") { ...@@ -61,6 +61,8 @@ js_library("metrics") {
"//ui/webui/resources/js:assert", "//ui/webui/resources/js:assert",
] ]
externs_list = [ externs_list = [
"$externs_path/chrome.js",
"$externs_path/chrome_extensions.js",
"$externs_path/file_manager_private.js", "$externs_path/file_manager_private.js",
"$externs_path/file_system_provider.js", "$externs_path/file_system_provider.js",
"$externs_path/metrics_private.js", "$externs_path/metrics_private.js",
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
# found in the LICENSE file. # found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
import("//ui/file_manager/js_unit_tests.gni")
js_type_check("closure_compile") { js_type_check("closure_compile_module") {
deps = [ deps = [
":background", ":background",
":cache", ":cache",
":closure_compile_externs",
":image_loader", ":image_loader",
":image_loader_client", ":image_loader_client",
":image_loader_util", ":image_loader_util",
...@@ -18,17 +18,6 @@ js_type_check("closure_compile") { ...@@ -18,17 +18,6 @@ js_type_check("closure_compile") {
] ]
} }
js_library("closure_compile_externs") {
sources = []
externs_list = [
"$externs_path/chrome_extensions.js",
"$externs_path/file_manager_private.js",
"$externs_path/file_system_provider.js",
"$externs_path/metrics_private.js",
"//third_party/analytics/externs.js",
]
}
js_library("background") { js_library("background") {
deps = [ deps = [
":image_loader", ":image_loader",
...@@ -38,6 +27,13 @@ js_library("background") { ...@@ -38,6 +27,13 @@ js_library("background") {
js_library("cache") { js_library("cache") {
} }
js_library("cache_unittest") {
deps = [
":cache",
"//ui/webui/resources/js:webui_resource_test",
]
}
js_library("image_loader") { js_library("image_loader") {
deps = [ deps = [
":cache", ":cache",
...@@ -45,6 +41,17 @@ js_library("image_loader") { ...@@ -45,6 +41,17 @@ js_library("image_loader") {
":request", ":request",
":scheduler", ":scheduler",
] ]
externs_list = [
"$externs_path/file_manager_private.js",
"$externs_path/file_system_provider.js",
]
}
js_library("image_loader_unittest") {
deps = [
":image_loader",
"//ui/webui/resources/js:webui_resource_test",
]
} }
js_library("image_loader_util") { js_library("image_loader_util") {
...@@ -58,6 +65,19 @@ js_library("image_loader_client") { ...@@ -58,6 +65,19 @@ js_library("image_loader_client") {
deps = [ deps = [
"../file_manager/common/js:lru_cache", "../file_manager/common/js:lru_cache",
] ]
externs_list = [
"$externs_path/chrome.js",
"$externs_path/chrome_extensions.js",
"$externs_path/metrics_private.js",
]
}
js_library("image_loader_client_unittest") {
deps = [
":image_loader_client",
"../file_manager/common/js:unittest_util",
"//ui/webui/resources/js:webui_resource_test",
]
} }
js_library("piex_loader") { js_library("piex_loader") {
...@@ -66,6 +86,15 @@ js_library("piex_loader") { ...@@ -66,6 +86,15 @@ js_library("piex_loader") {
] ]
} }
js_library("piex_loader_unittest") {
deps = [
":piex_loader",
"../file_manager/common/js:unittest_util",
"//ui/webui/resources/js:webui_resource_test",
"//ui/webui/resources/js/cr:ui",
]
}
js_library("request") { js_library("request") {
deps = [ deps = [
":cache", ":cache",
...@@ -82,3 +111,19 @@ js_library("scheduler") { ...@@ -82,3 +111,19 @@ js_library("scheduler") {
":request", ":request",
] ]
} }
js_unit_tests("unit_tests") {
deps = [
":cache_unittest",
":image_loader_client_unittest",
":image_loader_unittest",
":piex_loader_unittest",
]
}
group("closure_compile") {
deps = [
":closure_compile_module",
":unit_tests_type_check",
]
}
<!-- Copyright 2014 The Chromium Authors. All rights reserved.
-- Use of this source code is governed by a BSD-style license that can be
-- found in the LICENSE file.
-->
<script src="cache.js"></script>
<script src="cache_unittest.js"></script>
<!-- Copyright 2014 The Chromium Authors. All rights reserved.
-- Use of this source code is governed by a BSD-style license that can be
-- found in the LICENSE file.
-->
<script src="../file_manager/common/js/lru_cache.js"></script>
<script src="../file_manager/common/js/unittest_util.js"></script>
<script src="image_loader_client.js"></script>
<script src="image_loader_client_unittest.js"></script>
...@@ -4,19 +4,19 @@ ...@@ -4,19 +4,19 @@
'use strict'; 'use strict';
var chrome = { /** @suppress {const|checkTypes} */
metricsPrivate: { function setUp() {
MetricTypeType: { chrome.metricsPrivate = {
HISTOGRAM_LOG: 'histogram-log', MetricTypeType:
HISTOGRAM_LINEAR: 'histogram-linear' {HISTOGRAM_LOG: 'histogram-log', HISTOGRAM_LINEAR: 'histogram-linear'},
},
recordPercentage: function() {}, recordPercentage: function() {},
recordValue: function() {} recordValue: function() {}
}, };
i18n: {
getMessage: function() {} chrome.i18n = {
} getMessage: function() {},
}; };
}
/** /**
* Lets the client to load URL and returns the local cache (not caches in the * Lets the client to load URL and returns the local cache (not caches in the
...@@ -30,6 +30,7 @@ var chrome = { ...@@ -30,6 +30,7 @@ var chrome = {
function loadAndCheckCacheUsed(client, url, options) { function loadAndCheckCacheUsed(client, url, options) {
var cacheUsed = true; var cacheUsed = true;
/** @suppress {accessControls} */
ImageLoaderClient.sendMessage_ = function(message, callback) { ImageLoaderClient.sendMessage_ = function(message, callback) {
cacheUsed = false; cacheUsed = false;
if (callback) if (callback)
......
<!DOCTYPE html>
<!-- Copyright 2015 The Chromium Authors. All rights reserved.
-- Use of this source code is governed by a BSD-style license that can be
-- found in the LICENSE file.
-->
<script src="../../webui/resources/js/assert.js"></script>
<script src="../file_manager/foreground/js/metadata/image_orientation.js"></script>
<script src="image_loader_util.js"></script>
<script src="image_loader.js"></script>
<script src="image_loader_unittest.js"></script>
<!DOCTYPE html>
<!-- Copyright 2017 The Chromium Authors. All rights reserved.
-- Use of this source code is governed by a BSD-style license that can be
-- found in the LICENSE file.
-->
<script src="../../webui/resources/js/assert.js"></script>
<script src="../../webui/resources/js/cr.js"></script>
<script src="../../webui/resources/js/cr/ui.js"></script>
<script src="../file_manager/common/js/unittest_util.js"></script>
<script src="../file_manager/foreground/js/metadata/image_orientation.js"></script>
<script src="piex_loader.js"></script>
<script src="piex_loader_unittest.js"></script>
...@@ -8,7 +8,11 @@ chrome.fileManagerPrivate = { ...@@ -8,7 +8,11 @@ chrome.fileManagerPrivate = {
} }
}; };
var MockModule = cr.ui.define('div'); /**
* @constructor
* @extends {HTMLDivElement}
*/
var MockModule = /** @type{function(new:MockModule)}*/ (cr.ui.define('div'));
MockModule.prototype = Object.create(HTMLDivElement.prototype); MockModule.prototype = Object.create(HTMLDivElement.prototype);
MockModule.prototype.constructor = MockModule; MockModule.prototype.constructor = MockModule;
...@@ -70,7 +74,7 @@ function testUnloadingAfterTimeout(callback) { ...@@ -70,7 +74,7 @@ function testUnloadingAfterTimeout(callback) {
assertEquals('thumbnail-data', data.thumbnail); assertEquals('thumbnail-data', data.thumbnail);
assertEquals(0, unloadCount); assertEquals(0, unloadCount);
assertEquals(1, loadCount); assertEquals(1, loadCount);
return loader.load('http://foobar/another.raw') return loader.load('http://foobar/another.raw');
}) })
.then(function(data) { .then(function(data) {
// The NaCl module is not unloaded, as the next request came // The NaCl module is not unloaded, as the next request came
...@@ -85,7 +89,7 @@ function testUnloadingAfterTimeout(callback) { ...@@ -85,7 +89,7 @@ function testUnloadingAfterTimeout(callback) {
// unload the NaCl module. // unload the NaCl module.
loader.simulateIdleTimeoutPassedForTests(); loader.simulateIdleTimeoutPassedForTests();
assertEquals(1, unloadCount); assertEquals(1, unloadCount);
return loader.load('http://foobar/chocolate.raw') return loader.load('http://foobar/chocolate.raw');
}) })
.then(function(data) { .then(function(data) {
// Following requests should reload the NaCl module. // Following requests should reload the NaCl module.
...@@ -97,4 +101,4 @@ function testUnloadingAfterTimeout(callback) { ...@@ -97,4 +101,4 @@ function testUnloadingAfterTimeout(callback) {
unloadPromise unloadPromise
]), ]),
callback); callback);
}; }
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