| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 5 #ifndef DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
| 6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "device/bluetooth/bluetooth_adapter.h" | 10 #include "device/bluetooth/bluetooth_adapter.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 // Initializes the BluetoothAdapter |adapter_| with the system adapter forced | 31 // Initializes the BluetoothAdapter |adapter_| with the system adapter forced |
| 32 // to be ignored as if it did not exist. This enables tests for when an | 32 // to be ignored as if it did not exist. This enables tests for when an |
| 33 // adapter is not present on the system. | 33 // adapter is not present on the system. |
| 34 virtual void InitWithoutDefaultAdapter(){}; | 34 virtual void InitWithoutDefaultAdapter(){}; |
| 35 | 35 |
| 36 // Initializes the BluetoothAdapter |adapter_| with a fake adapter that can be | 36 // Initializes the BluetoothAdapter |adapter_| with a fake adapter that can be |
| 37 // controlled by this test fixture. | 37 // controlled by this test fixture. |
| 38 virtual void InitWithFakeAdapter(){}; | 38 virtual void InitWithFakeAdapter(){}; |
| 39 | 39 |
| 40 // Create a fake Low Energy device and discover it. |
| 41 // |device_ordinal| selects between multiple fake device data sets to produce. |
| 42 // 1: Device with simple default values. |
| 43 // 2: Same address as 1, but with different advertised Service UUIDs. |
| 44 // 3: Device with empty name, empty UUIDs. |
| 45 virtual void DiscoverLowEnergyDevice(int device_ordinal){}; |
| 46 |
| 40 // Callbacks that increment |callback_count_|, |error_callback_count_|: | 47 // Callbacks that increment |callback_count_|, |error_callback_count_|: |
| 41 void Callback(); | 48 void Callback(); |
| 42 void DiscoverySessionCallback(scoped_ptr<BluetoothDiscoverySession>); | 49 void DiscoverySessionCallback(scoped_ptr<BluetoothDiscoverySession>); |
| 43 void ErrorCallback(); | 50 void ErrorCallback(); |
| 44 | 51 |
| 45 // Accessors to get callbacks bound to this fixture: | 52 // Accessors to get callbacks bound to this fixture: |
| 46 base::Closure GetCallback(); | 53 base::Closure GetCallback(); |
| 47 BluetoothAdapter::DiscoverySessionCallback GetDiscoverySessionCallback(); | 54 BluetoothAdapter::DiscoverySessionCallback GetDiscoverySessionCallback(); |
| 48 BluetoothAdapter::ErrorCallback GetErrorCallback(); | 55 BluetoothAdapter::ErrorCallback GetErrorCallback(); |
| 49 | 56 |
| 50 // A Message loop is required by some implementations that will PostTasks and | 57 // A Message loop is required by some implementations that will PostTasks and |
| 51 // by base::RunLoop().RunUntilIdle() use in this fixuture. | 58 // by base::RunLoop().RunUntilIdle() use in this fixuture. |
| 52 base::MessageLoop message_loop_; | 59 base::MessageLoop message_loop_; |
| 53 | 60 |
| 54 scoped_refptr<BluetoothAdapter> adapter_; | 61 scoped_refptr<BluetoothAdapter> adapter_; |
| 55 ScopedVector<BluetoothDiscoverySession> discovery_sessions_; | 62 ScopedVector<BluetoothDiscoverySession> discovery_sessions_; |
| 56 int callback_count_ = 0; | 63 int callback_count_ = 0; |
| 57 int error_callback_count_ = 0; | 64 int error_callback_count_ = 0; |
| 58 bool run_message_loop_to_wait_for_callbacks_ = true; | 65 bool run_message_loop_to_wait_for_callbacks_ = true; |
| 59 }; | 66 }; |
| 60 | 67 |
| 61 } // namespace device | 68 } // namespace device |
| 62 | 69 |
| 63 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 70 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
| OLD | NEW |