File: fake_gatt_session_winrt.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (110 lines) | stat: -rw-r--r-- 4,324 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef DEVICE_BLUETOOTH_TEST_FAKE_GATT_SESSION_WINRT_H_
#define DEVICE_BLUETOOTH_TEST_FAKE_GATT_SESSION_WINRT_H_

#include <windows.devices.bluetooth.genericattributeprofile.h>
#include <windows.devices.bluetooth.h>
#include <windows.foundation.h>
#include <wrl/client.h>
#include <wrl/implements.h>

#include "base/memory/raw_ptr.h"

namespace device {

class BluetoothTestWinrt;

class FakeGattSessionWinrt
    : public Microsoft::WRL::RuntimeClass<
          Microsoft::WRL::RuntimeClassFlags<
              Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
          ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
              IGattSession,
          ABI::Windows::Foundation::IClosable> {
 public:
  FakeGattSessionWinrt(BluetoothTestWinrt* bluetooth_test_winrt);
  FakeGattSessionWinrt(const FakeGattSessionWinrt&) = delete;
  FakeGattSessionWinrt& operator=(const FakeGattSessionWinrt&) = delete;
  ~FakeGattSessionWinrt() override;

  void SimulateGattConnection();
  void SimulateGattDisconnection();
  void SimulateGattConnectionError();

  // IGattSession:
  IFACEMETHODIMP get_DeviceId(
      ABI::Windows::Devices::Bluetooth::IBluetoothDeviceId** value) override;
  IFACEMETHODIMP get_CanMaintainConnection(::boolean* value) override;
  IFACEMETHODIMP put_MaintainConnection(::boolean value) override;
  IFACEMETHODIMP get_MaintainConnection(::boolean* value) override;
  IFACEMETHODIMP get_MaxPduSize(UINT16* value) override;
  IFACEMETHODIMP get_SessionStatus(
      ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
          GattSessionStatus* value) override;
  IFACEMETHODIMP add_MaxPduSizeChanged(
      ABI::Windows::Foundation::ITypedEventHandler<
          ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
              GattSession*,
          IInspectable*>* handler,
      EventRegistrationToken* token) override;
  IFACEMETHODIMP
  remove_MaxPduSizeChanged(EventRegistrationToken token) override;
  IFACEMETHODIMP add_SessionStatusChanged(
      ABI::Windows::Foundation::ITypedEventHandler<
          ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
              GattSession*,
          ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
              GattSessionStatusChangedEventArgs*>* handler,
      EventRegistrationToken* token) override;
  IFACEMETHODIMP
  remove_SessionStatusChanged(EventRegistrationToken token) override;

  // IClosable:
  IFACEMETHODIMP Close() override;

 private:
  raw_ptr<BluetoothTestWinrt> bluetooth_test_winrt_ = nullptr;
  bool maintain_connection_ = false;

  ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::GattSessionStatus
      status_ = ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
          GattSessionStatus_Closed;

  Microsoft::WRL::ComPtr<ABI::Windows::Foundation::ITypedEventHandler<
      ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::GattSession*,
      ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
          GattSessionStatusChangedEventArgs*>>
      status_changed_handler_;
};

class FakeGattSessionStaticsWinrt
    : public Microsoft::WRL::RuntimeClass<
          Microsoft::WRL::RuntimeClassFlags<
              Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
          ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
              IGattSessionStatics> {
 public:
  FakeGattSessionStaticsWinrt(BluetoothTestWinrt* bluetooth_test_winrt);
  FakeGattSessionStaticsWinrt(const FakeGattSessionStaticsWinrt&) = delete;
  FakeGattSessionStaticsWinrt& operator=(const FakeGattSessionStaticsWinrt&) =
      delete;
  ~FakeGattSessionStaticsWinrt() override;

  // IGattSessionStatics:
  IFACEMETHODIMP FromDeviceIdAsync(
      ABI::Windows::Devices::Bluetooth::IBluetoothDeviceId* device_id,
      ABI::Windows::Foundation::IAsyncOperation<
          ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
              GattSession*>** operation) override;

 private:
  raw_ptr<BluetoothTestWinrt, DanglingUntriaged> bluetooth_test_winrt_ =
      nullptr;
};

}  // namespace device

#endif  // DEVICE_BLUETOOTH_TEST_FAKE_GATT_SESSION_WINRT_H_