OLD | NEW |
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 var model; | 5 var model; |
6 var fileSystem; | 6 var fileSystem; |
7 var item; | 7 var item; |
8 | 8 |
9 /** | 9 /** |
10 * Mock thumbnail model. | 10 * Mock thumbnail model. |
11 */ | 11 */ |
12 function ThumbnailModel() { | 12 function ThumbnailModel() { |
13 } | 13 } |
14 | 14 |
15 ThumbnailModel.prototype.get = function(entries) { | 15 ThumbnailModel.prototype.get = function(entries) { |
16 return Promise.resolve(entries.map(function() { | 16 return Promise.resolve(entries.map(function() { |
17 return {}; | 17 return {}; |
18 })); | 18 })); |
19 }; | 19 }; |
20 | 20 |
21 function setUp() { | 21 function setUp() { |
22 model = new GalleryDataModel( | 22 model = new GalleryDataModel( |
23 /* Mock MetadataModel */{ | 23 /* Mock MetadataModel */{ |
24 get: function() { | 24 get: function() { |
25 return Promise.resolve([{}]); | 25 return Promise.resolve([{}]); |
26 } | 26 } |
27 }, | 27 }, |
28 /* Mock EntryListWatcher */{}); | 28 /* Mock EntryListWatcher */{}); |
29 fileSystem = new MockFileSystem('volumeId'); | 29 fileSystem = new MockFileSystem('volumeId'); |
| 30 model.fallbackSaveDirectory = fileSystem.root; |
30 } | 31 } |
31 | 32 |
32 function testSaveItemOverwrite(callback) { | 33 function testSaveItemOverwrite(callback) { |
33 var item = new Gallery.Item( | 34 var item = new Gallery.Item( |
34 new MockEntry(fileSystem, '/test.jpg'), | 35 new MockEntry(fileSystem, '/test.jpg'), |
35 null, | 36 null, |
36 /* metadataItem */ {}, | 37 /* metadataItem */ {}, |
37 /* thumbnailMetadataItem */ {}, | 38 /* thumbnailMetadataItem */ {}, |
38 /* original */ true); | 39 /* original */ true); |
39 | 40 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 false /* not overwrite */). | 84 false /* not overwrite */). |
84 then(function() { | 85 then(function() { |
85 assertEquals(2, model.length); | 86 assertEquals(2, model.length); |
86 assertEquals('test (1).png', model.item(0).getFileName()); | 87 assertEquals('test (1).png', model.item(0).getFileName()); |
87 assertFalse(model.item(0).isOriginal()); | 88 assertFalse(model.item(0).isOriginal()); |
88 assertEquals('test.webp', model.item(1).getFileName()); | 89 assertEquals('test.webp', model.item(1).getFileName()); |
89 assertTrue(model.item(1).isOriginal()); | 90 assertTrue(model.item(1).isOriginal()); |
90 }), | 91 }), |
91 callback); | 92 callback); |
92 } | 93 } |
OLD | NEW |