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

Unified Diff: ui/file_manager/gallery/js/gallery_data_model_unittest.js

Issue 838993002: Gallery: Split GalleryDataModel from gallery.js. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the year. Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/gallery/js/gallery_data_model_unittest.js
diff --git a/ui/file_manager/gallery/js/gallery_data_model_unittest.js b/ui/file_manager/gallery/js/gallery_data_model_unittest.js
new file mode 100644
index 0000000000000000000000000000000000000000..8a280e49d0ea4dbae70d118b8b4e0c224834eca1
--- /dev/null
+++ b/ui/file_manager/gallery/js/gallery_data_model_unittest.js
@@ -0,0 +1,58 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+
+var model;
+var fileSystem;
+var item;
+
+function setUp() {
+ var metadataCache = new MockMetadataCache();
+ model = new GalleryDataModel(metadataCache, /* Mock EntryListWatcher */{});
+ fileSystem = new MockFileSystem('volumeId');
+ item = new Gallery.Item(
+ new MockEntry(fileSystem, '/test.jpg'),
+ null,
+ {media: {mimeType: 'image/jpeg'}},
+ metadataCache,
+ /* original */ true);
+}
+
+function testSaveItemOverwrite(callback) {
+ // Mocking the saveToFile method.
+ item.saveToFile = function(
+ volumeManager,
+ fallbackDir,
+ overwrite,
+ canvas,
+ callback) {
+ assertTrue(overwrite);
+ callback(true);
+ };
+ model.push(item);
+ reportPromise(
+ model.saveItem({}, item, document.createElement('canvas'), true).
+ then(function() { assertEquals(1, model.length); }),
+ callback);
+}
+
+function testSaveItemNewFile(callback) {
+ // Mocking the saveToFile method.
+ item.saveToFile = function(
+ volumeManager,
+ fallbackDir,
+ overwrite,
+ canvas,
+ callback) {
+ assertFalse(overwrite);
+ // Gallery item track new file.
+ this.entry_ = new MockEntry(fileSystem, '/test (1).jpg');
+ callback(true);
+ };
+ model.push(item);
+ reportPromise(
+ model.saveItem({}, item, document.createElement('canvas'), false).
+ then(function() { assertEquals(2, model.length); }),
+ callback);
+}
« no previous file with comments | « ui/file_manager/gallery/js/gallery_data_model_unittest.html ('k') | ui/file_manager/gallery/js/gallery_scripts.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698