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

Unified Diff: ui/file_manager/gallery/js/gallery_item_unittest.js

Issue 802283005: Gallery: Update metadata in GalleryItem when saving items. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/gallery/js/gallery_item_unittest.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/gallery/js/gallery_item_unittest.js
diff --git a/ui/file_manager/gallery/js/gallery_item_unittest.js b/ui/file_manager/gallery/js/gallery_item_unittest.js
new file mode 100644
index 0000000000000000000000000000000000000000..e3c545b28593bb85fecba06b6eb8620a5e1956fc
--- /dev/null
+++ b/ui/file_manager/gallery/js/gallery_item_unittest.js
@@ -0,0 +1,79 @@
+// 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 of ImageUtil.
+ */
+var ImageUtil = {
+ getMetricName: function() {},
+ metrics: {
+ recordEnum: function() {},
+ recordInterval: function() {},
+ startInterval: function() {}
+ }
+};
+
+/**
+ * Mock of ImageEncoder
+ */
+var ImageEncoder = {
+ encodeMetadata: function() {},
+ getBlob: function() {}
+};
+
+/**
+ * Load time data.
+ */
+loadTimeData.data = {
+ DRIVE_DIRECTORY_LABEL: '',
+ DOWNLOADS_DIRECTORY_LABEL: ''
+};
+
+/**
+ * Tests for GalleryItem#saveToFile.
+ */
+function testSaveToFile(callback) {
+ var fileSystem = new MockFileSystem('volumeId');
+ fileSystem.populate(['/test.jpg']);
+ var entry = fileSystem.entries['/test.jpg'];
+ entry.createWriter = function(callback) {
+ callback({
+ write: function() {
+ Promise.resolve().then(function() {
+ this.onwriteend();
+ }.bind(this));
+ },
+ truncate: function() {
+ this.write();
+ }
+ });
+ };
+ var fetchedMediaCleared = false;
+ var metadataCache = {
+ getLatest: function(entries, type, callback) {
+ callback([{name: 'newMetadata'}]);
+ },
+ clear: function(entries, type) {
+ fetchedMediaCleared = true;
+ }
+ };
+ var item = new Gallery.Item(
+ entry,
+ {isReadOnly: false},
+ {name: 'oldMetadata'},
+ metadataCache,
+ /* original */ true);
+ assertEquals('oldMetadata', item.getMetadata().name);
+ assertFalse(fetchedMediaCleared);
+ reportPromise(
+ new Promise(item.saveToFile.bind(
+ item,
+ {getLocationInfo: function() { return {}; }},
+ null,
+ true,
+ document.createElement('canvas'))).then(function() {
+ assertEquals('newMetadata', item.getMetadata().name);
+ assertTrue(fetchedMediaCleared);
+ }), callback);
+}
« no previous file with comments | « ui/file_manager/gallery/js/gallery_item_unittest.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698