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

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

Issue 1414483011: Deprecate Shift+Alt to switch IME and use Ctrl+Shift+Space instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ensure no line breaks in the middle of shortcuts texts Created 5 years, 1 month 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
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/accelerators/accelerator_table.h"
7 #include "base/basictypes.h" 8 #include "base/basictypes.h"
8 #include "ash/accelerators/accelerator_table.h" 9 #include "base/strings/string_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 namespace ash { 12 namespace ash {
12 13
13 namespace { 14 namespace {
14 15
15 struct Cmp { 16 struct Cmp {
16 bool operator()(const AcceleratorData& lhs, 17 bool operator()(const AcceleratorData& lhs,
17 const AcceleratorData& rhs) { 18 const AcceleratorData& rhs) {
18 if (lhs.trigger_on_press != rhs.trigger_on_press) 19 if (lhs.trigger_on_press != rhs.trigger_on_press)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) { 73 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) {
73 EXPECT_TRUE(actions.insert(kNonrepeatableActions[i]).second) 74 EXPECT_TRUE(actions.insert(kNonrepeatableActions[i]).second)
74 << "Duplicated action: " << kNonrepeatableActions[i] 75 << "Duplicated action: " << kNonrepeatableActions[i]
75 << " at index: " << i; 76 << " at index: " << i;
76 } 77 }
77 } 78 }
78 79
79 #if defined(OS_CHROMEOS) 80 #if defined(OS_CHROMEOS)
80 81
81 TEST(AcceleratorTableTest, CheckDeprecatedAccelerators) { 82 TEST(AcceleratorTableTest, CheckDeprecatedAccelerators) {
82 std::set<AcceleratorAction> deprecated_actions; 83 std::set<AcceleratorData, Cmp> deprecated_actions;
83 for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) { 84 for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) {
84 // A deprecated action can never appear twice in the list. 85 // A deprecated action can never appear twice in the list.
85 AcceleratorAction deprecated_action = 86 const AcceleratorData& entry = kDeprecatedAccelerators[i];
86 kDeprecatedAccelerators[i].deprecated_accelerator.action; 87 EXPECT_TRUE(deprecated_actions.insert(entry).second)
87 EXPECT_TRUE(deprecated_actions.insert(deprecated_action).second) 88 << "Duplicate deprecated accelerator: " << entry.trigger_on_press
88 << "Duplicated action: " << deprecated_action << " at index: " << i; 89 << ", " << entry.keycode << ", "
90 << (entry.modifiers & ui::EF_SHIFT_DOWN) << ", "
91 << (entry.modifiers & ui::EF_CONTROL_DOWN) << ", "
92 << (entry.modifiers & ui::EF_ALT_DOWN);
93 }
94
95 std::set<AcceleratorAction> actions;
96 for (size_t i = 0; i < kDeprecatedAcceleratorsDataLength; ++i) {
97 // There must never be any duplicated actions.
98 const DeprecatedAcceleratorData& data = kDeprecatedAcceleratorsData[i];
99 EXPECT_TRUE(actions.insert(data.action).second) << "Deprecated action: "
100 << data.action;
89 101
90 // The UMA histogram name must be of the format "Ash.Accelerators.*" 102 // The UMA histogram name must be of the format "Ash.Accelerators.*"
91 std::string uma_histogram(kDeprecatedAccelerators[i].uma_histogram_name); 103 std::string uma_histogram(data.uma_histogram_name);
92 EXPECT_TRUE(uma_histogram.find("Ash.Accelerators.") != std::string::npos); 104 EXPECT_TRUE(base::StartsWith(uma_histogram, "Ash.Accelerators.",
93 EXPECT_TRUE(uma_histogram.find("Ash.Accelerators.") == 0); 105 base::CompareCase::SENSITIVE));
94 } 106 }
95 } 107 }
96 108
97 #endif // defined(OS_CHROMEOS) 109 #endif // defined(OS_CHROMEOS)
98 110
99 } // namespace ash 111 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698