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

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

Issue 2761993002: cros: Eliminate bluetooth methods from SystemTrayDelegate (Closed)
Patch Set: review comments 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
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 "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "ash/common/system/date/date_default_view.h" 9 #include "ash/common/system/date/date_default_view.h"
10 #include "ash/common/system/date/date_view.h" 10 #include "ash/common/system/date/date_view.h"
11 #include "ash/common/system/date/system_info_default_view.h" 11 #include "ash/common/system/date/system_info_default_view.h"
12 #include "ash/common/system/date/tray_date.h" 12 #include "ash/common/system/date/tray_date.h"
13 #include "ash/common/system/date/tray_system_info.h" 13 #include "ash/common/system/date/tray_system_info.h"
14 #include "ash/common/system/tray/system_tray.h" 14 #include "ash/common/system/tray/system_tray.h"
15 #include "ash/common/wm_shell.h"
16 #include "ash/shell.h" 15 #include "ash/shell.h"
17 #include "base/macros.h" 16 #include "base/macros.h"
18 #include "chrome/browser/chromeos/login/login_manager_test.h" 17 #include "chrome/browser/chromeos/login/login_manager_test.h"
19 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 18 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
20 #include "chrome/browser/chromeos/login/startup_utils.h" 19 #include "chrome/browser/chromeos/login/startup_utils.h"
21 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" 20 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
22 #include "chrome/browser/chromeos/profiles/profile_helper.h" 21 #include "chrome/browser/chromeos/profiles/profile_helper.h"
23 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
24 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
25 #include "chrome/test/base/in_process_browser_test.h" 24 #include "chrome/test/base/in_process_browser_test.h"
26 #include "components/prefs/pref_service.h" 25 #include "components/prefs/pref_service.h"
27 #include "components/user_manager/user_manager.h" 26 #include "components/user_manager/user_manager.h"
28 #include "content/public/test/test_utils.h" 27 #include "content/public/test/test_utils.h"
29 #include "device/bluetooth/dbus/bluez_dbus_manager.h"
30 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
31
32 using bluez::BluezDBusManager;
33 using bluez::FakeBluetoothAdapterClient;
34 28
35 namespace chromeos { 29 namespace chromeos {
36 30
37 namespace { 31 namespace {
38 32
39 // Because policy is not needed this test it is better to use e-mails that 33 // Because policy is not needed this test it is better to use e-mails that
40 // are definitely not enterprise. This lets us to avoid faking of policy fetch 34 // are definitely not enterprise. This lets us to avoid faking of policy fetch
41 // procedure. 35 // procedure.
42 const char kUser1[] = "user1@gmail.com"; 36 const char kUser1[] = "user1@gmail.com";
43 const char kUser2[] = "user2@gmail.com"; 37 const char kUser2[] = "user2@gmail.com";
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 CreateDefaultView(); 104 CreateDefaultView();
111 EXPECT_EQ(base::k12HourClock, GetHourType()); 105 EXPECT_EQ(base::k12HourClock, GetHourType());
112 106
113 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_); 107 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_);
114 // Allow clock setting to be sent to ash over mojo. 108 // Allow clock setting to be sent to ash over mojo.
115 content::RunAllPendingInMessageLoop(); 109 content::RunAllPendingInMessageLoop();
116 CreateDefaultView(); 110 CreateDefaultView();
117 EXPECT_EQ(base::k24HourClock, GetHourType()); 111 EXPECT_EQ(base::k24HourClock, GetHourType());
118 } 112 }
119 113
120 using SystemTrayDelegateBluetoothTest = InProcessBrowserTest;
121
122 // Tests basic functionality of the Bluetooth interface.
123 // TODO(jamescook): Delete this test when TrayBluetoothHelper moves to ash.
124 // http://crbug.com/660043
125 IN_PROC_BROWSER_TEST_F(SystemTrayDelegateBluetoothTest, Basics) {
126 // Set Bluetooth discovery simulation delay to 0 so the test doesn't have to
127 // wait or use timers.
128 FakeBluetoothAdapterClient* adapter_client =
129 static_cast<FakeBluetoothAdapterClient*>(
130 BluezDBusManager::Get()->GetBluetoothAdapterClient());
131 adapter_client->SetSimulationIntervalMs(0);
132
133 ash::SystemTrayDelegate* delegate = ash::Shell::Get()->system_tray_delegate();
134 EXPECT_TRUE(delegate->GetBluetoothAvailable());
135 EXPECT_FALSE(delegate->GetBluetoothEnabled());
136 EXPECT_FALSE(delegate->GetBluetoothDiscovering());
137 EXPECT_FALSE(delegate->IsBluetoothDiscovering());
138
139 ash::BluetoothDeviceList devices;
140 delegate->GetAvailableBluetoothDevices(&devices);
141 // The devices are fake in tests, so don't assume any particular number.
142 EXPECT_FALSE(devices.empty());
143
144 // Turn Bluetooth on.
145 delegate->ToggleBluetooth();
146 content::RunAllPendingInMessageLoop();
147 EXPECT_TRUE(delegate->GetBluetoothEnabled());
148
149 delegate->BluetoothStartDiscovering();
150 content::RunAllPendingInMessageLoop();
151 EXPECT_TRUE(delegate->GetBluetoothDiscovering());
152 EXPECT_TRUE(delegate->IsBluetoothDiscovering());
153
154 delegate->BluetoothStopDiscovering();
155 content::RunAllPendingInMessageLoop();
156 EXPECT_FALSE(delegate->GetBluetoothDiscovering());
157 EXPECT_FALSE(delegate->IsBluetoothDiscovering());
158
159 // Turn Bluetooth off.
160 delegate->ToggleBluetooth();
161 content::RunAllPendingInMessageLoop();
162 EXPECT_FALSE(delegate->GetBluetoothEnabled());
163 }
164
165 } // namespace chromeos 114 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698