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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * Mock of ImageUtil.
7 */
8 var ImageUtil = {
9 getMetricName: function() {},
10 metrics: {
11 recordEnum: function() {},
12 recordInterval: function() {},
13 startInterval: function() {}
14 }
15 };
16
17 /**
18 * Mock of ImageEncoder
19 */
20 var ImageEncoder = {
21 encodeMetadata: function() {},
22 getBlob: function() {}
23 };
24
25 /**
26 * Load time data.
27 */
28 loadTimeData.data = {
29 DRIVE_DIRECTORY_LABEL: '',
30 DOWNLOADS_DIRECTORY_LABEL: ''
31 };
32
33 /**
34 * Tests for GalleryItem#saveToFile.
35 */
36 function testSaveToFile(callback) {
37 var fileSystem = new MockFileSystem('volumeId');
38 fileSystem.populate(['/test.jpg']);
39 var entry = fileSystem.entries['/test.jpg'];
40 entry.createWriter = function(callback) {
41 callback({
42 write: function() {
43 Promise.resolve().then(function() {
44 this.onwriteend();
45 }.bind(this));
46 },
47 truncate: function() {
48 this.write();
49 }
50 });
51 };
52 var fetchedMediaCleared = false;
53 var metadataCache = {
54 getLatest: function(entries, type, callback) {
55 callback([{name: 'newMetadata'}]);
56 },
57 clear: function(entries, type) {
58 fetchedMediaCleared = true;
59 }
60 };
61 var item = new Gallery.Item(
62 entry,
63 {isReadOnly: false},
64 {name: 'oldMetadata'},
65 metadataCache,
66 /* original */ true);
67 assertEquals('oldMetadata', item.getMetadata().name);
68 assertFalse(fetchedMediaCleared);
69 reportPromise(
70 new Promise(item.saveToFile.bind(
71 item,
72 {getLocationInfo: function() { return {}; }},
73 null,
74 true,
75 document.createElement('canvas'))).then(function() {
76 assertEquals('newMetadata', item.getMetadata().name);
77 assertTrue(fetchedMediaCleared);
78 }), callback);
79 }
OLDNEW
« 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