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

Unified Diff: chrome/browser/ui/views/accelerator_table_unittest.cc

Issue 10177002: Do not include Ctrl+N and Ctrl+Shift+N in chrome/browser/ui/views/accelerator_table.cc when USE_ASH (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/accelerator_table.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/accelerator_table_unittest.cc
diff --git a/chrome/browser/ui/views/accelerator_table_unittest.cc b/chrome/browser/ui/views/accelerator_table_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1451dfa5a7d8c2696e016512891ef4c0fc626ffd
--- /dev/null
+++ b/chrome/browser/ui/views/accelerator_table_unittest.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <set>
+
+#include "base/basictypes.h"
+#include "chrome/browser/ui/views/accelerator_table.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+#if defined(USE_ASH)
+#include "ash/accelerators/accelerator_table.h"
+#endif // USE_ASH
+
+namespace {
+
+struct Cmp {
+ bool operator()(const browser::AcceleratorMapping& lhs,
+ const browser::AcceleratorMapping& rhs) {
+ if (lhs.keycode != rhs.keycode)
+ return lhs.keycode < rhs.keycode;
+ if (lhs.shift_pressed != rhs.shift_pressed)
+ return lhs.shift_pressed < rhs.shift_pressed;
+ if (lhs.ctrl_pressed != rhs.ctrl_pressed)
+ return lhs.ctrl_pressed < rhs.ctrl_pressed;
+ return lhs.alt_pressed < rhs.alt_pressed;
+ // Do not check |command_id|.
+ }
+};
+
+} // namespace
+
+TEST(AcceleratorTableTest, CheckDuplicatedAccelerators) {
+ std::set<browser::AcceleratorMapping, Cmp> acclerators;
+ for (size_t i = 0; i < browser::kAcceleratorMapLength; ++i) {
+ const browser::AcceleratorMapping& entry = browser::kAcceleratorMap[i];
+ EXPECT_TRUE(acclerators.insert(entry).second)
+ << "Duplicated accelerator: " << entry.keycode << ", "
+ << entry.shift_pressed << ", " << entry.ctrl_pressed << ", "
+ << entry.alt_pressed;
+ }
+}
+
+#if defined(USE_ASH)
+TEST(AcceleratorTableTest, CheckDuplicatedAcceleratorsAsh) {
+ std::set<browser::AcceleratorMapping, Cmp> acclerators;
+ for (size_t i = 0; i < browser::kAcceleratorMapLength; ++i) {
+ const browser::AcceleratorMapping& entry = browser::kAcceleratorMap[i];
+ acclerators.insert(entry);
+ }
+ for (size_t i = 0; i < ash::kAcceleratorDataLength; ++i) {
+ const ash::AcceleratorData& ash_entry = ash::kAcceleratorData[i];
+ if (!ash_entry.trigger_on_press)
+ continue; // kAcceleratorMap does not have any release accelerators.
+ browser::AcceleratorMapping entry;
+ entry.keycode = ash_entry.keycode;
+ entry.shift_pressed = ash_entry.shift;
+ entry.ctrl_pressed = ash_entry.ctrl;
+ entry.alt_pressed = ash_entry.alt;
+ entry.command_id = 0; // dummy
+ EXPECT_TRUE(acclerators.insert(entry).second)
+ << "Duplicated accelerator: " << entry.keycode << ", "
+ << entry.shift_pressed << ", " << entry.ctrl_pressed << ", "
+ << entry.alt_pressed;
+ }
+}
+#endif // USE_ASH
« no previous file with comments | « chrome/browser/ui/views/accelerator_table.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698