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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/accelerator_table.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include <set>
6
7 #include "base/basictypes.h"
8 #include "chrome/browser/ui/views/accelerator_table.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 #if defined(USE_ASH)
12 #include "ash/accelerators/accelerator_table.h"
13 #endif // USE_ASH
14
15 namespace {
16
17 struct Cmp {
18 bool operator()(const browser::AcceleratorMapping& lhs,
19 const browser::AcceleratorMapping& rhs) {
20 if (lhs.keycode != rhs.keycode)
21 return lhs.keycode < rhs.keycode;
22 if (lhs.shift_pressed != rhs.shift_pressed)
23 return lhs.shift_pressed < rhs.shift_pressed;
24 if (lhs.ctrl_pressed != rhs.ctrl_pressed)
25 return lhs.ctrl_pressed < rhs.ctrl_pressed;
26 return lhs.alt_pressed < rhs.alt_pressed;
27 // Do not check |command_id|.
28 }
29 };
30
31 } // namespace
32
33 TEST(AcceleratorTableTest, CheckDuplicatedAccelerators) {
34 std::set<browser::AcceleratorMapping, Cmp> acclerators;
35 for (size_t i = 0; i < browser::kAcceleratorMapLength; ++i) {
36 const browser::AcceleratorMapping& entry = browser::kAcceleratorMap[i];
37 EXPECT_TRUE(acclerators.insert(entry).second)
38 << "Duplicated accelerator: " << entry.keycode << ", "
39 << entry.shift_pressed << ", " << entry.ctrl_pressed << ", "
40 << entry.alt_pressed;
41 }
42 }
43
44 #if defined(USE_ASH)
45 TEST(AcceleratorTableTest, CheckDuplicatedAcceleratorsAsh) {
46 std::set<browser::AcceleratorMapping, Cmp> acclerators;
47 for (size_t i = 0; i < browser::kAcceleratorMapLength; ++i) {
48 const browser::AcceleratorMapping& entry = browser::kAcceleratorMap[i];
49 acclerators.insert(entry);
50 }
51 for (size_t i = 0; i < ash::kAcceleratorDataLength; ++i) {
52 const ash::AcceleratorData& ash_entry = ash::kAcceleratorData[i];
53 if (!ash_entry.trigger_on_press)
54 continue; // kAcceleratorMap does not have any release accelerators.
55 browser::AcceleratorMapping entry;
56 entry.keycode = ash_entry.keycode;
57 entry.shift_pressed = ash_entry.shift;
58 entry.ctrl_pressed = ash_entry.ctrl;
59 entry.alt_pressed = ash_entry.alt;
60 entry.command_id = 0; // dummy
61 EXPECT_TRUE(acclerators.insert(entry).second)
62 << "Duplicated accelerator: " << entry.keycode << ", "
63 << entry.shift_pressed << ", " << entry.ctrl_pressed << ", "
64 << entry.alt_pressed;
65 }
66 }
67 #endif // USE_ASH
OLDNEW
« 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