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

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

Issue 2009753002: bluetooth: Make public BluetoothDevice::GetName method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split out name/alias Created 4 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
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_device.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_function_test_utils.h" 10 #include "chrome/browser/extensions/extension_function_test_utils.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ResultCatcher catcher; 148 ResultCatcher catcher;
149 catcher.RestrictToBrowserContext(browser()->profile()); 149 catcher.RestrictToBrowserContext(browser()->profile());
150 150
151 ASSERT_TRUE(LoadExtension( 151 ASSERT_TRUE(LoadExtension(
152 test_data_dir_.AppendASCII("bluetooth/device_events"))); 152 test_data_dir_.AppendASCII("bluetooth/device_events")));
153 153
154 ExtensionTestMessageListener events_received("ready", true); 154 ExtensionTestMessageListener events_received("ready", true);
155 event_router()->DeviceAdded(mock_adapter_, device1_.get()); 155 event_router()->DeviceAdded(mock_adapter_, device1_.get());
156 event_router()->DeviceAdded(mock_adapter_, device2_.get()); 156 event_router()->DeviceAdded(mock_adapter_, device2_.get());
157 157
158 EXPECT_CALL(*device2_, GetDeviceName()) 158 EXPECT_CALL(*device2_, GetName())
159 .WillRepeatedly(testing::Return("the real d2")); 159 .WillRepeatedly(
160 testing::Return(base::Optional<std::string>("the real d2")));
160 EXPECT_CALL(*device2_, GetNameForDisplay()) 161 EXPECT_CALL(*device2_, GetNameForDisplay())
161 .WillRepeatedly(testing::Return(base::UTF8ToUTF16("the real d2"))); 162 .WillRepeatedly(testing::Return(base::UTF8ToUTF16("the real d2")));
162 event_router()->DeviceChanged(mock_adapter_, device2_.get()); 163 event_router()->DeviceChanged(mock_adapter_, device2_.get());
163 164
164 event_router()->DeviceAdded(mock_adapter_, device3_.get()); 165 event_router()->DeviceAdded(mock_adapter_, device3_.get());
165 event_router()->DeviceRemoved(mock_adapter_, device1_.get()); 166 event_router()->DeviceRemoved(mock_adapter_, device1_.get());
166 EXPECT_TRUE(events_received.WaitUntilSatisfied()); 167 EXPECT_TRUE(events_received.WaitUntilSatisfied());
167 events_received.Reply("go"); 168 events_received.Reply("go");
168 169
169 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 170 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 406
406 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DeviceInfo) { 407 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DeviceInfo) {
407 ResultCatcher catcher; 408 ResultCatcher catcher;
408 catcher.RestrictToBrowserContext(browser()->profile()); 409 catcher.RestrictToBrowserContext(browser()->profile());
409 410
410 // Set up the first device object to reflect a real-world device. 411 // Set up the first device object to reflect a real-world device.
411 BluetoothAdapter::ConstDeviceList devices; 412 BluetoothAdapter::ConstDeviceList devices;
412 413
413 EXPECT_CALL(*device1_, GetAddress()) 414 EXPECT_CALL(*device1_, GetAddress())
414 .WillRepeatedly(testing::Return("A4:17:31:00:00:00")); 415 .WillRepeatedly(testing::Return("A4:17:31:00:00:00"));
415 EXPECT_CALL(*device1_, GetDeviceName()) 416 EXPECT_CALL(*device1_, GetName())
416 .WillRepeatedly(testing::Return("Chromebook Pixel")); 417 .WillRepeatedly(
418 testing::Return(base::Optional<std::string>("Chromebook Pixel")));
417 EXPECT_CALL(*device1_, GetNameForDisplay()) 419 EXPECT_CALL(*device1_, GetNameForDisplay())
418 .WillRepeatedly(testing::Return(base::UTF8ToUTF16("Chromebook Pixel"))); 420 .WillRepeatedly(testing::Return(base::UTF8ToUTF16("Chromebook Pixel")));
419 EXPECT_CALL(*device1_, GetBluetoothClass()) 421 EXPECT_CALL(*device1_, GetBluetoothClass())
420 .WillRepeatedly(testing::Return(0x080104)); 422 .WillRepeatedly(testing::Return(0x080104));
421 EXPECT_CALL(*device1_, GetDeviceType()) 423 EXPECT_CALL(*device1_, GetDeviceType())
422 .WillRepeatedly(testing::Return(BluetoothDevice::DEVICE_COMPUTER)); 424 .WillRepeatedly(testing::Return(BluetoothDevice::DEVICE_COMPUTER));
423 EXPECT_CALL(*device1_, GetVendorIDSource()) 425 EXPECT_CALL(*device1_, GetVendorIDSource())
424 .WillRepeatedly(testing::Return(BluetoothDevice::VENDOR_ID_BLUETOOTH)); 426 .WillRepeatedly(testing::Return(BluetoothDevice::VENDOR_ID_BLUETOOTH));
425 EXPECT_CALL(*device1_, GetVendorID()).WillRepeatedly(testing::Return(0x00E0)); 427 EXPECT_CALL(*device1_, GetVendorID()).WillRepeatedly(testing::Return(0x00E0));
426 EXPECT_CALL(*device1_, GetProductID()) 428 EXPECT_CALL(*device1_, GetProductID())
(...skipping 19 matching lines...) Expand all
446 // Load and wait for setup 448 // Load and wait for setup
447 ExtensionTestMessageListener listener("ready", true); 449 ExtensionTestMessageListener listener("ready", true);
448 ASSERT_TRUE( 450 ASSERT_TRUE(
449 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info"))); 451 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info")));
450 EXPECT_TRUE(listener.WaitUntilSatisfied()); 452 EXPECT_TRUE(listener.WaitUntilSatisfied());
451 453
452 listener.Reply("go"); 454 listener.Reply("go");
453 455
454 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 456 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
455 } 457 }
OLDNEW
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_device.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698