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

Side by Side Diff: chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc

Issue 224893002: device/bluetooth: Rename device::bluetooth_utils::UUID to device::BluetoothUUID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string.h> 5 #include <string.h>
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" 9 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h"
10 #include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h" 10 #include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h"
11 #include "chrome/browser/extensions/extension_apitest.h" 11 #include "chrome/browser/extensions/extension_apitest.h"
12 #include "chrome/browser/extensions/extension_function_test_utils.h" 12 #include "chrome/browser/extensions/extension_function_test_utils.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_test_message_listener.h" 14 #include "chrome/browser/extensions/extension_test_message_listener.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
17 #include "device/bluetooth/bluetooth_adapter.h" 17 #include "device/bluetooth/bluetooth_adapter.h"
18 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" 18 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h"
19 #include "device/bluetooth/bluetooth_uuid.h"
19 #include "device/bluetooth/test/mock_bluetooth_adapter.h" 20 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
20 #include "device/bluetooth/test/mock_bluetooth_device.h" 21 #include "device/bluetooth/test/mock_bluetooth_device.h"
21 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" 22 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h"
22 #include "device/bluetooth/test/mock_bluetooth_profile.h" 23 #include "device/bluetooth/test/mock_bluetooth_profile.h"
23 #include "device/bluetooth/test/mock_bluetooth_socket.h" 24 #include "device/bluetooth/test/mock_bluetooth_socket.h"
24 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
25 26
26 using device::BluetoothAdapter; 27 using device::BluetoothAdapter;
27 using device::BluetoothDevice; 28 using device::BluetoothDevice;
28 using device::BluetoothDiscoverySession; 29 using device::BluetoothDiscoverySession;
29 using device::BluetoothOutOfBandPairingData; 30 using device::BluetoothOutOfBandPairingData;
30 using device::BluetoothProfile; 31 using device::BluetoothProfile;
32 using device::BluetoothUUID;
31 using device::MockBluetoothAdapter; 33 using device::MockBluetoothAdapter;
32 using device::MockBluetoothDevice; 34 using device::MockBluetoothDevice;
33 using device::MockBluetoothDiscoverySession; 35 using device::MockBluetoothDiscoverySession;
34 using device::MockBluetoothProfile; 36 using device::MockBluetoothProfile;
35 using extensions::Extension; 37 using extensions::Extension;
36 38
37 namespace utils = extension_function_test_utils; 39 namespace utils = extension_function_test_utils;
38 namespace api = extensions::api; 40 namespace api = extensions::api;
39 41
40 namespace { 42 namespace {
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 // Load and wait for setup 555 // Load and wait for setup
554 ExtensionTestMessageListener listener("ready", true); 556 ExtensionTestMessageListener listener("ready", true);
555 scoped_refptr<const Extension> extension( 557 scoped_refptr<const Extension> extension(
556 LoadExtension(test_data_dir_.AppendASCII("bluetooth/on_connection"))); 558 LoadExtension(test_data_dir_.AppendASCII("bluetooth/on_connection")));
557 ASSERT_TRUE(extension.get()); 559 ASSERT_TRUE(extension.get());
558 EXPECT_TRUE(listener.WaitUntilSatisfied()); 560 EXPECT_TRUE(listener.WaitUntilSatisfied());
559 561
560 scoped_refptr<device::MockBluetoothSocket> socket = 562 scoped_refptr<device::MockBluetoothSocket> socket =
561 new device::MockBluetoothSocket(); 563 new device::MockBluetoothSocket();
562 564
563 event_router()->AddProfile("1234", extension->id(), profile1_.get()); 565 event_router()->AddProfile(
566 BluetoothUUID("1234"),
567 extension->id(), profile1_.get());
564 event_router()->DispatchConnectionEvent( 568 event_router()->DispatchConnectionEvent(
565 extension->id(), "1234", device1_.get(), socket); 569 extension->id(), BluetoothUUID("1234"), device1_.get(), socket);
566 570
567 listener.Reply("go"); 571 listener.Reply("go");
568 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 572 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
569 event_router()->RemoveProfile("1234"); 573 event_router()->RemoveProfile(BluetoothUUID("1234"));
570 } 574 }
571 575
572 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevices) { 576 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevices) {
573 ResultCatcher catcher; 577 ResultCatcher catcher;
574 catcher.RestrictToProfile(browser()->profile()); 578 catcher.RestrictToProfile(browser()->profile());
575 579
576 BluetoothAdapter::ConstDeviceList devices; 580 BluetoothAdapter::ConstDeviceList devices;
577 devices.push_back(device1_.get()); 581 devices.push_back(device1_.get());
578 devices.push_back(device2_.get()); 582 devices.push_back(device2_.get());
579 583
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 EXPECT_CALL(*device1_.get(), GetVendorIDSource()) 637 EXPECT_CALL(*device1_.get(), GetVendorIDSource())
634 .WillRepeatedly(testing::Return(BluetoothDevice::VENDOR_ID_BLUETOOTH)); 638 .WillRepeatedly(testing::Return(BluetoothDevice::VENDOR_ID_BLUETOOTH));
635 EXPECT_CALL(*device1_.get(), GetVendorID()) 639 EXPECT_CALL(*device1_.get(), GetVendorID())
636 .WillRepeatedly(testing::Return(0x00E0)); 640 .WillRepeatedly(testing::Return(0x00E0));
637 EXPECT_CALL(*device1_.get(), GetProductID()) 641 EXPECT_CALL(*device1_.get(), GetProductID())
638 .WillRepeatedly(testing::Return(0x240A)); 642 .WillRepeatedly(testing::Return(0x240A));
639 EXPECT_CALL(*device1_.get(), GetDeviceID()) 643 EXPECT_CALL(*device1_.get(), GetDeviceID())
640 .WillRepeatedly(testing::Return(0x0400)); 644 .WillRepeatedly(testing::Return(0x0400));
641 645
642 BluetoothDevice::UUIDList uuids; 646 BluetoothDevice::UUIDList uuids;
643 uuids.push_back("00001105-0000-1000-8000-00805f9b34fb"); 647 uuids.push_back(BluetoothUUID("1105"));
644 uuids.push_back("00001106-0000-1000-8000-00805f9b34fb"); 648 uuids.push_back(BluetoothUUID("1106"));
645 649
646 EXPECT_CALL(*device1_.get(), GetUUIDs()) 650 EXPECT_CALL(*device1_.get(), GetUUIDs())
647 .WillOnce(testing::Return(uuids)); 651 .WillOnce(testing::Return(uuids));
648 652
649 devices.push_back(device1_.get()); 653 devices.push_back(device1_.get());
650 654
651 // Leave the second largely empty so we can check a device without 655 // Leave the second largely empty so we can check a device without
652 // available information. 656 // available information.
653 devices.push_back(device2_.get()); 657 devices.push_back(device2_.get());
654 658
655 EXPECT_CALL(*mock_adapter_, GetDevices()) 659 EXPECT_CALL(*mock_adapter_, GetDevices())
656 .Times(1) 660 .Times(1)
657 .WillRepeatedly(testing::Return(devices)); 661 .WillRepeatedly(testing::Return(devices));
658 662
659 // Load and wait for setup 663 // Load and wait for setup
660 ExtensionTestMessageListener listener("ready", true); 664 ExtensionTestMessageListener listener("ready", true);
661 ASSERT_TRUE( 665 ASSERT_TRUE(
662 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info"))); 666 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info")));
663 EXPECT_TRUE(listener.WaitUntilSatisfied()); 667 EXPECT_TRUE(listener.WaitUntilSatisfied());
664 668
665 listener.Reply("go"); 669 listener.Reply("go");
666 670
667 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 671 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
668 } 672 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698