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

Side by Side Diff: chrome/browser/chromeos/login/hid_detection_browsertest.cc

Issue 913773002: Created fakes for HID-detection screen testing. Initial browsertest added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TaskRunner used for InputServiceProxy. Created 5 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/chromeos/device/input_service_proxy.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
10 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
11 #include "chrome/browser/chromeos/login/ui/oobe_display.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "device/bluetooth/bluetooth_adapter_factory.h"
14 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
15 #include "device/hid/fake_input_service_linux.h"
16 #include "device/hid/input_service_linux.h"
17 #include "testing/gmock/include/gmock/gmock.h"
18
19 using content::BrowserThread;
20 using device::InputServiceLinux;
21 using testing::_;
22
23 using InputDeviceInfo = InputServiceLinux::InputDeviceInfo;
24
25 namespace {
26
27 void SetUpBluetoothMock(
28 scoped_refptr<
29 testing::NiceMock<device::MockBluetoothAdapter> > mock_adapter,
30 bool is_present) {
31 device::BluetoothAdapterFactory::SetAdapterForTesting(mock_adapter);
32
33 EXPECT_CALL(*mock_adapter, IsPresent())
34 .WillRepeatedly(testing::Return(is_present));
35
36 EXPECT_CALL(*mock_adapter, IsPowered())
37 .WillRepeatedly(testing::Return(true));
38 EXPECT_CALL(*mock_adapter, GetDevices()).WillRepeatedly(
39 testing::Return(device::BluetoothAdapter::ConstDeviceList()));
40 }
41
42 } // namespace
43
44 namespace chromeos {
45
46 class HidDetectionTest : public OobeBaseTest {
47 public:
48 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo;
49
50 HidDetectionTest() : weak_ptr_factory_(this) {
51 InputServiceProxy::SetThreadIdForTesting(content::BrowserThread::UI);
52 HidDetectionTest::InitInputService();
53 }
54
55 ~HidDetectionTest() override {}
56
57 void InitInputService() {
58 input_service_linux_.reset(new device::FakeInputServiceLinux);
59 InputServiceLinux::SetForTesting(input_service_linux_.get());
60 }
61
62 void SetUpOnMainThread() override {
63 OobeBaseTest::SetUpOnMainThread();
64 }
65
66 void SetUpInProcessBrowserTestFixture() override {
67 OobeBaseTest::SetUpInProcessBrowserTestFixture();
68
69 mock_adapter_ = new testing::NiceMock<device::MockBluetoothAdapter>();
70 SetUpBluetoothMock(mock_adapter_, true);
71 }
72
73 void AddUsbMouse(const std::string& mouse_id) {
74 InputDeviceInfo mouse;
75 mouse.id = mouse_id;
76 mouse.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT;
77 mouse.type = InputDeviceInfo::TYPE_USB;
78 mouse.is_mouse = true;
79 LOG(ERROR) << input_service_linux_.get();
80 input_service_linux_->AddDeviceForTesting(mouse);
81 }
82
83 void AddUsbKeyboard(const std::string& keyboard_id) {
84 InputDeviceInfo keyboard;
85 keyboard.id = keyboard_id;
86 keyboard.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT;
87 keyboard.type = InputDeviceInfo::TYPE_USB;
88 keyboard.is_keyboard = true;
89 input_service_linux_->AddDeviceForTesting(keyboard);
90 }
91
92 private:
93 scoped_refptr<
94 testing::NiceMock<device::MockBluetoothAdapter> > mock_adapter_;
95
96 scoped_ptr<device::FakeInputServiceLinux> input_service_linux_;
97
98 base::WeakPtrFactory<HidDetectionTest> weak_ptr_factory_;
99
100 DISALLOW_COPY_AND_ASSIGN(HidDetectionTest);
101 };
102
103 class HidDetectionSkipTest : public HidDetectionTest {
104 public:
105 HidDetectionSkipTest() {
106 AddUsbMouse("mouse");
107 AddUsbKeyboard("keyboard");
108 }
109
110 void SetUpOnMainThread() override {
111 HidDetectionTest::SetUpOnMainThread();
112 }
113 };
114
115 IN_PROC_BROWSER_TEST_F(HidDetectionTest, NoDevicesConnected) {
116 OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_HID_DETECTION).Wait();
117 }
118
119 IN_PROC_BROWSER_TEST_F(HidDetectionSkipTest, BothDevicesPreConnected) {
120 OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_NETWORK).Wait();
121
122 }
123
124 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/device/input_service_proxy.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698