| OLD | NEW |
| 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/common/wm/window_state.h" | 9 #include "ash/common/wm/window_state.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1989 TEST_F(EventRewriterAshTest, TopRowKeysAreFunctionKeys) { | 1989 TEST_F(EventRewriterAshTest, TopRowKeysAreFunctionKeys) { |
| 1990 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(1)); | 1990 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(1)); |
| 1991 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window.get()); | 1991 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window.get()); |
| 1992 window_state->Activate(); | 1992 window_state->Activate(); |
| 1993 ScopedVector<ui::Event> events; | 1993 ScopedVector<ui::Event> events; |
| 1994 | 1994 |
| 1995 // Create a simulated keypress of F1 targetted at the window. | 1995 // Create a simulated keypress of F1 targetted at the window. |
| 1996 ui::KeyEvent press_f1(ui::ET_KEY_PRESSED, ui::VKEY_F1, ui::DomCode::F1, | 1996 ui::KeyEvent press_f1(ui::ET_KEY_PRESSED, ui::VKEY_F1, ui::DomCode::F1, |
| 1997 ui::EF_NONE, ui::DomKey::F1, ui::EventTimeForNow()); | 1997 ui::EF_NONE, ui::DomKey::F1, ui::EventTimeForNow()); |
| 1998 | 1998 |
| 1999 // Simulate an apps v2 window that has requested top row keys as function | |
| 2000 // keys. The event should not be rewritten. | |
| 2001 window_state->set_top_row_keys_are_function_keys(true); | |
| 2002 ui::EventDispatchDetails details = Send(&press_f1); | |
| 2003 ASSERT_FALSE(details.dispatcher_destroyed); | |
| 2004 PopEvents(&events); | |
| 2005 EXPECT_EQ(1u, events.size()); | |
| 2006 EXPECT_EQ( | |
| 2007 GetExpectedResultAsString(ui::ET_KEY_PRESSED, ui::VKEY_F1, | |
| 2008 ui::DomCode::F1, ui::EF_NONE, ui::DomKey::F1), | |
| 2009 GetKeyEventAsString(*static_cast<ui::KeyEvent*>(events[0]))); | |
| 2010 | |
| 2011 // The event should also not be rewritten if the send-function-keys pref is | 1999 // The event should also not be rewritten if the send-function-keys pref is |
| 2012 // additionally set, for both apps v2 and regular windows. | 2000 // additionally set, for both apps v2 and regular windows. |
| 2013 BooleanPrefMember send_function_keys_pref; | 2001 BooleanPrefMember send_function_keys_pref; |
| 2014 send_function_keys_pref.Init(prefs::kLanguageSendFunctionKeys, prefs()); | 2002 send_function_keys_pref.Init(prefs::kLanguageSendFunctionKeys, prefs()); |
| 2015 send_function_keys_pref.SetValue(true); | 2003 send_function_keys_pref.SetValue(true); |
| 2016 window_state->set_top_row_keys_are_function_keys(false); | 2004 ui::EventDispatchDetails details = Send(&press_f1); |
| 2017 details = Send(&press_f1); | |
| 2018 ASSERT_FALSE(details.dispatcher_destroyed); | 2005 ASSERT_FALSE(details.dispatcher_destroyed); |
| 2019 PopEvents(&events); | 2006 PopEvents(&events); |
| 2020 EXPECT_EQ(1u, events.size()); | 2007 EXPECT_EQ(1u, events.size()); |
| 2021 EXPECT_EQ( | 2008 EXPECT_EQ( |
| 2022 GetExpectedResultAsString(ui::ET_KEY_PRESSED, ui::VKEY_F1, | 2009 GetExpectedResultAsString(ui::ET_KEY_PRESSED, ui::VKEY_F1, |
| 2023 ui::DomCode::F1, ui::EF_NONE, ui::DomKey::F1), | 2010 ui::DomCode::F1, ui::EF_NONE, ui::DomKey::F1), |
| 2024 GetKeyEventAsString(*static_cast<ui::KeyEvent*>(events[0]))); | 2011 GetKeyEventAsString(*static_cast<ui::KeyEvent*>(events[0]))); |
| 2025 | 2012 |
| 2026 // If the pref isn't set when an event is sent to a regular window, F1 is | 2013 // If the pref isn't set when an event is sent to a regular window, F1 is |
| 2027 // rewritten to the back key. | 2014 // rewritten to the back key. |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2626 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN)); | 2613 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN)); |
| 2627 EXPECT_TRUE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN)); | 2614 EXPECT_TRUE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN)); |
| 2628 | 2615 |
| 2629 // Turn off AltGr and Mod3. | 2616 // Turn off AltGr and Mod3. |
| 2630 sticky_keys_controller_->SetModifiersEnabled(false, false); | 2617 sticky_keys_controller_->SetModifiersEnabled(false, false); |
| 2631 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN)); | 2618 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN)); |
| 2632 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN)); | 2619 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN)); |
| 2633 } | 2620 } |
| 2634 | 2621 |
| 2635 } // namespace chromeos | 2622 } // namespace chromeos |
| OLD | NEW |