OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 suite('<bookmarks-sidebar>', function() { | 5 suite('<bookmarks-sidebar>', function() { |
6 var sidebar; | 6 var sidebar; |
7 var store; | 7 var store; |
8 | 8 |
9 setup(function() { | 9 setup(function() { |
10 store = new bookmarks.TestStore({ | 10 store = new bookmarks.TestStore({ |
(...skipping 13 matching lines...) Expand all Loading... |
24 ])), | 24 ])), |
25 }); | 25 }); |
26 bookmarks.Store.instance_ = store; | 26 bookmarks.Store.instance_ = store; |
27 | 27 |
28 sidebar = document.createElement('bookmarks-sidebar'); | 28 sidebar = document.createElement('bookmarks-sidebar'); |
29 replaceBody(sidebar); | 29 replaceBody(sidebar); |
30 Polymer.dom.flush(); | 30 Polymer.dom.flush(); |
31 }); | 31 }); |
32 | 32 |
33 test('selecting and deselecting folders dispatches action', function() { | 33 test('selecting and deselecting folders dispatches action', function() { |
34 var rootFolders = sidebar.$['folder-tree'].children; | 34 var rootFolders = |
| 35 sidebar.$['folder-tree'].querySelectorAll('bookmarks-folder-node'); |
35 var firstGen = rootFolders[0].$['descendants'].querySelectorAll( | 36 var firstGen = rootFolders[0].$['descendants'].querySelectorAll( |
36 'bookmarks-folder-node'); | 37 'bookmarks-folder-node'); |
37 var secondGen = | 38 var secondGen = |
38 firstGen[0].$['descendants'].querySelectorAll('bookmarks-folder-node'); | 39 firstGen[0].$['descendants'].querySelectorAll('bookmarks-folder-node'); |
39 | 40 |
40 // Select nested folder. | 41 // Select nested folder. |
41 firedId = ''; | 42 firedId = ''; |
42 MockInteractions.tap(secondGen[0].$['folder-label']); | 43 MockInteractions.tap(secondGen[0].$['folder-label']); |
43 assertEquals('select-folder', store.lastAction.name); | 44 assertEquals('select-folder', store.lastAction.name); |
44 assertEquals(secondGen[0].itemId, store.lastAction.id); | 45 assertEquals(secondGen[0].itemId, store.lastAction.id); |
45 | 46 |
46 // Select folder in a separate subtree. | 47 // Select folder in a separate subtree. |
47 firedId = ''; | 48 firedId = ''; |
48 MockInteractions.tap(rootFolders[1].$['folder-label']); | 49 MockInteractions.tap(rootFolders[1].$['folder-label']); |
49 assertEquals('select-folder', store.lastAction.name); | 50 assertEquals('select-folder', store.lastAction.name); |
50 assertEquals(rootFolders[1].itemId, store.lastAction.id); | 51 assertEquals(rootFolders[1].itemId, store.lastAction.id); |
51 }); | 52 }); |
| 53 |
| 54 test('depth calculation', function() { |
| 55 var rootFolders = |
| 56 sidebar.$['folder-tree'].querySelectorAll('bookmarks-folder-node'); |
| 57 var firstGen = rootFolders[0].$['descendants'].querySelectorAll( |
| 58 'bookmarks-folder-node'); |
| 59 var secondGen = |
| 60 firstGen[0].$['descendants'].querySelectorAll('bookmarks-folder-node'); |
| 61 |
| 62 Array.prototype.forEach.call(rootFolders, function(f) { |
| 63 assertEquals(0, f.depth); |
| 64 assertEquals('0', f.style.getPropertyValue('--node-depth')); |
| 65 }); |
| 66 Array.prototype.forEach.call(firstGen, function(f) { |
| 67 assertEquals(1, f.depth); |
| 68 assertEquals('1', f.style.getPropertyValue('--node-depth')); |
| 69 }); |
| 70 Array.prototype.forEach.call(secondGen, function(f) { |
| 71 assertEquals(2, f.depth); |
| 72 assertEquals('2', f.style.getPropertyValue('--node-depth')); |
| 73 }); |
| 74 }) |
52 }); | 75 }); |
OLD | NEW |