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

Side by Side Diff: ash/common/accelerators/accelerator_table_unittest.cc

Issue 2689143002: ash: Remove OS_CHROMEOS ifdefs from accelerator files (Closed)
Patch Set: rebase Created 3 years, 10 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 | « ash/common/accelerators/accelerator_table.cc ('k') | ash/common/accelerators/debug_commands.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <set> 5 #include <set>
6 6
7 #include "ash/common/accelerators/accelerator_table.h" 7 #include "ash/common/accelerators/accelerator_table.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 TEST(AcceleratorTableTest, CheckDuplicatedRepeatableActions) { 69 TEST(AcceleratorTableTest, CheckDuplicatedRepeatableActions) {
70 std::set<AcceleratorAction> actions; 70 std::set<AcceleratorAction> actions;
71 for (size_t i = 0; i < kRepeatableActionsLength; ++i) { 71 for (size_t i = 0; i < kRepeatableActionsLength; ++i) {
72 EXPECT_TRUE(actions.insert(kRepeatableActions[i]).second) 72 EXPECT_TRUE(actions.insert(kRepeatableActions[i]).second)
73 << "Duplicated action: " << kRepeatableActions[i] << " at index: " << i; 73 << "Duplicated action: " << kRepeatableActions[i] << " at index: " << i;
74 } 74 }
75 } 75 }
76 76
77 #if defined(OS_CHROMEOS)
78
79 TEST(AcceleratorTableTest, CheckDeprecatedAccelerators) { 77 TEST(AcceleratorTableTest, CheckDeprecatedAccelerators) {
80 std::set<AcceleratorData, Cmp> deprecated_actions; 78 std::set<AcceleratorData, Cmp> deprecated_actions;
81 for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) { 79 for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) {
82 // A deprecated action can never appear twice in the list. 80 // A deprecated action can never appear twice in the list.
83 const AcceleratorData& entry = kDeprecatedAccelerators[i]; 81 const AcceleratorData& entry = kDeprecatedAccelerators[i];
84 EXPECT_TRUE(deprecated_actions.insert(entry).second) 82 EXPECT_TRUE(deprecated_actions.insert(entry).second)
85 << "Duplicate deprecated accelerator: " << entry.trigger_on_press 83 << "Duplicate deprecated accelerator: " << entry.trigger_on_press
86 << ", " << entry.keycode << ", " 84 << ", " << entry.keycode << ", "
87 << (entry.modifiers & ui::EF_SHIFT_DOWN) << ", " 85 << (entry.modifiers & ui::EF_SHIFT_DOWN) << ", "
88 << (entry.modifiers & ui::EF_CONTROL_DOWN) << ", " 86 << (entry.modifiers & ui::EF_CONTROL_DOWN) << ", "
89 << (entry.modifiers & ui::EF_ALT_DOWN); 87 << (entry.modifiers & ui::EF_ALT_DOWN);
90 } 88 }
91 89
92 std::set<AcceleratorAction> actions; 90 std::set<AcceleratorAction> actions;
93 for (size_t i = 0; i < kDeprecatedAcceleratorsDataLength; ++i) { 91 for (size_t i = 0; i < kDeprecatedAcceleratorsDataLength; ++i) {
94 // There must never be any duplicated actions. 92 // There must never be any duplicated actions.
95 const DeprecatedAcceleratorData& data = kDeprecatedAcceleratorsData[i]; 93 const DeprecatedAcceleratorData& data = kDeprecatedAcceleratorsData[i];
96 EXPECT_TRUE(actions.insert(data.action).second) << "Deprecated action: " 94 EXPECT_TRUE(actions.insert(data.action).second) << "Deprecated action: "
97 << data.action; 95 << data.action;
98 96
99 // The UMA histogram name must be of the format "Ash.Accelerators.*" 97 // The UMA histogram name must be of the format "Ash.Accelerators.*"
100 std::string uma_histogram(data.uma_histogram_name); 98 std::string uma_histogram(data.uma_histogram_name);
101 EXPECT_TRUE(base::StartsWith(uma_histogram, "Ash.Accelerators.", 99 EXPECT_TRUE(base::StartsWith(uma_histogram, "Ash.Accelerators.",
102 base::CompareCase::SENSITIVE)); 100 base::CompareCase::SENSITIVE));
103 } 101 }
104 } 102 }
105 103
106 #endif // defined(OS_CHROMEOS)
107
108 } // namespace ash 104 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/accelerators/accelerator_table.cc ('k') | ash/common/accelerators/debug_commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698