xref: /aosp_15_r20/external/pdfium/testing/invalid_seekable_read_stream.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2019 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef TESTING_INVALID_SEEKABLE_READ_STREAM_H_
6 #define TESTING_INVALID_SEEKABLE_READ_STREAM_H_
7 
8 #include "core/fxcrt/fx_stream.h"
9 #include "core/fxcrt/retain_ptr.h"
10 
11 // A stream used for testing where reads always fail.
12 class InvalidSeekableReadStream final : public IFX_SeekableReadStream {
13  public:
14   CONSTRUCT_VIA_MAKE_RETAIN;
15 
16   // IFX_SeekableReadStream overrides:
17   bool ReadBlockAtOffset(pdfium::span<uint8_t> buffer,
18                          FX_FILESIZE offset) override;
19   FX_FILESIZE GetSize() override;
20 
21  private:
22   explicit InvalidSeekableReadStream(FX_FILESIZE data_size);
23   ~InvalidSeekableReadStream() override;
24 
25   const FX_FILESIZE data_size_;
26 };
27 
28 #endif  // TESTING_INVALID_SEEKABLE_READ_STREAM_H_
29