| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "chromeos/dbus/dbus_thread_manager.h" | 8 #include "chromeos/dbus/dbus_thread_manager.h" |
| 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
| 10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 class BluetoothSocketChromeOSTest : public testing::Test { | 43 class BluetoothSocketChromeOSTest : public testing::Test { |
| 44 public: | 44 public: |
| 45 BluetoothSocketChromeOSTest() | 45 BluetoothSocketChromeOSTest() |
| 46 : success_callback_count_(0), | 46 : success_callback_count_(0), |
| 47 error_callback_count_(0), | 47 error_callback_count_(0), |
| 48 last_bytes_sent_(0), | 48 last_bytes_sent_(0), |
| 49 last_bytes_received_(0), | 49 last_bytes_received_(0), |
| 50 last_reason_(BluetoothSocket::kSystemError) {} | 50 last_reason_(BluetoothSocket::kSystemError) {} |
| 51 | 51 |
| 52 virtual void SetUp() OVERRIDE { | 52 virtual void SetUp() override { |
| 53 scoped_ptr<DBusThreadManagerSetter> dbus_setter = | 53 scoped_ptr<DBusThreadManagerSetter> dbus_setter = |
| 54 DBusThreadManager::GetSetterForTesting(); | 54 DBusThreadManager::GetSetterForTesting(); |
| 55 | 55 |
| 56 dbus_setter->SetBluetoothAdapterClient( | 56 dbus_setter->SetBluetoothAdapterClient( |
| 57 scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); | 57 scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); |
| 58 dbus_setter->SetBluetoothAgentManagerClient( | 58 dbus_setter->SetBluetoothAgentManagerClient( |
| 59 scoped_ptr<BluetoothAgentManagerClient>( | 59 scoped_ptr<BluetoothAgentManagerClient>( |
| 60 new FakeBluetoothAgentManagerClient)); | 60 new FakeBluetoothAgentManagerClient)); |
| 61 dbus_setter->SetBluetoothDeviceClient( | 61 dbus_setter->SetBluetoothDeviceClient( |
| 62 scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); | 62 scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 80 ASSERT_TRUE(adapter_->IsPresent()); | 80 ASSERT_TRUE(adapter_->IsPresent()); |
| 81 | 81 |
| 82 // Turn on the adapter. | 82 // Turn on the adapter. |
| 83 adapter_->SetPowered( | 83 adapter_->SetPowered( |
| 84 true, | 84 true, |
| 85 base::Bind(&base::DoNothing), | 85 base::Bind(&base::DoNothing), |
| 86 base::Bind(&base::DoNothing)); | 86 base::Bind(&base::DoNothing)); |
| 87 ASSERT_TRUE(adapter_->IsPowered()); | 87 ASSERT_TRUE(adapter_->IsPowered()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 virtual void TearDown() OVERRIDE { | 90 virtual void TearDown() override { |
| 91 adapter_ = NULL; | 91 adapter_ = NULL; |
| 92 BluetoothSocketThread::CleanupForTesting(); | 92 BluetoothSocketThread::CleanupForTesting(); |
| 93 DBusThreadManager::Shutdown(); | 93 DBusThreadManager::Shutdown(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void AdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { | 96 void AdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { |
| 97 adapter_ = adapter; | 97 adapter_ = adapter; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void SuccessCallback() { | 100 void SuccessCallback() { |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 | 503 |
| 504 // Cleanup the socket. | 504 // Cleanup the socket. |
| 505 socket->Disconnect( | 505 socket->Disconnect( |
| 506 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, | 506 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, |
| 507 base::Unretained(this))); | 507 base::Unretained(this))); |
| 508 | 508 |
| 509 EXPECT_EQ(1U, success_callback_count_); | 509 EXPECT_EQ(1U, success_callback_count_); |
| 510 } | 510 } |
| 511 | 511 |
| 512 } // namespace chromeos | 512 } // namespace chromeos |
| OLD | NEW |