Chromium Code Reviews| 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 fires event', function() { | 33 test('selecting and deselecting folders fires event', 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].item.id, store.lastAction.id); | 45 assertEquals(secondGen[0].item.id, 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].item.id, store.lastAction.id); | 51 assertEquals(rootFolders[1].item.id, 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( | |
|
tsergeant
2017/03/07 23:32:50
Testing CSS strings seems weird, even if those str
calamity
2017/03/08 06:52:45
That seems more brittle to me. This test is mostly
| |
| 65 `calc(0 * var(--padding-left-per-depth))`, | |
| 66 f.$['folder-label'].style.paddingLeft); | |
| 67 }); | |
| 68 Array.prototype.forEach.call(firstGen, function(f) { | |
| 69 assertEquals(1, f.depth); | |
| 70 assertEquals( | |
| 71 `calc(1 * var(--padding-left-per-depth))`, | |
| 72 f.$['folder-label'].style.paddingLeft); | |
| 73 }); | |
| 74 Array.prototype.forEach.call(secondGen, function(f) { | |
| 75 assertEquals(2, f.depth); | |
| 76 assertEquals( | |
| 77 `calc(2 * var(--padding-left-per-depth))`, | |
| 78 f.$['folder-label'].style.paddingLeft); | |
| 79 }); | |
| 80 }) | |
| 52 }); | 81 }); |
| OLD | NEW |