OLD | NEW |
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 SetUpMockAdapter(); | 190 SetUpMockAdapter(); |
191 | 191 |
192 // Create a mock session to be returned as a result. Get a handle to it as | 192 // Create a mock session to be returned as a result. Get a handle to it as |
193 // its ownership will be passed and |mock_session_| will be reset. | 193 // its ownership will be passed and |mock_session_| will be reset. |
194 mock_session_.reset(new testing::NiceMock<MockBluetoothDiscoverySession>()); | 194 mock_session_.reset(new testing::NiceMock<MockBluetoothDiscoverySession>()); |
195 MockBluetoothDiscoverySession* session = mock_session_.get(); | 195 MockBluetoothDiscoverySession* session = mock_session_.get(); |
196 EXPECT_CALL(*mock_adapter_, StartDiscoverySession(testing::_, testing::_)) | 196 EXPECT_CALL(*mock_adapter_, StartDiscoverySession(testing::_, testing::_)) |
197 .WillOnce( | 197 .WillOnce( |
198 testing::Invoke(this, &BluetoothApiTest::DiscoverySessionCallback)); | 198 testing::Invoke(this, &BluetoothApiTest::DiscoverySessionCallback)); |
199 start_function = setupFunction(new api::BluetoothStartDiscoveryFunction); | 199 start_function = setupFunction(new api::BluetoothStartDiscoveryFunction); |
200 (void) | 200 utils::RunFunction(start_function.get(), "[]", browser(), utils::NONE); |
201 utils::RunFunctionAndReturnError(start_function.get(), "[]", browser()); | |
202 | 201 |
203 // End the discovery session. The StopDiscovery function should succeed. | 202 // End the discovery session. The StopDiscovery function should succeed. |
204 testing::Mock::VerifyAndClearExpectations(mock_adapter_); | 203 testing::Mock::VerifyAndClearExpectations(mock_adapter_); |
205 EXPECT_CALL(*session, IsActive()).WillOnce(testing::Return(true)); | 204 EXPECT_CALL(*session, IsActive()).WillOnce(testing::Return(true)); |
206 EXPECT_CALL(*session, Stop(testing::_, testing::_)) | 205 EXPECT_CALL(*session, Stop(testing::_, testing::_)) |
207 .WillOnce(testing::Invoke(StopDiscoverySessionCallback)); | 206 .WillOnce(testing::Invoke(StopDiscoverySessionCallback)); |
208 | 207 |
209 // StopDiscovery success will remove the session object, unreferencing the | 208 // StopDiscovery success will remove the session object, unreferencing the |
210 // adapter. | 209 // adapter. |
211 scoped_refptr<api::BluetoothStopDiscoveryFunction> stop_function; | 210 scoped_refptr<api::BluetoothStopDiscoveryFunction> stop_function; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 // Load and wait for setup | 447 // Load and wait for setup |
449 ExtensionTestMessageListener listener("ready", true); | 448 ExtensionTestMessageListener listener("ready", true); |
450 ASSERT_TRUE( | 449 ASSERT_TRUE( |
451 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info"))); | 450 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info"))); |
452 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 451 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
453 | 452 |
454 listener.Reply("go"); | 453 listener.Reply("go"); |
455 | 454 |
456 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 455 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
457 } | 456 } |
OLD | NEW |