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 listener("onClicked fired for id1", false); | |
Mihai Parparita -not on Chrome
2012/08/16 19:52:42
Not: call this onclicked_listener.
| |
128 menu->ExecuteCommand(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST); | |
129 | |
130 ASSERT_TRUE(listener.WaitUntilSatisfied()); | |
131 } | |
132 | |
107 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) { | 133 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) { |
108 ASSERT_TRUE(StartTestServer()); | 134 ASSERT_TRUE(StartTestServer()); |
109 ASSERT_TRUE(RunPlatformAppTest("platform_apps/navigation")) << message_; | 135 ASSERT_TRUE(RunPlatformAppTest("platform_apps/navigation")) << message_; |
110 } | 136 } |
111 | 137 |
112 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) { | 138 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) { |
113 ASSERT_TRUE(StartTestServer()); | 139 ASSERT_TRUE(StartTestServer()); |
114 ASSERT_TRUE(RunPlatformAppTest("platform_apps/iframes")) << message_; | 140 ASSERT_TRUE(RunPlatformAppTest("platform_apps/iframes")) << message_; |
115 } | 141 } |
116 | 142 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 ASSERT_TRUE(StartTestServer()); | 335 ASSERT_TRUE(StartTestServer()); |
310 content::WindowedNotificationObserver observer( | 336 content::WindowedNotificationObserver observer( |
311 chrome::NOTIFICATION_TAB_ADDED, | 337 chrome::NOTIFICATION_TAB_ADDED, |
312 content::Source<content::WebContentsDelegate>(browser())); | 338 content::Source<content::WebContentsDelegate>(browser())); |
313 LoadAndLaunchPlatformApp("open_link"); | 339 LoadAndLaunchPlatformApp("open_link"); |
314 observer.Wait(); | 340 observer.Wait(); |
315 ASSERT_EQ(2, browser()->tab_count()); | 341 ASSERT_EQ(2, browser()->tab_count()); |
316 } | 342 } |
317 | 343 |
318 } // namespace extensions | 344 } // namespace extensions |
OLD | NEW |