OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright 2016 The Chromium Authors. All rights reserved. | 3 Copyright 2016 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel="import" href="/tracing/base/scalar.html"> | 8 <link rel="import" href="/tracing/base/scalar.html"> |
9 <link rel="import" href="/tracing/base/unit.html"> | 9 <link rel="import" href="/tracing/base/unit.html"> |
10 <link rel="import" href="/tracing/model/container_memory_dump.html"> | 10 <link rel="import" href="/tracing/model/container_memory_dump.html"> |
(...skipping 14 matching lines...) Expand all Loading... |
25 var MemoryAllocatorDump = tr.model.MemoryAllocatorDump; | 25 var MemoryAllocatorDump = tr.model.MemoryAllocatorDump; |
26 var MemoryAllocatorDumpLink = tr.model.MemoryAllocatorDumpLink; | 26 var MemoryAllocatorDumpLink = tr.model.MemoryAllocatorDumpLink; |
27 var VMRegion = tr.model.VMRegion; | 27 var VMRegion = tr.model.VMRegion; |
28 var VMRegionClassificationNode = tr.model.VMRegionClassificationNode; | 28 var VMRegionClassificationNode = tr.model.VMRegionClassificationNode; |
29 var Scalar = tr.b.Scalar; | 29 var Scalar = tr.b.Scalar; |
30 var sizeInBytes_smallerIsBetter = | 30 var sizeInBytes_smallerIsBetter = |
31 tr.b.Unit.byName.sizeInBytes_smallerIsBetter; | 31 tr.b.Unit.byName.sizeInBytes_smallerIsBetter; |
32 var LIGHT = tr.model.ContainerMemoryDump.LevelOfDetail.LIGHT; | 32 var LIGHT = tr.model.ContainerMemoryDump.LevelOfDetail.LIGHT; |
33 | 33 |
34 function castToScalar(value) { | 34 function castToScalar(value) { |
35 if (typeof value === 'number') | 35 if (typeof value === 'number') { |
36 return new Scalar(sizeInBytes_smallerIsBetter, value); | 36 return new Scalar(sizeInBytes_smallerIsBetter, value); |
| 37 } |
37 assert.instanceOf(value, Scalar); | 38 assert.instanceOf(value, Scalar); |
38 return value; | 39 return value; |
39 } | 40 } |
40 | 41 |
41 function getOption(opt_options, key, opt_defaultValue) { | 42 function getOption(opt_options, key, opt_defaultValue) { |
42 if (opt_options && (key in opt_options)) | 43 if (opt_options && (key in opt_options)) { |
43 return opt_options[key]; | 44 return opt_options[key]; |
| 45 } |
44 return opt_defaultValue; | 46 return opt_defaultValue; |
45 } | 47 } |
46 | 48 |
47 function MemoryDumpTestUtils() { | 49 function MemoryDumpTestUtils() { |
48 throw new Error('Static class'); | 50 throw new Error('Static class'); |
49 } | 51 } |
50 | 52 |
51 MemoryDumpTestUtils.SIZE_DELTA = 0.0001; | 53 MemoryDumpTestUtils.SIZE_DELTA = 0.0001; |
52 | 54 |
53 /** | 55 /** |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 assert.instanceOf(actualNumeric, tr.b.Scalar); | 172 assert.instanceOf(actualNumeric, tr.b.Scalar); |
171 assert.strictEqual(actualNumeric.unit, expectedNumeric.unit); | 173 assert.strictEqual(actualNumeric.unit, expectedNumeric.unit); |
172 assert.closeTo(actualNumeric.value, expectedNumeric.value, | 174 assert.closeTo(actualNumeric.value, expectedNumeric.value, |
173 MemoryDumpTestUtils.SIZE_DELTA); | 175 MemoryDumpTestUtils.SIZE_DELTA); |
174 } | 176 } |
175 | 177 |
176 assert.deepEqual(dump.diagnostics, expectedDiagnostics); | 178 assert.deepEqual(dump.diagnostics, expectedDiagnostics); |
177 }; | 179 }; |
178 | 180 |
179 MemoryDumpTestUtils.checkVMRegions = function(vmRegions, expectedRegions) { | 181 MemoryDumpTestUtils.checkVMRegions = function(vmRegions, expectedRegions) { |
180 if (vmRegions instanceof VMRegionClassificationNode) | 182 if (vmRegions instanceof VMRegionClassificationNode) { |
181 vmRegions = vmRegions.allRegionsForTesting; | 183 vmRegions = vmRegions.allRegionsForTesting; |
| 184 } |
182 | 185 |
183 var expectedRegionsMap = new Map(); | 186 var expectedRegionsMap = new Map(); |
184 expectedRegions.forEach(function(region) { | 187 expectedRegions.forEach(function(region) { |
185 if (!(region instanceof VMRegion)) | 188 if (!(region instanceof VMRegion)) { |
186 region = VMRegion.fromDict(region); | 189 region = VMRegion.fromDict(region); |
| 190 } |
187 expectedRegionsMap.set(region.uniqueIdWithinProcess, region); | 191 expectedRegionsMap.set(region.uniqueIdWithinProcess, region); |
188 }); | 192 }); |
189 var actualRegionsMap = new Map(); | 193 var actualRegionsMap = new Map(); |
190 vmRegions.forEach(function(region) { | 194 vmRegions.forEach(function(region) { |
191 actualRegionsMap.set(region.uniqueIdWithinProcess, region); | 195 actualRegionsMap.set(region.uniqueIdWithinProcess, region); |
192 }); | 196 }); |
193 | 197 |
194 assert.strictEqual(actualRegionsMap.size, expectedRegionsMap.size); | 198 assert.strictEqual(actualRegionsMap.size, expectedRegionsMap.size); |
195 for (var id of expectedRegionsMap.keys()) { | 199 for (var id of expectedRegionsMap.keys()) { |
196 var expectedRegion = expectedRegionsMap.get(id); | 200 var expectedRegion = expectedRegionsMap.get(id); |
197 var actualRegion = actualRegionsMap.get(id); | 201 var actualRegion = actualRegionsMap.get(id); |
198 | 202 |
199 assert.instanceOf(actualRegion, VMRegion); | 203 assert.instanceOf(actualRegion, VMRegion); |
200 assert.strictEqual(actualRegion.startAddress, | 204 assert.strictEqual(actualRegion.startAddress, |
201 expectedRegion.startAddress); | 205 expectedRegion.startAddress); |
202 assert.strictEqual(actualRegion.sizeInBytes, expectedRegion.sizeInBytes); | 206 assert.strictEqual(actualRegion.sizeInBytes, expectedRegion.sizeInBytes); |
203 assert.strictEqual(actualRegion.protectionFlags, | 207 assert.strictEqual(actualRegion.protectionFlags, |
204 expectedRegion.protectionFlags); | 208 expectedRegion.protectionFlags); |
205 assert.strictEqual(actualRegion.mappedFile, expectedRegion.mappedFile); | 209 assert.strictEqual(actualRegion.mappedFile, expectedRegion.mappedFile); |
206 assert.deepEqual(actualRegion.byteStats, expectedRegion.byteStats); | 210 assert.deepEqual(actualRegion.byteStats, expectedRegion.byteStats); |
207 } | 211 } |
208 }; | 212 }; |
209 | 213 |
210 return { | 214 return { |
211 MemoryDumpTestUtils, | 215 MemoryDumpTestUtils, |
212 }; | 216 }; |
213 }); | 217 }); |
214 </script> | 218 </script> |
OLD | NEW |