Add ICU message format support
[chromium-blink-merge.git] / ash / accelerators / accelerator_table_unittest.cc
blobb04c579594e443b1da57f8abec1ba59ba4800abd
1 // Copyright (c) 2012 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.
5 #include <set>
7 #include "base/basictypes.h"
8 #include "ash/accelerators/accelerator_table.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace ash {
13 namespace {
15 struct Cmp {
16 bool operator()(const AcceleratorData& lhs,
17 const AcceleratorData& rhs) {
18 if (lhs.trigger_on_press != rhs.trigger_on_press)
19 return lhs.trigger_on_press < rhs.trigger_on_press;
20 if (lhs.keycode != rhs.keycode)
21 return lhs.keycode < rhs.keycode;
22 return lhs.modifiers < rhs.modifiers;
23 // Do not check |action|.
27 } // namespace
29 TEST(AcceleratorTableTest, CheckDuplicatedAccelerators) {
30 std::set<AcceleratorData, Cmp> accelerators;
31 for (size_t i = 0; i < kAcceleratorDataLength; ++i) {
32 const AcceleratorData& entry = kAcceleratorData[i];
33 EXPECT_TRUE(accelerators.insert(entry).second)
34 << "Duplicated accelerator: " << entry.trigger_on_press << ", "
35 << entry.keycode << ", " << (entry.modifiers & ui::EF_SHIFT_DOWN)
36 << ", " << (entry.modifiers & ui::EF_CONTROL_DOWN) << ", "
37 << (entry.modifiers & ui::EF_ALT_DOWN);
41 TEST(AcceleratorTableTest, CheckDuplicatedReservedActions) {
42 std::set<AcceleratorAction> actions;
43 for (size_t i = 0; i < kReservedActionsLength; ++i) {
44 EXPECT_TRUE(actions.insert(kReservedActions[i]).second)
45 << "Duplicated action: " << kReservedActions[i];
49 TEST(AcceleratorTableTest, CheckDuplicatedActionsAllowedAtLoginOrLockScreen) {
50 std::set<AcceleratorAction> actions;
51 for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) {
52 EXPECT_TRUE(actions.insert(kActionsAllowedAtLoginOrLockScreen[i]).second)
53 << "Duplicated action: " << kActionsAllowedAtLoginOrLockScreen[i];
55 for (size_t i = 0; i < kActionsAllowedAtLockScreenLength; ++i) {
56 EXPECT_TRUE(actions.insert(kActionsAllowedAtLockScreen[i]).second)
57 << "Duplicated action: " << kActionsAllowedAtLockScreen[i];
61 TEST(AcceleratorTableTest, CheckDuplicatedActionsAllowedAtModalWindow) {
62 std::set<AcceleratorAction> actions;
63 for (size_t i = 0; i < kActionsAllowedAtModalWindowLength; ++i) {
64 EXPECT_TRUE(actions.insert(kActionsAllowedAtModalWindow[i]).second)
65 << "Duplicated action: " << kActionsAllowedAtModalWindow[i]
66 << " at index: " << i;
70 TEST(AcceleratorTableTest, CheckDuplicatedNonrepeatableActions) {
71 std::set<AcceleratorAction> actions;
72 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) {
73 EXPECT_TRUE(actions.insert(kNonrepeatableActions[i]).second)
74 << "Duplicated action: " << kNonrepeatableActions[i]
75 << " at index: " << i;
79 } // namespace ash