Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: device/bluetooth/test/bluetooth_test.h

Issue 1226103005: Revert of bluetooth: android: Initial Low Energy Discovery Sessions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-manifest-
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
10 #include "device/bluetooth/bluetooth_adapter.h" 9 #include "device/bluetooth/bluetooth_adapter.h"
11 #include "device/bluetooth/bluetooth_discovery_session.h"
12 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
13 11
14 namespace device { 12 namespace device {
15 13
16 class BluetoothAdapter; 14 class BluetoothAdapter;
17 15
18 // A test fixture for Bluetooth that abstracts platform specifics for creating 16 // A test fixture for Bluetooth that abstracts platform specifics for creating
19 // and controlling fake low level objects. 17 // and controlling fake low level objects.
20 // 18 //
21 // Subclasses on each platform implement this, and are then typedef-ed to 19 // Subclasses on each platform implement this, and are then typedef-ed to
22 // BluetoothTest. 20 // BluetoothTest.
23 class BluetoothTestBase : public testing::Test { 21 class BluetoothTestBase : public testing::Test {
24 public: 22 public:
25 BluetoothTestBase(); 23 BluetoothTestBase();
26 ~BluetoothTestBase() override; 24 ~BluetoothTestBase() override;
27 25
28 // Initializes the BluetoothAdapter |adapter_| with the system adapter. 26 // Initializes the BluetoothAdapter |adapter_| with the system adapter.
29 virtual void InitWithDefaultAdapter(){}; 27 virtual void InitWithDefaultAdapter(){};
30 28
31 // Initializes the BluetoothAdapter |adapter_| with the system adapter forced 29 // 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 30 // to be ignored as if it did not exist. This enables tests for when an
33 // adapter is not present on the system. 31 // adapter is not present on the system.
34 virtual void InitWithoutDefaultAdapter(){}; 32 virtual void InitWithoutDefaultAdapter(){};
35 33
36 // Initializes the BluetoothAdapter |adapter_| with a fake adapter that can be 34 // Initializes the BluetoothAdapter |adapter_| with a fake adapter that can be
37 // controlled by this test fixture. 35 // controlled by this test fixture.
38 virtual void InitWithFakeAdapter(){}; 36 virtual void InitWithFakeAdapter(){};
39 37
40 // Callbacks that increment |callback_count_|, |error_callback_count_|:
41 void Callback();
42 void DiscoverySessionCallback(scoped_ptr<BluetoothDiscoverySession>);
43 void ErrorCallback();
44
45 // Accessors to get callbacks bound to this fixture:
46 base::Closure GetCallback();
47 BluetoothAdapter::DiscoverySessionCallback GetDiscoverySessionCallback();
48 BluetoothAdapter::ErrorCallback GetErrorCallback();
49
50 // A Message loop is required by some implementations that will PostTasks and
51 // by base::RunLoop().RunUntilIdle() use in this fixuture.
52 base::MessageLoop message_loop_;
53
54 scoped_refptr<BluetoothAdapter> adapter_; 38 scoped_refptr<BluetoothAdapter> adapter_;
55 ScopedVector<BluetoothDiscoverySession> discovery_sessions_;
56 int callback_count_ = 0;
57 int error_callback_count_ = 0;
58 bool run_message_loop_to_wait_for_callbacks_ = true;
59 }; 39 };
60 40
61 } // namespace device 41 } // namespace device
62 42
63 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ 43 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698