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

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

Issue 1897873003: bluetooth: Check if device name is null before trying to convert (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
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 no name.
120 TEST_F(BluetoothTest, GetDeviceName_NullName) {
121 if (!PlatformSupportsLowEnergy()) {
122 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
123 return;
124 }
125 InitWithFakeAdapter();
126 StartLowEnergyDiscoverySession();
127 BluetoothDevice* device = DiscoverLowEnergyDevice(5);
128 EXPECT_EQ("", device->GetDeviceName());
129 }
130 #endif // defined(OS_ANDROID)
131
118 // TODO(scheib): Test with a device with no name. http://crbug.com/506415 132 // TODO(scheib): Test with a device with no name. http://crbug.com/506415
119 // BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() will run, which 133 // BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() will run, which
120 // requires string resources to be loaded. For that, something like 134 // requires string resources to be loaded. For that, something like
121 // InitSharedInstance must be run. See unittest files that call that. It will 135 // InitSharedInstance must be run. See unittest files that call that. It will
122 // also require build configuration to generate string resources into a .pak 136 // also require build configuration to generate string resources into a .pak
123 // file. 137 // file.
124 138
125 #if defined(OS_ANDROID) || defined(OS_MACOSX) 139 #if defined(OS_ANDROID) || defined(OS_MACOSX)
126 // Basic CreateGattConnection test. 140 // Basic CreateGattConnection test.
127 TEST_F(BluetoothTest, CreateGattConnection) { 141 TEST_F(BluetoothTest, CreateGattConnection) {
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 ResetEventCounts(); 611 ResetEventCounts();
598 SimulateGattConnection(device); 612 SimulateGattConnection(device);
599 EXPECT_EQ(1, gatt_discovery_attempts_); 613 EXPECT_EQ(1, gatt_discovery_attempts_);
600 614
601 SimulateGattServicesDiscoveryError(device); 615 SimulateGattServicesDiscoveryError(device);
602 EXPECT_EQ(0u, device->GetGattServices().size()); 616 EXPECT_EQ(0u, device->GetGattServices().size());
603 } 617 }
604 #endif // defined(OS_ANDROID) 618 #endif // defined(OS_ANDROID)
605 619
606 } // namespace device 620 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698