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

Side by Side Diff: chrome/browser/chromeos/events/event_rewriter_unittest.cc

Issue 1908633002: Introduce ScopedCommandLine (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update CrOS Unit Test Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/chromeos/events/event_rewriter.h" 5 #include "chrome/browser/chromeos/events/event_rewriter.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/sticky_keys/sticky_keys_controller.h" 10 #include "ash/sticky_keys/sticky_keys_controller.h"
11 #include "ash/sticky_keys/sticky_keys_overlay.h" 11 #include "ash/sticky_keys/sticky_keys_overlay.h"
12 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
13 #include "ash/wm/window_state.h" 13 #include "ash/wm/window_state.h"
14 #include "ash/wm/window_state_aura.h" 14 #include "ash/wm/window_state_aura.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/test/command_line_test_util.h"
18 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" 19 #include "chrome/browser/chromeos/input_method/input_method_configuration.h"
19 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" 20 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h"
20 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 21 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
21 #include "chrome/browser/chromeos/preferences.h" 22 #include "chrome/browser/chromeos/preferences.h"
22 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
23 #include "chromeos/chromeos_switches.h" 24 #include "chromeos/chromeos_switches.h"
24 #include "components/prefs/pref_member.h" 25 #include "components/prefs/pref_member.h"
25 #include "components/syncable_prefs/testing_pref_service_syncable.h" 26 #include "components/syncable_prefs/testing_pref_service_syncable.h"
26 #include "components/user_manager/fake_user_manager.h" 27 #include "components/user_manager/fake_user_manager.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 CheckKeyTestCase(&rewriter, test); 483 CheckKeyTestCase(&rewriter, test);
483 } 484 }
484 } 485 }
485 486
486 TEST_F(EventRewriterTest, TestRewriteNumPadKeys) { 487 TEST_F(EventRewriterTest, TestRewriteNumPadKeys) {
487 TestRewriteNumPadKeys(); 488 TestRewriteNumPadKeys();
488 } 489 }
489 490
490 TEST_F(EventRewriterTest, TestRewriteNumPadKeysWithDiamondKeyFlag) { 491 TEST_F(EventRewriterTest, TestRewriteNumPadKeysWithDiamondKeyFlag) {
491 // Make sure the num lock works correctly even when Diamond key exists. 492 // Make sure the num lock works correctly even when Diamond key exists.
492 const base::CommandLine original_cl(*base::CommandLine::ForCurrentProcess()); 493 base::test::ScopedCommandLine scoped_command_line;
493 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 494 scoped_command_line.GetProcessCommandLine()->AppendSwitchASCII(
494 chromeos::switches::kHasChromeOSDiamondKey, ""); 495 chromeos::switches::kHasChromeOSDiamondKey, "");
495
496 TestRewriteNumPadKeys(); 496 TestRewriteNumPadKeys();
497 *base::CommandLine::ForCurrentProcess() = original_cl;
498 } 497 }
499 498
500 // Tests if the rewriter can handle a Command + Num Pad event. 499 // Tests if the rewriter can handle a Command + Num Pad event.
501 void EventRewriterTest::TestRewriteNumPadKeysOnAppleKeyboard() { 500 void EventRewriterTest::TestRewriteNumPadKeysOnAppleKeyboard() {
502 syncable_prefs::TestingPrefServiceSyncable prefs; 501 syncable_prefs::TestingPrefServiceSyncable prefs;
503 EventRewriter rewriter(NULL); 502 EventRewriter rewriter(NULL);
504 rewriter.KeyboardDeviceAddedForTesting(kKeyboardDeviceId, "Apple Keyboard"); 503 rewriter.KeyboardDeviceAddedForTesting(kKeyboardDeviceId, "Apple Keyboard");
505 rewriter.set_last_keyboard_device_id_for_testing(kKeyboardDeviceId); 504 rewriter.set_last_keyboard_device_id_for_testing(kKeyboardDeviceId);
506 rewriter.set_pref_service_for_testing(&prefs); 505 rewriter.set_pref_service_for_testing(&prefs);
507 506
(...skipping 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN)); 2628 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN));
2630 EXPECT_TRUE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN)); 2629 EXPECT_TRUE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN));
2631 2630
2632 // Turn off AltGr and Mod3. 2631 // Turn off AltGr and Mod3.
2633 sticky_keys_controller_->SetModifiersEnabled(false, false); 2632 sticky_keys_controller_->SetModifiersEnabled(false, false);
2634 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN)); 2633 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN));
2635 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN)); 2634 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN));
2636 } 2635 }
2637 2636
2638 } // namespace chromeos 2637 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698