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

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

Issue 1232613004: The first 3 BluetoothTest.* unit tests now running on Mac as well. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@movCBCM
Patch Set: comment edit 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 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "device/bluetooth/bluetooth_adapter.h" 8 #include "device/bluetooth/bluetooth_adapter.h"
9 #include "device/bluetooth/bluetooth_device.h" 9 #include "device/bluetooth/bluetooth_device.h"
10 #include "device/bluetooth/bluetooth_discovery_session.h" 10 #include "device/bluetooth/bluetooth_discovery_session.h"
11 #include "device/bluetooth/test/bluetooth_test.h" 11 #include "device/bluetooth/test/bluetooth_test.h"
12 #include "device/bluetooth/test/test_bluetooth_adapter_observer.h" 12 #include "device/bluetooth/test/test_bluetooth_adapter_observer.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 #if defined(OS_ANDROID) 15 #if defined(OS_ANDROID)
16 #include "device/bluetooth/test/bluetooth_test_android.h" 16 #include "device/bluetooth/test/bluetooth_test_android.h"
17 #elif defined(OS_MACOSX)
18 #include "device/bluetooth/test/bluetooth_test_mac.h"
17 #endif 19 #endif
18 20
19 using device::BluetoothDevice; 21 using device::BluetoothDevice;
20 22
21 namespace device { 23 namespace device {
22 24
23 class TestBluetoothAdapter : public BluetoothAdapter { 25 class TestBluetoothAdapter : public BluetoothAdapter {
24 public: 26 public:
25 TestBluetoothAdapter() { 27 TestBluetoothAdapter() {
26 } 28 }
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 resulting_uuids.end()); 396 resulting_uuids.end());
395 397
396 resulting_filter = adapter->GetMergedDiscoveryFilterMasked(df); 398 resulting_filter = adapter->GetMergedDiscoveryFilterMasked(df);
397 EXPECT_EQ(BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL, 399 EXPECT_EQ(BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL,
398 resulting_filter->GetTransport()); 400 resulting_filter->GetTransport());
399 401
400 adapter->CleanupSessions(); 402 adapter->CleanupSessions();
401 } 403 }
402 404
403 // TODO(scheib): Enable BluetoothTest fixture tests on all platforms. 405 // TODO(scheib): Enable BluetoothTest fixture tests on all platforms.
404 #if defined(OS_ANDROID) 406 #if defined(OS_ANDROID) || defined(OS_MACOSX)
405 TEST_F(BluetoothTest, ConstructDefaultAdapter) { 407 TEST_F(BluetoothTest, ConstructDefaultAdapter) {
406 InitWithDefaultAdapter(); 408 InitWithDefaultAdapter();
407 if (!adapter_->IsPresent()) { 409 if (!adapter_->IsPresent()) {
408 LOG(WARNING) << "Bluetooth adapter not present; skipping unit test."; 410 LOG(WARNING) << "Bluetooth adapter not present; skipping unit test.";
409 return; 411 return;
410 } 412 }
411 EXPECT_GT(adapter_->GetAddress().length(), 0u); 413 EXPECT_GT(adapter_->GetAddress().length(), 0u);
412 EXPECT_GT(adapter_->GetName().length(), 0u); 414 EXPECT_GT(adapter_->GetName().length(), 0u);
413 EXPECT_TRUE(adapter_->IsPresent()); 415 EXPECT_TRUE(adapter_->IsPresent());
414 // Don't know on test machines if adapter will be powered or not, but 416 // Don't know on test machines if adapter will be powered or not, but
415 // the call should be safe to make and consistent. 417 // the call should be safe to make and consistent.
416 EXPECT_EQ(adapter_->IsPowered(), adapter_->IsPowered()); 418 EXPECT_EQ(adapter_->IsPowered(), adapter_->IsPowered());
417 EXPECT_FALSE(adapter_->IsDiscoverable()); 419 EXPECT_FALSE(adapter_->IsDiscoverable());
418 EXPECT_FALSE(adapter_->IsDiscovering()); 420 EXPECT_FALSE(adapter_->IsDiscovering());
419 } 421 }
420 #endif // defined(OS_ANDROID) 422 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
421 423
422 // TODO(scheib): Enable BluetoothTest fixture tests on all platforms. 424 // TODO(scheib): Enable BluetoothTest fixture tests on all platforms.
423 #if defined(OS_ANDROID) 425 #if defined(OS_ANDROID) || defined(OS_MACOSX)
424 TEST_F(BluetoothTest, ConstructWithoutDefaultAdapter) { 426 TEST_F(BluetoothTest, ConstructWithoutDefaultAdapter) {
425 InitWithoutDefaultAdapter(); 427 InitWithoutDefaultAdapter();
426 EXPECT_EQ(adapter_->GetAddress(), ""); 428 EXPECT_EQ(adapter_->GetAddress(), "");
427 EXPECT_EQ(adapter_->GetName(), ""); 429 EXPECT_EQ(adapter_->GetName(), "");
428 EXPECT_FALSE(adapter_->IsPresent()); 430 EXPECT_FALSE(adapter_->IsPresent());
429 EXPECT_FALSE(adapter_->IsPowered()); 431 EXPECT_FALSE(adapter_->IsPowered());
430 EXPECT_FALSE(adapter_->IsDiscoverable()); 432 EXPECT_FALSE(adapter_->IsDiscoverable());
431 EXPECT_FALSE(adapter_->IsDiscovering()); 433 EXPECT_FALSE(adapter_->IsDiscovering());
432 } 434 }
433 #endif // defined(OS_ANDROID) 435 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
434 436
435 // TODO(scheib): Enable BluetoothTest fixture tests on all platforms. 437 // TODO(scheib): Enable BluetoothTest fixture tests on all platforms.
436 #if defined(OS_ANDROID) 438 #if defined(OS_ANDROID) || defined(OS_MACOSX)
437 TEST_F(BluetoothTest, ConstructFakeAdapter) { 439 TEST_F(BluetoothTest, ConstructFakeAdapter) {
438 InitWithFakeAdapter(); 440 InitWithFakeAdapter();
439 EXPECT_EQ(adapter_->GetAddress(), "A1:B2:C3:D4:E5:F6"); 441 EXPECT_EQ(adapter_->GetAddress(), kTestAdapterAddress);
440 EXPECT_EQ(adapter_->GetName(), "FakeBluetoothAdapter"); 442 EXPECT_EQ(adapter_->GetName(), kTestAdapterName);
441 EXPECT_TRUE(adapter_->IsPresent()); 443 EXPECT_TRUE(adapter_->IsPresent());
442 EXPECT_TRUE(adapter_->IsPowered()); 444 EXPECT_TRUE(adapter_->IsPowered());
443 EXPECT_FALSE(adapter_->IsDiscoverable()); 445 EXPECT_FALSE(adapter_->IsDiscoverable());
444 EXPECT_FALSE(adapter_->IsDiscovering()); 446 EXPECT_FALSE(adapter_->IsDiscovering());
445 } 447 }
446 #endif // defined(OS_ANDROID) 448 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
447 449
448 // TODO(scheib): Enable BluetoothTest fixture tests on all platforms. 450 // TODO(scheib): Enable BluetoothTest fixture tests on all platforms.
449 #if defined(OS_ANDROID) 451 #if defined(OS_ANDROID)
450 // Starts and Stops a discovery session. 452 // Starts and Stops a discovery session.
451 TEST_F(BluetoothTest, DiscoverySession) { 453 TEST_F(BluetoothTest, DiscoverySession) {
452 InitWithFakeAdapter(); 454 InitWithFakeAdapter();
453 EXPECT_FALSE(adapter_->IsDiscovering()); 455 EXPECT_FALSE(adapter_->IsDiscovering());
454 456
455 adapter_->StartDiscoverySession(GetDiscoverySessionCallback(), 457 adapter_->StartDiscoverySession(GetDiscoverySessionCallback(),
456 GetErrorCallback()); 458 GetErrorCallback());
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 base::RunLoop().RunUntilIdle(); 573 base::RunLoop().RunUntilIdle();
572 DiscoverLowEnergyDevice(1); 574 DiscoverLowEnergyDevice(1);
573 DiscoverLowEnergyDevice(4); 575 DiscoverLowEnergyDevice(4);
574 base::RunLoop().RunUntilIdle(); 576 base::RunLoop().RunUntilIdle();
575 EXPECT_EQ(2, observer.device_added_count()); 577 EXPECT_EQ(2, observer.device_added_count());
576 EXPECT_EQ(2u, adapter_->GetDevices().size()); 578 EXPECT_EQ(2u, adapter_->GetDevices().size());
577 } 579 }
578 #endif // defined(OS_ANDROID) 580 #endif // defined(OS_ANDROID)
579 581
580 } // namespace device 582 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_mac_unittest.mm ('k') | device/bluetooth/test/bluetooth_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698