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

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

Issue 258173003: Remove static initializer in device/bluetooth/bluetooth_gatt_descriptor.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update unit tests Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_gatt_descriptor.h » ('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 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/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" 7 #include "chromeos/dbus/fake_bluetooth_adapter_client.h"
8 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" 8 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h"
9 #include "chromeos/dbus/fake_bluetooth_device_client.h" 9 #include "chromeos/dbus/fake_bluetooth_device_client.h"
10 #include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" 10 #include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h"
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 EXPECT_TRUE(characteristic->GetDescriptors().empty()); 521 EXPECT_TRUE(characteristic->GetDescriptors().empty());
522 522
523 characteristic = service->GetCharacteristic( 523 characteristic = service->GetCharacteristic(
524 fake_bluetooth_gatt_characteristic_client_-> 524 fake_bluetooth_gatt_characteristic_client_->
525 GetHeartRateMeasurementPath().value()); 525 GetHeartRateMeasurementPath().value());
526 ASSERT_TRUE(characteristic); 526 ASSERT_TRUE(characteristic);
527 EXPECT_EQ(1U, characteristic->GetDescriptors().size()); 527 EXPECT_EQ(1U, characteristic->GetDescriptors().size());
528 528
529 BluetoothGattDescriptor* descriptor = characteristic->GetDescriptors()[0]; 529 BluetoothGattDescriptor* descriptor = characteristic->GetDescriptors()[0];
530 EXPECT_FALSE(descriptor->IsLocal()); 530 EXPECT_FALSE(descriptor->IsLocal());
531 EXPECT_EQ(BluetoothGattDescriptor::kClientCharacteristicConfigurationUuid, 531 EXPECT_EQ(BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid(),
532 descriptor->GetUUID()); 532 descriptor->GetUUID());
533 533
534 // Hide the descriptor. 534 // Hide the descriptor.
535 fake_bluetooth_gatt_descriptor_client_->HideDescriptor( 535 fake_bluetooth_gatt_descriptor_client_->HideDescriptor(
536 dbus::ObjectPath(descriptor->GetIdentifier())); 536 dbus::ObjectPath(descriptor->GetIdentifier()));
537 EXPECT_TRUE(characteristic->GetDescriptors().empty()); 537 EXPECT_TRUE(characteristic->GetDescriptors().empty());
538 EXPECT_EQ(5, service_observer.gatt_service_changed_count_); 538 EXPECT_EQ(5, service_observer.gatt_service_changed_count_);
539 539
540 // Expose the descriptor again. 540 // Expose the descriptor again.
541 fake_bluetooth_gatt_descriptor_client_->ExposeDescriptor( 541 fake_bluetooth_gatt_descriptor_client_->ExposeDescriptor(
542 dbus::ObjectPath(characteristic->GetIdentifier()), 542 dbus::ObjectPath(characteristic->GetIdentifier()),
543 FakeBluetoothGattDescriptorClient:: 543 FakeBluetoothGattDescriptorClient::
544 kClientCharacteristicConfigurationUUID); 544 kClientCharacteristicConfigurationUUID);
545 EXPECT_EQ(6, service_observer.gatt_service_changed_count_); 545 EXPECT_EQ(6, service_observer.gatt_service_changed_count_);
546 EXPECT_EQ(1U, characteristic->GetDescriptors().size()); 546 EXPECT_EQ(1U, characteristic->GetDescriptors().size());
547 547
548 descriptor = characteristic->GetDescriptors()[0]; 548 descriptor = characteristic->GetDescriptors()[0];
549 EXPECT_FALSE(descriptor->IsLocal()); 549 EXPECT_FALSE(descriptor->IsLocal());
550 EXPECT_EQ(BluetoothGattDescriptor::kClientCharacteristicConfigurationUuid, 550 EXPECT_EQ(BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid(),
551 descriptor->GetUUID()); 551 descriptor->GetUUID());
552 } 552 }
553 553
554 TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) { 554 TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) {
555 // This unit test tests that all remote GATT objects are created for D-Bus 555 // This unit test tests that all remote GATT objects are created for D-Bus
556 // objects that were already exposed. 556 // objects that were already exposed.
557 adapter_ = NULL; 557 adapter_ = NULL;
558 EXPECT_FALSE(device::BluetoothAdapterFactory::HasSharedInstanceForTesting()); 558 EXPECT_FALSE(device::BluetoothAdapterFactory::HasSharedInstanceForTesting());
559 559
560 // Create the fake D-Bus objects. 560 // Create the fake D-Bus objects.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 ASSERT_TRUE(characteristic); 615 ASSERT_TRUE(characteristic);
616 EXPECT_EQ( 616 EXPECT_EQ(
617 BluetoothUUID(FakeBluetoothGattCharacteristicClient:: 617 BluetoothUUID(FakeBluetoothGattCharacteristicClient::
618 kHeartRateMeasurementUUID), 618 kHeartRateMeasurementUUID),
619 characteristic->GetUUID()); 619 characteristic->GetUUID());
620 EXPECT_FALSE(characteristic->IsLocal()); 620 EXPECT_FALSE(characteristic->IsLocal());
621 EXPECT_EQ(1U, characteristic->GetDescriptors().size()); 621 EXPECT_EQ(1U, characteristic->GetDescriptors().size());
622 622
623 BluetoothGattDescriptor* descriptor = characteristic->GetDescriptors()[0]; 623 BluetoothGattDescriptor* descriptor = characteristic->GetDescriptors()[0];
624 ASSERT_TRUE(descriptor); 624 ASSERT_TRUE(descriptor);
625 EXPECT_EQ(BluetoothGattDescriptor::kClientCharacteristicConfigurationUuid, 625 EXPECT_EQ(BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid(),
626 descriptor->GetUUID()); 626 descriptor->GetUUID());
627 EXPECT_FALSE(descriptor->IsLocal()); 627 EXPECT_FALSE(descriptor->IsLocal());
628 } 628 }
629 629
630 TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { 630 TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) {
631 fake_bluetooth_device_client_->CreateDevice( 631 fake_bluetooth_device_client_->CreateDevice(
632 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), 632 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
633 dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); 633 dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath));
634 BluetoothDevice* device = adapter_->GetDevice( 634 BluetoothDevice* device = adapter_->GetDevice(
635 FakeBluetoothDeviceClient::kLowEnergyAddress); 635 FakeBluetoothDeviceClient::kLowEnergyAddress);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 806
807 // Only the Heart Rate Measurement characteristic has a descriptor. 807 // Only the Heart Rate Measurement characteristic has a descriptor.
808 BluetoothGattCharacteristic* characteristic = service->GetCharacteristic( 808 BluetoothGattCharacteristic* characteristic = service->GetCharacteristic(
809 fake_bluetooth_gatt_characteristic_client_-> 809 fake_bluetooth_gatt_characteristic_client_->
810 GetHeartRateMeasurementPath().value()); 810 GetHeartRateMeasurementPath().value());
811 ASSERT_TRUE(characteristic); 811 ASSERT_TRUE(characteristic);
812 EXPECT_EQ(1U, characteristic->GetDescriptors().size()); 812 EXPECT_EQ(1U, characteristic->GetDescriptors().size());
813 813
814 BluetoothGattDescriptor* descriptor = characteristic->GetDescriptors()[0]; 814 BluetoothGattDescriptor* descriptor = characteristic->GetDescriptors()[0];
815 EXPECT_FALSE(descriptor->IsLocal()); 815 EXPECT_FALSE(descriptor->IsLocal());
816 EXPECT_EQ(BluetoothGattDescriptor::kClientCharacteristicConfigurationUuid, 816 EXPECT_EQ(BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid(),
817 descriptor->GetUUID()); 817 descriptor->GetUUID());
818 818
819 std::vector<uint8> desc_value; 819 std::vector<uint8> desc_value;
820 desc_value.push_back(0); 820 desc_value.push_back(0);
821 desc_value.push_back(0); 821 desc_value.push_back(0);
822 EXPECT_TRUE(ValuesEqual(desc_value, descriptor->GetValue())); 822 EXPECT_TRUE(ValuesEqual(desc_value, descriptor->GetValue()));
823 823
824 EXPECT_EQ(0, success_callback_count_); 824 EXPECT_EQ(0, success_callback_count_);
825 EXPECT_EQ(0, error_callback_count_); 825 EXPECT_EQ(0, error_callback_count_);
826 EXPECT_TRUE(last_read_value_.empty()); 826 EXPECT_TRUE(last_read_value_.empty());
(...skipping 27 matching lines...) Expand all
854 base::Unretained(this)), 854 base::Unretained(this)),
855 base::Bind(&BluetoothGattChromeOSTest::ErrorCallback, 855 base::Bind(&BluetoothGattChromeOSTest::ErrorCallback,
856 base::Unretained(this))); 856 base::Unretained(this)));
857 EXPECT_EQ(3, success_callback_count_); 857 EXPECT_EQ(3, success_callback_count_);
858 EXPECT_EQ(0, error_callback_count_); 858 EXPECT_EQ(0, error_callback_count_);
859 EXPECT_TRUE(ValuesEqual(last_read_value_, descriptor->GetValue())); 859 EXPECT_TRUE(ValuesEqual(last_read_value_, descriptor->GetValue()));
860 EXPECT_TRUE(ValuesEqual(desc_value, descriptor->GetValue())); 860 EXPECT_TRUE(ValuesEqual(desc_value, descriptor->GetValue()));
861 } 861 }
862 862
863 } // namespace chromeos 863 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_gatt_descriptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698