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

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: Created 8 years, 4 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 #include "chrome/app/chrome_command_ids.h" 5 #include "chrome/app/chrome_command_ids.h"
6 #include "chrome/browser/automation/automation_util.h" 6 #include "chrome/browser/automation/automation_util.h"
7 #include "chrome/browser/tab_contents/render_view_context_menu.h" 7 #include "chrome/browser/tab_contents/render_view_context_menu.h"
8 #include "chrome/browser/extensions/extension_test_message_listener.h" 8 #include "chrome/browser/extensions/extension_test_message_listener.h"
9 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 9 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
10 #include "chrome/browser/extensions/shell_window_registry.h" 10 #include "chrome/browser/extensions/shell_window_registry.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 WebKit::WebContextMenuData data; 95 WebKit::WebContextMenuData data;
96 content::ContextMenuParams params(data); 96 content::ContextMenuParams params(data);
97 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents, 97 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents,
98 params); 98 params);
99 menu->Init(); 99 menu->Init();
100 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); 100 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
101 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); 101 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
102 ASSERT_TRUE(menu->HasCommandWithId(IDC_RELOAD)); 102 ASSERT_TRUE(menu->HasCommandWithId(IDC_RELOAD));
103 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); 103 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
104 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); 104 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
105 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
106 }
107
108 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuTextField) {
109 ExtensionTestMessageListener launched_listener("Launched", false);
110 LoadAndLaunchPlatformApp("context_menu");
111
112 // Wait for the extension to tell us it's initialized its context menus and
113 // launched a window.
114 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
115
116 // The context_menu app has one context menu item. This, along with a
117 // separator and the developer tools, is all that should be in the menu.
118 WebContents* web_contents = GetFirstShellWindowWebContents();
119 ASSERT_TRUE(web_contents);
120 WebKit::WebContextMenuData data;
121 content::ContextMenuParams params(data);
122 params.is_editable = true;
123 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents,
124 params);
125 menu->Init();
126 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
127 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
128 ASSERT_TRUE(menu->HasCommandWithId(IDC_RELOAD));
129 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
130 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY));
131 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
132 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
105 } 133 }
106 134
107 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) { 135 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) {
108 ExtensionTestMessageListener launched_listener("Launched", false); 136 ExtensionTestMessageListener launched_listener("Launched", false);
109 LoadAndLaunchPlatformApp("context_menu_click"); 137 LoadAndLaunchPlatformApp("context_menu_click");
110 138
111 // Wait for the extension to tell us it's initialized its context menus and 139 // Wait for the extension to tell us it's initialized its context menus and
112 // launched a window. 140 // launched a window.
113 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 141 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
114 142
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 ASSERT_TRUE(StartTestServer()); 364 ASSERT_TRUE(StartTestServer());
337 content::WindowedNotificationObserver observer( 365 content::WindowedNotificationObserver observer(
338 chrome::NOTIFICATION_TAB_ADDED, 366 chrome::NOTIFICATION_TAB_ADDED,
339 content::Source<content::WebContentsDelegate>(browser())); 367 content::Source<content::WebContentsDelegate>(browser()));
340 LoadAndLaunchPlatformApp("open_link"); 368 LoadAndLaunchPlatformApp("open_link");
341 observer.Wait(); 369 observer.Wait();
342 ASSERT_EQ(2, browser()->tab_count()); 370 ASSERT_EQ(2, browser()->tab_count());
343 } 371 }
344 372
345 } // namespace extensions 373 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698