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

Side by Side Diff: chrome/browser/ui/ash/tray_bluetooth_helper_unittest.cc

Issue 2753313002: cros: Init SystemTrayDelegate earlier to break bluetooth init dependency (Closed)
Patch Set: fix test 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/ash/tray_bluetooth_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/ui/ash/tray_bluetooth_helper.h" 5 #include "chrome/browser/ui/ash/tray_bluetooth_helper.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/common/system/tray/system_tray_delegate.h" 9 #include "ash/common/system/tray/system_tray_delegate.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
11 #include "device/bluetooth/dbus/bluez_dbus_manager.h" 11 #include "device/bluetooth/dbus/bluez_dbus_manager.h"
12 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" 12 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
13 13
14 using bluez::BluezDBusManager; 14 using bluez::BluezDBusManager;
15 using bluez::FakeBluetoothAdapterClient; 15 using bluez::FakeBluetoothAdapterClient;
16 16
17 using TrayBluetoothHelperTest = ash::test::AshTestBase; 17 using TrayBluetoothHelperTest = ash::test::AshTestBase;
18 18
19 // Tests basic functionality like turning Bluetooth on and off. 19 // Tests basic functionality like turning Bluetooth on and off.
20 TEST_F(TrayBluetoothHelperTest, Basics) { 20 TEST_F(TrayBluetoothHelperTest, Basics) {
21 // Set Bluetooth discovery simulation delay to 0 so the test doesn't have to 21 // Set Bluetooth discovery simulation delay to 0 so the test doesn't have to
22 // wait or use timers. 22 // wait or use timers.
23 FakeBluetoothAdapterClient* adapter_client = 23 FakeBluetoothAdapterClient* adapter_client =
24 static_cast<FakeBluetoothAdapterClient*>( 24 static_cast<FakeBluetoothAdapterClient*>(
25 BluezDBusManager::Get()->GetBluetoothAdapterClient()); 25 BluezDBusManager::Get()->GetBluetoothAdapterClient());
26 adapter_client->SetSimulationIntervalMs(0); 26 adapter_client->SetSimulationIntervalMs(0);
27 27
28 TrayBluetoothHelper helper(nullptr); 28 TrayBluetoothHelper helper;
29 helper.Initialize(); 29 helper.Initialize();
30 RunAllPendingInMessageLoop(); 30 RunAllPendingInMessageLoop();
31 EXPECT_TRUE(helper.GetAvailable()); 31 EXPECT_TRUE(helper.GetAvailable());
32 EXPECT_FALSE(helper.GetEnabled()); 32 EXPECT_FALSE(helper.GetEnabled());
33 EXPECT_FALSE(helper.HasDiscoverySession()); 33 EXPECT_FALSE(helper.HasDiscoverySession());
34 EXPECT_FALSE(helper.IsDiscovering()); 34 EXPECT_FALSE(helper.IsDiscovering());
35 35
36 std::vector<ash::BluetoothDeviceInfo> devices; 36 std::vector<ash::BluetoothDeviceInfo> devices;
37 helper.GetAvailableDevices(&devices); 37 helper.GetAvailableDevices(&devices);
38 // The devices are fake in tests, so don't assume any particular number. 38 // The devices are fake in tests, so don't assume any particular number.
(...skipping 12 matching lines...) Expand all
51 helper.StopDiscovering(); 51 helper.StopDiscovering();
52 RunAllPendingInMessageLoop(); 52 RunAllPendingInMessageLoop();
53 EXPECT_FALSE(helper.HasDiscoverySession()); 53 EXPECT_FALSE(helper.HasDiscoverySession());
54 EXPECT_FALSE(helper.IsDiscovering()); 54 EXPECT_FALSE(helper.IsDiscovering());
55 55
56 // Turn Bluetooth off. 56 // Turn Bluetooth off.
57 helper.ToggleEnabled(); 57 helper.ToggleEnabled();
58 RunAllPendingInMessageLoop(); 58 RunAllPendingInMessageLoop();
59 EXPECT_FALSE(helper.GetEnabled()); 59 EXPECT_FALSE(helper.GetEnabled());
60 } 60 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/tray_bluetooth_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698