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-item>', function() { | 5 suite('<bookmarks-item>', function() { |
6 var item; | 6 var item; |
7 var TEST_ITEM = createItem('0'); | 7 var TEST_ITEM = createItem('0'); |
8 | 8 |
9 setup(function() { | 9 setup(function() { |
10 item = document.createElement('bookmarks-item'); | 10 item = document.createElement('bookmarks-item'); |
11 replaceBody(item); | 11 replaceBody(item); |
12 item.item = TEST_ITEM; | 12 item.item = TEST_ITEM; |
13 }); | 13 }); |
14 | 14 |
15 test('changing the url changes the favicon', function() { | 15 test('changing the url changes the favicon', function() { |
16 var favicon = item.$.icon.style.backgroundImage; | 16 var favicon = item.$.icon.style.backgroundImage; |
17 item.set('item.url', 'http://www.mail.google.com'); | 17 item.set('item.url', 'http://www.mail.google.com'); |
18 assertNotEquals(favicon, item.$.icon.style.backgroundImage); | 18 assertNotEquals(favicon, item.$.icon.style.backgroundImage); |
19 }); | 19 }); |
20 | 20 |
21 test('changing isFolder_ hides/unhides the folder/icon', function() { | 21 test('changing isFolder_ hides/unhides the folder/icon', function() { |
22 item.isFolder_ = true; | 22 item.isFolder_ = true; |
23 assertFalse(item.$['folder-icon'].hidden); | 23 assertFalse(item.$['folder-icon'].hidden); |
24 assertTrue(item.$.icon.hidden); | 24 assertTrue(item.$.icon.hidden); |
25 | 25 |
26 item.isFolder_ = false; | 26 item.isFolder_ = false; |
27 assertTrue(item.$['folder-icon'].hidden); | 27 assertTrue(item.$['folder-icon'].hidden); |
28 assertFalse(item.$.icon.hidden); | 28 assertFalse(item.$.icon.hidden); |
29 }); | 29 }); |
30 | |
31 test('pressing the buttons fires the right event', function() { | |
32 var shiftEventCount = 0; | |
33 var ctrlEventCount = 0; | |
34 var normalEventCount = 0; | |
35 | |
36 document.addEventListener('select-single-item', function() { | |
37 normalEventCount++; | |
38 }); | |
39 MockInteractions.tap(item); | |
40 assertEquals(1, normalEventCount); | |
41 | |
42 document.addEventListener('shift-select-multiple-items', function() { | |
43 shiftEventCount++; | |
44 }); | |
45 customClick(item, {shiftKey: true}); | |
46 assertEquals(1, normalEventCount); | |
47 assertEquals(1, shiftEventCount); | |
48 | |
49 document.addEventListener('ctrl-select-multiple-items', function() { | |
50 ctrlEventCount++; | |
51 }); | |
calamity
2017/01/17 06:12:22
Add all 3 event listeners at the beginning and ass
jiaxi
2017/01/20 04:51:09
Done.
| |
52 customClick(item, {ctrlKey: true}); | |
53 assertEquals(1, normalEventCount); | |
54 assertEquals(1, shiftEventCount); | |
55 assertEquals(1, ctrlEventCount); | |
56 }); | |
30 }); | 57 }); |
OLD | NEW |