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

Side by Side Diff: device/bluetooth/bluetooth_device_unittest.cc

Issue 1876753004: bluetooth: Check if device name is null before trying to convert (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Created 4 years, 8 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 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 "device/bluetooth/bluetooth_device.h" 5 #include "device/bluetooth/bluetooth_device.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 InitWithFakeAdapter(); 109 InitWithFakeAdapter();
110 StartLowEnergyDiscoverySession(); 110 StartLowEnergyDiscoverySession();
111 BluetoothDevice* device = DiscoverLowEnergyDevice(3); 111 BluetoothDevice* device = DiscoverLowEnergyDevice(3);
112 ASSERT_TRUE(device); 112 ASSERT_TRUE(device);
113 BluetoothDevice::UUIDList uuids = device->GetUUIDs(); 113 BluetoothDevice::UUIDList uuids = device->GetUUIDs();
114 EXPECT_EQ(0u, uuids.size()); 114 EXPECT_EQ(0u, uuids.size());
115 } 115 }
116 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 116 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
117 117
118 #if defined(OS_ANDROID)
119 // GetDeviceName for Device with name.
120 TEST_F(BluetoothTest, GetDeviceName) {
121 if (!PlatformSupportsLowEnergy()) {
122 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
123 return;
124 }
125 InitWithFakeAdapter();
126 StartLowEnergyDiscoverySession();
127 BluetoothDevice* device = DiscoverLowEnergyDevice(1);
128 EXPECT_EQ("FakeBluetoothDevice", device->GetDeviceName());
scheib 2016/04/11 17:58:12 We already have LowEnergyDeviceProperties that tes
ortuno 2016/04/11 18:11:58 Removed the test. Should I add a call to GetDevice
129 }
130 #endif // defined(OS_ANDROID)
131
132 #if defined(OS_ANDROID)
133 // GetDeviceName for Device with no name.
134 TEST_F(BluetoothTest, GetDeviceName_NullName) {
135 if (!PlatformSupportsLowEnergy()) {
136 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
137 return;
138 }
139 InitWithFakeAdapter();
140 StartLowEnergyDiscoverySession();
141 BluetoothDevice* device = DiscoverLowEnergyDevice(5);
scheib 2016/04/11 17:58:12 Document '5' in bluetooth/test/bluetooth_test.h
ortuno 2016/04/11 18:11:58 Done.
142 EXPECT_EQ("", device->GetDeviceName());
143 }
144 #endif // defined(OS_ANDROID)
145
118 // TODO(scheib): Test with a device with no name. http://crbug.com/506415 146 // TODO(scheib): Test with a device with no name. http://crbug.com/506415
119 // BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() will run, which 147 // BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() will run, which
120 // requires string resources to be loaded. For that, something like 148 // requires string resources to be loaded. For that, something like
121 // InitSharedInstance must be run. See unittest files that call that. It will 149 // InitSharedInstance must be run. See unittest files that call that. It will
122 // also require build configuration to generate string resources into a .pak 150 // also require build configuration to generate string resources into a .pak
123 // file. 151 // file.
124 152
125 #if defined(OS_ANDROID) || defined(OS_MACOSX) 153 #if defined(OS_ANDROID) || defined(OS_MACOSX)
126 // Basic CreateGattConnection test. 154 // Basic CreateGattConnection test.
127 TEST_F(BluetoothTest, CreateGattConnection) { 155 TEST_F(BluetoothTest, CreateGattConnection) {
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 ResetEventCounts(); 625 ResetEventCounts();
598 SimulateGattConnection(device); 626 SimulateGattConnection(device);
599 EXPECT_EQ(1, gatt_discovery_attempts_); 627 EXPECT_EQ(1, gatt_discovery_attempts_);
600 628
601 SimulateGattServicesDiscoveryError(device); 629 SimulateGattServicesDiscoveryError(device);
602 EXPECT_EQ(0u, device->GetGattServices().size()); 630 EXPECT_EQ(0u, device->GetGattServices().size());
603 } 631 }
604 #endif // defined(OS_ANDROID) 632 #endif // defined(OS_ANDROID)
605 633
606 } // namespace device 634 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698