OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 BluetoothAPI::Get(test_profile_)->event_router()->AddProfile( | 150 BluetoothAPI::Get(test_profile_)->event_router()->AddProfile( |
151 kAudioProfileUuid, kTestExtensionId, &mock_audio_profile_); | 151 kAudioProfileUuid, kTestExtensionId, &mock_audio_profile_); |
152 | 152 |
153 BluetoothAPI::Get(test_profile_)->DispatchConnectionEvent( | 153 BluetoothAPI::Get(test_profile_)->DispatchConnectionEvent( |
154 kTestExtensionId, kAudioProfileUuid, &mock_device, mock_socket); | 154 kTestExtensionId, kAudioProfileUuid, &mock_device, mock_socket); |
155 // Connection events are dispatched using a couple of PostTask to the UI | 155 // Connection events are dispatched using a couple of PostTask to the UI |
156 // thread. Waiting until idle ensures the event is dispatched to the | 156 // thread. Waiting until idle ensures the event is dispatched to the |
157 // receiver(s). | 157 // receiver(s). |
158 base::RunLoop().RunUntilIdle(); | 158 base::RunLoop().RunUntilIdle(); |
159 | 159 |
160 FakeEventRouter* fake_event_router = static_cast<FakeEventRouter*>( | 160 FakeEventRouter* fake_event_router = |
161 ExtensionSystem::Get(test_profile_)->event_router()); | 161 static_cast<FakeEventRouter*>(EventRouter::Get(test_profile_)); |
162 | 162 |
163 ASSERT_TRUE(fake_event_router->event()); | 163 ASSERT_TRUE(fake_event_router->event()); |
164 EXPECT_STREQ(kTestExtensionId, fake_event_router->extension_id().c_str()); | 164 EXPECT_STREQ(kTestExtensionId, fake_event_router->extension_id().c_str()); |
165 EXPECT_STREQ(bluetooth::OnConnection::kEventName, | 165 EXPECT_STREQ(bluetooth::OnConnection::kEventName, |
166 fake_event_router->event()->event_name.c_str()); | 166 fake_event_router->event()->event_name.c_str()); |
167 | 167 |
168 base::ListValue* event_args = fake_event_router->event()->event_args.get(); | 168 base::ListValue* event_args = fake_event_router->event()->event_args.get(); |
169 base::DictionaryValue* socket_value = NULL; | 169 base::DictionaryValue* socket_value = NULL; |
170 ASSERT_TRUE(event_args->GetDictionary(0, &socket_value)); | 170 ASSERT_TRUE(event_args->GetDictionary(0, &socket_value)); |
171 int socket_id; | 171 int socket_id; |
(...skipping 18 matching lines...) Expand all Loading... |
190 new testing::NiceMock<device::MockBluetoothSocket>()); | 190 new testing::NiceMock<device::MockBluetoothSocket>()); |
191 | 191 |
192 // Connection event won't be dispatched for non-registered profiles. | 192 // Connection event won't be dispatched for non-registered profiles. |
193 BluetoothAPI::Get(test_profile_)->DispatchConnectionEvent( | 193 BluetoothAPI::Get(test_profile_)->DispatchConnectionEvent( |
194 kTestExtensionId, kAudioProfileUuid, &mock_device, mock_socket); | 194 kTestExtensionId, kAudioProfileUuid, &mock_device, mock_socket); |
195 // Connection events are dispatched using a couple of PostTask to the UI | 195 // Connection events are dispatched using a couple of PostTask to the UI |
196 // thread. Waiting until idle ensures the event is dispatched to the | 196 // thread. Waiting until idle ensures the event is dispatched to the |
197 // receiver(s). | 197 // receiver(s). |
198 base::RunLoop().RunUntilIdle(); | 198 base::RunLoop().RunUntilIdle(); |
199 | 199 |
200 FakeEventRouter* fake_event_router = static_cast<FakeEventRouter*>( | 200 FakeEventRouter* fake_event_router = |
201 ExtensionSystem::Get(test_profile_)->event_router()); | 201 static_cast<FakeEventRouter*>(EventRouter::Get(test_profile_)); |
202 EXPECT_TRUE(fake_event_router->event() == NULL); | 202 EXPECT_TRUE(fake_event_router->event() == NULL); |
203 | 203 |
204 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); | 204 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); |
205 } | 205 } |
206 | 206 |
207 } // namespace extensions | 207 } // namespace extensions |
OLD | NEW |