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

Side by Side Diff: components/keyboard_lock/keyboard_lock_host_unittest.cc

Issue 2815023002: [System-Keyboard-Lock] Add KeyboardLockHost and KeyEventInterceptor (Closed)
Patch Set: More comments Created 3 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/keyboard_lock/keyboard_lock_host.h"
6
7 #include "components/keyboard_lock/key_event_interceptor_installer.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace keyboard_lock {
11
12 namespace {
13
14 class FakeKeyEventInterceptor : public KeyEventInterceptorInstaller {
15 public:
16 // Owned by |host|.
17 static FakeKeyEventInterceptor* Create(KeyboardLockHost* host);
18 ~FakeKeyEventInterceptor() override { deleted_count++; }
19
20 bool OnKeyDown(ui::KeyboardCode code) override { return false; }
21 bool OnKeyUp(ui::KeyboardCode code) override { return false; }
22
23 static int deleted_count;
24
25 private:
26 FakeKeyEventInterceptor(KeyboardLockHost* host)
27 : KeyEventInterceptorInstaller(host) {}
28 };
29
30 int FakeKeyEventInterceptor::deleted_count = 0;
31
32 // static
33 FakeKeyEventInterceptor* FakeKeyEventInterceptor::Create(
34 KeyboardLockHost* host) {
35 FakeKeyEventInterceptor* interceptor = new FakeKeyEventInterceptor(host);
36 interceptor->Install();
37 return interceptor;
38 }
39
40 }
41
42 TEST(KeyboardLockHostTest, KeyEventInterceptorInstallationTest) {
43 {
44 KeyboardLockHost host;
45 FakeKeyEventInterceptor* interceptor =
46 FakeKeyEventInterceptor::Create(&host);
47 ASSERT_EQ(interceptor, host.interceptor());
48 }
49 ASSERT_EQ(FakeKeyEventInterceptor::deleted_count, 1);
50 }
51
52 } // namespace keyboard_lock
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698