OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "chromeos/dbus/fake_bluetooth_device_client.h" | 6 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
7 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" | 7 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" |
8 #include "chromeos/dbus/fake_bluetooth_profile_service_provider.h" | 8 #include "chromeos/dbus/fake_bluetooth_profile_service_provider.h" |
9 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 9 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
10 #include "device/bluetooth/bluetooth_adapter.h" | 10 #include "device/bluetooth/bluetooth_adapter.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 BluetoothProfileChromeOSTest() | 31 BluetoothProfileChromeOSTest() |
32 : message_loop_(base::MessageLoop::TYPE_IO), | 32 : message_loop_(base::MessageLoop::TYPE_IO), |
33 callback_count_(0), | 33 callback_count_(0), |
34 error_callback_count_(0), | 34 error_callback_count_(0), |
35 profile_callback_count_(0), | 35 profile_callback_count_(0), |
36 connection_callback_count_(0), | 36 connection_callback_count_(0), |
37 last_profile_(NULL), | 37 last_profile_(NULL), |
38 last_device_(NULL) {} | 38 last_device_(NULL) {} |
39 | 39 |
40 virtual void SetUp() { | 40 virtual void SetUp() { |
41 fake_dbus_thread_manager_ = new FakeDBusThreadManager(); | 41 FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; |
42 DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager_); | |
43 | |
44 fake_bluetooth_profile_manager_client_ = | 42 fake_bluetooth_profile_manager_client_ = |
45 fake_dbus_thread_manager_->fake_bluetooth_profile_manager_client(); | 43 new FakeBluetoothProfileManagerClient; |
| 44 fake_dbus_thread_manager->SetBluetoothProfileManagerClient( |
| 45 scoped_ptr<BluetoothProfileManagerClient>( |
| 46 fake_bluetooth_profile_manager_client_)); |
| 47 DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager); |
46 | 48 |
47 device::BluetoothAdapterFactory::GetAdapter( | 49 device::BluetoothAdapterFactory::GetAdapter( |
48 base::Bind(&BluetoothProfileChromeOSTest::AdapterCallback, | 50 base::Bind(&BluetoothProfileChromeOSTest::AdapterCallback, |
49 base::Unretained(this))); | 51 base::Unretained(this))); |
50 ASSERT_TRUE(adapter_.get() != NULL); | 52 ASSERT_TRUE(adapter_.get() != NULL); |
51 ASSERT_TRUE(adapter_->IsInitialized()); | 53 ASSERT_TRUE(adapter_->IsInitialized()); |
52 ASSERT_TRUE(adapter_->IsPresent()); | 54 ASSERT_TRUE(adapter_->IsPresent()); |
53 | 55 |
54 adapter_->SetPowered( | 56 adapter_->SetPowered( |
55 true, | 57 true, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 last_device_ = device; | 90 last_device_ = device; |
89 last_socket_ = socket; | 91 last_socket_ = socket; |
90 | 92 |
91 message_loop_.Quit(); | 93 message_loop_.Quit(); |
92 } | 94 } |
93 | 95 |
94 protected: | 96 protected: |
95 base::MessageLoop message_loop_; | 97 base::MessageLoop message_loop_; |
96 | 98 |
97 FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client_; | 99 FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client_; |
98 FakeDBusThreadManager* fake_dbus_thread_manager_; | |
99 scoped_refptr<BluetoothAdapter> adapter_; | 100 scoped_refptr<BluetoothAdapter> adapter_; |
100 | 101 |
101 unsigned int callback_count_; | 102 unsigned int callback_count_; |
102 unsigned int error_callback_count_; | 103 unsigned int error_callback_count_; |
103 unsigned int profile_callback_count_; | 104 unsigned int profile_callback_count_; |
104 unsigned int connection_callback_count_; | 105 unsigned int connection_callback_count_; |
105 BluetoothProfile* last_profile_; | 106 BluetoothProfile* last_profile_; |
106 const BluetoothDevice* last_device_; | 107 const BluetoothDevice* last_device_; |
107 scoped_refptr<BluetoothSocket> last_socket_; | 108 scoped_refptr<BluetoothSocket> last_socket_; |
108 }; | 109 }; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 // Unregister the profile, make sure it's no longer registered. | 352 // Unregister the profile, make sure it's no longer registered. |
352 last_profile_->Unregister(); | 353 last_profile_->Unregister(); |
353 | 354 |
354 profile_service_provider = | 355 profile_service_provider = |
355 fake_bluetooth_profile_manager_client_->GetProfileServiceProvider( | 356 fake_bluetooth_profile_manager_client_->GetProfileServiceProvider( |
356 FakeBluetoothProfileManagerClient::kRfcommUuid); | 357 FakeBluetoothProfileManagerClient::kRfcommUuid); |
357 EXPECT_TRUE(profile_service_provider == NULL); | 358 EXPECT_TRUE(profile_service_provider == NULL); |
358 } | 359 } |
359 | 360 |
360 } // namespace chromeos | 361 } // namespace chromeos |
OLD | NEW |