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.
9 getMetricName: function() {},
11 recordEnum: function() {},
12 recordInterval: function() {},
13 startInterval: function() {}
18 * Mock of ImageEncoder
21 encodeMetadata: function() {},
22 getBlob: function() {}
29 DRIVE_DIRECTORY_LABEL
: '',
30 DOWNLOADS_DIRECTORY_LABEL
: ''
34 * Tests for GalleryItem#saveToFile.
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
) {
43 Promise
.resolve().then(function() {
47 truncate: function() {
52 var fetchedMediaCleared
= false;
54 getLatest: function(entries
, type
, callback
) {
55 callback([{name
: 'newMetadata'}]);
57 clear: function(entries
, type
) {
58 fetchedMediaCleared
= true;
61 var item
= new Gallery
.Item(
64 {name
: 'oldMetadata'},
67 assertEquals('oldMetadata', item
.getMetadata().name
);
68 assertFalse(fetchedMediaCleared
);
70 new Promise(item
.saveToFile
.bind(
72 {getLocationInfo: function() { return {}; }},
75 document
.createElement('canvas'))).then(function() {
76 assertEquals('newMetadata', item
.getMetadata().name
);
77 assertTrue(fetchedMediaCleared
);