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

Side by Side Diff: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc

Issue 402303002: bluetoothLowEnergy: Send onServiceAdded after all characteristics are discovered (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.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/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ y_api.h" 6 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ y_api.h"
7 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ y_event_router.h" 7 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ y_event_router.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/extensions/extension_function_test_utils.h" 9 #include "chrome/browser/extensions/extension_function_test_utils.h"
10 #include "chrome/browser/extensions/extension_test_message_listener.h" 10 #include "chrome/browser/extensions/extension_test_message_listener.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 catcher.RestrictToProfile(browser()->profile()); 323 catcher.RestrictToProfile(browser()->profile());
324 324
325 // Load the extension and let it set up. 325 // Load the extension and let it set up.
326 ExtensionTestMessageListener listener("ready", true); 326 ExtensionTestMessageListener listener("ready", true);
327 ASSERT_TRUE(LoadExtension( 327 ASSERT_TRUE(LoadExtension(
328 test_data_dir_.AppendASCII("bluetooth_low_energy/service_events"))); 328 test_data_dir_.AppendASCII("bluetooth_low_energy/service_events")));
329 329
330 // Cause events to be sent to the extension. 330 // Cause events to be sent to the extension.
331 event_router()->DeviceAdded(mock_adapter_, device0_.get()); 331 event_router()->DeviceAdded(mock_adapter_, device0_.get());
332 332
333 // These will create the identifier mappings.
333 event_router()->GattServiceAdded(device0_.get(), service0_.get()); 334 event_router()->GattServiceAdded(device0_.get(), service0_.get());
334 event_router()->GattServiceAdded(device0_.get(), service1_.get()); 335 event_router()->GattServiceAdded(device0_.get(), service1_.get());
336
337 // These will send the onServiceAdded event to apps.
338 event_router()->GattDiscoveryCompleteForService(service0_.get());
339 event_router()->GattDiscoveryCompleteForService(service1_.get());
340
341 // This will send the onServiceChanged event to apps.
335 event_router()->GattServiceChanged(service1_.get()); 342 event_router()->GattServiceChanged(service1_.get());
343
344 // This will send the onServiceRemoved event to apps.
336 event_router()->GattServiceRemoved(device0_.get(), service0_.get()); 345 event_router()->GattServiceRemoved(device0_.get(), service0_.get());
337 346
338 EXPECT_TRUE(listener.WaitUntilSatisfied()); 347 EXPECT_TRUE(listener.WaitUntilSatisfied());
339 listener.Reply("go"); 348 listener.Reply("go");
340 349
341 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 350 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
342 event_router()->GattServiceRemoved(device0_.get(), service1_.get()); 351 event_router()->GattServiceRemoved(device0_.get(), service1_.get());
343 event_router()->DeviceRemoved(mock_adapter_, device0_.get()); 352 event_router()->DeviceRemoved(mock_adapter_, device0_.get());
344 } 353 }
345 354
346 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedService) { 355 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedService) {
347 ResultCatcher catcher; 356 ResultCatcher catcher;
348 catcher.RestrictToProfile(browser()->profile()); 357 catcher.RestrictToProfile(browser()->profile());
349 358
350 // Load the extension and let it set up. 359 // Load the extension and let it set up.
351 ASSERT_TRUE(LoadExtension( 360 ASSERT_TRUE(LoadExtension(
352 test_data_dir_.AppendASCII("bluetooth_low_energy/get_removed_service"))); 361 test_data_dir_.AppendASCII("bluetooth_low_energy/get_removed_service")));
353 362
354 // 1. getService success. 363 // 1. getService success.
355 EXPECT_CALL(*mock_adapter_, GetDevice(_)) 364 EXPECT_CALL(*mock_adapter_, GetDevice(_))
356 .Times(1) 365 .Times(1)
357 .WillOnce(Return(device0_.get())); 366 .WillOnce(Return(device0_.get()));
358 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)) 367 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0))
359 .Times(1) 368 .Times(1)
360 .WillOnce(Return(service0_.get())); 369 .WillOnce(Return(service0_.get()));
361 370
362 event_router()->DeviceAdded(mock_adapter_, device0_.get()); 371 event_router()->DeviceAdded(mock_adapter_, device0_.get());
363 event_router()->GattServiceAdded(device0_.get(), service0_.get()); 372 event_router()->GattServiceAdded(device0_.get(), service0_.get());
373 event_router()->GattDiscoveryCompleteForService(service0_.get());
364 374
365 ExtensionTestMessageListener get_service_success_listener("getServiceSuccess", 375 ExtensionTestMessageListener get_service_success_listener("getServiceSuccess",
366 true); 376 true);
367 EXPECT_TRUE(get_service_success_listener.WaitUntilSatisfied()); 377 EXPECT_TRUE(get_service_success_listener.WaitUntilSatisfied());
368 testing::Mock::VerifyAndClearExpectations(mock_adapter_); 378 testing::Mock::VerifyAndClearExpectations(mock_adapter_);
369 testing::Mock::VerifyAndClearExpectations(device0_.get()); 379 testing::Mock::VerifyAndClearExpectations(device0_.get());
370 380
371 // 2. getService fail. 381 // 2. getService fail.
372 EXPECT_CALL(*mock_adapter_, GetDevice(_)).Times(0); 382 EXPECT_CALL(*mock_adapter_, GetDevice(_)).Times(0);
373 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)).Times(0); 383 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)).Times(0);
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 1273 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
1264 event_router()->GattCharacteristicRemoved(service1_.get(), chrc2_.get()); 1274 event_router()->GattCharacteristicRemoved(service1_.get(), chrc2_.get());
1265 event_router()->GattCharacteristicRemoved(service0_.get(), chrc1_.get()); 1275 event_router()->GattCharacteristicRemoved(service0_.get(), chrc1_.get());
1266 event_router()->GattCharacteristicRemoved(service0_.get(), chrc0_.get()); 1276 event_router()->GattCharacteristicRemoved(service0_.get(), chrc0_.get());
1267 event_router()->GattServiceRemoved(device0_.get(), service1_.get()); 1277 event_router()->GattServiceRemoved(device0_.get(), service1_.get());
1268 event_router()->GattServiceRemoved(device0_.get(), service0_.get()); 1278 event_router()->GattServiceRemoved(device0_.get(), service0_.get());
1269 event_router()->DeviceRemoved(mock_adapter_, device0_.get()); 1279 event_router()->DeviceRemoved(mock_adapter_, device0_.get());
1270 } 1280 }
1271 1281
1272 } // namespace 1282 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698