blob: e2d407d22d69c152b8409a1b93a04b9bf2cea147 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// ignore_for_file: implementation_imports
import 'dart:typed_data';
import 'package:zircon/zircon.dart';
import 'package:fuchsia_inspect/src/vmo/vmo_holder.dart';
class FakeVmoReader implements VmoHolder {
/// The memory contents of this "VMO".
final ByteData bytes;
Vmo get vmo => null;
/// Size of the "VMO".
final int size;
/// Wraps a [FakeVmoReader] around the given data.
FakeVmoReader.usingData(this.bytes) : size = bytes.lengthInBytes;
void beginWork() {}
void commit() {}
/// Writes to the "VMO".
void write(int offset, ByteData data) {}
/// Reads from the "VMO".
ByteData read(int offset, int size) {
var reading = ByteData(size);
.setAll(0, bytes.buffer.asUint8List(offset, size));
return reading;
/// Writes int64 to VMO.
void writeInt64(int offset, int value) {}
/// Writes int64 directly to VMO for immediate visibility.
void writeInt64Direct(int offset, int value) {}
/// Reads int64 from VMO.
int readInt64(int offset) => bytes.getInt64(offset, Endian.little);