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

Side by Side Diff: ui/file_manager/gallery/js/gallery_item_unittest.js

Issue 1053653003: Gallery: Support RAW files in Gallery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the second bind. Created 5 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Mock of ImageUtil. 6 * Mock of ImageUtil.
7 */ 7 */
8 var ImageUtil = { 8 var ImageUtil = {
9 getMetricName: function() {}, 9 getMetricName: function() {},
10 metrics: { 10 metrics: {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 item, 183 item,
184 {getLocationInfo: function() { return {}; }}, 184 {getLocationInfo: function() { return {}; }},
185 getMockMetadataModel(), 185 getMockMetadataModel(),
186 /* fallbackDir */ null, 186 /* fallbackDir */ null,
187 /* overwrite */ true, 187 /* overwrite */ true,
188 document.createElement('canvas'))).then(function(result) { 188 document.createElement('canvas'))).then(function(result) {
189 assertFalse(result); 189 assertFalse(result);
190 assertFalse(writeOperationRun); 190 assertFalse(writeOperationRun);
191 }), callback); 191 }), callback);
192 } 192 }
193
194 function testSaveToFileRaw(callback) {
195 var fileSystem = new MockFileSystem('volumeId');
196 fileSystem.populate(['/test.arw']);
197 fileSystem.entries['/'].getFile = function(name, options, success, error) {
198 if (options.create) {
199 assertEquals('test - Edited.jpg', name);
200 fileSystem.populate(['/test - Edited.jpg']);
201 var entry = fileSystem.entries['/test - Edited.jpg'];
202 entry.createWriter = function(callback) {
203 callback({
204 write: function() {
205 Promise.resolve().then(function() {
206 this.onwriteend();
207 }.bind(this));
208 },
209 truncate: function() {
210 this.write();
211 }
212 });
213 };
214 }
215 MockDirectoryEntry.prototype.getFile.apply(this, arguments);
216 };
217 var entryChanged = false;
218 var metadataModel = getMockMetadataModel();
219 metadataModel.notifyEntriesChanged = function() {
220 entryChanged = true;
221 };
222
223 var item = new Gallery.Item(
224 fileSystem.entries['/test.arw'],
225 {isReadOnly: false},
226 {size: 100},
227 {},
228 /* original */ true);
229 assertEquals(100, item.getMetadataItem().size);
230 assertFalse(entryChanged);
231 reportPromise(
232 new Promise(item.saveToFile.bind(
233 item,
234 {getLocationInfo: function() { return {}; }},
235 metadataModel,
236 /* fallbackDir */ null,
237 /* overwrite is true but ignored */ true,
238 document.createElement('canvas'))).then(function(success) {
239 assertTrue(success);
240 assertEquals(200, item.getMetadataItem().size);
241 assertTrue(entryChanged);
242 assertFalse(item.isOriginal());
243 }), callback);
244 }
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/gallery_item_unittest.html ('k') | ui/file_manager/gallery/js/gallery_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698