Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/webserial/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

Quelle  TestSerialPlatformService.h

  Sprache: C
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#ifndef mozilla_dom_TestSerialPlatformService_h
#define mozilla_dom_TestSerialPlatformService_h

#include "mozilla/dom/SerialPlatformService.h"
#include "nsIAsyncInputStream.h"
#include "nsIAsyncOutputStream.h"
#include "nsTArray.h"

namespace mozilla::dom {

struct MockSerialPort {
  IPCSerialPortInfo mInfo;
  bool mIsOpen = false;
  IPCSerialOptions mOptions;
  IPCSerialOutputSignals mOutputSignals = {Some(false), Some(false),
                                           Some(false)};
  nsCOMPtr<nsIAsyncInputStream> mPipeReadStream;
  nsCOMPtr<nsIAsyncOutputStream> mPipeWriteStream;
};

class TestSerialPlatformService final : public SerialPlatformService {
 public:
  TestSerialPlatformService();

  void Shutdown() override;

  void AddMockDevice(const nsString& aId, const nsString& aPath,
                     uint16_t aVendorId = 0, uint16_t aProductId = 0);

  void SimulateDeviceConnection(const nsString& aId, const nsString& aPath,
                                uint16_t aVendorId = 0,
                                uint16_t aProductId = 0);

  void SimulateDeviceDisconnection(const nsString& aId);

  void RemoveAllMockDevices();

  void ResetToDefaultMockDevices();

  virtual TestSerialPlatformService* AsTestService() override;

 private:
  ~TestSerialPlatformService() override = default;

  nsresult EnumeratePortsImpl(SerialPortList& aPorts,
                              bool* aLikelyAccessDenied) override;
  nsresult OpenImpl(const nsString& aPortId,
                    const IPCSerialOptions& aOptions) override;
  nsresult CloseImpl(const nsString& aPortId) override;
  nsresult WriteImpl(const nsString& aPortId,
                     Span<const uint8_t> aData) override;
  nsresult DrainImpl(const nsString& aPortId) override;
  nsresult FlushImpl(const nsString& aPortId, bool aReceive) override;
  nsresult SetSignalsImpl(const nsString& aPortId,
                          const IPCSerialOutputSignals& aSignals) override;
  nsresult GetSignalsImpl(const nsString& aPortId,
                          IPCSerialInputSignals& aSignals) override;
  nsresult GetReadStreamImpl(const nsString& aPortId, uint32_t aBufferSize,
                             nsIAsyncInputStream** aStream) override;

  MockSerialPort* FindPort(const nsString& aPortId);
  void RemoveMockDevice(const nsString& aId);
  MockSerialPort CreateMockPort(const nsString& aId, const nsString& aPath,
                                uint16_t aVendorId, uint16_t aProductId);
  void AddDefaultMockPorts();

  nsTArray<MockSerialPort> mMockPorts;
};

}  // namespace mozilla::dom

#endif  // mozilla_dom_TestSerialPlatformService_h

Messung V0.5 in Prozent
C=91 H=95 G=92

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet am  2026-08-25) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.