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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 1637743002: Identify context menus being opened via the long press gesture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add the MENU_SOURCE_LONG_TAP context menu source type and ensure that it gets sent from blink in th… Created 4 years, 10 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 "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 3738 matching lines...) Expand 10 before | Expand all | Expand 10 after
3749 // getting called. This means that the request worked correctly. 3749 // getting called. This means that the request worked correctly.
3750 ContextMenuParams context_menu_params; 3750 ContextMenuParams context_menu_params;
3751 context_menu_params.source_type = ui::MENU_SOURCE_MOUSE; 3751 context_menu_params.source_type = ui::MENU_SOURCE_MOUSE;
3752 contents()->ShowContextMenu(contents()->GetRenderViewHost()->GetMainFrame(), 3752 contents()->ShowContextMenu(contents()->GetRenderViewHost()->GetMainFrame(),
3753 context_menu_params); 3753 context_menu_params);
3754 EXPECT_TRUE(delegate->context_menu_request_received()); 3754 EXPECT_TRUE(delegate->context_menu_request_received());
3755 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_MOUSE); 3755 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_MOUSE);
3756 3756
3757 // A context menu request with the MENU_SOURCE_TOUCH source type should 3757 // A context menu request with the MENU_SOURCE_TOUCH source type should
3758 // result in the MockWebContentsViewDelegate::ShowContextMenu method 3758 // result in the MockWebContentsViewDelegate::ShowContextMenu method
3759 // getting called on non Windows platforms. This means that the request 3759 // getting called on all platforms. This means that the request worked
3760 // worked correctly. On Windows this should be blocked. 3760 // correctly.
3761 delegate->ClearState(); 3761 delegate->ClearState();
3762 context_menu_params.source_type = ui::MENU_SOURCE_TOUCH; 3762 context_menu_params.source_type = ui::MENU_SOURCE_TOUCH;
3763 contents()->ShowContextMenu(contents()->GetRenderViewHost()->GetMainFrame(), 3763 contents()->ShowContextMenu(contents()->GetRenderViewHost()->GetMainFrame(),
3764 context_menu_params); 3764 context_menu_params);
3765 EXPECT_TRUE(delegate->context_menu_request_received());
3766
3767 // A context menu request with the MENU_SOURCE_LONG_TAP source type should
3768 // result in the MockWebContentsViewDelegate::ShowContextMenu method
3769 // getting called on all platforms. This means that the request worked
3770 // correctly.
3771 delegate->ClearState();
3772 context_menu_params.source_type = ui::MENU_SOURCE_LONG_TAP;
3773 contents()->ShowContextMenu(contents()->GetRenderViewHost()->GetMainFrame(),
3774 context_menu_params);
3775 EXPECT_TRUE(delegate->context_menu_request_received());
3776
3777 // A context menu request with the MENU_SOURCE_LONG_PRESS source type should
3778 // result in the MockWebContentsViewDelegate::ShowContextMenu method
3779 // getting called on non Windows platforms. This means that the request
3780 // worked correctly. On Windows this should be blocked.
3781 delegate->ClearState();
3782 context_menu_params.source_type = ui::MENU_SOURCE_LONG_PRESS;
3783 contents()->ShowContextMenu(contents()->GetRenderViewHost()->GetMainFrame(),
3784 context_menu_params);
3765 #if defined(OS_WIN) 3785 #if defined(OS_WIN)
3766 EXPECT_FALSE(delegate->context_menu_request_received()); 3786 EXPECT_FALSE(delegate->context_menu_request_received());
3767 #else 3787 #else
3768 EXPECT_TRUE(delegate->context_menu_request_received()); 3788 EXPECT_TRUE(delegate->context_menu_request_received());
3769 #endif 3789 #endif
3770 3790
3771 #if defined(OS_WIN) 3791 #if defined(OS_WIN)
3772 // On Windows the context menu request blocked above should be received when 3792 // On Windows the context menu request blocked above should be received when
3773 // the ET_GESTURE_LONG_TAP gesture is sent to the RenderWidgetHostViewAura 3793 // the ET_GESTURE_LONG_TAP gesture is sent to the RenderWidgetHostViewAura
3774 // instance. This means that the touch was released. 3794 // instance. This means that the touch was released.
3775 delegate->ClearState(); 3795 delegate->ClearState();
3776 3796
3777 ui::GestureEventDetails event_details(ui::ET_GESTURE_LONG_TAP); 3797 ui::GestureEventDetails event_details(ui::ET_GESTURE_LONG_TAP);
3778 ui::GestureEvent gesture_event( 3798 ui::GestureEvent gesture_event(
3779 100, 100, 0, ui::EventTimeForNow(), event_details); 3799 100, 100, 0, ui::EventTimeForNow(), event_details);
3780 view()->OnGestureEvent(&gesture_event); 3800 view()->OnGestureEvent(&gesture_event);
3781 3801
3782 EXPECT_TRUE(delegate->context_menu_request_received()); 3802 EXPECT_TRUE(delegate->context_menu_request_received());
3783 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_MOUSE); 3803 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH);
3784 #endif 3804 #endif
3785 3805
3786 RenderViewHostFactory::set_is_real_render_view_host(false); 3806 RenderViewHostFactory::set_is_real_render_view_host(false);
3787 } 3807 }
3788 3808
3789 } // namespace content 3809 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698