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

Side by Side Diff: chrome/browser/apps/app_browsertest.cc

Issue 166573005: Rename apps::ShellWindow to apps::AppWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, nits (rename) Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "apps/app_window.h"
6 #include "apps/app_window_registry.h"
5 #include "apps/launcher.h" 7 #include "apps/launcher.h"
6 #include "apps/shell_window.h"
7 #include "apps/shell_window_registry.h"
8 #include "apps/ui/native_app_window.h" 8 #include "apps/ui/native_app_window.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/app/chrome_command_ids.h" 16 #include "chrome/app/chrome_command_ids.h"
17 #include "chrome/browser/apps/app_browsertest_util.h" 17 #include "chrome/browser/apps/app_browsertest_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 #if defined(OS_CHROMEOS) 50 #if defined(OS_CHROMEOS)
51 #include "base/memory/scoped_ptr.h" 51 #include "base/memory/scoped_ptr.h"
52 #include "chrome/browser/chromeos/login/mock_user_manager.h" 52 #include "chrome/browser/chromeos/login/mock_user_manager.h"
53 #include "chrome/browser/chromeos/login/user_manager.h" 53 #include "chrome/browser/chromeos/login/user_manager.h"
54 #include "chromeos/dbus/dbus_thread_manager.h" 54 #include "chromeos/dbus/dbus_thread_manager.h"
55 #include "chromeos/dbus/fake_dbus_thread_manager.h" 55 #include "chromeos/dbus/fake_dbus_thread_manager.h"
56 #include "chromeos/dbus/fake_power_manager_client.h" 56 #include "chromeos/dbus/fake_power_manager_client.h"
57 #endif 57 #endif
58 58
59 using apps::ShellWindow; 59 using apps::AppWindow;
60 using apps::ShellWindowRegistry; 60 using apps::AppWindowRegistry;
61 using content::WebContents; 61 using content::WebContents;
62 using web_modal::WebContentsModalDialogManager; 62 using web_modal::WebContentsModalDialogManager;
63 63
64 namespace extensions { 64 namespace extensions {
65 65
66 namespace app_runtime = api::app_runtime; 66 namespace app_runtime = api::app_runtime;
67 67
68 namespace { 68 namespace {
69 69
70 // Non-abstract RenderViewContextMenu class. 70 // Non-abstract RenderViewContextMenu class.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return true; 189 return true;
190 } 190 }
191 #endif // !defined(OS_CHROMEOS) && !defined(OS_WIN) 191 #endif // !defined(OS_CHROMEOS) && !defined(OS_WIN)
192 192
193 #if !defined(OS_CHROMEOS) 193 #if !defined(OS_CHROMEOS)
194 const char kTestFilePath[] = "platform_apps/launch_files/test.txt"; 194 const char kTestFilePath[] = "platform_apps/launch_files/test.txt";
195 #endif 195 #endif
196 196
197 } // namespace 197 } // namespace
198 198
199 // Tests that CreateShellWindow doesn't crash if you close it straight away. 199 // Tests that CreateAppWindow doesn't crash if you close it straight away.
200 // LauncherPlatformAppBrowserTest relies on this behaviour, but is only run for 200 // LauncherPlatformAppBrowserTest relies on this behaviour, but is only run for
201 // ash, so we test that it works here. 201 // ash, so we test that it works here.
202 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, CreateAndCloseShellWindow) { 202 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, CreateAndCloseAppWindow) {
203 const Extension* extension = LoadAndLaunchPlatformApp("minimal"); 203 const Extension* extension = LoadAndLaunchPlatformApp("minimal");
204 ShellWindow* window = CreateShellWindow(extension); 204 AppWindow* window = CreateAppWindow(extension);
205 CloseShellWindow(window); 205 CloseAppWindow(window);
206 } 206 }
207 207
208 // Tests that platform apps received the "launch" event when launched. 208 // Tests that platform apps received the "launch" event when launched.
209 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OnLaunchedEvent) { 209 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OnLaunchedEvent) {
210 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch")) << message_; 210 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch")) << message_;
211 } 211 }
212 212
213 // Tests that platform apps cannot use certain disabled window properties, but 213 // Tests that platform apps cannot use certain disabled window properties, but
214 // can override them and then use them. 214 // can override them and then use them.
215 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisabledWindowProperties) { 215 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisabledWindowProperties) {
216 ASSERT_TRUE(RunPlatformAppTest("platform_apps/disabled_window_properties")) 216 ASSERT_TRUE(RunPlatformAppTest("platform_apps/disabled_window_properties"))
217 << message_; 217 << message_;
218 } 218 }
219 219
220 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, EmptyContextMenu) { 220 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, EmptyContextMenu) {
221 ExtensionTestMessageListener launched_listener("Launched", false); 221 ExtensionTestMessageListener launched_listener("Launched", false);
222 LoadAndLaunchPlatformApp("minimal"); 222 LoadAndLaunchPlatformApp("minimal");
223 223
224 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 224 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
225 225
226 // The empty app doesn't add any context menu items, so its menu should 226 // The empty app doesn't add any context menu items, so its menu should
227 // only include the developer tools. 227 // only include the developer tools.
228 WebContents* web_contents = GetFirstShellWindowWebContents(); 228 WebContents* web_contents = GetFirstAppWindowWebContents();
229 ASSERT_TRUE(web_contents); 229 ASSERT_TRUE(web_contents);
230 content::ContextMenuParams params; 230 content::ContextMenuParams params;
231 scoped_ptr<PlatformAppContextMenu> menu; 231 scoped_ptr<PlatformAppContextMenu> menu;
232 menu.reset(new PlatformAppContextMenu(web_contents->GetMainFrame(), params)); 232 menu.reset(new PlatformAppContextMenu(web_contents->GetMainFrame(), params));
233 menu->Init(); 233 menu->Init();
234 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); 234 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
235 ASSERT_TRUE( 235 ASSERT_TRUE(
236 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE)); 236 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
237 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP)); 237 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
238 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); 238 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
239 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); 239 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
240 } 240 }
241 241
242 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) { 242 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) {
243 ExtensionTestMessageListener launched_listener("Launched", false); 243 ExtensionTestMessageListener launched_listener("Launched", false);
244 LoadAndLaunchPlatformApp("context_menu"); 244 LoadAndLaunchPlatformApp("context_menu");
245 245
246 // Wait for the extension to tell us it's initialized its context menus and 246 // Wait for the extension to tell us it's initialized its context menus and
247 // launched a window. 247 // launched a window.
248 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 248 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
249 249
250 // The context_menu app has two context menu items. These, along with a 250 // The context_menu app has two context menu items. These, along with a
251 // separator and the developer tools, is all that should be in the menu. 251 // separator and the developer tools, is all that should be in the menu.
252 WebContents* web_contents = GetFirstShellWindowWebContents(); 252 WebContents* web_contents = GetFirstAppWindowWebContents();
253 ASSERT_TRUE(web_contents); 253 ASSERT_TRUE(web_contents);
254 content::ContextMenuParams params; 254 content::ContextMenuParams params;
255 scoped_ptr<PlatformAppContextMenu> menu; 255 scoped_ptr<PlatformAppContextMenu> menu;
256 menu.reset(new PlatformAppContextMenu(web_contents->GetMainFrame(), params)); 256 menu.reset(new PlatformAppContextMenu(web_contents->GetMainFrame(), params));
257 menu->Init(); 257 menu->Init();
258 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); 258 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
259 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1)); 259 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1));
260 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); 260 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
261 ASSERT_TRUE( 261 ASSERT_TRUE(
262 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE)); 262 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
263 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP)); 263 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
264 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); 264 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
265 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); 265 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
266 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); 266 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
267 } 267 }
268 268
269 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, InstalledAppWithContextMenu) { 269 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, InstalledAppWithContextMenu) {
270 ExtensionTestMessageListener launched_listener("Launched", false); 270 ExtensionTestMessageListener launched_listener("Launched", false);
271 InstallAndLaunchPlatformApp("context_menu"); 271 InstallAndLaunchPlatformApp("context_menu");
272 272
273 // Wait for the extension to tell us it's initialized its context menus and 273 // Wait for the extension to tell us it's initialized its context menus and
274 // launched a window. 274 // launched a window.
275 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 275 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
276 276
277 // The context_menu app has two context menu items. For an installed app 277 // The context_menu app has two context menu items. For an installed app
278 // these are all that should be in the menu. 278 // these are all that should be in the menu.
279 WebContents* web_contents = GetFirstShellWindowWebContents(); 279 WebContents* web_contents = GetFirstAppWindowWebContents();
280 ASSERT_TRUE(web_contents); 280 ASSERT_TRUE(web_contents);
281 content::ContextMenuParams params; 281 content::ContextMenuParams params;
282 scoped_ptr<PlatformAppContextMenu> menu; 282 scoped_ptr<PlatformAppContextMenu> menu;
283 menu.reset(new PlatformAppContextMenu(web_contents->GetMainFrame(), params)); 283 menu.reset(new PlatformAppContextMenu(web_contents->GetMainFrame(), params));
284 menu->Init(); 284 menu->Init();
285 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); 285 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
286 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1)); 286 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1));
287 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); 287 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
288 ASSERT_FALSE( 288 ASSERT_FALSE(
289 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE)); 289 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
290 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP)); 290 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
291 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); 291 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
292 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); 292 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
293 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); 293 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
294 } 294 }
295 295
296 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuTextField) { 296 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuTextField) {
297 ExtensionTestMessageListener launched_listener("Launched", false); 297 ExtensionTestMessageListener launched_listener("Launched", false);
298 LoadAndLaunchPlatformApp("context_menu"); 298 LoadAndLaunchPlatformApp("context_menu");
299 299
300 // Wait for the extension to tell us it's initialized its context menus and 300 // Wait for the extension to tell us it's initialized its context menus and
301 // launched a window. 301 // launched a window.
302 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 302 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
303 303
304 // The context_menu app has one context menu item. This, along with a 304 // The context_menu app has one context menu item. This, along with a
305 // separator and the developer tools, is all that should be in the menu. 305 // separator and the developer tools, is all that should be in the menu.
306 WebContents* web_contents = GetFirstShellWindowWebContents(); 306 WebContents* web_contents = GetFirstAppWindowWebContents();
307 ASSERT_TRUE(web_contents); 307 ASSERT_TRUE(web_contents);
308 content::ContextMenuParams params; 308 content::ContextMenuParams params;
309 params.is_editable = true; 309 params.is_editable = true;
310 scoped_ptr<PlatformAppContextMenu> menu; 310 scoped_ptr<PlatformAppContextMenu> menu;
311 menu.reset(new PlatformAppContextMenu(web_contents->GetMainFrame(), params)); 311 menu.reset(new PlatformAppContextMenu(web_contents->GetMainFrame(), params));
312 menu->Init(); 312 menu->Init();
313 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); 313 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
314 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); 314 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
315 ASSERT_TRUE( 315 ASSERT_TRUE(
316 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE)); 316 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
317 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP)); 317 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
318 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); 318 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
319 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); 319 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY));
320 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); 320 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
321 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); 321 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
322 } 322 }
323 323
324 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuSelection) { 324 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuSelection) {
325 ExtensionTestMessageListener launched_listener("Launched", false); 325 ExtensionTestMessageListener launched_listener("Launched", false);
326 LoadAndLaunchPlatformApp("context_menu"); 326 LoadAndLaunchPlatformApp("context_menu");
327 327
328 // Wait for the extension to tell us it's initialized its context menus and 328 // Wait for the extension to tell us it's initialized its context menus and
329 // launched a window. 329 // launched a window.
330 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 330 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
331 331
332 // The context_menu app has one context menu item. This, along with a 332 // The context_menu app has one context menu item. This, along with a
333 // separator and the developer tools, is all that should be in the menu. 333 // separator and the developer tools, is all that should be in the menu.
334 WebContents* web_contents = GetFirstShellWindowWebContents(); 334 WebContents* web_contents = GetFirstAppWindowWebContents();
335 ASSERT_TRUE(web_contents); 335 ASSERT_TRUE(web_contents);
336 content::ContextMenuParams params; 336 content::ContextMenuParams params;
337 params.selection_text = base::ASCIIToUTF16("Hello World"); 337 params.selection_text = base::ASCIIToUTF16("Hello World");
338 scoped_ptr<PlatformAppContextMenu> menu; 338 scoped_ptr<PlatformAppContextMenu> menu;
339 menu.reset(new PlatformAppContextMenu(web_contents->GetMainFrame(), params)); 339 menu.reset(new PlatformAppContextMenu(web_contents->GetMainFrame(), params));
340 menu->Init(); 340 menu->Init();
341 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); 341 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
342 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); 342 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
343 ASSERT_TRUE( 343 ASSERT_TRUE(
344 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE)); 344 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
345 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP)); 345 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
346 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); 346 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
347 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); 347 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY));
348 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); 348 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
349 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); 349 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
350 } 350 }
351 351
352 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) { 352 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) {
353 ExtensionTestMessageListener launched_listener("Launched", false); 353 ExtensionTestMessageListener launched_listener("Launched", false);
354 LoadAndLaunchPlatformApp("context_menu_click"); 354 LoadAndLaunchPlatformApp("context_menu_click");
355 355
356 // Wait for the extension to tell us it's initialized its context menus and 356 // Wait for the extension to tell us it's initialized its context menus and
357 // launched a window. 357 // launched a window.
358 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 358 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
359 359
360 // Test that the menu item shows up 360 // Test that the menu item shows up
361 WebContents* web_contents = GetFirstShellWindowWebContents(); 361 WebContents* web_contents = GetFirstAppWindowWebContents();
362 ASSERT_TRUE(web_contents); 362 ASSERT_TRUE(web_contents);
363 content::ContextMenuParams params; 363 content::ContextMenuParams params;
364 params.page_url = GURL("http://foo.bar"); 364 params.page_url = GURL("http://foo.bar");
365 scoped_ptr<PlatformAppContextMenu> menu; 365 scoped_ptr<PlatformAppContextMenu> menu;
366 menu.reset(new PlatformAppContextMenu(web_contents->GetMainFrame(), params)); 366 menu.reset(new PlatformAppContextMenu(web_contents->GetMainFrame(), params));
367 menu->Init(); 367 menu->Init();
368 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); 368 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
369 369
370 // Execute the menu item 370 // Execute the menu item
371 ExtensionTestMessageListener onclicked_listener("onClicked fired for id1", 371 ExtensionTestMessageListener onclicked_listener("onClicked fired for id1",
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 #define MAYBE_ExtensionWindowingApis ExtensionWindowingApis 454 #define MAYBE_ExtensionWindowingApis ExtensionWindowingApis
455 #endif 455 #endif
456 456
457 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_ExtensionWindowingApis) { 457 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_ExtensionWindowingApis) {
458 // Initially there should be just the one browser window visible to the 458 // Initially there should be just the one browser window visible to the
459 // extensions API. 459 // extensions API.
460 const Extension* extension = LoadExtension( 460 const Extension* extension = LoadExtension(
461 test_data_dir_.AppendASCII("common/background_page")); 461 test_data_dir_.AppendASCII("common/background_page"));
462 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension)); 462 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension));
463 463
464 // And no shell windows. 464 // And no app windows.
465 ASSERT_EQ(0U, GetShellWindowCount()); 465 ASSERT_EQ(0U, GetAppWindowCount());
466 466
467 // Launch a platform app that shows a window. 467 // Launch a platform app that shows a window.
468 ExtensionTestMessageListener launched_listener("Launched", false); 468 ExtensionTestMessageListener launched_listener("Launched", false);
469 LoadAndLaunchPlatformApp("minimal"); 469 LoadAndLaunchPlatformApp("minimal");
470 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 470 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
471 ASSERT_EQ(1U, GetShellWindowCount()); 471 ASSERT_EQ(1U, GetAppWindowCount());
472 int shell_window_id = GetFirstShellWindow()->session_id().id(); 472 int app_window_id = GetFirstAppWindow()->session_id().id();
473 473
474 // But it's not visible to the extensions API, it still thinks there's just 474 // But it's not visible to the extensions API, it still thinks there's just
475 // one browser window. 475 // one browser window.
476 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension)); 476 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension));
477 // It can't look it up by ID either 477 // It can't look it up by ID either
478 ASSERT_FALSE(RunGetWindowFunctionForExtension(shell_window_id, extension)); 478 ASSERT_FALSE(RunGetWindowFunctionForExtension(app_window_id, extension));
479 479
480 // The app can also only see one window (its own). 480 // The app can also only see one window (its own).
481 // TODO(jeremya): add an extension function to get a shell window by ID, and 481 // TODO(jeremya): add an extension function to get an app window by ID, and
482 // to get a list of all the shell windows, so we can test this. 482 // to get a list of all the app windows, so we can test this.
483 483
484 // Launch another platform app that also shows a window. 484 // Launch another platform app that also shows a window.
485 ExtensionTestMessageListener launched_listener2("Launched", false); 485 ExtensionTestMessageListener launched_listener2("Launched", false);
486 LoadAndLaunchPlatformApp("context_menu"); 486 LoadAndLaunchPlatformApp("context_menu");
487 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied()); 487 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied());
488 488
489 // There are two total shell windows, but each app can only see its own. 489 // There are two total app windows, but each app can only see its own.
490 ASSERT_EQ(2U, GetShellWindowCount()); 490 ASSERT_EQ(2U, GetAppWindowCount());
491 // TODO(jeremya): as above, this requires more extension functions. 491 // TODO(jeremya): as above, this requires more extension functions.
492 } 492 }
493 493
494 // ChromeOS does not support passing arguments on the command line, so the tests 494 // ChromeOS does not support passing arguments on the command line, so the tests
495 // that rely on this functionality are disabled. 495 // that rely on this functionality are disabled.
496 #if !defined(OS_CHROMEOS) 496 #if !defined(OS_CHROMEOS)
497 // Tests that command line parameters get passed through to platform apps 497 // Tests that command line parameters get passed through to platform apps
498 // via launchData correctly when launching with a file. 498 // via launchData correctly when launching with a file.
499 // TODO(benwells/jeremya): tests need a way to specify a handler ID. 499 // TODO(benwells/jeremya): tests need a way to specify a handler ID.
500 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithFile) { 500 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithFile) {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 708 ASSERT_EQ(2, browser()->tab_strip_model()->count());
709 } 709 }
710 710
711 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) { 711 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) {
712 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_; 712 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_;
713 } 713 }
714 714
715 // This appears to be unreliable on linux. 715 // This appears to be unreliable on linux.
716 // TODO(stevenjb): Investigate and enable 716 // TODO(stevenjb): Investigate and enable
717 #if defined(OS_LINUX) && !defined(USE_ASH) 717 #if defined(OS_LINUX) && !defined(USE_ASH)
718 #define MAYBE_ShellWindowRestoreState DISABLED_ShellWindowRestoreState 718 #define MAYBE_AppWindowRestoreState DISABLED_AppWindowRestoreState
719 #else 719 #else
720 #define MAYBE_ShellWindowRestoreState ShellWindowRestoreState 720 #define MAYBE_AppWindowRestoreState AppWindowRestoreState
721 #endif 721 #endif
722 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, 722 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_AppWindowRestoreState) {
723 MAYBE_ShellWindowRestoreState) {
724 ASSERT_TRUE(RunPlatformAppTest("platform_apps/restore_state")); 723 ASSERT_TRUE(RunPlatformAppTest("platform_apps/restore_state"));
725 } 724 }
726 725
727 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, 726 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
728 ShellWindowAdjustBoundsToBeVisibleOnScreen) { 727 AppWindowAdjustBoundsToBeVisibleOnScreen) {
729 const Extension* extension = LoadAndLaunchPlatformApp("minimal"); 728 const Extension* extension = LoadAndLaunchPlatformApp("minimal");
730 ShellWindow* window = CreateShellWindow(extension); 729 AppWindow* window = CreateAppWindow(extension);
731 730
732 // The screen bounds didn't change, the cached bounds didn't need to adjust. 731 // The screen bounds didn't change, the cached bounds didn't need to adjust.
733 gfx::Rect cached_bounds(80, 100, 400, 400); 732 gfx::Rect cached_bounds(80, 100, 400, 400);
734 gfx::Rect cached_screen_bounds(0, 0, 1600, 900); 733 gfx::Rect cached_screen_bounds(0, 0, 1600, 900);
735 gfx::Rect current_screen_bounds(0, 0, 1600, 900); 734 gfx::Rect current_screen_bounds(0, 0, 1600, 900);
736 gfx::Size minimum_size(200, 200); 735 gfx::Size minimum_size(200, 200);
737 gfx::Rect bounds; 736 gfx::Rect bounds;
738 CallAdjustBoundsToBeVisibleOnScreenForShellWindow(window, 737 CallAdjustBoundsToBeVisibleOnScreenForAppWindow(window,
739 cached_bounds, 738 cached_bounds,
740 cached_screen_bounds, 739 cached_screen_bounds,
741 current_screen_bounds, 740 current_screen_bounds,
742 minimum_size, 741 minimum_size,
743 &bounds); 742 &bounds);
744 EXPECT_EQ(bounds, cached_bounds); 743 EXPECT_EQ(bounds, cached_bounds);
745 744
746 // We have an empty screen bounds, the cached bounds didn't need to adjust. 745 // We have an empty screen bounds, the cached bounds didn't need to adjust.
747 gfx::Rect empty_screen_bounds; 746 gfx::Rect empty_screen_bounds;
748 CallAdjustBoundsToBeVisibleOnScreenForShellWindow(window, 747 CallAdjustBoundsToBeVisibleOnScreenForAppWindow(window,
749 cached_bounds, 748 cached_bounds,
750 empty_screen_bounds, 749 empty_screen_bounds,
751 current_screen_bounds, 750 current_screen_bounds,
752 minimum_size, 751 minimum_size,
753 &bounds); 752 &bounds);
754 EXPECT_EQ(bounds, cached_bounds); 753 EXPECT_EQ(bounds, cached_bounds);
755 754
756 // Cached bounds is completely off the new screen bounds in horizontal 755 // Cached bounds is completely off the new screen bounds in horizontal
757 // locations. Expect to reposition the bounds. 756 // locations. Expect to reposition the bounds.
758 gfx::Rect horizontal_out_of_screen_bounds(-800, 100, 400, 400); 757 gfx::Rect horizontal_out_of_screen_bounds(-800, 100, 400, 400);
759 CallAdjustBoundsToBeVisibleOnScreenForShellWindow( 758 CallAdjustBoundsToBeVisibleOnScreenForAppWindow(
760 window, 759 window,
761 horizontal_out_of_screen_bounds, 760 horizontal_out_of_screen_bounds,
762 gfx::Rect(-1366, 0, 1600, 900), 761 gfx::Rect(-1366, 0, 1600, 900),
763 current_screen_bounds, 762 current_screen_bounds,
764 minimum_size, 763 minimum_size,
765 &bounds); 764 &bounds);
766 EXPECT_EQ(bounds, gfx::Rect(0, 100, 400, 400)); 765 EXPECT_EQ(bounds, gfx::Rect(0, 100, 400, 400));
767 766
768 // Cached bounds is completely off the new screen bounds in vertical 767 // Cached bounds is completely off the new screen bounds in vertical
769 // locations. Expect to reposition the bounds. 768 // locations. Expect to reposition the bounds.
770 gfx::Rect vertical_out_of_screen_bounds(10, 1000, 400, 400); 769 gfx::Rect vertical_out_of_screen_bounds(10, 1000, 400, 400);
771 CallAdjustBoundsToBeVisibleOnScreenForShellWindow( 770 CallAdjustBoundsToBeVisibleOnScreenForAppWindow(
772 window, 771 window,
773 vertical_out_of_screen_bounds, 772 vertical_out_of_screen_bounds,
774 gfx::Rect(-1366, 0, 1600, 900), 773 gfx::Rect(-1366, 0, 1600, 900),
775 current_screen_bounds, 774 current_screen_bounds,
776 minimum_size, 775 minimum_size,
777 &bounds); 776 &bounds);
778 EXPECT_EQ(bounds, gfx::Rect(10, 500, 400, 400)); 777 EXPECT_EQ(bounds, gfx::Rect(10, 500, 400, 400));
779 778
780 // From a large screen resulotion to a small one. Expect it fit on screen. 779 // From a large screen resulotion to a small one. Expect it fit on screen.
781 gfx::Rect big_cache_bounds(10, 10, 1000, 1000); 780 gfx::Rect big_cache_bounds(10, 10, 1000, 1000);
782 CallAdjustBoundsToBeVisibleOnScreenForShellWindow( 781 CallAdjustBoundsToBeVisibleOnScreenForAppWindow(window,
783 window, 782 big_cache_bounds,
784 big_cache_bounds, 783 gfx::Rect(0, 0, 1600, 1000),
785 gfx::Rect(0, 0, 1600, 1000), 784 gfx::Rect(0, 0, 800, 600),
786 gfx::Rect(0, 0, 800, 600), 785 minimum_size,
787 minimum_size, 786 &bounds);
788 &bounds);
789 EXPECT_EQ(bounds, gfx::Rect(0, 0, 800, 600)); 787 EXPECT_EQ(bounds, gfx::Rect(0, 0, 800, 600));
790 788
791 // Don't resize the bounds smaller than minimum size, when the minimum size is 789 // Don't resize the bounds smaller than minimum size, when the minimum size is
792 // larger than the screen. 790 // larger than the screen.
793 CallAdjustBoundsToBeVisibleOnScreenForShellWindow( 791 CallAdjustBoundsToBeVisibleOnScreenForAppWindow(window,
794 window, 792 big_cache_bounds,
795 big_cache_bounds, 793 gfx::Rect(0, 0, 1600, 1000),
796 gfx::Rect(0, 0, 1600, 1000), 794 gfx::Rect(0, 0, 800, 600),
797 gfx::Rect(0, 0, 800, 600), 795 gfx::Size(900, 900),
798 gfx::Size(900, 900), 796 &bounds);
799 &bounds);
800 EXPECT_EQ(bounds, gfx::Rect(0, 0, 900, 900)); 797 EXPECT_EQ(bounds, gfx::Rect(0, 0, 900, 900));
801 } 798 }
802 799
803 namespace { 800 namespace {
804 801
805 class PlatformAppDevToolsBrowserTest : public PlatformAppBrowserTest { 802 class PlatformAppDevToolsBrowserTest : public PlatformAppBrowserTest {
806 protected: 803 protected:
807 enum TestFlags { 804 enum TestFlags {
808 RELAUNCH = 0x1, 805 RELAUNCH = 0x1,
809 HAS_ID = 0x2, 806 HAS_ID = 0x2,
810 }; 807 };
811 // Runs a test inside a harness that opens DevTools on a shell window. 808 // Runs a test inside a harness that opens DevTools on an app window.
812 void RunTestWithDevTools(const char* name, int test_flags); 809 void RunTestWithDevTools(const char* name, int test_flags);
813 }; 810 };
814 811
815 void PlatformAppDevToolsBrowserTest::RunTestWithDevTools( 812 void PlatformAppDevToolsBrowserTest::RunTestWithDevTools(
816 const char* name, int test_flags) { 813 const char* name, int test_flags) {
817 using content::DevToolsAgentHost; 814 using content::DevToolsAgentHost;
818 ExtensionTestMessageListener launched_listener("Launched", false); 815 ExtensionTestMessageListener launched_listener("Launched", false);
819 const Extension* extension = LoadAndLaunchPlatformApp(name); 816 const Extension* extension = LoadAndLaunchPlatformApp(name);
820 ASSERT_TRUE(extension); 817 ASSERT_TRUE(extension);
821 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 818 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
822 ShellWindow* window = GetFirstShellWindow(); 819 AppWindow* window = GetFirstAppWindow();
823 ASSERT_TRUE(window); 820 ASSERT_TRUE(window);
824 ASSERT_EQ(window->window_key().empty(), (test_flags & HAS_ID) == 0); 821 ASSERT_EQ(window->window_key().empty(), (test_flags & HAS_ID) == 0);
825 content::RenderViewHost* rvh = window->web_contents()->GetRenderViewHost(); 822 content::RenderViewHost* rvh = window->web_contents()->GetRenderViewHost();
826 ASSERT_TRUE(rvh); 823 ASSERT_TRUE(rvh);
827 824
828 // Ensure no DevTools open for the ShellWindow, then open one. 825 // Ensure no DevTools open for the AppWindow, then open one.
829 ASSERT_FALSE(DevToolsAgentHost::HasFor(rvh)); 826 ASSERT_FALSE(DevToolsAgentHost::HasFor(rvh));
830 DevToolsWindow::OpenDevToolsWindow(rvh); 827 DevToolsWindow::OpenDevToolsWindow(rvh);
831 ASSERT_TRUE(DevToolsAgentHost::HasFor(rvh)); 828 ASSERT_TRUE(DevToolsAgentHost::HasFor(rvh));
832 829
833 if (test_flags & RELAUNCH) { 830 if (test_flags & RELAUNCH) {
834 // Close the ShellWindow, and ensure it is gone. 831 // Close the AppWindow, and ensure it is gone.
835 CloseShellWindow(window); 832 CloseAppWindow(window);
836 ASSERT_FALSE(GetFirstShellWindow()); 833 ASSERT_FALSE(GetFirstAppWindow());
837 834
838 // Relaunch the app and get a new ShellWindow. 835 // Relaunch the app and get a new AppWindow.
839 content::WindowedNotificationObserver app_loaded_observer( 836 content::WindowedNotificationObserver app_loaded_observer(
840 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 837 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
841 content::NotificationService::AllSources()); 838 content::NotificationService::AllSources());
842 OpenApplication(AppLaunchParams( 839 OpenApplication(AppLaunchParams(
843 browser()->profile(), extension, LAUNCH_CONTAINER_NONE, NEW_WINDOW)); 840 browser()->profile(), extension, LAUNCH_CONTAINER_NONE, NEW_WINDOW));
844 app_loaded_observer.Wait(); 841 app_loaded_observer.Wait();
845 window = GetFirstShellWindow(); 842 window = GetFirstAppWindow();
846 ASSERT_TRUE(window); 843 ASSERT_TRUE(window);
847 844
848 // DevTools should have reopened with the relaunch. 845 // DevTools should have reopened with the relaunch.
849 rvh = window->web_contents()->GetRenderViewHost(); 846 rvh = window->web_contents()->GetRenderViewHost();
850 ASSERT_TRUE(rvh); 847 ASSERT_TRUE(rvh);
851 ASSERT_TRUE(DevToolsAgentHost::HasFor(rvh)); 848 ASSERT_TRUE(DevToolsAgentHost::HasFor(rvh));
852 } 849 }
853 } 850 }
854 851
855 } // namespace 852 } // namespace
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 // fixed. 885 // fixed.
889 #define MAYBE_ConstrainedWindowRequest DISABLED_ConstrainedWindowRequest 886 #define MAYBE_ConstrainedWindowRequest DISABLED_ConstrainedWindowRequest
890 #endif 887 #endif
891 888
892 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_ConstrainedWindowRequest) { 889 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_ConstrainedWindowRequest) {
893 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); 890 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true);
894 const Extension* extension = 891 const Extension* extension =
895 LoadAndLaunchPlatformApp("optional_permission_request"); 892 LoadAndLaunchPlatformApp("optional_permission_request");
896 ASSERT_TRUE(extension) << "Failed to load extension."; 893 ASSERT_TRUE(extension) << "Failed to load extension.";
897 894
898 WebContents* web_contents = GetFirstShellWindowWebContents(); 895 WebContents* web_contents = GetFirstAppWindowWebContents();
899 ASSERT_TRUE(web_contents); 896 ASSERT_TRUE(web_contents);
900 897
901 // Verify that the shell window has a dialog attached. 898 // Verify that the app window has a dialog attached.
902 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 899 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
903 WebContentsModalDialogManager::FromWebContents(web_contents); 900 WebContentsModalDialogManager::FromWebContents(web_contents);
904 EXPECT_TRUE(web_contents_modal_dialog_manager->IsDialogActive()); 901 EXPECT_TRUE(web_contents_modal_dialog_manager->IsDialogActive());
905 902
906 // Close the constrained window and wait for the reply to the permission 903 // Close the constrained window and wait for the reply to the permission
907 // request. 904 // request.
908 ExtensionTestMessageListener listener("PermissionRequestDone", false); 905 ExtensionTestMessageListener listener("PermissionRequestDone", false);
909 WebContentsModalDialogManager::TestApi test_api( 906 WebContentsModalDialogManager::TestApi test_api(
910 web_contents_modal_dialog_manager); 907 web_contents_modal_dialog_manager);
911 test_api.CloseAllDialogs(); 908 test_api.CloseAllDialogs();
912 ASSERT_TRUE(listener.WaitUntilSatisfied()); 909 ASSERT_TRUE(listener.WaitUntilSatisfied());
913 } 910 }
914 911
915 // Tests that an app calling chrome.runtime.reload will reload the app and 912 // Tests that an app calling chrome.runtime.reload will reload the app and
916 // relaunch it if it was running. 913 // relaunch it if it was running.
917 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) { 914 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) {
918 ExtensionTestMessageListener launched_listener("Launched", true); 915 ExtensionTestMessageListener launched_listener("Launched", true);
919 const Extension* extension = LoadAndLaunchPlatformApp("reload"); 916 const Extension* extension = LoadAndLaunchPlatformApp("reload");
920 ASSERT_TRUE(extension); 917 ASSERT_TRUE(extension);
921 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 918 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
922 ASSERT_TRUE(GetFirstShellWindow()); 919 ASSERT_TRUE(GetFirstAppWindow());
923 920
924 // Now tell the app to reload itself 921 // Now tell the app to reload itself
925 ExtensionTestMessageListener launched_listener2("Launched", false); 922 ExtensionTestMessageListener launched_listener2("Launched", false);
926 launched_listener.Reply("reload"); 923 launched_listener.Reply("reload");
927 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied()); 924 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied());
928 ASSERT_TRUE(GetFirstShellWindow()); 925 ASSERT_TRUE(GetFirstAppWindow());
929 } 926 }
930 927
931 namespace { 928 namespace {
932 929
933 // Simple observer to check for NOTIFICATION_EXTENSION_INSTALLED events to 930 // Simple observer to check for NOTIFICATION_EXTENSION_INSTALLED events to
934 // ensure installation does or does not occur in certain scenarios. 931 // ensure installation does or does not occur in certain scenarios.
935 class CheckExtensionInstalledObserver : public content::NotificationObserver { 932 class CheckExtensionInstalledObserver : public content::NotificationObserver {
936 public: 933 public:
937 CheckExtensionInstalledObserver() : seen_(false) { 934 CheckExtensionInstalledObserver() : seen_(false) {
938 registrar_.Add(this, 935 registrar_.Add(this,
(...skipping 16 matching lines...) Expand all
955 private: 952 private:
956 bool seen_; 953 bool seen_;
957 content::NotificationRegistrar registrar_; 954 content::NotificationRegistrar registrar_;
958 }; 955 };
959 956
960 } // namespace 957 } // namespace
961 958
962 // Component App Test 1 of 3: ensure that the initial load of a component 959 // Component App Test 1 of 3: ensure that the initial load of a component
963 // extension utilizing a background page (e.g. a v2 platform app) has its 960 // extension utilizing a background page (e.g. a v2 platform app) has its
964 // background page run and is launchable. Waits for the Launched response from 961 // background page run and is launchable. Waits for the Launched response from
965 // the script resource in the opened shell window. 962 // the script resource in the opened app window.
966 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, 963 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
967 PRE_PRE_ComponentAppBackgroundPage) { 964 PRE_PRE_ComponentAppBackgroundPage) {
968 CheckExtensionInstalledObserver should_install; 965 CheckExtensionInstalledObserver should_install;
969 966
970 // Ensure that we wait until the background page is run (to register the 967 // Ensure that we wait until the background page is run (to register the
971 // OnLaunched listener) before trying to open the application. This is similar 968 // OnLaunched listener) before trying to open the application. This is similar
972 // to LoadAndLaunchPlatformApp, but we want to load as a component extension. 969 // to LoadAndLaunchPlatformApp, but we want to load as a component extension.
973 content::WindowedNotificationObserver app_loaded_observer( 970 content::WindowedNotificationObserver app_loaded_observer(
974 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 971 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
975 content::NotificationService::AllSources()); 972 content::NotificationService::AllSources());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 #else 1066 #else
1070 // This test depends on focus and so needs to be in interactive_ui_tests. 1067 // This test depends on focus and so needs to be in interactive_ui_tests.
1071 // http://crbug.com/227041 1068 // http://crbug.com/227041
1072 #define MAYBE_WebContentsHasFocus DISABLED_WebContentsHasFocus 1069 #define MAYBE_WebContentsHasFocus DISABLED_WebContentsHasFocus
1073 #endif 1070 #endif
1074 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_WebContentsHasFocus) { 1071 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_WebContentsHasFocus) {
1075 ExtensionTestMessageListener launched_listener("Launched", true); 1072 ExtensionTestMessageListener launched_listener("Launched", true);
1076 LoadAndLaunchPlatformApp("minimal"); 1073 LoadAndLaunchPlatformApp("minimal");
1077 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 1074 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
1078 1075
1079 EXPECT_EQ(1LU, GetShellWindowCount()); 1076 EXPECT_EQ(1LU, GetAppWindowCount());
1080 EXPECT_TRUE(GetFirstShellWindow()->web_contents()-> 1077 EXPECT_TRUE(GetFirstAppWindow()
1081 GetRenderWidgetHostView()->HasFocus()); 1078 ->web_contents()
1079 ->GetRenderWidgetHostView()
1080 ->HasFocus());
1082 } 1081 }
1083 1082
1084 // The next three tests will only run automatically with Chrome branded builds 1083 // The next three tests will only run automatically with Chrome branded builds
1085 // because they require the PDF preview plug-in. To run these tests manually for 1084 // because they require the PDF preview plug-in. To run these tests manually for
1086 // Chromium (non-Chrome branded) builds in a development environment: 1085 // Chromium (non-Chrome branded) builds in a development environment:
1087 // 1086 //
1088 // 1) Remove "MAYBE_" in the first line of each test definition 1087 // 1) Remove "MAYBE_" in the first line of each test definition
1089 // 2) Build Chromium browser_tests 1088 // 2) Build Chromium browser_tests
1090 // 3) Make a copy of the PDF plug-in from a recent version of Chrome (Canary 1089 // 3) Make a copy of the PDF plug-in from a recent version of Chrome (Canary
1091 // or a recent development build) to your Chromium build: 1090 // or a recent development build) to your Chromium build:
(...skipping 27 matching lines...) Expand all
1119 #define MAYBE_ClosingWindowWhilePrintingShouldNotCrash \ 1118 #define MAYBE_ClosingWindowWhilePrintingShouldNotCrash \
1120 ClosingWindowWhilePrintingShouldNotCrash 1119 ClosingWindowWhilePrintingShouldNotCrash
1121 #endif 1120 #endif
1122 1121
1123 // This test verifies that http://crbug.com/297179 is fixed. 1122 // This test verifies that http://crbug.com/297179 is fixed.
1124 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, 1123 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
1125 MAYBE_ClosingWindowWhilePrintingShouldNotCrash) { 1124 MAYBE_ClosingWindowWhilePrintingShouldNotCrash) {
1126 ScopedPreviewTestingDelegate preview_delegate(false); 1125 ScopedPreviewTestingDelegate preview_delegate(false);
1127 ASSERT_TRUE(RunPlatformAppTest("platform_apps/print_api")) << message_; 1126 ASSERT_TRUE(RunPlatformAppTest("platform_apps/print_api")) << message_;
1128 preview_delegate.WaitUntilPreviewIsReady(); 1127 preview_delegate.WaitUntilPreviewIsReady();
1129 GetFirstShellWindow()->GetBaseWindow()->Close(); 1128 GetFirstAppWindow()->GetBaseWindow()->Close();
1130 } 1129 }
1131 1130
1132 // This test currently only passes on OS X (on other platforms the print preview 1131 // This test currently only passes on OS X (on other platforms the print preview
1133 // dialog's size is limited by the size of the window being printed). 1132 // dialog's size is limited by the size of the window being printed).
1134 #if !defined(GOOGLE_CHROME_BUILD) || !defined(OS_MACOSX) 1133 #if !defined(GOOGLE_CHROME_BUILD) || !defined(OS_MACOSX)
1135 #define MAYBE_PrintPreviewShouldNotBeTooSmall \ 1134 #define MAYBE_PrintPreviewShouldNotBeTooSmall \
1136 DISABLED_PrintPreviewShouldNotBeTooSmall 1135 DISABLED_PrintPreviewShouldNotBeTooSmall
1137 #else 1136 #else
1138 #define MAYBE_PrintPreviewShouldNotBeTooSmall \ 1137 #define MAYBE_PrintPreviewShouldNotBeTooSmall \
1139 PrintPreviewShouldNotBeTooSmall 1138 PrintPreviewShouldNotBeTooSmall
1140 #endif 1139 #endif
1141 1140
1142 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, 1141 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
1143 MAYBE_PrintPreviewShouldNotBeTooSmall) { 1142 MAYBE_PrintPreviewShouldNotBeTooSmall) {
1144 // Print preview dialogs with widths less than 410 pixels will have preview 1143 // Print preview dialogs with widths less than 410 pixels will have preview
1145 // areas that are too small, and ones with heights less than 191 pixels will 1144 // areas that are too small, and ones with heights less than 191 pixels will
1146 // have vertical scrollers for their controls that are too small. 1145 // have vertical scrollers for their controls that are too small.
1147 gfx::Size minimum_dialog_size(410, 191); 1146 gfx::Size minimum_dialog_size(410, 191);
1148 ScopedPreviewTestingDelegate preview_delegate(false); 1147 ScopedPreviewTestingDelegate preview_delegate(false);
1149 ASSERT_TRUE(RunPlatformAppTest("platform_apps/print_api")) << message_; 1148 ASSERT_TRUE(RunPlatformAppTest("platform_apps/print_api")) << message_;
1150 preview_delegate.WaitUntilPreviewIsReady(); 1149 preview_delegate.WaitUntilPreviewIsReady();
1151 EXPECT_GE(preview_delegate.dialog_size().width(), 1150 EXPECT_GE(preview_delegate.dialog_size().width(),
1152 minimum_dialog_size.width()); 1151 minimum_dialog_size.width());
1153 EXPECT_GE(preview_delegate.dialog_size().height(), 1152 EXPECT_GE(preview_delegate.dialog_size().height(),
1154 minimum_dialog_size.height()); 1153 minimum_dialog_size.height());
1155 GetFirstShellWindow()->GetBaseWindow()->Close(); 1154 GetFirstAppWindow()->GetBaseWindow()->Close();
1156 } 1155 }
1157 1156
1158 1157
1159 #if defined(OS_CHROMEOS) 1158 #if defined(OS_CHROMEOS)
1160 1159
1161 class PlatformAppIncognitoBrowserTest : public PlatformAppBrowserTest, 1160 class PlatformAppIncognitoBrowserTest : public PlatformAppBrowserTest,
1162 public ShellWindowRegistry::Observer { 1161 public AppWindowRegistry::Observer {
1163 public: 1162 public:
1164 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 1163 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
1165 // Tell chromeos to launch in Guest mode, aka incognito. 1164 // Tell chromeos to launch in Guest mode, aka incognito.
1166 command_line->AppendSwitch(switches::kIncognito); 1165 command_line->AppendSwitch(switches::kIncognito);
1167 PlatformAppBrowserTest::SetUpCommandLine(command_line); 1166 PlatformAppBrowserTest::SetUpCommandLine(command_line);
1168 } 1167 }
1169 virtual void SetUp() OVERRIDE { 1168 virtual void SetUp() OVERRIDE {
1170 // Make sure the file manager actually gets loaded. 1169 // Make sure the file manager actually gets loaded.
1171 ComponentLoader::EnableBackgroundExtensionsForTesting(); 1170 ComponentLoader::EnableBackgroundExtensionsForTesting();
1172 PlatformAppBrowserTest::SetUp(); 1171 PlatformAppBrowserTest::SetUp();
1173 } 1172 }
1174 1173
1175 // ShellWindowRegistry::Observer implementation. 1174 // AppWindowRegistry::Observer implementation.
1176 virtual void OnShellWindowAdded(ShellWindow* shell_window) OVERRIDE { 1175 virtual void OnAppWindowAdded(AppWindow* app_window) OVERRIDE {
1177 opener_app_ids_.insert(shell_window->extension()->id()); 1176 opener_app_ids_.insert(app_window->extension()->id());
1178 } 1177 }
1179 virtual void OnShellWindowIconChanged(ShellWindow* shell_window) OVERRIDE {} 1178 virtual void OnAppWindowIconChanged(AppWindow* app_window) OVERRIDE {}
1180 virtual void OnShellWindowRemoved(ShellWindow* shell_window) OVERRIDE {} 1179 virtual void OnAppWindowRemoved(AppWindow* app_window) OVERRIDE {}
1181 1180
1182 protected: 1181 protected:
1183 // A set of ids of apps we've seen open a shell window. 1182 // A set of ids of apps we've seen open a app window.
1184 std::set<std::string> opener_app_ids_; 1183 std::set<std::string> opener_app_ids_;
1185 }; 1184 };
1186 1185
1187 IN_PROC_BROWSER_TEST_F(PlatformAppIncognitoBrowserTest, IncognitoComponentApp) { 1186 IN_PROC_BROWSER_TEST_F(PlatformAppIncognitoBrowserTest, IncognitoComponentApp) {
1188 // Get the file manager app. 1187 // Get the file manager app.
1189 const Extension* file_manager = extension_service()->GetExtensionById( 1188 const Extension* file_manager = extension_service()->GetExtensionById(
1190 "hhaomjibdihmijegdhdafkllkbggdgoj", false); 1189 "hhaomjibdihmijegdhdafkllkbggdgoj", false);
1191 ASSERT_TRUE(file_manager != NULL); 1190 ASSERT_TRUE(file_manager != NULL);
1192 Profile* incognito_profile = profile()->GetOffTheRecordProfile(); 1191 Profile* incognito_profile = profile()->GetOffTheRecordProfile();
1193 ASSERT_TRUE(incognito_profile != NULL); 1192 ASSERT_TRUE(incognito_profile != NULL);
1194 1193
1195 // Wait until the file manager has had a chance to register its listener 1194 // Wait until the file manager has had a chance to register its listener
1196 // for the launch event. 1195 // for the launch event.
1197 EventRouter* router = ExtensionSystem::Get(incognito_profile)->event_router(); 1196 EventRouter* router = ExtensionSystem::Get(incognito_profile)->event_router();
1198 ASSERT_TRUE(router != NULL); 1197 ASSERT_TRUE(router != NULL);
1199 while (!router->ExtensionHasEventListener( 1198 while (!router->ExtensionHasEventListener(
1200 file_manager->id(), app_runtime::OnLaunched::kEventName)) { 1199 file_manager->id(), app_runtime::OnLaunched::kEventName)) {
1201 content::RunAllPendingInMessageLoop(); 1200 content::RunAllPendingInMessageLoop();
1202 } 1201 }
1203 1202
1204 // Listen for new shell windows so we see the file manager app launch itself. 1203 // Listen for new app windows so we see the file manager app launch itself.
1205 ShellWindowRegistry* registry = ShellWindowRegistry::Get(incognito_profile); 1204 AppWindowRegistry* registry = AppWindowRegistry::Get(incognito_profile);
1206 ASSERT_TRUE(registry != NULL); 1205 ASSERT_TRUE(registry != NULL);
1207 registry->AddObserver(this); 1206 registry->AddObserver(this);
1208 1207
1209 OpenApplication(AppLaunchParams( 1208 OpenApplication(AppLaunchParams(
1210 incognito_profile, file_manager, 0, chrome::HOST_DESKTOP_TYPE_NATIVE)); 1209 incognito_profile, file_manager, 0, chrome::HOST_DESKTOP_TYPE_NATIVE));
1211 1210
1212 while (!ContainsKey(opener_app_ids_, file_manager->id())) { 1211 while (!ContainsKey(opener_app_ids_, file_manager->id())) {
1213 content::RunAllPendingInMessageLoop(); 1212 content::RunAllPendingInMessageLoop();
1214 } 1213 }
1215 } 1214 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 1321
1323 ExtensionApiTest::ResultCatcher result_catcher; 1322 ExtensionApiTest::ResultCatcher result_catcher;
1324 1323
1325 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 1324 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
1326 1325
1327 EXPECT_TRUE(result_catcher.GetNextResult()); 1326 EXPECT_TRUE(result_catcher.GetNextResult());
1328 } 1327 }
1329 } 1328 }
1330 1329
1331 } // namespace extensions 1330 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/app_controller_mac_browsertest.mm ('k') | chrome/browser/apps/app_browsertest_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698