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

Unified Diff: chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.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
Index: chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.cc
diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.cc b/chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.cc
index a64eb66e65d4eb7e6d5e960d9c495791bfed8220..6e45b847b35af1f7e8ef3c7d4bbf5092f7c5a7ef 100644
--- a/chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.cc
+++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.cc
@@ -12,6 +12,7 @@
#include "ash/common/system/date/tray_date.h"
#include "ash/common/system/date/tray_system_info.h"
#include "ash/common/system/tray/system_tray.h"
+#include "ash/common/wm_shell.h"
#include "ash/shell.h"
#include "base/macros.h"
#include "chrome/browser/chromeos/login/login_manager_test.h"
@@ -25,6 +26,11 @@
#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
#include "content/public/test/test_utils.h"
+#include "device/bluetooth/dbus/bluez_dbus_manager.h"
+#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
+
+using bluez::BluezDBusManager;
+using bluez::FakeBluetoothAdapterClient;
namespace chromeos {
@@ -111,4 +117,50 @@ IN_PROC_BROWSER_TEST_F(SystemTrayDelegateChromeOSTest,
EXPECT_EQ(base::k24HourClock, GetHourType());
}
+using SystemTrayDelegateBluetoothTest = InProcessBrowserTest;
+
+// Tests basic functionality of the Bluetooth interface.
+// TODO(jamescook): Delete this test when TrayBluetoothHelper moves to ash.
+// http://crbug.com/660043
+IN_PROC_BROWSER_TEST_F(SystemTrayDelegateBluetoothTest, 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);
+
+ ash::SystemTrayDelegate* delegate =
+ ash::WmShell::Get()->system_tray_delegate();
+ EXPECT_TRUE(delegate->GetBluetoothAvailable());
+ EXPECT_FALSE(delegate->GetBluetoothEnabled());
+ EXPECT_FALSE(delegate->GetBluetoothDiscovering());
+ EXPECT_FALSE(delegate->IsBluetoothDiscovering());
+
+ ash::BluetoothDeviceList devices;
+ delegate->GetAvailableBluetoothDevices(&devices);
+ // The devices are fake in tests, so don't assume any particular number.
+ EXPECT_FALSE(devices.empty());
+
+ // Turn Bluetooth on.
+ delegate->ToggleBluetooth();
+ content::RunAllPendingInMessageLoop();
+ EXPECT_TRUE(delegate->GetBluetoothEnabled());
+
+ delegate->BluetoothStartDiscovering();
+ content::RunAllPendingInMessageLoop();
+ EXPECT_TRUE(delegate->GetBluetoothDiscovering());
+ EXPECT_TRUE(delegate->IsBluetoothDiscovering());
+
+ delegate->BluetoothStopDiscovering();
+ content::RunAllPendingInMessageLoop();
+ EXPECT_FALSE(delegate->GetBluetoothDiscovering());
+ EXPECT_FALSE(delegate->IsBluetoothDiscovering());
+
+ // Turn Bluetooth off.
+ delegate->ToggleBluetooth();
+ content::RunAllPendingInMessageLoop();
+ EXPECT_FALSE(delegate->GetBluetoothEnabled());
+}
+
} // namespace chromeos
« no previous file with comments | « chrome/browser/ui/ash/system_tray_delegate_chromeos.cc ('k') | chrome/browser/ui/ash/tray_bluetooth_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698