| 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: AA:00:00:00:00:01 with simple default values. |
| 43 // 2: AA:00:00:00:00:01 with different advertised Service UUIDs vs 1. |
| 44 // 3: AA:00:00:00:00:01 with empty name, empty UUIDs. |
| 45 // 4: BB:00:00:00:00:02 with empty name, empty UUIDs. |
| 46 virtual void DiscoverLowEnergyDevice(int device_ordinal){}; |
| 47 |
| 40 // Callbacks that increment |callback_count_|, |error_callback_count_|: | 48 // Callbacks that increment |callback_count_|, |error_callback_count_|: |
| 41 void Callback(); | 49 void Callback(); |
| 42 void DiscoverySessionCallback(scoped_ptr<BluetoothDiscoverySession>); | 50 void DiscoverySessionCallback(scoped_ptr<BluetoothDiscoverySession>); |
| 43 void ErrorCallback(); | 51 void ErrorCallback(); |
| 44 | 52 |
| 45 // Accessors to get callbacks bound to this fixture: | 53 // Accessors to get callbacks bound to this fixture: |
| 46 base::Closure GetCallback(); | 54 base::Closure GetCallback(); |
| 47 BluetoothAdapter::DiscoverySessionCallback GetDiscoverySessionCallback(); | 55 BluetoothAdapter::DiscoverySessionCallback GetDiscoverySessionCallback(); |
| 48 BluetoothAdapter::ErrorCallback GetErrorCallback(); | 56 BluetoothAdapter::ErrorCallback GetErrorCallback(); |
| 49 | 57 |
| 50 // A Message loop is required by some implementations that will PostTasks and | 58 // A Message loop is required by some implementations that will PostTasks and |
| 51 // by base::RunLoop().RunUntilIdle() use in this fixuture. | 59 // by base::RunLoop().RunUntilIdle() use in this fixuture. |
| 52 base::MessageLoop message_loop_; | 60 base::MessageLoop message_loop_; |
| 53 | 61 |
| 54 scoped_refptr<BluetoothAdapter> adapter_; | 62 scoped_refptr<BluetoothAdapter> adapter_; |
| 55 ScopedVector<BluetoothDiscoverySession> discovery_sessions_; | 63 ScopedVector<BluetoothDiscoverySession> discovery_sessions_; |
| 56 int callback_count_ = 0; | 64 int callback_count_ = 0; |
| 57 int error_callback_count_ = 0; | 65 int error_callback_count_ = 0; |
| 58 bool run_message_loop_to_wait_for_callbacks_ = true; | 66 bool run_message_loop_to_wait_for_callbacks_ = true; |
| 59 }; | 67 }; |
| 60 | 68 |
| 61 } // namespace device | 69 } // namespace device |
| 62 | 70 |
| 63 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 71 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
| OLD | NEW |