| 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/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" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 #include "ui/events/devices/x11/touch_factory_x11.h" | 39 #include "ui/events/devices/x11/touch_factory_x11.h" |
| 40 #include "ui/events/event_utils.h" | 40 #include "ui/events/event_utils.h" |
| 41 #include "ui/events/test/events_test_utils_x11.h" | 41 #include "ui/events/test/events_test_utils_x11.h" |
| 42 #include "ui/gfx/x/x11_types.h" | 42 #include "ui/gfx/x/x11_types.h" |
| 43 #endif | 43 #endif |
| 44 | 44 |
| 45 namespace { | 45 namespace { |
| 46 | 46 |
| 47 // The device id of the test touchpad device. | 47 // The device id of the test touchpad device. |
| 48 const unsigned int kTouchPadDeviceId = 1; | 48 const int kTouchPadDeviceId = 1; |
| 49 const int kKeyboardDeviceId = 2; | 49 const int kKeyboardDeviceId = 2; |
| 50 const int kMasterKeyboardDeviceId = 3; | 50 const int kMasterKeyboardDeviceId = 3; |
| 51 | 51 |
| 52 std::string GetExpectedResultAsString(ui::KeyboardCode ui_keycode, | 52 std::string GetExpectedResultAsString(ui::KeyboardCode ui_keycode, |
| 53 int ui_flags, | 53 int ui_flags, |
| 54 ui::EventType ui_type) { | 54 ui::EventType ui_type) { |
| 55 return base::StringPrintf("ui_keycode=0x%X ui_flags=0x%X ui_type=%d", | 55 return base::StringPrintf("ui_keycode=0x%X ui_flags=0x%X ui_type=%d", |
| 56 ui_keycode, | 56 ui_keycode, |
| 57 ui_flags & ~ui::EF_IS_REPEAT, | 57 ui_flags & ~ui::EF_IS_REPEAT, |
| 58 ui_type); | 58 ui_type); |
| (...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1924 details = Send(&press_f1); | 1924 details = Send(&press_f1); |
| 1925 ASSERT_FALSE(details.dispatcher_destroyed); | 1925 ASSERT_FALSE(details.dispatcher_destroyed); |
| 1926 PopEvents(&events); | 1926 PopEvents(&events); |
| 1927 EXPECT_EQ(1u, events.size()); | 1927 EXPECT_EQ(1u, events.size()); |
| 1928 EXPECT_EQ(GetExpectedResultAsString( | 1928 EXPECT_EQ(GetExpectedResultAsString( |
| 1929 ui::VKEY_BROWSER_BACK, ui::EF_NONE, ui::ET_KEY_PRESSED), | 1929 ui::VKEY_BROWSER_BACK, ui::EF_NONE, ui::ET_KEY_PRESSED), |
| 1930 GetKeyEventAsString(*static_cast<ui::KeyEvent*>(events[0]))); | 1930 GetKeyEventAsString(*static_cast<ui::KeyEvent*>(events[0]))); |
| 1931 } | 1931 } |
| 1932 | 1932 |
| 1933 TEST_F(EventRewriterTest, TestRewrittenModifierClick) { | 1933 TEST_F(EventRewriterTest, TestRewrittenModifierClick) { |
| 1934 std::vector<unsigned int> device_list; | 1934 std::vector<int> device_list; |
| 1935 device_list.push_back(10); | 1935 device_list.push_back(10); |
| 1936 ui::TouchFactory::GetInstance()->SetPointerDeviceForTest(device_list); | 1936 ui::TouchFactory::GetInstance()->SetPointerDeviceForTest(device_list); |
| 1937 | 1937 |
| 1938 // Remap Control to Alt. | 1938 // Remap Control to Alt. |
| 1939 TestingPrefServiceSyncable prefs; | 1939 TestingPrefServiceSyncable prefs; |
| 1940 chromeos::Preferences::RegisterProfilePrefs(prefs.registry()); | 1940 chromeos::Preferences::RegisterProfilePrefs(prefs.registry()); |
| 1941 IntegerPrefMember control; | 1941 IntegerPrefMember control; |
| 1942 control.Init(prefs::kLanguageRemapControlKeyTo, &prefs); | 1942 control.Init(prefs::kLanguageRemapControlKeyTo, &prefs); |
| 1943 control.SetValue(chromeos::input_method::kAltKey); | 1943 control.SetValue(chromeos::input_method::kAltKey); |
| 1944 | 1944 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1963 EXPECT_TRUE(ui::EF_RIGHT_MOUSE_BUTTON & result->flags()); | 1963 EXPECT_TRUE(ui::EF_RIGHT_MOUSE_BUTTON & result->flags()); |
| 1964 EXPECT_FALSE(ui::EF_LEFT_MOUSE_BUTTON & result->flags()); | 1964 EXPECT_FALSE(ui::EF_LEFT_MOUSE_BUTTON & result->flags()); |
| 1965 EXPECT_FALSE(ui::EF_CONTROL_DOWN & result->flags()); | 1965 EXPECT_FALSE(ui::EF_CONTROL_DOWN & result->flags()); |
| 1966 EXPECT_FALSE(ui::EF_ALT_DOWN & result->flags()); | 1966 EXPECT_FALSE(ui::EF_ALT_DOWN & result->flags()); |
| 1967 EXPECT_TRUE(ui::EF_RIGHT_MOUSE_BUTTON & result->flags()); | 1967 EXPECT_TRUE(ui::EF_RIGHT_MOUSE_BUTTON & result->flags()); |
| 1968 } | 1968 } |
| 1969 | 1969 |
| 1970 TEST_F(EventRewriterTest, DontRewriteIfNotRewritten) { | 1970 TEST_F(EventRewriterTest, DontRewriteIfNotRewritten) { |
| 1971 // TODO(kpschoedel): pending changes for crbug.com/360377 | 1971 // TODO(kpschoedel): pending changes for crbug.com/360377 |
| 1972 // to |chromeos::EventRewriter::RewriteLocatedEvent() | 1972 // to |chromeos::EventRewriter::RewriteLocatedEvent() |
| 1973 std::vector<unsigned int> device_list; | 1973 std::vector<int> device_list; |
| 1974 device_list.push_back(10); | 1974 device_list.push_back(10); |
| 1975 device_list.push_back(11); | 1975 device_list.push_back(11); |
| 1976 ui::TouchFactory::GetInstance()->SetPointerDeviceForTest(device_list); | 1976 ui::TouchFactory::GetInstance()->SetPointerDeviceForTest(device_list); |
| 1977 TestingPrefServiceSyncable prefs; | 1977 TestingPrefServiceSyncable prefs; |
| 1978 EventRewriter rewriter(NULL); | 1978 EventRewriter rewriter(NULL); |
| 1979 rewriter.set_pref_service_for_testing(&prefs); | 1979 rewriter.set_pref_service_for_testing(&prefs); |
| 1980 const int kLeftAndAltFlag = ui::EF_LEFT_MOUSE_BUTTON | ui::EF_ALT_DOWN; | 1980 const int kLeftAndAltFlag = ui::EF_LEFT_MOUSE_BUTTON | ui::EF_ALT_DOWN; |
| 1981 | 1981 |
| 1982 // Test Alt + Left click. | 1982 // Test Alt + Left click. |
| 1983 { | 1983 { |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2461 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN)); | 2461 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN)); |
| 2462 EXPECT_TRUE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN)); | 2462 EXPECT_TRUE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN)); |
| 2463 | 2463 |
| 2464 // Turn off AltGr and Mod3. | 2464 // Turn off AltGr and Mod3. |
| 2465 sticky_keys_controller_->SetModifiersEnabled(false, false); | 2465 sticky_keys_controller_->SetModifiersEnabled(false, false); |
| 2466 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN)); | 2466 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_ALTGR_DOWN)); |
| 2467 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN)); | 2467 EXPECT_FALSE(overlay_->GetModifierVisible(ui::EF_MOD3_DOWN)); |
| 2468 } | 2468 } |
| 2469 | 2469 |
| 2470 } // namespace chromeos | 2470 } // namespace chromeos |
| OLD | NEW |