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.
11 * Mock thumbnail model.
13 function ThumbnailModel() {
16 ThumbnailModel.prototype.get = function(entries) {
17 return Promise.resolve(entries.map(function() {
23 model = new GalleryDataModel(
24 /* Mock MetadataModel */{
26 return Promise.resolve([{}]);
29 /* Mock EntryListWatcher */{});
30 fileSystem = new MockFileSystem('volumeId');
31 item = new Gallery.Item(
32 new MockEntry(fileSystem, '/test.jpg'),
34 /* metadataItem */ {},
35 /* thumbnailMetadataItem */ {},
39 function testSaveItemOverwrite(callback) {
40 // Mocking the saveToFile method.
41 item.saveToFile = function(
48 assertTrue(overwrite);
53 model.saveItem({}, item, document.createElement('canvas'), true).
54 then(function() { assertEquals(1, model.length); }),
58 function testSaveItemNewFile(callback) {
59 // Mocking the saveToFile method.
60 item.saveToFile = function(
67 assertFalse(overwrite);
68 // Gallery item track new file.
69 this.entry_ = new MockEntry(fileSystem, '/test (1).jpg');
74 model.saveItem({}, item, document.createElement('canvas'), false).
75 then(function() { assertEquals(2, model.length); }),