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

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

Issue 287673002: chrome.bluetoothLowEnergy: Implement the onDescriptorValueChanged event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased 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 | chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc » ('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 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 EXPECT_TRUE(listener.WaitUntilSatisfied()); 820 EXPECT_TRUE(listener.WaitUntilSatisfied());
821 821
822 listener.Reply("go"); 822 listener.Reply("go");
823 823
824 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 824 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
825 event_router()->GattCharacteristicRemoved(service0_.get(), chrc0_.get()); 825 event_router()->GattCharacteristicRemoved(service0_.get(), chrc0_.get());
826 event_router()->GattServiceRemoved(device_.get(), service0_.get()); 826 event_router()->GattServiceRemoved(device_.get(), service0_.get());
827 event_router()->DeviceRemoved(mock_adapter_, device_.get()); 827 event_router()->DeviceRemoved(mock_adapter_, device_.get());
828 } 828 }
829 829
830 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, DescriptorValueChanged) {
831 ResultCatcher catcher;
832 catcher.RestrictToProfile(browser()->profile());
833
834 event_router()->DeviceAdded(mock_adapter_, device_.get());
835 event_router()->GattServiceAdded(device_.get(), service0_.get());
836 event_router()->GattCharacteristicAdded(service0_.get(), chrc0_.get());
837 event_router()->GattDescriptorAdded(chrc0_.get(), desc0_.get());
838 event_router()->GattDescriptorAdded(chrc0_.get(), desc1_.get());
839
840 // Load the extension and let it set up.
841 ExtensionTestMessageListener listener("ready", true);
842 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
843 "bluetooth_low_energy/descriptor_value_changed")));
844
845 // Cause events to be sent to the extension.
846 std::vector<uint8> value;
847 event_router()->GattDescriptorValueChanged(chrc0_.get(), desc0_.get(), value);
848 event_router()->GattDescriptorValueChanged(chrc0_.get(), desc1_.get(), value);
849
850 EXPECT_TRUE(listener.WaitUntilSatisfied());
851 listener.Reply("go");
852
853 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
854 event_router()->GattDescriptorRemoved(chrc0_.get(), desc1_.get());
855 event_router()->GattDescriptorRemoved(chrc0_.get(), desc0_.get());
856 event_router()->GattCharacteristicRemoved(service0_.get(), chrc0_.get());
857 event_router()->GattServiceRemoved(device_.get(), service0_.get());
858 event_router()->DeviceRemoved(mock_adapter_, device_.get());
859 }
860
830 } // namespace 861 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698