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

Side by Side 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 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"
15 #include "ash/shell.h" 16 #include "ash/shell.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "chrome/browser/chromeos/login/login_manager_test.h" 18 #include "chrome/browser/chromeos/login/login_manager_test.h"
18 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 19 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
19 #include "chrome/browser/chromeos/login/startup_utils.h" 20 #include "chrome/browser/chromeos/login/startup_utils.h"
20 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" 21 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
21 #include "chrome/browser/chromeos/profiles/profile_helper.h" 22 #include "chrome/browser/chromeos/profiles/profile_helper.h"
22 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
23 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
24 #include "chrome/test/base/in_process_browser_test.h" 25 #include "chrome/test/base/in_process_browser_test.h"
25 #include "components/prefs/pref_service.h" 26 #include "components/prefs/pref_service.h"
26 #include "components/user_manager/user_manager.h" 27 #include "components/user_manager/user_manager.h"
27 #include "content/public/test/test_utils.h" 28 #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;
28 34
29 namespace chromeos { 35 namespace chromeos {
30 36
31 namespace { 37 namespace {
32 38
33 // Because policy is not needed this test it is better to use e-mails that 39 // Because policy is not needed this test it is better to use e-mails that
34 // are definitely not enterprise. This lets us to avoid faking of policy fetch 40 // are definitely not enterprise. This lets us to avoid faking of policy fetch
35 // procedure. 41 // procedure.
36 const char kUser1[] = "user1@gmail.com"; 42 const char kUser1[] = "user1@gmail.com";
37 const char kUser2[] = "user2@gmail.com"; 43 const char kUser2[] = "user2@gmail.com";
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 CreateDefaultView(); 110 CreateDefaultView();
105 EXPECT_EQ(base::k12HourClock, GetHourType()); 111 EXPECT_EQ(base::k12HourClock, GetHourType());
106 112
107 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_); 113 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_);
108 // Allow clock setting to be sent to ash over mojo. 114 // Allow clock setting to be sent to ash over mojo.
109 content::RunAllPendingInMessageLoop(); 115 content::RunAllPendingInMessageLoop();
110 CreateDefaultView(); 116 CreateDefaultView();
111 EXPECT_EQ(base::k24HourClock, GetHourType()); 117 EXPECT_EQ(base::k24HourClock, GetHourType());
112 } 118 }
113 119
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 =
134 ash::WmShell::Get()->system_tray_delegate();
135 EXPECT_TRUE(delegate->GetBluetoothAvailable());
136 EXPECT_FALSE(delegate->GetBluetoothEnabled());
137 EXPECT_FALSE(delegate->GetBluetoothDiscovering());
138 EXPECT_FALSE(delegate->IsBluetoothDiscovering());
139
140 ash::BluetoothDeviceList devices;
141 delegate->GetAvailableBluetoothDevices(&devices);
142 // The devices are fake in tests, so don't assume any particular number.
143 EXPECT_FALSE(devices.empty());
144
145 // Turn Bluetooth on.
146 delegate->ToggleBluetooth();
147 content::RunAllPendingInMessageLoop();
148 EXPECT_TRUE(delegate->GetBluetoothEnabled());
149
150 delegate->BluetoothStartDiscovering();
151 content::RunAllPendingInMessageLoop();
152 EXPECT_TRUE(delegate->GetBluetoothDiscovering());
153 EXPECT_TRUE(delegate->IsBluetoothDiscovering());
154
155 delegate->BluetoothStopDiscovering();
156 content::RunAllPendingInMessageLoop();
157 EXPECT_FALSE(delegate->GetBluetoothDiscovering());
158 EXPECT_FALSE(delegate->IsBluetoothDiscovering());
159
160 // Turn Bluetooth off.
161 delegate->ToggleBluetooth();
162 content::RunAllPendingInMessageLoop();
163 EXPECT_FALSE(delegate->GetBluetoothEnabled());
164 }
165
114 } // namespace chromeos 166 } // namespace chromeos
OLDNEW
« 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