Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: ui/file_manager/file_manager/foreground/js/mock_thumbnail_loader.js

Issue 885323002: Initial implementation for ListThumbnailLoader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/list_thumbnail_loader_unittest.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/mock_thumbnail_loader.js
diff --git a/ui/file_manager/file_manager/foreground/js/mock_thumbnail_loader.js b/ui/file_manager/file_manager/foreground/js/mock_thumbnail_loader.js
new file mode 100644
index 0000000000000000000000000000000000000000..bf49a7ec9a6f63a32f5509a7c421053dd06755e0
--- /dev/null
+++ b/ui/file_manager/file_manager/foreground/js/mock_thumbnail_loader.js
@@ -0,0 +1,56 @@
+// 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.
+
+/**
+ * Mock thumbnail loader.
+ *
+ * @param {Entry} entry An entry.
+ * @param {ThumbnailLoader.LoaderType=} opt_loaderType Loader type.
+ * @param {Object=} opt_metadata Metadata.
+ * @param {string=} opt_mediaType Media type.
+ * @param {Array<ThumbnailLoader.LoadTarget>=} opt_loadTargets Load targets.
+ * @param {number=} opt_priority Priority.
+ */
+function MockThumbnailLoader(entry, opt_loaderType, opt_metadata, opt_mediaType,
+ opt_loadTargets, opt_priority) {
+ this.testImageDataUrl_ = null;
+}
+
+/**
+ * @type {string} Data url of an image.
+ */
+MockThumbnailLoader.testImageDataUrl_ = null;
+
+/**
+ * Set data url of an image which is returned for testing.
+ *
+ * @param {string} dataUrl Data url of an image.
+ */
+MockThumbnailLoader.setTestImageDataUrl = function(dataUrl) {
+ MockThumbnailLoader.testImageDataUrl_ = dataUrl;
+};
+
+/**
+ * Load an image. (This mock implementation does not attach an image to the
+ * box).
+ *
+ * @param {Element} box Box.
+ * @param {ThumbnailLoader.FillMode} fillMode Fill mode.
+ * @param {ThumbnailLoader.OptimizationMode=} opt_optimizationMode Optimization.
+ * @param {function(Image, Object)=} opt_onSuccess Success callback.
+ * @param {function()=} opt_onError Error callback.
+ * @param {function()=} opt_onGeneric Callback which is called when generic
+ * image is used.
+ */
+MockThumbnailLoader.prototype.load = function(
+ box, fillMode, opt_optimizationMode, opt_onSuccess, opt_onError,
+ opt_onGeneric) {
+ if (opt_onSuccess && MockThumbnailLoader.testImageDataUrl_) {
+ var image = new Image();
+ image.onload = function() {
+ opt_onSuccess(image, null);
+ };
+ image.src = MockThumbnailLoader.testImageDataUrl_;
+ }
+};
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/list_thumbnail_loader_unittest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698