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

Side by Side Diff: device/bluetooth/bluetooth_chromeos_unittest.cc

Issue 49773003: ChromeOS: Remove MockDBusThreadManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed tests. Created 7 years, 1 month 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" 7 #include "chromeos/dbus/fake_bluetooth_adapter_client.h"
8 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h"
8 #include "chromeos/dbus/fake_bluetooth_device_client.h" 9 #include "chromeos/dbus/fake_bluetooth_device_client.h"
10 #include "chromeos/dbus/fake_bluetooth_input_client.h"
9 #include "chromeos/dbus/fake_dbus_thread_manager.h" 11 #include "chromeos/dbus/fake_dbus_thread_manager.h"
10 #include "dbus/object_path.h" 12 #include "dbus/object_path.h"
11 #include "device/bluetooth/bluetooth_adapter.h" 13 #include "device/bluetooth/bluetooth_adapter.h"
12 #include "device/bluetooth/bluetooth_adapter_chromeos.h" 14 #include "device/bluetooth/bluetooth_adapter_chromeos.h"
13 #include "device/bluetooth/bluetooth_adapter_factory.h" 15 #include "device/bluetooth/bluetooth_adapter_factory.h"
14 #include "device/bluetooth/bluetooth_device.h" 16 #include "device/bluetooth/bluetooth_device.h"
15 #include "device/bluetooth/bluetooth_device_chromeos.h" 17 #include "device/bluetooth/bluetooth_device_chromeos.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
17 19
18 using device::BluetoothAdapter; 20 using device::BluetoothAdapter;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 void QuitMessageLoop() { 203 void QuitMessageLoop() {
202 if (base::MessageLoop::current() && 204 if (base::MessageLoop::current() &&
203 base::MessageLoop::current()->is_running()) 205 base::MessageLoop::current()->is_running())
204 base::MessageLoop::current()->Quit(); 206 base::MessageLoop::current()->Quit();
205 } 207 }
206 }; 208 };
207 209
208 class BluetoothChromeOSTest : public testing::Test { 210 class BluetoothChromeOSTest : public testing::Test {
209 public: 211 public:
210 virtual void SetUp() { 212 virtual void SetUp() {
211 fake_dbus_thread_manager_ = new FakeDBusThreadManager(); 213 FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager;
212 DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager_); 214 fake_bluetooth_adapter_client_ = new FakeBluetoothAdapterClient;
213 215 fake_dbus_thread_manager->SetBluetoothAdapterClient(
214 fake_bluetooth_adapter_client_ = 216 scoped_ptr<BluetoothAdapterClient>(fake_bluetooth_adapter_client_));
215 fake_dbus_thread_manager_->fake_bluetooth_adapter_client(); 217 fake_bluetooth_device_client_ = new FakeBluetoothDeviceClient;
216 fake_bluetooth_device_client_ = 218 fake_dbus_thread_manager->SetBluetoothDeviceClient(
217 fake_dbus_thread_manager_->fake_bluetooth_device_client(); 219 scoped_ptr<BluetoothDeviceClient>(fake_bluetooth_device_client_));
220 fake_dbus_thread_manager->SetBluetoothInputClient(
221 scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient));
222 fake_dbus_thread_manager->SetBluetoothAgentManagerClient(
223 scoped_ptr<BluetoothAgentManagerClient>(
224 new FakeBluetoothAgentManagerClient));
225 DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager);
218 226
219 callback_count_ = 0; 227 callback_count_ = 0;
220 error_callback_count_ = 0; 228 error_callback_count_ = 0;
221 last_connect_error_ = BluetoothDevice::ERROR_UNKNOWN; 229 last_connect_error_ = BluetoothDevice::ERROR_UNKNOWN;
222 } 230 }
223 231
224 virtual void TearDown() { 232 virtual void TearDown() {
225 adapter_ = NULL; 233 adapter_ = NULL;
226 DBusThreadManager::Shutdown(); 234 DBusThreadManager::Shutdown();
227 } 235 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // Run a discovery phase so we have devices that can be paired with. 313 // Run a discovery phase so we have devices that can be paired with.
306 void DiscoverDevices() { 314 void DiscoverDevices() {
307 // Pass an invalid address for the device so that the discovery process 315 // Pass an invalid address for the device so that the discovery process
308 // completes with all devices. 316 // completes with all devices.
309 DiscoverDevice("does not exist"); 317 DiscoverDevice("does not exist");
310 } 318 }
311 319
312 protected: 320 protected:
313 FakeBluetoothAdapterClient* fake_bluetooth_adapter_client_; 321 FakeBluetoothAdapterClient* fake_bluetooth_adapter_client_;
314 FakeBluetoothDeviceClient* fake_bluetooth_device_client_; 322 FakeBluetoothDeviceClient* fake_bluetooth_device_client_;
315 FakeDBusThreadManager* fake_dbus_thread_manager_;
316 scoped_refptr<BluetoothAdapter> adapter_; 323 scoped_refptr<BluetoothAdapter> adapter_;
317 324
318 int callback_count_; 325 int callback_count_;
319 int error_callback_count_; 326 int error_callback_count_;
320 enum BluetoothDevice::ConnectErrorCode last_connect_error_; 327 enum BluetoothDevice::ConnectErrorCode last_connect_error_;
321 }; 328 };
322 329
323 TEST_F(BluetoothChromeOSTest, AlreadyPresent) { 330 TEST_F(BluetoothChromeOSTest, AlreadyPresent) {
324 GetAdapter(); 331 GetAdapter();
325 332
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 EXPECT_FALSE(device->IsConnected()); 2024 EXPECT_FALSE(device->IsConnected());
2018 EXPECT_FALSE(device->IsConnecting()); 2025 EXPECT_FALSE(device->IsConnecting());
2019 EXPECT_FALSE(device->IsPaired()); 2026 EXPECT_FALSE(device->IsPaired());
2020 2027
2021 // Pairing dialog should be dismissed 2028 // Pairing dialog should be dismissed
2022 EXPECT_EQ(1, pairing_delegate.call_count_); 2029 EXPECT_EQ(1, pairing_delegate.call_count_);
2023 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 2030 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
2024 } 2031 }
2025 2032
2026 } // namespace chromeos 2033 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_configuration_handler_unittest.cc ('k') | device/bluetooth/bluetooth_profile_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698