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 model = new GalleryDataModel(
12 /* Mock MetadataModel */{},
13 /* Mock EntryListWatcher */{});
14 fileSystem = new MockFileSystem('volumeId');
15 item = new Gallery.Item(
16 new MockEntry(fileSystem, '/test.jpg'),
18 /* metadataItem */ {},
19 /* thumbnailMetadataItem */ {},
23 function testSaveItemOverwrite(callback) {
24 // Mocking the saveToFile method.
25 item.saveToFile = function(
32 assertTrue(overwrite);
37 model.saveItem({}, item, document.createElement('canvas'), true).
38 then(function() { assertEquals(1, model.length); }),
42 function testSaveItemNewFile(callback) {
43 // Mocking the saveToFile method.
44 item.saveToFile = function(
51 assertFalse(overwrite);
52 // Gallery item track new file.
53 this.entry_ = new MockEntry(fileSystem, '/test (1).jpg');
58 model.saveItem({}, item, document.createElement('canvas'), false).
59 then(function() { assertEquals(2, model.length); }),