OLD | NEW |
(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 FakeKeyEventInterceptor(KeyboardLockHost* host) |
| 17 : KeyEventInterceptorInstaller(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 |
| 26 int FakeKeyEventInterceptor::deleted_count = 0; |
| 27 } |
| 28 |
| 29 TEST(KeyboardLockHostTest, KeyEventInterceptorInstallationTest) { |
| 30 { |
| 31 KeyboardLockHost host; |
| 32 FakeKeyEventInterceptor* interceptor = new FakeKeyEventInterceptor(&host); |
| 33 ASSERT_EQ(interceptor, host.interceptor()); |
| 34 } |
| 35 ASSERT_EQ(FakeKeyEventInterceptor::deleted_count, 1); |
| 36 } |
| 37 |
| 38 } // namespace keyboard_lock |
OLD | NEW |