| <!DOCTYPE html> |
| <!-- |
| Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style license that can be |
| found in the LICENSE file. |
| --> |
| |
| <link rel="import" href="/core/test_utils.html"> |
| <link rel="import" href="/model/selection_state.html"> |
| <link rel="import" href="/core/tracks/memory_dump_track_test_utils.html"> |
| <link rel="import" href="/core/tracks/memory_dump_track_util.html"> |
| |
| <script> |
| 'use strict'; |
| |
| tr.b.unittest.testSuite(function() { |
| var SelectionState = tr.model.SelectionState; |
| var createTestGlobalMemoryDumps = tr.c.tracks.createTestGlobalMemoryDumps; |
| var createTestProcessMemoryDumps = tr.c.tracks.createTestProcessMemoryDumps; |
| |
| test('buildMemoryLetterDots_withoutVMRegions', function() { |
| var dumps = createTestGlobalMemoryDumps(false, false); |
| var items = tr.c.tracks.buildMemoryLetterDots(dumps); |
| |
| assert.lengthOf(items, 4); |
| assert.equal(items[0].start, 0); |
| assert.equal(items[1].start, 5); |
| assert.equal(items[2].start, 15); |
| assert.equal(items[3].start, 18); |
| |
| // Check model mapping. |
| assert.equal(items[1].selectionState, SelectionState.HIGHLIGHTED); |
| assert.isTrue(items[2].selected); |
| assert.equal(items[3].modelItem, dumps[3]); |
| }); |
| |
| test('buildMemoryLetterDots_withVMRegions', function() { |
| var dumps = createTestGlobalMemoryDumps(false, false); |
| var items = tr.c.tracks.buildMemoryLetterDots(dumps); |
| |
| assert.lengthOf(items, 4); |
| assert.equal(items[0].start, 0); |
| assert.equal(items[1].start, 5); |
| assert.equal(items[2].start, 15); |
| assert.equal(items[3].start, 18); |
| |
| // Check model mapping. |
| assert.equal(items[1].selectionState, SelectionState.HIGHLIGHTED); |
| assert.isTrue(items[2].selected); |
| assert.equal(items[3].modelItem, dumps[3]); |
| }); |
| |
| test('buildGlobalUsedMemoryChartSeries_withoutVMRegions', function() { |
| var dumps = createTestGlobalMemoryDumps(false, false); |
| var series = tr.c.tracks.buildGlobalUsedMemoryChartSeries(dumps); |
| |
| assert.isUndefined(series); |
| }); |
| |
| test('buildGlobalUsedMemoryChartSeries_withVMRegions', function() { |
| var dumps = createTestGlobalMemoryDumps(true, false); |
| var series = tr.c.tracks.buildGlobalUsedMemoryChartSeries(dumps); |
| |
| assert.lengthOf(series, 3); |
| |
| var sa = series[2]; |
| var sb = series[1]; |
| var sc = series[0]; |
| |
| assert.lengthOf(sa.points, 4); |
| assert.lengthOf(sb.points, 4); |
| assert.lengthOf(sc.points, 4); |
| |
| // Process A: VM regions defined -> sum their PSS values (111). |
| // Process B: VM regions undefined and no previous value -> assume zero. |
| // Process C: Memory dump not present -> assume process not alive (0). |
| assert.equal(sa.points[0].x, 0); |
| assert.equal(sb.points[0].x, 0); |
| assert.equal(sc.points[0].x, 0); |
| assert.equal(sa.points[0].y, 111); |
| assert.equal(sb.points[0].y, 111); |
| assert.equal(sc.points[0].y, 111); |
| assert.equal(sa.points[0].yBase, 0); |
| assert.equal(sb.points[0].yBase, 111); |
| assert.equal(sc.points[0].yBase, 111); |
| |
| // Process A: VM regions undefined -> assume previous value (111). |
| // Process B: VM regions defined -> sum their PSS values (555). |
| // Process C: VM regions undefined -> assume previous value (0). |
| assert.equal(sa.points[1].x, 5); |
| assert.equal(sb.points[1].x, 5); |
| assert.equal(sc.points[1].x, 5); |
| assert.equal(sa.points[1].y, 111); |
| assert.equal(sb.points[1].y, 261); |
| assert.equal(sc.points[1].y, 261); |
| assert.equal(sa.points[1].yBase, 0); |
| assert.equal(sb.points[1].yBase, 111); |
| assert.equal(sc.points[1].yBase, 261); |
| |
| // Process A: VM regions defined -> sum their PSS values (0). |
| // Process B: Memory dump not present -> assume process not alive (0). |
| // Process C: VM regions defined -> sum their PSS values (999). |
| assert.equal(sa.points[2].x, 15); |
| assert.equal(sb.points[2].x, 15); |
| assert.equal(sc.points[2].x, 15); |
| assert.equal(sa.points[2].y, 0); |
| assert.equal(sb.points[2].y, 0); |
| assert.equal(sc.points[2].y, 210); |
| assert.equal(sa.points[2].yBase, 0); |
| assert.equal(sb.points[2].yBase, 0); |
| assert.equal(sc.points[2].yBase, 0); |
| |
| // All processes: Memory dump not present -> assume process not alive (0). |
| assert.equal(sa.points[3].x, 18); |
| assert.equal(sb.points[3].x, 18); |
| assert.equal(sc.points[3].x, 18); |
| assert.equal(sa.points[3].y, 0); |
| assert.equal(sb.points[3].y, 0); |
| assert.equal(sc.points[3].y, 0); |
| assert.equal(sc.points[3].yBase, 0); |
| assert.equal(sc.points[3].yBase, 0); |
| assert.equal(sc.points[3].yBase, 0); |
| |
| // Check model mapping. |
| assert.equal(sa.points[1].selectionState, SelectionState.HIGHLIGHTED); |
| assert.isTrue(sb.points[2].selected); |
| assert.equal(sc.points[3].modelItem, dumps[3]); |
| }); |
| |
| test('buildGlobalAllocatedMemoryChartSeries_withoutMemoryAllocatorDumps', |
| function() { |
| var dumps = createTestGlobalMemoryDumps(false, false); |
| var series = tr.c.tracks.buildGlobalAllocatedMemoryChartSeries(dumps); |
| |
| assert.isUndefined(series); |
| }); |
| |
| test('buildGlobalAllocatedMemoryChartSeries_withMemoryAllocatorDumps', |
| function() { |
| var dumps = createTestGlobalMemoryDumps(false, true); |
| var series = tr.c.tracks.buildGlobalAllocatedMemoryChartSeries(dumps); |
| |
| assert.lengthOf(series, 2); |
| |
| var so = series[0]; |
| var sv = series[1]; |
| |
| assert.lengthOf(so.points, 4); |
| assert.lengthOf(sv.points, 4); |
| |
| // Oilpan: Only process B dumps allocated objects size (1024). |
| // V8: No process dumps allocated objects size (0). |
| assert.equal(so.points[0].x, 0); |
| assert.equal(sv.points[0].x, 0); |
| assert.equal(so.points[0].y, 1024); |
| assert.equal(sv.points[0].y, 0); |
| |
| // Oilpan: Process B did not provide a value and process C dumps (128). |
| // V8: Processes B and C dump (512 + 256). |
| assert.equal(so.points[1].x, 5); |
| assert.equal(sv.points[1].x, 5); |
| assert.equal(so.points[1].y, 128); |
| assert.equal(sv.points[1].y, 768); |
| |
| // Oilpan: Process B assumed not alive and process C dumps (512) |
| // V8: Process A dumps now, process B assumed not alive, process C did not |
| // provide a value (768). |
| assert.equal(so.points[2].x, 15); |
| assert.equal(sv.points[2].x, 15); |
| assert.equal(so.points[2].y, 512); |
| assert.equal(sv.points[2].y, 768); |
| |
| // All processes: Memory dump not present -> assume process not alive (0). |
| assert.equal(so.points[3].x, 18); |
| assert.equal(sv.points[3].x, 18); |
| assert.equal(so.points[3].y, 0); |
| assert.equal(sv.points[3].y, 0); |
| |
| // Check model mapping. |
| assert.equal(so.points[1].selectionState, SelectionState.HIGHLIGHTED); |
| assert.isTrue(sv.points[2].selected); |
| assert.equal(so.points[3].modelItem, dumps[3]); |
| }); |
| |
| test('buildProcessAllocatedMemoryChartSeries_withoutMemoryAllocatorDumps', |
| function() { |
| var dumps = createTestProcessMemoryDumps(false, false); |
| var series = tr.c.tracks.buildProcessAllocatedMemoryChartSeries(dumps); |
| |
| assert.isUndefined(series); |
| }); |
| |
| test('buildProcessAllocatedMemoryChartSeries_withMemoryAllocatorDumps', |
| function() { |
| var dumps = createTestProcessMemoryDumps(false, true); |
| var series = tr.c.tracks.buildProcessAllocatedMemoryChartSeries(dumps); |
| |
| // There should be only 2 series (because 'tracing' is not shown in the |
| // charts). |
| assert.lengthOf(series, 2); |
| |
| var so = series[0]; |
| var sv = series[1]; |
| |
| assert.lengthOf(so.points, 2); |
| assert.lengthOf(sv.points, 2); |
| |
| // Oilpan: Process dumps (128). |
| // V8: Process dumps (256). |
| assert.equal(so.points[0].x, 5.12); |
| assert.equal(sv.points[0].x, 5.12); |
| assert.equal(so.points[0].y, 128); |
| assert.equal(sv.points[0].y, 256); |
| |
| // Oilpan: Process dumps (512). |
| // V8: Process did not provide a value (0). |
| assert.equal(so.points[1].x, 14.5); |
| assert.equal(sv.points[1].x, 14.5); |
| assert.equal(so.points[1].y, 512); |
| assert.equal(sv.points[1].y, 0); |
| |
| // Check model mapping. |
| assert.equal(so.points[1].selectionState, SelectionState.HIGHLIGHTED); |
| assert.isTrue(sv.points[0].selected); |
| assert.equal(so.points[1].modelItem, dumps[1]); |
| }); |
| }); |
| </script> |