OLD | NEW |
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_adapter.h" | 5 #include "device/bluetooth/bluetooth_adapter.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 } | 423 } |
424 | 424 |
425 // TODO(scheib): Enable BluetoothTest fixture tests on all platforms. | 425 // TODO(scheib): Enable BluetoothTest fixture tests on all platforms. |
426 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) | 426 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) |
427 TEST_F(BluetoothTest, ConstructDefaultAdapter) { | 427 TEST_F(BluetoothTest, ConstructDefaultAdapter) { |
428 InitWithDefaultAdapter(); | 428 InitWithDefaultAdapter(); |
429 if (!adapter_->IsPresent()) { | 429 if (!adapter_->IsPresent()) { |
430 LOG(WARNING) << "Bluetooth adapter not present; skipping unit test."; | 430 LOG(WARNING) << "Bluetooth adapter not present; skipping unit test."; |
431 return; | 431 return; |
432 } | 432 } |
433 EXPECT_GT(adapter_->GetAddress().length(), 0u); | 433 |
434 EXPECT_GT(adapter_->GetName().length(), 0u); | 434 bool expected = false; |
| 435 // MacOS returns empty for name and address if the adapter is off. |
| 436 #if defined(OS_MACOSX) |
| 437 expected = !adapter_->IsPowered(); |
| 438 #endif // defined(OS_MACOSX) |
| 439 |
| 440 EXPECT_EQ(expected, adapter_->GetAddress().empty()); |
| 441 EXPECT_EQ(expected, adapter_->GetName().empty()); |
| 442 |
435 EXPECT_TRUE(adapter_->IsPresent()); | 443 EXPECT_TRUE(adapter_->IsPresent()); |
436 // Don't know on test machines if adapter will be powered or not, but | 444 // Don't know on test machines if adapter will be powered or not, but |
437 // the call should be safe to make and consistent. | 445 // the call should be safe to make and consistent. |
438 EXPECT_EQ(adapter_->IsPowered(), adapter_->IsPowered()); | 446 EXPECT_EQ(adapter_->IsPowered(), adapter_->IsPowered()); |
439 EXPECT_FALSE(adapter_->IsDiscoverable()); | 447 EXPECT_FALSE(adapter_->IsDiscoverable()); |
440 EXPECT_FALSE(adapter_->IsDiscovering()); | 448 EXPECT_FALSE(adapter_->IsDiscovering()); |
441 } | 449 } |
442 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) | 450 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) |
443 | 451 |
444 // TODO(scheib): Enable BluetoothTest fixture tests on all platforms. | 452 // TODO(scheib): Enable BluetoothTest fixture tests on all platforms. |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 GetConnectErrorCallback(Call::NOT_EXPECTED)); | 869 GetConnectErrorCallback(Call::NOT_EXPECTED)); |
862 SimulateGattConnection(device); | 870 SimulateGattConnection(device); |
863 EXPECT_EQ(1u, adapter_->GetDevices().size()); | 871 EXPECT_EQ(1u, adapter_->GetDevices().size()); |
864 RemoveTimedOutDevices(); | 872 RemoveTimedOutDevices(); |
865 EXPECT_EQ(0, observer.device_removed_count()); | 873 EXPECT_EQ(0, observer.device_removed_count()); |
866 EXPECT_EQ(1u, adapter_->GetDevices().size()); | 874 EXPECT_EQ(1u, adapter_->GetDevices().size()); |
867 } | 875 } |
868 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) | 876 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
869 | 877 |
870 } // namespace device | 878 } // namespace device |
OLD | NEW |