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

Side by Side Diff: ui/base/accelerators/accelerator_manager_unittest.cc

Issue 2751323002: Converts ui::Accelerator::type to an enum (Closed)
Patch Set: remove dcheck Created 3 years, 9 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
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 "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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 Accelerator accelerator(GetAccelerator(VKEY_A, modifiers)); 240 Accelerator accelerator(GetAccelerator(VKEY_A, modifiers));
241 manager_.Register({accelerator}, AcceleratorManager::kNormalPriority, 241 manager_.Register({accelerator}, AcceleratorManager::kNormalPriority,
242 &target); 242 &target);
243 243
244 // The registered accelerator is processed. 244 // The registered accelerator is processed.
245 const int last_count = target.accelerator_pressed_count(); 245 const int last_count = target.accelerator_pressed_count();
246 EXPECT_TRUE(manager_.Process(accelerator)) << i; 246 EXPECT_TRUE(manager_.Process(accelerator)) << i;
247 EXPECT_EQ(last_count + 1, target.accelerator_pressed_count()) << i; 247 EXPECT_EQ(last_count + 1, target.accelerator_pressed_count()) << i;
248 248
249 // The non-registered accelerators are not processed. 249 // The non-registered accelerators are not processed.
250 accelerator.set_type(ET_UNKNOWN); 250 accelerator.set_key_state(Accelerator::KeyState::RELEASED);
251 EXPECT_FALSE(manager_.Process(accelerator)) << i; // different type
252 accelerator.set_type(ET_KEY_RELEASED);
253 EXPECT_FALSE(manager_.Process(accelerator)) << i; // different type 251 EXPECT_FALSE(manager_.Process(accelerator)) << i; // different type
254 252
255 EXPECT_FALSE(manager_.Process(GetAccelerator(VKEY_UNKNOWN, modifiers))) 253 EXPECT_FALSE(manager_.Process(GetAccelerator(VKEY_UNKNOWN, modifiers)))
256 << i; // different vkey 254 << i; // different vkey
257 EXPECT_FALSE(manager_.Process(GetAccelerator(VKEY_B, modifiers))) 255 EXPECT_FALSE(manager_.Process(GetAccelerator(VKEY_B, modifiers)))
258 << i; // different vkey 256 << i; // different vkey
259 EXPECT_FALSE(manager_.Process(GetAccelerator(VKEY_SHIFT, modifiers))) 257 EXPECT_FALSE(manager_.Process(GetAccelerator(VKEY_SHIFT, modifiers)))
260 << i; // different vkey 258 << i; // different vkey
261 259
262 for (size_t test_i = 0; test_i < (1 << arraysize(kAcceleratorModifiers)); 260 for (size_t test_i = 0; test_i < (1 << arraysize(kAcceleratorModifiers));
(...skipping 23 matching lines...) Expand all
286 EXPECT_EQ("Register a", delegate_.GetAndClearCommands()); 284 EXPECT_EQ("Register a", delegate_.GetAndClearCommands());
287 manager_.UnregisterAll(&target); 285 manager_.UnregisterAll(&target);
288 EXPECT_EQ("Unregister a", delegate_.GetAndClearCommands()); 286 EXPECT_EQ("Unregister a", delegate_.GetAndClearCommands());
289 manager_.Register({accelerator_a}, AcceleratorManager::kNormalPriority, 287 manager_.Register({accelerator_a}, AcceleratorManager::kNormalPriority,
290 &target); 288 &target);
291 EXPECT_EQ("Register a", delegate_.GetAndClearCommands()); 289 EXPECT_EQ("Register a", delegate_.GetAndClearCommands());
292 } 290 }
293 291
294 } // namespace test 292 } // namespace test
295 } // namespace ui 293 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698