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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // Wait for the app icon gets fully loaded. | 87 // Wait for the app icon gets fully loaded. |
88 WaitForAppIconAvailable(panel); | 88 WaitForAppIconAvailable(panel); |
89 | 89 |
90 // First verify on the panel level. | 90 // First verify on the panel level. |
91 gfx::ImageSkia app_icon = panel->app_icon().AsImageSkia(); | 91 gfx::ImageSkia app_icon = panel->app_icon().AsImageSkia(); |
92 EXPECT_EQ(panel::kPanelAppIconSize, app_icon.width()); | 92 EXPECT_EQ(panel::kPanelAppIconSize, app_icon.width()); |
93 EXPECT_EQ(panel::kPanelAppIconSize, app_icon.height()); | 93 EXPECT_EQ(panel::kPanelAppIconSize, app_icon.height()); |
94 | 94 |
95 // Then verify on the native panel level. | 95 // Then verify on the native panel level. |
96 #if !defined(OS_WIN) || !defined(USE_AURA) | 96 #if !defined(OS_WIN) || !defined(USE_AURA) |
97 scoped_ptr<NativePanelTesting> native_panel_testing( | 97 std::unique_ptr<NativePanelTesting> native_panel_testing( |
98 CreateNativePanelTesting(panel)); | 98 CreateNativePanelTesting(panel)); |
99 EXPECT_TRUE(native_panel_testing->VerifyAppIcon()); | 99 EXPECT_TRUE(native_panel_testing->VerifyAppIcon()); |
100 #endif | 100 #endif |
101 | 101 |
102 panel->Close(); | 102 panel->Close(); |
103 } | 103 } |
104 #endif | 104 #endif |
105 | 105 |
106 IN_PROC_BROWSER_TEST_F(PanelExtensionBrowserTest, | 106 IN_PROC_BROWSER_TEST_F(PanelExtensionBrowserTest, |
107 ClosePanelBeforeIconLoadingCompleted) { | 107 ClosePanelBeforeIconLoadingCompleted) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 // Verify basic menu contents. The basic extension does not add any | 149 // Verify basic menu contents. The basic extension does not add any |
150 // context menu items so the panel's menu should include only the | 150 // context menu items so the panel's menu should include only the |
151 // developer tools. | 151 // developer tools. |
152 { | 152 { |
153 content::ContextMenuParams params; | 153 content::ContextMenuParams params; |
154 params.page_url = web_contents->GetURL(); | 154 params.page_url = web_contents->GetURL(); |
155 // Ensure context menu isn't swallowed by WebContentsDelegate (the panel). | 155 // Ensure context menu isn't swallowed by WebContentsDelegate (the panel). |
156 EXPECT_FALSE(web_contents->GetDelegate()->HandleContextMenu(params)); | 156 EXPECT_FALSE(web_contents->GetDelegate()->HandleContextMenu(params)); |
157 | 157 |
158 scoped_ptr<PanelContextMenu> menu( | 158 std::unique_ptr<PanelContextMenu> menu( |
159 new PanelContextMenu(web_contents->GetMainFrame(), params)); | 159 new PanelContextMenu(web_contents->GetMainFrame(), params)); |
160 menu->Init(); | 160 menu->Init(); |
161 | 161 |
162 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); | 162 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); |
163 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); | 163 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); |
164 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_PASTE)); | 164 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_PASTE)); |
165 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); | 165 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); |
166 EXPECT_FALSE(menu->HasCommandWithId(IDC_BACK)); | 166 EXPECT_FALSE(menu->HasCommandWithId(IDC_BACK)); |
167 EXPECT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); | 167 EXPECT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); |
168 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPYLINKLOCATION)); | 168 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPYLINKLOCATION)); |
169 } | 169 } |
170 | 170 |
171 // Verify expected menu contents for editable item. | 171 // Verify expected menu contents for editable item. |
172 { | 172 { |
173 content::ContextMenuParams params; | 173 content::ContextMenuParams params; |
174 params.is_editable = true; | 174 params.is_editable = true; |
175 params.page_url = web_contents->GetURL(); | 175 params.page_url = web_contents->GetURL(); |
176 // Ensure context menu isn't swallowed by WebContentsDelegate (the panel). | 176 // Ensure context menu isn't swallowed by WebContentsDelegate (the panel). |
177 EXPECT_FALSE(web_contents->GetDelegate()->HandleContextMenu(params)); | 177 EXPECT_FALSE(web_contents->GetDelegate()->HandleContextMenu(params)); |
178 | 178 |
179 scoped_ptr<PanelContextMenu> menu( | 179 std::unique_ptr<PanelContextMenu> menu( |
180 new PanelContextMenu(web_contents->GetMainFrame(), params)); | 180 new PanelContextMenu(web_contents->GetMainFrame(), params)); |
181 menu->Init(); | 181 menu->Init(); |
182 | 182 |
183 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); | 183 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); |
184 EXPECT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); | 184 EXPECT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); |
185 EXPECT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_PASTE)); | 185 EXPECT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_PASTE)); |
186 EXPECT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); | 186 EXPECT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); |
187 EXPECT_FALSE(menu->HasCommandWithId(IDC_BACK)); | 187 EXPECT_FALSE(menu->HasCommandWithId(IDC_BACK)); |
188 EXPECT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); | 188 EXPECT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); |
189 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPYLINKLOCATION)); | 189 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPYLINKLOCATION)); |
190 } | 190 } |
191 | 191 |
192 // Verify expected menu contents for text selection. | 192 // Verify expected menu contents for text selection. |
193 { | 193 { |
194 content::ContextMenuParams params; | 194 content::ContextMenuParams params; |
195 params.page_url = web_contents->GetURL(); | 195 params.page_url = web_contents->GetURL(); |
196 params.selection_text = base::ASCIIToUTF16("Select me"); | 196 params.selection_text = base::ASCIIToUTF16("Select me"); |
197 // Ensure context menu isn't swallowed by WebContentsDelegate (the panel). | 197 // Ensure context menu isn't swallowed by WebContentsDelegate (the panel). |
198 EXPECT_FALSE(web_contents->GetDelegate()->HandleContextMenu(params)); | 198 EXPECT_FALSE(web_contents->GetDelegate()->HandleContextMenu(params)); |
199 | 199 |
200 scoped_ptr<PanelContextMenu> menu( | 200 std::unique_ptr<PanelContextMenu> menu( |
201 new PanelContextMenu(web_contents->GetMainFrame(), params)); | 201 new PanelContextMenu(web_contents->GetMainFrame(), params)); |
202 menu->Init(); | 202 menu->Init(); |
203 | 203 |
204 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); | 204 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); |
205 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); | 205 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); |
206 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_PASTE)); | 206 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_PASTE)); |
207 EXPECT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); | 207 EXPECT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); |
208 EXPECT_FALSE(menu->HasCommandWithId(IDC_BACK)); | 208 EXPECT_FALSE(menu->HasCommandWithId(IDC_BACK)); |
209 EXPECT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); | 209 EXPECT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); |
210 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPYLINKLOCATION)); | 210 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPYLINKLOCATION)); |
211 } | 211 } |
212 | 212 |
213 // Verify expected menu contexts for a link. | 213 // Verify expected menu contexts for a link. |
214 { | 214 { |
215 content::ContextMenuParams params; | 215 content::ContextMenuParams params; |
216 params.page_url = web_contents->GetURL(); | 216 params.page_url = web_contents->GetURL(); |
217 params.unfiltered_link_url = GURL("http://google.com/"); | 217 params.unfiltered_link_url = GURL("http://google.com/"); |
218 // Ensure context menu isn't swallowed by WebContentsDelegate (the panel). | 218 // Ensure context menu isn't swallowed by WebContentsDelegate (the panel). |
219 EXPECT_FALSE(web_contents->GetDelegate()->HandleContextMenu(params)); | 219 EXPECT_FALSE(web_contents->GetDelegate()->HandleContextMenu(params)); |
220 | 220 |
221 scoped_ptr<PanelContextMenu> menu( | 221 std::unique_ptr<PanelContextMenu> menu( |
222 new PanelContextMenu(web_contents->GetMainFrame(), params)); | 222 new PanelContextMenu(web_contents->GetMainFrame(), params)); |
223 menu->Init(); | 223 menu->Init(); |
224 | 224 |
225 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); | 225 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); |
226 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); | 226 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); |
227 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_PASTE)); | 227 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_PASTE)); |
228 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); | 228 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); |
229 EXPECT_FALSE(menu->HasCommandWithId(IDC_BACK)); | 229 EXPECT_FALSE(menu->HasCommandWithId(IDC_BACK)); |
230 EXPECT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); | 230 EXPECT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); |
231 EXPECT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPYLINKLOCATION)); | 231 EXPECT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPYLINKLOCATION)); |
(...skipping 17 matching lines...) Expand all Loading... |
249 content::WebContents* web_contents = panel->GetWebContents(); | 249 content::WebContents* web_contents = panel->GetWebContents(); |
250 ASSERT_TRUE(web_contents); | 250 ASSERT_TRUE(web_contents); |
251 | 251 |
252 content::ContextMenuParams params; | 252 content::ContextMenuParams params; |
253 params.page_url = web_contents->GetURL(); | 253 params.page_url = web_contents->GetURL(); |
254 | 254 |
255 // Ensure context menu isn't swallowed by WebContentsDelegate (the panel). | 255 // Ensure context menu isn't swallowed by WebContentsDelegate (the panel). |
256 EXPECT_FALSE(web_contents->GetDelegate()->HandleContextMenu(params)); | 256 EXPECT_FALSE(web_contents->GetDelegate()->HandleContextMenu(params)); |
257 | 257 |
258 // Verify menu contents contains the custom item added by their own extension. | 258 // Verify menu contents contains the custom item added by their own extension. |
259 scoped_ptr<PanelContextMenu> menu; | 259 std::unique_ptr<PanelContextMenu> menu; |
260 menu.reset(new PanelContextMenu(web_contents->GetMainFrame(), params)); | 260 menu.reset(new PanelContextMenu(web_contents->GetMainFrame(), params)); |
261 menu->Init(); | 261 menu->Init(); |
262 EXPECT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); | 262 EXPECT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); |
263 EXPECT_FALSE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1)); | 263 EXPECT_FALSE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1)); |
264 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); | 264 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); |
265 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); | 265 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); |
266 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_PASTE)); | 266 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_PASTE)); |
267 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); | 267 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); |
268 EXPECT_FALSE(menu->HasCommandWithId(IDC_BACK)); | 268 EXPECT_FALSE(menu->HasCommandWithId(IDC_BACK)); |
269 EXPECT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); | 269 EXPECT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); |
270 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPYLINKLOCATION)); | 270 EXPECT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPYLINKLOCATION)); |
271 | 271 |
272 // Execute the extension's custom menu item and wait for the extension's | 272 // Execute the extension's custom menu item and wait for the extension's |
273 // script to tell us its onclick fired. | 273 // script to tell us its onclick fired. |
274 ExtensionTestMessageListener onclick_listener("clicked", false); | 274 ExtensionTestMessageListener onclick_listener("clicked", false); |
275 int command_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST; | 275 int command_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST; |
276 ASSERT_TRUE(menu->IsCommandIdEnabled(command_id)); | 276 ASSERT_TRUE(menu->IsCommandIdEnabled(command_id)); |
277 menu->ExecuteCommand(command_id, 0); | 277 menu->ExecuteCommand(command_id, 0); |
278 EXPECT_TRUE(onclick_listener.WaitUntilSatisfied()); | 278 EXPECT_TRUE(onclick_listener.WaitUntilSatisfied()); |
279 } | 279 } |
OLD | NEW |