Chromium Code Reviews| 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() { |
|
mtomasz
2013/10/29 07:28:17
How are these test cases called?
yoshiki
2013/10/31 09:07:23
They are called from ui/webui/resources/js/webui_r
|
| + 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); |
|
mtomasz
2013/10/29 07:28:17
assertEquals -> expectEquals where it is possible
yoshiki
2013/10/31 09:07:23
This framework (ui/webui/resources/js/webui_resour
mtomasz
2013/10/31 09:13:12
SGTM
|
| + |
| + // 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); |
|
mtomasz
2013/10/29 07:28:17
ditto
|
| + 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); |
|
mtomasz
2013/10/29 07:28:17
ditto here and in other cases
|
| + 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); |
| +} |