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

Side by Side Diff: components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc

Issue 2571763003: Reduce FakeArcBridgeService usage. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « components/arc/arc_bridge_service.cc ('k') | components/arc/ime/arc_ime_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/arc/bluetooth/arc_bluetooth_bridge.h" 5 #include "components/arc/bluetooth/arc_bluetooth_bridge.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "components/arc/arc_bridge_service.h"
14 #include "components/arc/bluetooth/bluetooth_type_converters.h" 15 #include "components/arc/bluetooth/bluetooth_type_converters.h"
15 #include "components/arc/common/bluetooth.mojom.h" 16 #include "components/arc/common/bluetooth.mojom.h"
16 #include "components/arc/test/fake_arc_bridge_service.h"
17 #include "components/arc/test/fake_bluetooth_instance.h" 17 #include "components/arc/test/fake_bluetooth_instance.h"
18 #include "device/bluetooth/dbus/bluez_dbus_manager.h" 18 #include "device/bluetooth/dbus/bluez_dbus_manager.h"
19 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" 19 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
20 #include "device/bluetooth/dbus/fake_bluetooth_device_client.h" 20 #include "device/bluetooth/dbus/fake_bluetooth_device_client.h"
21 #include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h" 21 #include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h"
22 #include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h" 22 #include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h"
23 #include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h" 23 #include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h"
24 #include "device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h" 24 #include "device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h"
25 #include "mojo/public/cpp/bindings/array.h" 25 #include "mojo/public/cpp/bindings/array.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 fake_bluetooth_device_client->RemoveAllDevices(); 82 fake_bluetooth_device_client->RemoveAllDevices();
83 dbus_setter->SetBluetoothDeviceClient( 83 dbus_setter->SetBluetoothDeviceClient(
84 std::move(fake_bluetooth_device_client)); 84 std::move(fake_bluetooth_device_client));
85 dbus_setter->SetBluetoothGattServiceClient( 85 dbus_setter->SetBluetoothGattServiceClient(
86 base::MakeUnique<bluez::FakeBluetoothGattServiceClient>()); 86 base::MakeUnique<bluez::FakeBluetoothGattServiceClient>());
87 dbus_setter->SetBluetoothGattCharacteristicClient( 87 dbus_setter->SetBluetoothGattCharacteristicClient(
88 base::MakeUnique<bluez::FakeBluetoothGattCharacteristicClient>()); 88 base::MakeUnique<bluez::FakeBluetoothGattCharacteristicClient>());
89 dbus_setter->SetBluetoothGattDescriptorClient( 89 dbus_setter->SetBluetoothGattDescriptorClient(
90 base::MakeUnique<bluez::FakeBluetoothGattDescriptorClient>()); 90 base::MakeUnique<bluez::FakeBluetoothGattDescriptorClient>());
91 91
92 fake_arc_bridge_service_.reset(new FakeArcBridgeService()); 92 arc_bridge_service_ = base::MakeUnique<ArcBridgeService>();
93 fake_bluetooth_instance_.reset(new FakeBluetoothInstance()); 93 fake_bluetooth_instance_ = base::MakeUnique<FakeBluetoothInstance>();
94 fake_arc_bridge_service_->bluetooth()->SetInstance( 94 arc_bridge_service_->bluetooth()->SetInstance(
95 fake_bluetooth_instance_.get(), 2); 95 fake_bluetooth_instance_.get(), 2);
96 arc_bluetooth_bridge_.reset( 96 arc_bluetooth_bridge_ =
97 new ArcBluetoothBridge(fake_arc_bridge_service_.get())); 97 base::MakeUnique<ArcBluetoothBridge>(arc_bridge_service_.get());
98 98
99 device::BluetoothAdapterFactory::GetAdapter(base::Bind( 99 device::BluetoothAdapterFactory::GetAdapter(base::Bind(
100 &ArcBluetoothBridgeTest::OnAdapterInitialized, base::Unretained(this))); 100 &ArcBluetoothBridgeTest::OnAdapterInitialized, base::Unretained(this)));
101 // We will quit the loop once we get the adapter. 101 // We will quit the loop once we get the adapter.
102 get_adapter_run_loop_.Run(); 102 get_adapter_run_loop_.Run();
103 } 103 }
104 104
105 // Helper methods for multi advertisement tests. 105 // Helper methods for multi advertisement tests.
106 int32_t ReserveAdvertisementHandle() { 106 int32_t ReserveAdvertisementHandle() {
107 constexpr int kSentinelHandle = -2; 107 constexpr int kSentinelHandle = -2;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 bluez::FakeBluetoothLEAdvertisingManagerClient* adv_client = 159 bluez::FakeBluetoothLEAdvertisingManagerClient* adv_client =
160 static_cast<bluez::FakeBluetoothLEAdvertisingManagerClient*>( 160 static_cast<bluez::FakeBluetoothLEAdvertisingManagerClient*>(
161 bluez::BluezDBusManager::Get() 161 bluez::BluezDBusManager::Get()
162 ->GetBluetoothLEAdvertisingManagerClient()); 162 ->GetBluetoothLEAdvertisingManagerClient());
163 return adv_client->currently_registered(); 163 return adv_client->currently_registered();
164 } 164 }
165 165
166 int last_adv_handle_; 166 int last_adv_handle_;
167 mojom::BluetoothGattStatus last_status_; 167 mojom::BluetoothGattStatus last_status_;
168 168
169 std::unique_ptr<FakeArcBridgeService> fake_arc_bridge_service_; 169 std::unique_ptr<ArcBridgeService> arc_bridge_service_;
170 std::unique_ptr<FakeBluetoothInstance> fake_bluetooth_instance_; 170 std::unique_ptr<FakeBluetoothInstance> fake_bluetooth_instance_;
171 std::unique_ptr<ArcBluetoothBridge> arc_bluetooth_bridge_; 171 std::unique_ptr<ArcBluetoothBridge> arc_bluetooth_bridge_;
172 scoped_refptr<device::BluetoothAdapter> adapter_; 172 scoped_refptr<device::BluetoothAdapter> adapter_;
173 base::MessageLoop message_loop_; 173 base::MessageLoop message_loop_;
174 base::RunLoop get_adapter_run_loop_; 174 base::RunLoop get_adapter_run_loop_;
175 }; 175 };
176 176
177 // When we add device to bluez::FakeBluetoothDeviceClient, ArcBluetoothBridge 177 // When we add device to bluez::FakeBluetoothDeviceClient, ArcBluetoothBridge
178 // should send new device data to Android. This test will then check 178 // should send new device data to Android. This test will then check
179 // the correctness of the device properties sent via arc bridge. 179 // the correctness of the device properties sent via arc bridge.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 BroadcastAdvertisement(handle, std::move(adv_data)); 322 BroadcastAdvertisement(handle, std::move(adv_data));
323 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status); 323 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status);
324 EXPECT_EQ(1, NumActiveAdvertisements()); 324 EXPECT_EQ(1, NumActiveAdvertisements());
325 325
326 status = ReleaseAdvertisementHandle(handle); 326 status = ReleaseAdvertisementHandle(handle);
327 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status); 327 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status);
328 EXPECT_EQ(0, NumActiveAdvertisements()); 328 EXPECT_EQ(0, NumActiveAdvertisements());
329 } 329 }
330 330
331 } // namespace arc 331 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/arc_bridge_service.cc ('k') | components/arc/ime/arc_ime_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698