Skip to content

Commit

Permalink
Remove io import from devtools_app that was only used for tests (flut…
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzieschmoll authored Oct 27, 2023
1 parent f4d7c5d commit 3d3450d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
13 changes: 0 additions & 13 deletions packages/devtools_app/lib/src/shared/memory/adapted_heap_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:vm_service/vm_service.dart';

Expand Down Expand Up @@ -74,17 +72,6 @@ class AdaptedHeapData {
return AdaptedHeapData(objects);
}

@visibleForTesting
static Future<AdaptedHeapData> fromFile(
String fileName,
) async {
final file = File(fileName);
final bytes = await file.readAsBytes();
final data = bytes.buffer.asByteData();
final graph = HeapSnapshotGraph.fromChunks([data]);
return AdaptedHeapData.fromHeapSnapshot(graph);
}

/// Default value for rootIndex is taken from the doc:
/// https://github.com/dart-lang/sdk/blob/main/runtime/vm/service/heap_snapshot.md#object-ids
static const int _defaultRootIndex = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

import 'package:devtools_app/src/shared/memory/adapted_heap_data.dart';
import 'package:vm_service/vm_service.dart';

const _dataDir = 'test/test_infra/test_data/memory/heap/';

Expand All @@ -20,8 +23,7 @@ class GoldenHeapTest {
/// Loads the heap data from a file.
///
/// Format is format used by [NativeRuntime.writeHeapSnapshotToFile].
Future<AdaptedHeapData> loadHeap() =>
AdaptedHeapData.fromFile('$_dataDir$fileName');
Future<AdaptedHeapData> loadHeap() => heapFromFile('$_dataDir$fileName');
}

List<GoldenHeapTest> goldenHeapTests = <GoldenHeapTest>[
Expand All @@ -42,3 +44,13 @@ List<GoldenHeapTest> goldenHeapTests = <GoldenHeapTest>[
appClassName: 'MyApp',
),
];

Future<AdaptedHeapData> heapFromFile(
String fileName,
) async {
final file = File(fileName);
final bytes = await file.readAsBytes();
final data = bytes.buffer.asByteData();
final graph = HeapSnapshotGraph.fromChunks([data]);
return AdaptedHeapData.fromHeapSnapshot(graph);
}

0 comments on commit 3d3450d

Please sign in to comment.