| 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 "ui/base/accelerators/accelerator_manager.h" | 5 #include "ui/base/accelerators/accelerator_manager.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 const std::string& id) { | 83 const std::string& id) { |
| 84 accelerator_to_id_[accelerator] = id; | 84 accelerator_to_id_[accelerator] = id; |
| 85 } | 85 } |
| 86 | 86 |
| 87 std::string GetAndClearCommands() { | 87 std::string GetAndClearCommands() { |
| 88 std::string commands; | 88 std::string commands; |
| 89 std::swap(commands, commands_); | 89 std::swap(commands, commands_); |
| 90 return commands; | 90 return commands; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void OnAcceleratorsRegistered( |
| 94 std::vector<ui::Accelerator>& accelerators) { |
| 95 NOT_IMPLEMENTED(); |
| 96 } |
| 97 |
| 98 void OnAcceleratorsUnregistered( |
| 99 std::vector<ui::Accelerator>& accelerators) { |
| 100 NOT_IMPLEMENTED(); |
| 101 } |
| 93 // AcceleratorManagerDelegate: | 102 // AcceleratorManagerDelegate: |
| 94 void OnAcceleratorRegistered(const Accelerator& accelerator) override { | 103 void OnAcceleratorRegistered(const Accelerator& accelerator) override { |
| 95 if (!commands_.empty()) | 104 if (!commands_.empty()) |
| 96 commands_ += " "; | 105 commands_ += " "; |
| 97 commands_ += "Register " + accelerator_to_id_[accelerator]; | 106 commands_ += "Register " + accelerator_to_id_[accelerator]; |
| 98 } | 107 } |
| 99 void OnAcceleratorUnregistered(const Accelerator& accelerator) override { | 108 void OnAcceleratorUnregistered(const Accelerator& accelerator) override { |
| 100 if (!commands_.empty()) | 109 if (!commands_.empty()) |
| 101 commands_ += " "; | 110 commands_ += " "; |
| 102 commands_ += "Unregister " + accelerator_to_id_[accelerator]; | 111 commands_ += "Unregister " + accelerator_to_id_[accelerator]; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 EXPECT_EQ("Register a", delegate_.GetAndClearCommands()); | 281 EXPECT_EQ("Register a", delegate_.GetAndClearCommands()); |
| 273 manager_.UnregisterAll(&target); | 282 manager_.UnregisterAll(&target); |
| 274 EXPECT_EQ("Unregister a", delegate_.GetAndClearCommands()); | 283 EXPECT_EQ("Unregister a", delegate_.GetAndClearCommands()); |
| 275 manager_.Register(accelerator_a, AcceleratorManager::kNormalPriority, | 284 manager_.Register(accelerator_a, AcceleratorManager::kNormalPriority, |
| 276 &target); | 285 &target); |
| 277 EXPECT_EQ("Register a", delegate_.GetAndClearCommands()); | 286 EXPECT_EQ("Register a", delegate_.GetAndClearCommands()); |
| 278 } | 287 } |
| 279 | 288 |
| 280 } // namespace test | 289 } // namespace test |
| 281 } // namespace ui | 290 } // namespace ui |
| OLD | NEW |