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

Side by Side Diff: chrome/browser/extensions/platform_app_browsertest.cc

Issue 10828392: Context menus for text fields in platform apps should show available actions (copy, paste, etc). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix conflicts Created 8 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/tab_contents/render_view_context_menu.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/utf_string_conversions.h"
5 #include "chrome/app/chrome_command_ids.h" 6 #include "chrome/app/chrome_command_ids.h"
6 #include "chrome/browser/automation/automation_util.h" 7 #include "chrome/browser/automation/automation_util.h"
7 #include "chrome/browser/tab_contents/render_view_context_menu.h" 8 #include "chrome/browser/tab_contents/render_view_context_menu.h"
8 #include "chrome/browser/extensions/extension_test_message_listener.h" 9 #include "chrome/browser/extensions/extension_test_message_listener.h"
9 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 10 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
10 #include "chrome/browser/extensions/shell_window_registry.h" 11 #include "chrome/browser/extensions/shell_window_registry.h"
11 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_tabstrip.h" 13 #include "chrome/browser/ui/browser_tabstrip.h"
13 #include "chrome/browser/ui/extensions/application_launch.h" 14 #include "chrome/browser/ui/extensions/application_launch.h"
14 #include "chrome/browser/ui/extensions/shell_window.h" 15 #include "chrome/browser/ui/extensions/shell_window.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 content::ContextMenuParams params(data); 104 content::ContextMenuParams params(data);
104 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents, 105 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents,
105 params); 106 params);
106 menu->Init(); 107 menu->Init();
107 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); 108 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
108 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1)); 109 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1));
109 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); 110 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
110 ASSERT_TRUE(menu->HasCommandWithId(IDC_RELOAD)); 111 ASSERT_TRUE(menu->HasCommandWithId(IDC_RELOAD));
111 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); 112 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
112 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); 113 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
114 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
115 }
116
117 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuTextField) {
118 ExtensionTestMessageListener launched_listener("Launched", false);
119 LoadAndLaunchPlatformApp("context_menu");
120
121 // Wait for the extension to tell us it's initialized its context menus and
122 // launched a window.
123 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
124
125 // The context_menu app has one context menu item. This, along with a
126 // separator and the developer tools, is all that should be in the menu.
127 WebContents* web_contents = GetFirstShellWindowWebContents();
128 ASSERT_TRUE(web_contents);
129 WebKit::WebContextMenuData data;
130 content::ContextMenuParams params(data);
131 params.is_editable = true;
132 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents,
133 params);
134 menu->Init();
135 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
136 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
137 ASSERT_TRUE(menu->HasCommandWithId(IDC_RELOAD));
138 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
139 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY));
140 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
141 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
142 }
143
144 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuSelection) {
145 ExtensionTestMessageListener launched_listener("Launched", false);
146 LoadAndLaunchPlatformApp("context_menu");
147
148 // Wait for the extension to tell us it's initialized its context menus and
149 // launched a window.
150 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
151
152 // The context_menu app has one context menu item. This, along with a
153 // separator and the developer tools, is all that should be in the menu.
154 WebContents* web_contents = GetFirstShellWindowWebContents();
155 ASSERT_TRUE(web_contents);
156 WebKit::WebContextMenuData data;
157 content::ContextMenuParams params(data);
158 params.selection_text = ASCIIToUTF16("Hello World");
159 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents,
160 params);
161 menu->Init();
162 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
163 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
164 ASSERT_TRUE(menu->HasCommandWithId(IDC_RELOAD));
165 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
166 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY));
167 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
168 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
113 } 169 }
114 170
115 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) { 171 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) {
116 ExtensionTestMessageListener launched_listener("Launched", false); 172 ExtensionTestMessageListener launched_listener("Launched", false);
117 LoadAndLaunchPlatformApp("context_menu_click"); 173 LoadAndLaunchPlatformApp("context_menu_click");
118 174
119 // Wait for the extension to tell us it's initialized its context menus and 175 // Wait for the extension to tell us it's initialized its context menus and
120 // launched a window. 176 // launched a window.
121 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 177 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
122 178
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 LoadAndLaunchPlatformApp("open_link"); 404 LoadAndLaunchPlatformApp("open_link");
349 observer.Wait(); 405 observer.Wait();
350 ASSERT_EQ(2, browser()->tab_count()); 406 ASSERT_EQ(2, browser()->tab_count());
351 } 407 }
352 408
353 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) { 409 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) {
354 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_; 410 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_;
355 } 411 }
356 412
357 } // namespace extensions 413 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/tab_contents/render_view_context_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698