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

Unified Diff: chrome/browser/ui/ash/tray_bluetooth_helper_unittest.cc

Issue 2755643005: cros: Extract TrayBluetoothHelper from SystemTrayDelegateChromeOS (Closed)
Patch Set: rebase Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/ash/tray_bluetooth_helper.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/ash/tray_bluetooth_helper_unittest.cc
diff --git a/chrome/browser/ui/ash/tray_bluetooth_helper_unittest.cc b/chrome/browser/ui/ash/tray_bluetooth_helper_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4f52058b08cd3faab31ca13d4420a42e36c1348d
--- /dev/null
+++ b/chrome/browser/ui/ash/tray_bluetooth_helper_unittest.cc
@@ -0,0 +1,60 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/ash/tray_bluetooth_helper.h"
+
+#include <vector>
+
+#include "ash/common/system/tray/system_tray_delegate.h"
+#include "ash/test/ash_test_base.h"
+#include "device/bluetooth/dbus/bluez_dbus_manager.h"
+#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
+
+using bluez::BluezDBusManager;
+using bluez::FakeBluetoothAdapterClient;
+
+using TrayBluetoothHelperTest = ash::test::AshTestBase;
+
+// Tests basic functionality like turning Bluetooth on and off.
+TEST_F(TrayBluetoothHelperTest, Basics) {
+ // Set Bluetooth discovery simulation delay to 0 so the test doesn't have to
+ // wait or use timers.
+ FakeBluetoothAdapterClient* adapter_client =
+ static_cast<FakeBluetoothAdapterClient*>(
+ BluezDBusManager::Get()->GetBluetoothAdapterClient());
+ adapter_client->SetSimulationIntervalMs(0);
+
+ TrayBluetoothHelper helper(nullptr);
+ helper.Initialize();
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(helper.GetAvailable());
+ EXPECT_FALSE(helper.GetEnabled());
+ EXPECT_FALSE(helper.HasDiscoverySession());
+ EXPECT_FALSE(helper.IsDiscovering());
+
+ std::vector<ash::BluetoothDeviceInfo> devices;
+ helper.GetAvailableDevices(&devices);
+ // The devices are fake in tests, so don't assume any particular number.
+ EXPECT_FALSE(devices.empty());
+
+ // Turn Bluetooth on.
+ helper.ToggleEnabled();
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(helper.GetEnabled());
+
+ helper.StartDiscovering();
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(helper.HasDiscoverySession());
+ EXPECT_TRUE(helper.IsDiscovering());
+
+ helper.StopDiscovering();
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(helper.HasDiscoverySession());
+ EXPECT_FALSE(helper.IsDiscovering());
+
+ // Turn Bluetooth off.
+ helper.ToggleEnabled();
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(helper.GetEnabled());
+}
« no previous file with comments | « chrome/browser/ui/ash/tray_bluetooth_helper.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698