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

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

Issue 1150833002: bluetooth: android: Initial Low Energy Discovery Sessions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-manifest-
Patch Set: https://codereview.chromium.org/1231883004 fixs runtime error. Created 5 years, 5 months 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
OLDNEW
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/run_loop.h" 7 #include "base/run_loop.h"
8 #include "device/bluetooth/bluetooth_adapter.h" 8 #include "device/bluetooth/bluetooth_adapter.h"
9 #include "device/bluetooth/bluetooth_device.h" 9 #include "device/bluetooth/bluetooth_device.h"
10 #include "device/bluetooth/bluetooth_discovery_session.h" 10 #include "device/bluetooth/bluetooth_discovery_session.h"
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 InitWithFakeAdapter(); 437 InitWithFakeAdapter();
438 EXPECT_EQ(adapter_->GetAddress(), "A1:B2:C3:D4:E5:F6"); 438 EXPECT_EQ(adapter_->GetAddress(), "A1:B2:C3:D4:E5:F6");
439 EXPECT_EQ(adapter_->GetName(), "FakeBluetoothAdapter"); 439 EXPECT_EQ(adapter_->GetName(), "FakeBluetoothAdapter");
440 EXPECT_TRUE(adapter_->IsPresent()); 440 EXPECT_TRUE(adapter_->IsPresent());
441 EXPECT_TRUE(adapter_->IsPowered()); 441 EXPECT_TRUE(adapter_->IsPowered());
442 EXPECT_FALSE(adapter_->IsDiscoverable()); 442 EXPECT_FALSE(adapter_->IsDiscoverable());
443 EXPECT_FALSE(adapter_->IsDiscovering()); 443 EXPECT_FALSE(adapter_->IsDiscovering());
444 } 444 }
445 #endif // defined(OS_ANDROID) 445 #endif // defined(OS_ANDROID)
446 446
447 // TODO(scheib): Enable BluetoothTest fixture tests on all platforms.
448 #if defined(OS_ANDROID)
449 TEST_F(BluetoothTest, DiscoverySession) {
450 InitWithFakeAdapter();
451 EXPECT_FALSE(adapter_->IsDiscovering());
452
453 adapter_->StartDiscoverySession(GetDiscoverySessionCallback(),
454 GetErrorCallback());
455 base::RunLoop().RunUntilIdle();
456 EXPECT_EQ(1, callback_count_--);
457 EXPECT_EQ(0, error_callback_count_);
458 EXPECT_TRUE(adapter_->IsDiscovering());
459 ASSERT_EQ((size_t)1, discovery_sessions_.size());
460 EXPECT_TRUE(discovery_sessions_[0]->IsActive());
461
462 discovery_sessions_[0]->Stop(GetCallback(), GetErrorCallback());
463 base::RunLoop().RunUntilIdle();
464 EXPECT_EQ(1, callback_count_--);
465 EXPECT_EQ(0, error_callback_count_);
466 EXPECT_FALSE(adapter_->IsDiscovering());
467 EXPECT_FALSE(discovery_sessions_[0]->IsActive());
468 }
469 #endif // defined(OS_ANDROID)
470
447 } // namespace device 471 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698