| OLD | NEW |
| 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "chrome/browser/ui/views/accelerator_table.h" | 8 #include "chrome/browser/ui/views/accelerator_table.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/events/event_constants.h" | 10 #include "ui/events/event_constants.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 if (lhs.keycode != rhs.keycode) | 23 if (lhs.keycode != rhs.keycode) |
| 24 return lhs.keycode < rhs.keycode; | 24 return lhs.keycode < rhs.keycode; |
| 25 return lhs.modifiers < rhs.modifiers; | 25 return lhs.modifiers < rhs.modifiers; |
| 26 // Do not check |command_id|. | 26 // Do not check |command_id|. |
| 27 } | 27 } |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 TEST(AcceleratorTableTest, CheckDuplicatedAccelerators) { | 32 TEST(AcceleratorTableTest, CheckDuplicatedAccelerators) { |
| 33 std::set<AcceleratorMapping, Cmp> acclerators; | 33 std::set<AcceleratorMapping, Cmp> accelerators; |
| 34 const std::vector<AcceleratorMapping> accelerator_list(GetAcceleratorList()); | 34 const std::vector<AcceleratorMapping> accelerator_list(GetAcceleratorList()); |
| 35 for (std::vector<AcceleratorMapping>::const_iterator it = | 35 for (std::vector<AcceleratorMapping>::const_iterator it = |
| 36 accelerator_list.begin(); it != accelerator_list.end(); ++it) { | 36 accelerator_list.begin(); it != accelerator_list.end(); ++it) { |
| 37 const AcceleratorMapping& entry = *it; | 37 const AcceleratorMapping& entry = *it; |
| 38 EXPECT_TRUE(acclerators.insert(entry).second) | 38 EXPECT_TRUE(accelerators.insert(entry).second) |
| 39 << "Duplicated accelerator: " << entry.keycode << ", " | 39 << "Duplicated accelerator: " << entry.keycode << ", " |
| 40 << (entry.modifiers & ui::EF_SHIFT_DOWN) << ", " | 40 << (entry.modifiers & ui::EF_SHIFT_DOWN) << ", " |
| 41 << (entry.modifiers & ui::EF_CONTROL_DOWN) << ", " | 41 << (entry.modifiers & ui::EF_CONTROL_DOWN) << ", " |
| 42 << (entry.modifiers & ui::EF_ALT_DOWN); | 42 << (entry.modifiers & ui::EF_ALT_DOWN); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 #if defined(OS_CHROMEOS) | 46 #if defined(OS_CHROMEOS) |
| 47 TEST(AcceleratorTableTest, CheckDuplicatedAcceleratorsAsh) { | 47 TEST(AcceleratorTableTest, CheckDuplicatedAcceleratorsAsh) { |
| 48 std::set<AcceleratorMapping, Cmp> acclerators; | 48 std::set<AcceleratorMapping, Cmp> accelerators; |
| 49 const std::vector<AcceleratorMapping> accelerator_list(GetAcceleratorList()); | 49 const std::vector<AcceleratorMapping> accelerator_list(GetAcceleratorList()); |
| 50 for (std::vector<AcceleratorMapping>::const_iterator it = | 50 for (std::vector<AcceleratorMapping>::const_iterator it = |
| 51 accelerator_list.begin(); it != accelerator_list.end(); ++it) { | 51 accelerator_list.begin(); it != accelerator_list.end(); ++it) { |
| 52 const AcceleratorMapping& entry = *it; | 52 const AcceleratorMapping& entry = *it; |
| 53 acclerators.insert(entry); | 53 accelerators.insert(entry); |
| 54 } | 54 } |
| 55 for (size_t i = 0; i < ash::kAcceleratorDataLength; ++i) { | 55 for (size_t i = 0; i < ash::kAcceleratorDataLength; ++i) { |
| 56 const ash::AcceleratorData& ash_entry = ash::kAcceleratorData[i]; | 56 const ash::AcceleratorData& ash_entry = ash::kAcceleratorData[i]; |
| 57 if (!ash_entry.trigger_on_press) | 57 if (!ash_entry.trigger_on_press) |
| 58 continue; // kAcceleratorMap does not have any release accelerators. | 58 continue; // kAcceleratorMap does not have any release accelerators. |
| 59 // The shortcuts to toggle minimized state, to show the task manager, and | 59 // The shortcuts to toggle minimized state, to show the task manager, and |
| 60 // to toggle touch HUD are defined on browser side as well as ash side by | 60 // to toggle touch HUD are defined on browser side as well as ash side by |
| 61 // design so that web contents can consume these short cuts. (see | 61 // design so that web contents can consume these short cuts. (see |
| 62 // crbug.com/309915, 370019, 412435 and CL) | 62 // crbug.com/309915, 370019, 412435 and CL) |
| 63 if (ash_entry.action == ash::WINDOW_MINIMIZE || | 63 if (ash_entry.action == ash::WINDOW_MINIMIZE || |
| 64 ash_entry.action == ash::SHOW_TASK_MANAGER || | 64 ash_entry.action == ash::SHOW_TASK_MANAGER || |
| 65 ash_entry.action == ash::TOUCH_HUD_PROJECTION_TOGGLE) | 65 ash_entry.action == ash::TOUCH_HUD_PROJECTION_TOGGLE) |
| 66 continue; | 66 continue; |
| 67 AcceleratorMapping entry; | 67 AcceleratorMapping entry; |
| 68 entry.keycode = ash_entry.keycode; | 68 entry.keycode = ash_entry.keycode; |
| 69 entry.modifiers = ash_entry.modifiers; | 69 entry.modifiers = ash_entry.modifiers; |
| 70 entry.command_id = 0; // dummy | 70 entry.command_id = 0; // dummy |
| 71 EXPECT_TRUE(acclerators.insert(entry).second) | 71 EXPECT_TRUE(accelerators.insert(entry).second) |
| 72 << "Duplicated accelerator: " << entry.keycode << ", " | 72 << "Duplicated accelerator: " << entry.keycode << ", " |
| 73 << (entry.modifiers & ui::EF_SHIFT_DOWN) << ", " | 73 << (entry.modifiers & ui::EF_SHIFT_DOWN) << ", " |
| 74 << (entry.modifiers & ui::EF_CONTROL_DOWN) << ", " | 74 << (entry.modifiers & ui::EF_CONTROL_DOWN) << ", " |
| 75 << (entry.modifiers & ui::EF_ALT_DOWN); | 75 << (entry.modifiers & ui::EF_ALT_DOWN); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 #endif // USE_ASH | 78 #endif // USE_ASH |
| 79 | 79 |
| 80 } // namespace chrome | 80 } // namespace chrome |
| OLD | NEW |