|
| 1 | +// Copyright 2025 The Chromium Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +import * as SDK from '../../core/sdk/sdk.js'; |
| 6 | +import {createTarget} from '../../testing/EnvironmentHelpers.js'; |
| 7 | +import {expectCall} from '../../testing/ExpectStubCall.js'; |
| 8 | +import {describeWithMockConnection} from '../../testing/MockConnection.js'; |
| 9 | +import * as UI from '../../ui/legacy/legacy.js'; |
| 10 | + |
| 11 | +describeWithMockConnection('TrackingHeapSnapshotProfileType', () => { |
| 12 | + describe('buttonClicked', () => { |
| 13 | + let releaseAllAnimationsStub: sinon.SinonStub; |
| 14 | + let startTrackingHeapObjectsStub: sinon.SinonStub; |
| 15 | + beforeEach(() => { |
| 16 | + const target = createTarget(); |
| 17 | + const heapProfilerModel = target.model(SDK.HeapProfilerModel.HeapProfilerModel); |
| 18 | + UI.Context.Context.instance().setFlavor(SDK.HeapProfilerModel.HeapProfilerModel, heapProfilerModel); |
| 19 | + |
| 20 | + releaseAllAnimationsStub = |
| 21 | + sinon.stub(SDK.AnimationModel.AnimationModel.prototype, 'releaseAllAnimations').resolves(); |
| 22 | + startTrackingHeapObjectsStub = |
| 23 | + sinon.stub(SDK.HeapProfilerModel.HeapProfilerModel.prototype, 'startTrackingHeapObjects').resolves(); |
| 24 | + }); |
| 25 | + |
| 26 | + it('releases all animations before `startTrackingHeapObjects` call', async () => { |
| 27 | + // We need dynamic import here because statically importing the module requires locale vars to be initialized vars. |
| 28 | + const Profiler = await import('./profiler.js'); |
| 29 | + Profiler.ProfileTypeRegistry.instance.trackingHeapSnapshotProfileType.buttonClicked(); |
| 30 | + |
| 31 | + assert.isTrue(releaseAllAnimationsStub.calledOnce, 'Expected release all animations to be called'); |
| 32 | + await expectCall(startTrackingHeapObjectsStub); |
| 33 | + }); |
| 34 | + }); |
| 35 | +}); |
0 commit comments