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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm

Issue 10377158: Move keyboard related methods from RenderViewHostDelegate to a new RenderWidgetHostDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove crbug link Created 8 years, 7 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 | Annotate | Revision Log
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 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h" 5 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "content/browser/renderer_host/render_widget_host_delegate.h"
10 #include "content/browser/renderer_host/render_widget_host_impl.h" 11 #include "content/browser/renderer_host/render_widget_host_impl.h"
11 #include "content/common/view_messages.h" 12 #include "content/common/view_messages.h"
12 #include "content/test/mock_render_process_host.h" 13 #include "content/test/mock_render_process_host.h"
13 #include "content/test/test_browser_context.h" 14 #include "content/test/test_browser_context.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "testing/platform_test.h" 17 #include "testing/platform_test.h"
17 18
18 using content::MockRenderProcessHost; 19 using content::MockRenderProcessHost;
19 using content::RenderWidgetHostImpl; 20 using content::RenderWidgetHostImpl;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 NSString* sel_str = [edit_command_name stringByAppendingString:@":"]; 65 NSString* sel_str = [edit_command_name stringByAppendingString:@":"];
65 if (![test_obj respondsToSelector:NSSelectorFromString(sel_str)]) { 66 if (![test_obj respondsToSelector:NSSelectorFromString(sel_str)]) {
66 return false; 67 return false;
67 } 68 }
68 } 69 }
69 70
70 return true; 71 return true;
71 } 72 }
72 } // namespace 73 } // namespace
73 74
75 class MockRenderWidgetHostDelegate : public content::RenderWidgetHostDelegate {
76 public:
77 MockRenderWidgetHostDelegate() {}
78 virtual ~MockRenderWidgetHostDelegate() {}
79 };
80
74 // Create a RenderWidget for which we can filter messages. 81 // Create a RenderWidget for which we can filter messages.
75 class RenderWidgetHostEditCommandCounter : public RenderWidgetHostImpl { 82 class RenderWidgetHostEditCommandCounter : public RenderWidgetHostImpl {
76 public: 83 public:
77 RenderWidgetHostEditCommandCounter(content::RenderProcessHost* process, 84 RenderWidgetHostEditCommandCounter(
78 int routing_id) 85 content::RenderWidgetHostDelegate* delegate,
79 : RenderWidgetHostImpl(process, routing_id), 86 content::RenderProcessHost* process,
87 int routing_id)
88 : RenderWidgetHostImpl(delegate, process, routing_id),
80 edit_command_message_count_(0) { 89 edit_command_message_count_(0) {
81 } 90 }
82 91
83 virtual bool Send(IPC::Message* message) { 92 virtual bool Send(IPC::Message* message) {
84 if (message->type() == ViewMsg_ExecuteEditCommand::ID) 93 if (message->type() == ViewMsg_ExecuteEditCommand::ID)
85 edit_command_message_count_++; 94 edit_command_message_count_++;
86 return RenderWidgetHostImpl::Send(message); 95 return RenderWidgetHostImpl::Send(message);
87 } 96 }
88 97
89 unsigned int edit_command_message_count_; 98 unsigned int edit_command_message_count_;
90 }; 99 };
91 100
92 101
93 // Tests that editing commands make it through the pipeline all the way to 102 // Tests that editing commands make it through the pipeline all the way to
94 // RenderWidgetHost. 103 // RenderWidgetHost.
95 // Disabled, http://crbug.com/93286. 104 // Disabled, http://crbug.com/93286.
96 TEST_F(RenderWidgetHostViewMacEditCommandHelperTest, 105 TEST_F(RenderWidgetHostViewMacEditCommandHelperTest,
97 DISABLED_TestEditingCommandDelivery) { 106 DISABLED_TestEditingCommandDelivery) {
98 RenderWidgetHostViewMacEditCommandHelper helper; 107 RenderWidgetHostViewMacEditCommandHelper helper;
99 NSArray* edit_command_strings = helper.GetEditSelectorNames(); 108 NSArray* edit_command_strings = helper.GetEditSelectorNames();
100 109
101 // Set up a mock render widget and set expectations. 110 // Set up a mock render widget and set expectations.
102 MessageLoopForUI message_loop; 111 MessageLoopForUI message_loop;
103 TestBrowserContext browser_context; 112 TestBrowserContext browser_context;
104 MockRenderProcessHost mock_process(&browser_context); 113 MockRenderProcessHost mock_process(&browser_context);
105 RenderWidgetHostEditCommandCounter render_widget(&mock_process, 0); 114 MockRenderWidgetHostDelegate delegate;
115 RenderWidgetHostEditCommandCounter render_widget(&delegate, &mock_process, 0);
106 116
107 // RenderWidgetHostViewMac self destructs (RenderWidgetHostViewMacCocoa 117 // RenderWidgetHostViewMac self destructs (RenderWidgetHostViewMacCocoa
108 // takes ownership) so no need to delete it ourselves. 118 // takes ownership) so no need to delete it ourselves.
109 RenderWidgetHostViewMac* rwhvm = static_cast<RenderWidgetHostViewMac*>( 119 RenderWidgetHostViewMac* rwhvm = static_cast<RenderWidgetHostViewMac*>(
110 content::RenderWidgetHostView::CreateViewForWidget(&render_widget)); 120 content::RenderWidgetHostView::CreateViewForWidget(&render_widget));
111 121
112 RenderWidgetHostViewMacOwner* rwhwvm_owner = 122 RenderWidgetHostViewMacOwner* rwhwvm_owner =
113 [[[RenderWidgetHostViewMacOwner alloc] 123 [[[RenderWidgetHostViewMacOwner alloc]
114 initWithRenderWidgetHostViewMac:rwhvm] autorelease]; 124 initWithRenderWidgetHostViewMac:rwhvm] autorelease];
115 125
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 SEL select_all = NSSelectorFromString(@"selectAll:"); 174 SEL select_all = NSSelectorFromString(@"selectAll:");
165 ASSERT_TRUE(helper.IsMenuItemEnabled(select_all, rwhvm_owner)); 175 ASSERT_TRUE(helper.IsMenuItemEnabled(select_all, rwhvm_owner));
166 176
167 // Random selectors should be enabled by the function. 177 // Random selectors should be enabled by the function.
168 SEL garbage_selector = NSSelectorFromString(@"randomGarbageSelector:"); 178 SEL garbage_selector = NSSelectorFromString(@"randomGarbageSelector:");
169 ASSERT_FALSE(helper.IsMenuItemEnabled(garbage_selector, rwhvm_owner)); 179 ASSERT_FALSE(helper.IsMenuItemEnabled(garbage_selector, rwhvm_owner));
170 180
171 // TODO(jeremy): Currently IsMenuItemEnabled just returns true for all edit 181 // TODO(jeremy): Currently IsMenuItemEnabled just returns true for all edit
172 // selectors. Once we go past that we should do more extensive testing here. 182 // selectors. Once we go past that we should do more extensive testing here.
173 } 183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698