OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "device/bluetooth/bluetooth_adapter.h" | 6 #include "device/bluetooth/bluetooth_adapter.h" |
7 #include "device/bluetooth/bluetooth_device.h" | 7 #include "device/bluetooth/bluetooth_device.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 using device::BluetoothAdapter; | 10 using device::BluetoothAdapter; |
11 using device::BluetoothDevice; | 11 using device::BluetoothDevice; |
12 | 12 |
13 namespace device { | 13 namespace device { |
14 | 14 |
15 class TestBluetoothAdapter : public BluetoothAdapter { | 15 class TestBluetoothAdapter : public BluetoothAdapter { |
16 public: | 16 public: |
17 TestBluetoothAdapter() { | 17 TestBluetoothAdapter() { |
18 } | 18 } |
19 | 19 |
20 virtual void AddObserver(BluetoothAdapter::Observer* observer) OVERRIDE { | 20 virtual void AddObserver(BluetoothAdapter::Observer* observer) override { |
21 } | 21 } |
22 | 22 |
23 virtual void RemoveObserver(BluetoothAdapter::Observer* observer) OVERRIDE { | 23 virtual void RemoveObserver(BluetoothAdapter::Observer* observer) override { |
24 | 24 |
25 } | 25 } |
26 | 26 |
27 virtual std::string GetAddress() const OVERRIDE { | 27 virtual std::string GetAddress() const override { |
28 return ""; | 28 return ""; |
29 } | 29 } |
30 | 30 |
31 virtual std::string GetName() const OVERRIDE { | 31 virtual std::string GetName() const override { |
32 return ""; | 32 return ""; |
33 } | 33 } |
34 | 34 |
35 virtual void SetName(const std::string& name, | 35 virtual void SetName(const std::string& name, |
36 const base::Closure& callback, | 36 const base::Closure& callback, |
37 const ErrorCallback& error_callback) OVERRIDE { | 37 const ErrorCallback& error_callback) override { |
38 } | 38 } |
39 | 39 |
40 virtual bool IsInitialized() const OVERRIDE { | 40 virtual bool IsInitialized() const override { |
41 return false; | 41 return false; |
42 } | 42 } |
43 | 43 |
44 virtual bool IsPresent() const OVERRIDE { | 44 virtual bool IsPresent() const override { |
45 return false; | 45 return false; |
46 } | 46 } |
47 | 47 |
48 virtual bool IsPowered() const OVERRIDE { | 48 virtual bool IsPowered() const override { |
49 return false; | 49 return false; |
50 } | 50 } |
51 | 51 |
52 virtual void SetPowered( | 52 virtual void SetPowered( |
53 bool powered, | 53 bool powered, |
54 const base::Closure& callback, | 54 const base::Closure& callback, |
55 const ErrorCallback& error_callback) OVERRIDE { | 55 const ErrorCallback& error_callback) override { |
56 } | 56 } |
57 | 57 |
58 virtual bool IsDiscoverable() const OVERRIDE { | 58 virtual bool IsDiscoverable() const override { |
59 return false; | 59 return false; |
60 } | 60 } |
61 | 61 |
62 virtual void SetDiscoverable( | 62 virtual void SetDiscoverable( |
63 bool discoverable, | 63 bool discoverable, |
64 const base::Closure& callback, | 64 const base::Closure& callback, |
65 const ErrorCallback& error_callback) OVERRIDE { | 65 const ErrorCallback& error_callback) override { |
66 } | 66 } |
67 | 67 |
68 virtual bool IsDiscovering() const OVERRIDE { | 68 virtual bool IsDiscovering() const override { |
69 return false; | 69 return false; |
70 } | 70 } |
71 | 71 |
72 virtual void StartDiscoverySession( | 72 virtual void StartDiscoverySession( |
73 const DiscoverySessionCallback& callback, | 73 const DiscoverySessionCallback& callback, |
74 const ErrorCallback& error_callback) OVERRIDE { | 74 const ErrorCallback& error_callback) override { |
75 } | 75 } |
76 | 76 |
77 virtual void CreateRfcommService( | 77 virtual void CreateRfcommService( |
78 const BluetoothUUID& uuid, | 78 const BluetoothUUID& uuid, |
79 const ServiceOptions& options, | 79 const ServiceOptions& options, |
80 const CreateServiceCallback& callback, | 80 const CreateServiceCallback& callback, |
81 const CreateServiceErrorCallback& error_callback) OVERRIDE { | 81 const CreateServiceErrorCallback& error_callback) override { |
82 } | 82 } |
83 | 83 |
84 virtual void CreateL2capService( | 84 virtual void CreateL2capService( |
85 const BluetoothUUID& uuid, | 85 const BluetoothUUID& uuid, |
86 const ServiceOptions& options, | 86 const ServiceOptions& options, |
87 const CreateServiceCallback& callback, | 87 const CreateServiceCallback& callback, |
88 const CreateServiceErrorCallback& error_callback) OVERRIDE { | 88 const CreateServiceErrorCallback& error_callback) override { |
89 } | 89 } |
90 | 90 |
91 protected: | 91 protected: |
92 virtual ~TestBluetoothAdapter() {} | 92 virtual ~TestBluetoothAdapter() {} |
93 | 93 |
94 virtual void AddDiscoverySession( | 94 virtual void AddDiscoverySession( |
95 const base::Closure& callback, | 95 const base::Closure& callback, |
96 const ErrorCallback& error_callback) OVERRIDE { | 96 const ErrorCallback& error_callback) override { |
97 } | 97 } |
98 | 98 |
99 virtual void RemoveDiscoverySession( | 99 virtual void RemoveDiscoverySession( |
100 const base::Closure& callback, | 100 const base::Closure& callback, |
101 const ErrorCallback& error_callback) OVERRIDE { | 101 const ErrorCallback& error_callback) override { |
102 } | 102 } |
103 | 103 |
104 virtual void RemovePairingDelegateInternal( | 104 virtual void RemovePairingDelegateInternal( |
105 BluetoothDevice::PairingDelegate* pairing_delegate) OVERRIDE { | 105 BluetoothDevice::PairingDelegate* pairing_delegate) override { |
106 } | 106 } |
107 }; | 107 }; |
108 | 108 |
109 class TestPairingDelegate : public BluetoothDevice::PairingDelegate { | 109 class TestPairingDelegate : public BluetoothDevice::PairingDelegate { |
110 public: | 110 public: |
111 virtual void RequestPinCode(BluetoothDevice* device) OVERRIDE {} | 111 virtual void RequestPinCode(BluetoothDevice* device) override {} |
112 virtual void RequestPasskey(BluetoothDevice* device) OVERRIDE {} | 112 virtual void RequestPasskey(BluetoothDevice* device) override {} |
113 virtual void DisplayPinCode(BluetoothDevice* device, | 113 virtual void DisplayPinCode(BluetoothDevice* device, |
114 const std::string& pincode) OVERRIDE {} | 114 const std::string& pincode) override {} |
115 virtual void DisplayPasskey(BluetoothDevice* device, | 115 virtual void DisplayPasskey(BluetoothDevice* device, |
116 uint32 passkey) OVERRIDE {} | 116 uint32 passkey) override {} |
117 virtual void KeysEntered(BluetoothDevice* device, | 117 virtual void KeysEntered(BluetoothDevice* device, |
118 uint32 entered) OVERRIDE {} | 118 uint32 entered) override {} |
119 virtual void ConfirmPasskey(BluetoothDevice* device, | 119 virtual void ConfirmPasskey(BluetoothDevice* device, |
120 uint32 passkey) OVERRIDE {} | 120 uint32 passkey) override {} |
121 virtual void AuthorizePairing(BluetoothDevice* device) OVERRIDE {} | 121 virtual void AuthorizePairing(BluetoothDevice* device) override {} |
122 }; | 122 }; |
123 | 123 |
124 | 124 |
125 TEST(BluetoothAdapterTest, NoDefaultPairingDelegate) { | 125 TEST(BluetoothAdapterTest, NoDefaultPairingDelegate) { |
126 scoped_refptr<BluetoothAdapter> adapter = new TestBluetoothAdapter(); | 126 scoped_refptr<BluetoothAdapter> adapter = new TestBluetoothAdapter(); |
127 | 127 |
128 // Verify that when there is no registered pairing delegate, NULL is returned. | 128 // Verify that when there is no registered pairing delegate, NULL is returned. |
129 EXPECT_TRUE(adapter->DefaultPairingDelegate() == NULL); | 129 EXPECT_TRUE(adapter->DefaultPairingDelegate() == NULL); |
130 } | 130 } |
131 | 131 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 TestPairingDelegate delegate; | 183 TestPairingDelegate delegate; |
184 | 184 |
185 adapter->AddPairingDelegate(&delegate, | 185 adapter->AddPairingDelegate(&delegate, |
186 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_LOW); | 186 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_LOW); |
187 adapter->RemovePairingDelegate(&delegate); | 187 adapter->RemovePairingDelegate(&delegate); |
188 | 188 |
189 EXPECT_TRUE(adapter->DefaultPairingDelegate() == NULL); | 189 EXPECT_TRUE(adapter->DefaultPairingDelegate() == NULL); |
190 } | 190 } |
191 | 191 |
192 } // namespace device | 192 } // namespace device |
OLD | NEW |