| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 "media/base/keyboard_event_counter.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" |
| 12 #include "build/build_config.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/skia/include/core/SkPoint.h" |
| 16 |
| 17 namespace media { |
| 18 |
| 19 TEST(KeyboardEventCounterTest, KeyPressCounter) { |
| 20 KeyboardEventCounter counter; |
| 21 |
| 22 EXPECT_EQ(0u, counter.GetKeyPressCount()); |
| 23 |
| 24 counter.OnKeyboardEvent(ui::ET_KEY_PRESSED, ui::VKEY_0); |
| 25 EXPECT_EQ(1u, counter.GetKeyPressCount()); |
| 26 |
| 27 // Holding the same key without releasing it does not increase the count. |
| 28 counter.OnKeyboardEvent(ui::ET_KEY_PRESSED, ui::VKEY_0); |
| 29 EXPECT_EQ(1u, counter.GetKeyPressCount()); |
| 30 |
| 31 // Releasing the key does not affect the total count. |
| 32 counter.OnKeyboardEvent(ui::ET_KEY_RELEASED, ui::VKEY_0); |
| 33 EXPECT_EQ(1u, counter.GetKeyPressCount()); |
| 34 |
| 35 counter.OnKeyboardEvent(ui::ET_KEY_PRESSED, ui::VKEY_0); |
| 36 counter.OnKeyboardEvent(ui::ET_KEY_RELEASED, ui::VKEY_0); |
| 37 EXPECT_EQ(2u, counter.GetKeyPressCount()); |
| 38 } |
| 39 |
| 40 } // namespace media |
| OLD | NEW |