OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chromeos/chromeos_switches.h" | 8 #include "chromeos/chromeos_switches.h" |
9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
10 #include "chromeos/dbus/fake_bluetooth_device_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 // Install an observer; expect the DeviceChanged method to be called when | 780 // Install an observer; expect the DeviceChanged method to be called when |
781 // we change the class of the device. | 781 // we change the class of the device. |
782 TestObserver observer(adapter_); | 782 TestObserver observer(adapter_); |
783 adapter_->AddObserver(&observer); | 783 adapter_->AddObserver(&observer); |
784 | 784 |
785 FakeBluetoothDeviceClient::Properties* properties = | 785 FakeBluetoothDeviceClient::Properties* properties = |
786 fake_bluetooth_device_client_->GetProperties( | 786 fake_bluetooth_device_client_->GetProperties( |
787 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); | 787 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); |
788 | 788 |
789 properties->bluetooth_class.ReplaceValue(0x002580); | 789 properties->bluetooth_class.ReplaceValue(0x002580); |
790 properties->NotifyPropertyChanged(properties->bluetooth_class.name()); | |
791 | 790 |
792 EXPECT_EQ(1, observer.device_changed_count_); | 791 EXPECT_EQ(1, observer.device_changed_count_); |
793 EXPECT_EQ(devices[0], observer.last_device_); | 792 EXPECT_EQ(devices[0], observer.last_device_); |
794 | 793 |
795 EXPECT_EQ(BluetoothDevice::DEVICE_MOUSE, devices[0]->GetDeviceType()); | 794 EXPECT_EQ(BluetoothDevice::DEVICE_MOUSE, devices[0]->GetDeviceType()); |
796 } | 795 } |
797 | 796 |
798 TEST_F(BluetoothExperimentalChromeOSTest, DeviceNameChanged) { | 797 TEST_F(BluetoothExperimentalChromeOSTest, DeviceNameChanged) { |
799 // Simulate a change of name of a device. | 798 // Simulate a change of name of a device. |
800 GetAdapter(); | 799 GetAdapter(); |
801 | 800 |
802 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); | 801 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); |
803 ASSERT_EQ(1U, devices.size()); | 802 ASSERT_EQ(1U, devices.size()); |
804 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, | 803 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, |
805 devices[0]->GetAddress()); | 804 devices[0]->GetAddress()); |
806 ASSERT_EQ(UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName), | 805 ASSERT_EQ(UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName), |
807 devices[0]->GetName()); | 806 devices[0]->GetName()); |
808 | 807 |
809 // Install an observer; expect the DeviceChanged method to be called when | 808 // Install an observer; expect the DeviceChanged method to be called when |
810 // we change the alias of the device. | 809 // we change the alias of the device. |
811 TestObserver observer(adapter_); | 810 TestObserver observer(adapter_); |
812 adapter_->AddObserver(&observer); | 811 adapter_->AddObserver(&observer); |
813 | 812 |
814 FakeBluetoothDeviceClient::Properties* properties = | 813 FakeBluetoothDeviceClient::Properties* properties = |
815 fake_bluetooth_device_client_->GetProperties( | 814 fake_bluetooth_device_client_->GetProperties( |
816 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); | 815 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); |
817 | 816 |
818 static const std::string new_name("New Device Name"); | 817 static const std::string new_name("New Device Name"); |
819 properties->alias.ReplaceValue(new_name); | 818 properties->alias.ReplaceValue(new_name); |
820 properties->NotifyPropertyChanged(properties->alias.name()); | |
821 | 819 |
822 EXPECT_EQ(1, observer.device_changed_count_); | 820 EXPECT_EQ(1, observer.device_changed_count_); |
823 EXPECT_EQ(devices[0], observer.last_device_); | 821 EXPECT_EQ(devices[0], observer.last_device_); |
824 | 822 |
825 EXPECT_EQ(UTF8ToUTF16(new_name), devices[0]->GetName()); | 823 EXPECT_EQ(UTF8ToUTF16(new_name), devices[0]->GetName()); |
826 } | 824 } |
827 | 825 |
828 TEST_F(BluetoothExperimentalChromeOSTest, DeviceUuidsChanged) { | 826 TEST_F(BluetoothExperimentalChromeOSTest, DeviceUuidsChanged) { |
829 // Simulate a change of advertised services of a device. | 827 // Simulate a change of advertised services of a device. |
830 GetAdapter(); | 828 GetAdapter(); |
(...skipping 15 matching lines...) Expand all Loading... |
846 | 844 |
847 FakeBluetoothDeviceClient::Properties* properties = | 845 FakeBluetoothDeviceClient::Properties* properties = |
848 fake_bluetooth_device_client_->GetProperties( | 846 fake_bluetooth_device_client_->GetProperties( |
849 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); | 847 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); |
850 | 848 |
851 uuids.push_back("0000110c-0000-1000-8000-00805f9b34fb"); | 849 uuids.push_back("0000110c-0000-1000-8000-00805f9b34fb"); |
852 uuids.push_back("0000110e-0000-1000-8000-00805f9b34fb"); | 850 uuids.push_back("0000110e-0000-1000-8000-00805f9b34fb"); |
853 uuids.push_back("0000110a-0000-1000-8000-00805f9b34fb"); | 851 uuids.push_back("0000110a-0000-1000-8000-00805f9b34fb"); |
854 | 852 |
855 properties->uuids.ReplaceValue(uuids); | 853 properties->uuids.ReplaceValue(uuids); |
856 properties->NotifyPropertyChanged(properties->uuids.name()); | |
857 | 854 |
858 EXPECT_EQ(1, observer.device_changed_count_); | 855 EXPECT_EQ(1, observer.device_changed_count_); |
859 EXPECT_EQ(devices[0], observer.last_device_); | 856 EXPECT_EQ(devices[0], observer.last_device_); |
860 | 857 |
861 // Fetching the value should give the new one. | 858 // Fetching the value should give the new one. |
862 uuids = devices[0]->GetServices(); | 859 uuids = devices[0]->GetServices(); |
863 ASSERT_EQ(5U, uuids.size()); | 860 ASSERT_EQ(5U, uuids.size()); |
864 EXPECT_EQ(uuids[0], "00001800-0000-1000-8000-00805f9b34fb"); | 861 EXPECT_EQ(uuids[0], "00001800-0000-1000-8000-00805f9b34fb"); |
865 EXPECT_EQ(uuids[1], "00001801-0000-1000-8000-00805f9b34fb"); | 862 EXPECT_EQ(uuids[1], "00001801-0000-1000-8000-00805f9b34fb"); |
866 EXPECT_EQ(uuids[2], "0000110c-0000-1000-8000-00805f9b34fb"); | 863 EXPECT_EQ(uuids[2], "0000110c-0000-1000-8000-00805f9b34fb"); |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1966 EXPECT_FALSE(device->IsConnected()); | 1963 EXPECT_FALSE(device->IsConnected()); |
1967 EXPECT_FALSE(device->IsConnecting()); | 1964 EXPECT_FALSE(device->IsConnecting()); |
1968 EXPECT_FALSE(device->IsPaired()); | 1965 EXPECT_FALSE(device->IsPaired()); |
1969 | 1966 |
1970 // Pairing dialog should be dismissed | 1967 // Pairing dialog should be dismissed |
1971 EXPECT_EQ(1, pairing_delegate.call_count_); | 1968 EXPECT_EQ(1, pairing_delegate.call_count_); |
1972 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1969 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
1973 } | 1970 } |
1974 | 1971 |
1975 } // namespace chromeos | 1972 } // namespace chromeos |
OLD | NEW |