| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2013 The Chromium Authors. All rights reserved. | 2 Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
| 4 found in the LICENSE file. | 4 found in the LICENSE file. |
| 5 --> | 5 --> |
| 6 <!DOCTYPE html> | 6 <!DOCTYPE html> |
| 7 <html> | 7 <html> |
| 8 <body> | 8 <body> |
| 9 <script> | 9 <script> |
| 10 window.chrome = {}; | 10 window.chrome = {}; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 key = 'key', | 75 key = 'key', |
| 76 value = 'value'; | 76 value = 'value'; |
| 77 | 77 |
| 78 var pi = new PlayerInfo('example_ID'); | 78 var pi = new PlayerInfo('example_ID'); |
| 79 pi.addProperty(firstTimestamp, key, value); | 79 pi.addProperty(firstTimestamp, key, value); |
| 80 pi.addProperty(secondTimestamp, key, value); | 80 pi.addProperty(secondTimestamp, key, value); |
| 81 | 81 |
| 82 assertEquals(firstTimestamp, pi.firstTimestamp_); | 82 assertEquals(firstTimestamp, pi.firstTimestamp_); |
| 83 assertEquals(0, pi.allEvents[0].time); | 83 assertEquals(0, pi.allEvents[0].time); |
| 84 assertEquals(deltaT, pi.allEvents[1].time); | 84 assertEquals(deltaT, pi.allEvents[1].time); |
| 85 | |
| 86 assertTrue(undefined !== pi.pastValues[key]); | |
| 87 | |
| 88 console.log(pi.pastValues); | |
| 89 | |
| 90 assertEquals(0, pi.pastValues[key][0].time); | |
| 91 assertEquals(deltaT, pi.pastValues[key][1].time); | |
| 92 }; | |
| 93 | |
| 94 // Check to make sure that properties are correctly | |
| 95 // added to the relevant pastValues array. | |
| 96 window.testAddPropertyPastValues = function() { | |
| 97 var pi = new PlayerInfo('example_ID'), | |
| 98 timestamp = 50, | |
| 99 key = 'key', | |
| 100 value = 'value'; | |
| 101 | |
| 102 pi.addProperty(timestamp, key, value); | |
| 103 | |
| 104 assertEquals(value, pi.pastValues[key][0].value); | |
| 105 assertEquals(key, pi.pastValues[key][0].key); | |
| 106 assertEquals(0, pi.pastValues[key][0].time); | |
| 107 }; | 85 }; |
| 108 | 86 |
| 109 // The list of all events should be recorded in correctly. | 87 // The list of all events should be recorded in correctly. |
| 110 window.testAllEvents = function() { | 88 window.testAllEvents = function() { |
| 111 var pi = new PlayerInfo('example_ID'), | 89 var pi = new PlayerInfo('example_ID'), |
| 112 timestamp = 50, | 90 timestamp = 50, |
| 113 key = 'key', | 91 key = 'key', |
| 114 value = 'value', | 92 value = 'value', |
| 115 key2 = 'key2', | 93 key2 = 'key2', |
| 116 value2 = 'value2'; | 94 value2 = 'value2'; |
| 117 | 95 |
| 118 pi.addProperty(timestamp, key, value); | 96 pi.addProperty(timestamp, key, value); |
| 119 assertEquals(value, pi.allEvents[0].value); | 97 assertEquals(value, pi.allEvents[0].value); |
| 120 assertEquals(key, pi.allEvents[0].key); | 98 assertEquals(key, pi.allEvents[0].key); |
| 121 | 99 |
| 122 pi.addProperty(timestamp, key2, value2); | 100 pi.addProperty(timestamp, key2, value2); |
| 123 assertEquals(value2, pi.allEvents[1].value); | 101 assertEquals(value2, pi.allEvents[1].value); |
| 124 assertEquals(key2, pi.allEvents[1].key); | 102 assertEquals(key2, pi.allEvents[1].key); |
| 125 }; | 103 }; |
| 126 | 104 |
| 127 // Using noRecord should make it not show up in allEvents, | 105 // Using noRecord should make it not show up in allEvents. |
| 128 // but it should still show up in pastValues[key]. | |
| 129 window.testNoRecord = function() { | 106 window.testNoRecord = function() { |
| 130 var pi = new PlayerInfo('example_ID'), | 107 var pi = new PlayerInfo('example_ID'), |
| 131 timestamp = 50, | 108 timestamp = 50, |
| 132 key = 'key', | 109 key = 'key', |
| 133 value = 'value'; | 110 value = 'value'; |
| 134 pi.addPropertyNoRecord(timestamp, key, value); | 111 pi.addPropertyNoRecord(timestamp, key, value); |
| 135 | 112 |
| 136 assertEquals(value, pi.properties[key]); | 113 assertEquals(value, pi.properties[key]); |
| 137 assertEquals(0, pi.allEvents.length); | 114 assertEquals(0, pi.allEvents.length); |
| 138 assertEquals(1, pi.pastValues[key].length); | |
| 139 }; | 115 }; |
| 140 </script> | 116 </script> |
| 141 </body> | 117 </body> |
| 142 </html> | 118 </html> |
| OLD | NEW |