OLD | NEW |
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } | 105 } |
106 | 106 |
| 107 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) { |
| 108 ExtensionTestMessageListener launched_listener("Launched", false); |
| 109 LoadAndLaunchPlatformApp("context_menu_click"); |
| 110 |
| 111 // Wait for the extension to tell us it's initialized its context menus and |
| 112 // launched a window. |
| 113 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| 114 |
| 115 // Test that the menu item shows up |
| 116 WebContents* web_contents = GetFirstShellWindowWebContents(); |
| 117 ASSERT_TRUE(web_contents); |
| 118 WebKit::WebContextMenuData data; |
| 119 content::ContextMenuParams params(data); |
| 120 params.page_url = GURL("http://foo.bar"); |
| 121 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents, |
| 122 params); |
| 123 menu->Init(); |
| 124 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); |
| 125 |
| 126 // Execute the menu item |
| 127 ExtensionTestMessageListener onclicked_listener("onClicked fired for id1", |
| 128 false); |
| 129 menu->ExecuteCommand(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST); |
| 130 |
| 131 ASSERT_TRUE(onclicked_listener.WaitUntilSatisfied()); |
| 132 } |
| 133 |
107 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) { | 134 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) { |
108 ASSERT_TRUE(StartTestServer()); | 135 ASSERT_TRUE(StartTestServer()); |
109 ASSERT_TRUE(RunPlatformAppTest("platform_apps/navigation")) << message_; | 136 ASSERT_TRUE(RunPlatformAppTest("platform_apps/navigation")) << message_; |
110 } | 137 } |
111 | 138 |
112 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) { | 139 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) { |
113 ASSERT_TRUE(StartTestServer()); | 140 ASSERT_TRUE(StartTestServer()); |
114 ASSERT_TRUE(RunPlatformAppTest("platform_apps/iframes")) << message_; | 141 ASSERT_TRUE(RunPlatformAppTest("platform_apps/iframes")) << message_; |
115 } | 142 } |
116 | 143 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 ASSERT_TRUE(StartTestServer()); | 336 ASSERT_TRUE(StartTestServer()); |
310 content::WindowedNotificationObserver observer( | 337 content::WindowedNotificationObserver observer( |
311 chrome::NOTIFICATION_TAB_ADDED, | 338 chrome::NOTIFICATION_TAB_ADDED, |
312 content::Source<content::WebContentsDelegate>(browser())); | 339 content::Source<content::WebContentsDelegate>(browser())); |
313 LoadAndLaunchPlatformApp("open_link"); | 340 LoadAndLaunchPlatformApp("open_link"); |
314 observer.Wait(); | 341 observer.Wait(); |
315 ASSERT_EQ(2, browser()->tab_count()); | 342 ASSERT_EQ(2, browser()->tab_count()); |
316 } | 343 } |
317 | 344 |
318 } // namespace extensions | 345 } // namespace extensions |
OLD | NEW |