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

Unified Diff: chrome/test/data/file_manager/unit_tests/navigation_list_model_unittest.js

Issue 48623002: [Files.app] Add an unittest of NavigationListModel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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
« no previous file with comments | « chrome/test/data/file_manager/unit_tests/navigation_list_model_unittest.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/file_manager/unit_tests/navigation_list_model_unittest.js
diff --git a/chrome/test/data/file_manager/unit_tests/navigation_list_model_unittest.js b/chrome/test/data/file_manager/unit_tests/navigation_list_model_unittest.js
new file mode 100644
index 0000000000000000000000000000000000000000..3b49957a9291cd978bf2ddac349000ff05c215d1
--- /dev/null
+++ b/chrome/test/data/file_manager/unit_tests/navigation_list_model_unittest.js
@@ -0,0 +1,98 @@
+// Copyright 2013 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.
+
+function testModel() {
+ var volumeManager = new MockVolumeManager();
+ var shortcutListModel =
+ new MockFolderShortcutDataModel(['/drive/root/shortcut']);
+ var model = new NavigationListModel(volumeManager, shortcutListModel);
+ assertEquals(3, model.length);
+ assertEquals('/drive/root', model.item(0).path);
+ assertEquals('/Downloads', model.item(1).path);
+ assertEquals('/drive/root/shortcut', model.item(2).path);
+}
+
+function testAddAndRemoveShortcuts() {
+ var volumeManager = new MockVolumeManager();
+ var shortcutListModel =
+ new MockFolderShortcutDataModel(['/drive/root/shortcut']);
+ var model = new NavigationListModel(volumeManager, shortcutListModel);
+
+ assertEquals(3, model.length);
+
+ // Add a shortcut at the tail.
+ shortcutListModel.splice(1, 0, '/drive/root/shortcut2');
+ assertEquals(4, model.length);
+ assertEquals('/drive/root/shortcut2', model.item(3).path);
+
+ // Add a shortcut at the head.
+ shortcutListModel.splice(0, 0, '/drive/root/hoge');
+ assertEquals(5, model.length);
+ assertEquals('/drive/root/hoge', model.item(2).path);
+ assertEquals('/drive/root/shortcut', model.item(3).path);
+ assertEquals('/drive/root/shortcut2', model.item(4).path);
+
+ // Remove the last shortcut.
+ shortcutListModel.splice(2, 1);
+ assertEquals(4, model.length);
+ assertEquals('/drive/root/hoge', model.item(2).path);
+ assertEquals('/drive/root/shortcut', model.item(3).path);
+
+ // Remove the first shortcut.
+ shortcutListModel.splice(0, 1);
+ assertEquals(3, model.length);
+ assertEquals('/drive/root/shortcut', model.item(2).path);
+}
+
+function testAddAndRemoveVolumes() {
+ var volumeManager = new MockVolumeManager();
+ var shortcutListModel =
+ new MockFolderShortcutDataModel(['/drive/root/shortcut']);
+ var model = new NavigationListModel(volumeManager, shortcutListModel);
+
+ assertEquals(3, model.length);
+
+ // Removable volume 'hoge' is mounted.
+ volumeManager.volumeInfoList.push(MockVolumeManager.createMockVolumeInfo(
+ util.VolumeType.REMOVABLE, '/removable/hoge'));
+ assertEquals(4, model.length);
+ assertEquals('/drive/root', model.item(0).path);
+ assertEquals('/Downloads', model.item(1).path);
+ assertEquals('/removable/hoge', model.item(2).path);
+ assertEquals('/drive/root/shortcut', model.item(3).path);
+
+ // Removable volume 'fuga' is mounted.
+ volumeManager.volumeInfoList.push(MockVolumeManager.createMockVolumeInfo(
+ util.VolumeType.REMOVABLE, '/removable/fuga'));
+ assertEquals(5, model.length);
+ assertEquals('/drive/root', model.item(0).path);
+ assertEquals('/Downloads', model.item(1).path);
+ assertEquals('/removable/hoge', model.item(2).path);
+ assertEquals('/removable/fuga', model.item(3).path);
+ assertEquals('/drive/root/shortcut', model.item(4).path);
+
+ // A shortcut is created on the 'hoge' volume.
+ shortcutListModel.splice(1, 0, '/removable/hoge/shortcut2');
+ assertEquals(6, model.length);
+ assertEquals('/drive/root', model.item(0).path);
+ assertEquals('/Downloads', model.item(1).path);
+ assertEquals('/removable/hoge', model.item(2).path);
+ assertEquals('/removable/fuga', model.item(3).path);
+ assertEquals('/drive/root/shortcut', model.item(4).path);
+ assertEquals('/removable/hoge/shortcut2', model.item(5).path);
+
+ // The 'hoge' is unmounted. A shortcut on 'hoge' is removed.
+ volumeManager.volumeInfoList.splice(2, 1);
+ assertEquals(4, model.length);
+ assertEquals('/drive/root', model.item(0).path);
+ assertEquals('/Downloads', model.item(1).path);
+ assertEquals('/removable/fuga', model.item(2).path);
+ assertEquals('/drive/root/shortcut', model.item(3).path);
+
+ // The Drive is unmounted. A shortcut on the Drive is removed.
+ volumeManager.volumeInfoList.splice(0, 1);
+ assertEquals(2, model.length);
+ assertEquals('/Downloads', model.item(0).path);
+ assertEquals('/removable/fuga', model.item(1).path);
+}
« no previous file with comments | « chrome/test/data/file_manager/unit_tests/navigation_list_model_unittest.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698