summaryrefslogtreecommitdiff
path: root/chromium/device/bluetooth/bluetooth_adapter_unittest.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/device/bluetooth/bluetooth_adapter_unittest.cc
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/device/bluetooth/bluetooth_adapter_unittest.cc')
-rw-r--r--chromium/device/bluetooth/bluetooth_adapter_unittest.cc47
1 files changed, 38 insertions, 9 deletions
diff --git a/chromium/device/bluetooth/bluetooth_adapter_unittest.cc b/chromium/device/bluetooth/bluetooth_adapter_unittest.cc
index 55f6b2d8333..593c5782a30 100644
--- a/chromium/device/bluetooth/bluetooth_adapter_unittest.cc
+++ b/chromium/device/bluetooth/bluetooth_adapter_unittest.cc
@@ -14,6 +14,7 @@
#include "base/barrier_closure.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/test/bind_test_util.h"
@@ -131,12 +132,6 @@ class TestBluetoothAdapter final : public BluetoothAdapter {
void TestErrorCallback() {}
- void TestOnStartDiscoverySession(
- std::unique_ptr<device::BluetoothDiscoverySession> discovery_session) {
- ++callback_count_;
- discovery_sessions_holder_.push(std::move(discovery_session));
- }
-
void OnStartDiscoverySessionQuitLoop(
base::Closure run_loop_quit,
std::unique_ptr<device::BluetoothDiscoverySession> discovery_session) {
@@ -723,7 +718,7 @@ TEST_F(BluetoothTest, MAYBE_ConstructDefaultAdapter) {
EXPECT_EQ(adapter_->IsPowered(), adapter_->IsPowered());
EXPECT_FALSE(adapter_->IsDiscoverable());
EXPECT_FALSE(adapter_->IsDiscovering());
-}
+} // namespace device
// TODO(scheib): Enable BluetoothTest fixture tests on all platforms.
#if defined(OS_ANDROID) || defined(OS_MACOSX)
@@ -1420,6 +1415,34 @@ TEST_F(BluetoothTest, MAYBE_TogglePowerBeforeScan) {
EXPECT_TRUE(discovery_sessions_[0]->IsActive());
}
+#if defined(OS_WIN)
+TEST_P(BluetoothTestWinrtOnly, DiscoverySessionFailure) {
+ if (!PlatformSupportsLowEnergy()) {
+ LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
+ return;
+ }
+
+ InitWithFakeAdapter();
+ TestBluetoothAdapterObserver observer(adapter_);
+ EXPECT_FALSE(adapter_->IsDiscovering());
+
+ StartLowEnergyDiscoverySession();
+ EXPECT_EQ(1, callback_count_);
+ EXPECT_EQ(0, error_callback_count_);
+ EXPECT_TRUE(adapter_->IsDiscovering());
+ EXPECT_EQ(1, observer.discovering_changed_count());
+ EXPECT_TRUE(observer.last_discovering());
+ ASSERT_EQ((size_t)1, discovery_sessions_.size());
+ EXPECT_TRUE(discovery_sessions_[0]->IsActive());
+
+ SimulateLowEnergyDiscoveryFailure();
+ EXPECT_FALSE(adapter_->IsDiscovering());
+ EXPECT_FALSE(discovery_sessions_[0]->IsActive());
+ EXPECT_EQ(2, observer.discovering_changed_count());
+ EXPECT_FALSE(observer.last_discovering());
+}
+#endif // defined(OS_WIN)
+
#if defined(OS_MACOSX)
#define MAYBE_TurnOffAdapterWithConnectedDevice \
TurnOffAdapterWithConnectedDevice
@@ -2093,9 +2116,15 @@ TEST_F(BluetoothTest, DiscoverConnectedLowEnergyDeviceTwice) {
#endif // defined(OS_MACOSX)
#if defined(OS_WIN)
-INSTANTIATE_TEST_SUITE_P(All, BluetoothTestWinrt, ::testing::Bool());
+INSTANTIATE_TEST_SUITE_P(All,
+ BluetoothTestWinrt,
+ ::testing::ValuesIn(kBluetoothTestWinrtParamAll));
+
+INSTANTIATE_TEST_SUITE_P(
+ All,
+ BluetoothTestWinrtOnly,
+ ::testing::ValuesIn(kBluetoothTestWinrtParamWinrtOnly));
-INSTANTIATE_TEST_SUITE_P(All, BluetoothTestWinrtOnly, ::testing::Values(true));
#endif // defined(OS_WIN)
} // namespace device