OLD | NEW |
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/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
10 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 uint32 last_passkey_; | 150 uint32 last_passkey_; |
151 uint32 last_entered_; | 151 uint32 last_entered_; |
152 std::string last_pincode_; | 152 std::string last_pincode_; |
153 | 153 |
154 private: | 154 private: |
155 // Some tests use a message loop since background processing is simulated; | 155 // Some tests use a message loop since background processing is simulated; |
156 // break out of those loops. | 156 // break out of those loops. |
157 void QuitMessageLoop() { | 157 void QuitMessageLoop() { |
158 if (base::MessageLoop::current() && | 158 if (base::MessageLoop::current() && |
159 base::MessageLoop::current()->is_running()) { | 159 base::MessageLoop::current()->is_running()) { |
160 base::MessageLoop::current()->Quit(); | 160 base::MessageLoop::current()->QuitWhenIdle(); |
161 } | 161 } |
162 } | 162 } |
163 }; | 163 }; |
164 | 164 |
165 class BluetoothChromeOSTest : public testing::Test { | 165 class BluetoothChromeOSTest : public testing::Test { |
166 public: | 166 public: |
167 void SetUp() override { | 167 void SetUp() override { |
168 scoped_ptr<DBusThreadManagerSetter> dbus_setter = | 168 scoped_ptr<DBusThreadManagerSetter> dbus_setter = |
169 chromeos::DBusThreadManager::GetSetterForTesting(); | 169 chromeos::DBusThreadManager::GetSetterForTesting(); |
170 // We need to initialize DBusThreadManager early to prevent | 170 // We need to initialize DBusThreadManager early to prevent |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 std::string last_client_error_; | 347 std::string last_client_error_; |
348 ScopedVector<BluetoothDiscoverySession> discovery_sessions_; | 348 ScopedVector<BluetoothDiscoverySession> discovery_sessions_; |
349 BluetoothAdapterProfileChromeOS* adapter_profile_; | 349 BluetoothAdapterProfileChromeOS* adapter_profile_; |
350 | 350 |
351 private: | 351 private: |
352 // Some tests use a message loop since background processing is simulated; | 352 // Some tests use a message loop since background processing is simulated; |
353 // break out of those loops. | 353 // break out of those loops. |
354 void QuitMessageLoop() { | 354 void QuitMessageLoop() { |
355 if (base::MessageLoop::current() && | 355 if (base::MessageLoop::current() && |
356 base::MessageLoop::current()->is_running()) { | 356 base::MessageLoop::current()->is_running()) { |
357 base::MessageLoop::current()->Quit(); | 357 base::MessageLoop::current()->QuitWhenIdle(); |
358 } | 358 } |
359 } | 359 } |
360 }; | 360 }; |
361 | 361 |
362 TEST_F(BluetoothChromeOSTest, AlreadyPresent) { | 362 TEST_F(BluetoothChromeOSTest, AlreadyPresent) { |
363 GetAdapter(); | 363 GetAdapter(); |
364 | 364 |
365 // This verifies that the class gets the list of adapters when created; | 365 // This verifies that the class gets the list of adapters when created; |
366 // and initializes with an existing adapter if there is one. | 366 // and initializes with an existing adapter if there is one. |
367 EXPECT_TRUE(adapter_->IsPresent()); | 367 EXPECT_TRUE(adapter_->IsPresent()); |
(...skipping 3935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4303 adapter_->Shutdown(); | 4303 adapter_->Shutdown(); |
4304 adapter_chrome_os->OnStopDiscoveryError(GetDiscoveryErrorCallback(), "", ""); | 4304 adapter_chrome_os->OnStopDiscoveryError(GetDiscoveryErrorCallback(), "", ""); |
4305 | 4305 |
4306 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError, | 4306 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError, |
4307 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession. | 4307 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession. |
4308 EXPECT_EQ(0, callback_count_); | 4308 EXPECT_EQ(0, callback_count_); |
4309 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); | 4309 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); |
4310 } | 4310 } |
4311 | 4311 |
4312 } // namespace chromeos | 4312 } // namespace chromeos |
OLD | NEW |