OLD | NEW |
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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 374 |
375 private: | 375 private: |
376 | 376 |
377 DISALLOW_COPY_AND_ASSIGN(ShelfAppBrowserTestNoDefaultBrowser); | 377 DISALLOW_COPY_AND_ASSIGN(ShelfAppBrowserTestNoDefaultBrowser); |
378 }; | 378 }; |
379 | 379 |
380 // Test that we can launch a platform app and get a running item. | 380 // Test that we can launch a platform app and get a running item. |
381 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) { | 381 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) { |
382 int item_count = shelf_model()->item_count(); | 382 int item_count = shelf_model()->item_count(); |
383 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 383 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
384 AppWindow* window = CreateAppWindow(extension); | 384 AppWindow* window = CreateAppWindow(browser()->profile(), extension); |
385 ++item_count; | 385 ++item_count; |
386 ASSERT_EQ(item_count, shelf_model()->item_count()); | 386 ASSERT_EQ(item_count, shelf_model()->item_count()); |
387 const ash::ShelfItem& item = GetLastLauncherItem(); | 387 const ash::ShelfItem& item = GetLastLauncherItem(); |
388 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); | 388 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); |
389 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 389 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
390 CloseAppWindow(window); | 390 CloseAppWindow(window); |
391 --item_count; | 391 --item_count; |
392 EXPECT_EQ(item_count, shelf_model()->item_count()); | 392 EXPECT_EQ(item_count, shelf_model()->item_count()); |
393 } | 393 } |
394 | 394 |
395 // Test that we can launch a platform app that already has a shortcut. | 395 // Test that we can launch a platform app that already has a shortcut. |
396 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { | 396 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) { |
397 int item_count = shelf_model()->item_count(); | 397 int item_count = shelf_model()->item_count(); |
398 | 398 |
399 // First get app_id. | 399 // First get app_id. |
400 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 400 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
401 const std::string app_id = extension->id(); | 401 const std::string app_id = extension->id(); |
402 | 402 |
403 // Then create a shortcut. | 403 // Then create a shortcut. |
404 ash::ShelfID shortcut_id = CreateAppShortcutLauncherItem(app_id); | 404 ash::ShelfID shortcut_id = CreateAppShortcutLauncherItem(app_id); |
405 ++item_count; | 405 ++item_count; |
406 ASSERT_EQ(item_count, shelf_model()->item_count()); | 406 ASSERT_EQ(item_count, shelf_model()->item_count()); |
407 ash::ShelfItem item = *shelf_model()->ItemByID(shortcut_id); | 407 ash::ShelfItem item = *shelf_model()->ItemByID(shortcut_id); |
408 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 408 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
409 EXPECT_EQ(ash::STATUS_CLOSED, item.status); | 409 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
410 | 410 |
411 // Open a window. Confirm the item is now running. | 411 // Open a window. Confirm the item is now running. |
412 AppWindow* window = CreateAppWindow(extension); | 412 AppWindow* window = CreateAppWindow(browser()->profile(), extension); |
413 ash::wm::ActivateWindow(window->GetNativeWindow()); | 413 ash::wm::ActivateWindow(window->GetNativeWindow()); |
414 ASSERT_EQ(item_count, shelf_model()->item_count()); | 414 ASSERT_EQ(item_count, shelf_model()->item_count()); |
415 item = *shelf_model()->ItemByID(shortcut_id); | 415 item = *shelf_model()->ItemByID(shortcut_id); |
416 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 416 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
417 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 417 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
418 | 418 |
419 // Then close it, make sure there's still an item. | 419 // Then close it, make sure there's still an item. |
420 CloseAppWindow(window); | 420 CloseAppWindow(window); |
421 ASSERT_EQ(item_count, shelf_model()->item_count()); | 421 ASSERT_EQ(item_count, shelf_model()->item_count()); |
422 item = *shelf_model()->ItemByID(shortcut_id); | 422 item = *shelf_model()->ItemByID(shortcut_id); |
423 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 423 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
424 EXPECT_EQ(ash::STATUS_CLOSED, item.status); | 424 EXPECT_EQ(ash::STATUS_CLOSED, item.status); |
425 } | 425 } |
426 | 426 |
427 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) { | 427 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) { |
428 // Run. | 428 // Run. |
429 int item_count = shelf_model()->item_count(); | 429 int item_count = shelf_model()->item_count(); |
430 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 430 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
431 AppWindow* window = CreateAppWindow(extension); | 431 AppWindow* window = CreateAppWindow(browser()->profile(), extension); |
432 ++item_count; | 432 ++item_count; |
433 ASSERT_EQ(item_count, shelf_model()->item_count()); | 433 ASSERT_EQ(item_count, shelf_model()->item_count()); |
434 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 434 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
435 ash::ShelfID id = item1.id; | 435 ash::ShelfID id = item1.id; |
436 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 436 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
437 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 437 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
438 | 438 |
439 // Create a shortcut. The app item should be after it. | 439 // Create a shortcut. The app item should be after it. |
440 ash::ShelfID foo_id = CreateAppShortcutLauncherItem("foo"); | 440 ash::ShelfID foo_id = CreateAppShortcutLauncherItem("foo"); |
441 ++item_count; | 441 ++item_count; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 479 |
480 // Create a second shortcut. This will be needed to force the first one to | 480 // Create a second shortcut. This will be needed to force the first one to |
481 // move once it gets unpinned. | 481 // move once it gets unpinned. |
482 ash::ShelfID foo_id = CreateAppShortcutLauncherItem("foo"); | 482 ash::ShelfID foo_id = CreateAppShortcutLauncherItem("foo"); |
483 ++item_count; | 483 ++item_count; |
484 ASSERT_EQ(item_count, shelf_model()->item_count()); | 484 ASSERT_EQ(item_count, shelf_model()->item_count()); |
485 EXPECT_LT(shelf_model()->ItemIndexByID(shortcut_id), | 485 EXPECT_LT(shelf_model()->ItemIndexByID(shortcut_id), |
486 shelf_model()->ItemIndexByID(foo_id)); | 486 shelf_model()->ItemIndexByID(foo_id)); |
487 | 487 |
488 // Open a window. Confirm the item is now running. | 488 // Open a window. Confirm the item is now running. |
489 AppWindow* window = CreateAppWindow(extension); | 489 AppWindow* window = CreateAppWindow(browser()->profile(), extension); |
490 ash::wm::ActivateWindow(window->GetNativeWindow()); | 490 ash::wm::ActivateWindow(window->GetNativeWindow()); |
491 ASSERT_EQ(item_count, shelf_model()->item_count()); | 491 ASSERT_EQ(item_count, shelf_model()->item_count()); |
492 item = *shelf_model()->ItemByID(shortcut_id); | 492 item = *shelf_model()->ItemByID(shortcut_id); |
493 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); | 493 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
494 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 494 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
495 | 495 |
496 // Unpin the app. The item should remain. | 496 // Unpin the app. The item should remain. |
497 controller_->Unpin(shortcut_id); | 497 controller_->Unpin(shortcut_id); |
498 ASSERT_EQ(item_count, shelf_model()->item_count()); | 498 ASSERT_EQ(item_count, shelf_model()->item_count()); |
499 item = *shelf_model()->ItemByID(shortcut_id); | 499 item = *shelf_model()->ItemByID(shortcut_id); |
500 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); | 500 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); |
501 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 501 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
502 // The item should have moved after the other shortcuts. | 502 // The item should have moved after the other shortcuts. |
503 EXPECT_GT(shelf_model()->ItemIndexByID(shortcut_id), | 503 EXPECT_GT(shelf_model()->ItemIndexByID(shortcut_id), |
504 shelf_model()->ItemIndexByID(foo_id)); | 504 shelf_model()->ItemIndexByID(foo_id)); |
505 | 505 |
506 // Then close it, make sure the item's gone. | 506 // Then close it, make sure the item's gone. |
507 CloseAppWindow(window); | 507 CloseAppWindow(window); |
508 --item_count; | 508 --item_count; |
509 ASSERT_EQ(item_count, shelf_model()->item_count()); | 509 ASSERT_EQ(item_count, shelf_model()->item_count()); |
510 } | 510 } |
511 | 511 |
512 // Test that we can launch a platform app with more than one window. | 512 // Test that we can launch a platform app with more than one window. |
513 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) { | 513 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) { |
514 int item_count = shelf_model()->item_count(); | 514 int item_count = shelf_model()->item_count(); |
515 | 515 |
516 // First run app. | 516 // First run app. |
517 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 517 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
518 AppWindow* window1 = CreateAppWindow(extension); | 518 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension); |
519 ++item_count; | 519 ++item_count; |
520 ASSERT_EQ(item_count, shelf_model()->item_count()); | 520 ASSERT_EQ(item_count, shelf_model()->item_count()); |
521 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 521 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
522 ash::ShelfID item_id = item1.id; | 522 ash::ShelfID item_id = item1.id; |
523 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 523 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
524 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 524 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
525 EXPECT_EQ(2, GetNumApplicationMenuItems(item1)); // Title + 1 window | 525 EXPECT_EQ(2, GetNumApplicationMenuItems(item1)); // Title + 1 window |
526 | 526 |
527 // Add second window. | 527 // Add second window. |
528 AppWindow* window2 = CreateAppWindow(extension); | 528 AppWindow* window2 = CreateAppWindow(browser()->profile(), extension); |
529 // Confirm item stays. | 529 // Confirm item stays. |
530 ASSERT_EQ(item_count, shelf_model()->item_count()); | 530 ASSERT_EQ(item_count, shelf_model()->item_count()); |
531 const ash::ShelfItem& item2 = *shelf_model()->ItemByID(item_id); | 531 const ash::ShelfItem& item2 = *shelf_model()->ItemByID(item_id); |
532 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); | 532 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); |
533 EXPECT_EQ(3, GetNumApplicationMenuItems(item2)); // Title + 2 windows | 533 EXPECT_EQ(3, GetNumApplicationMenuItems(item2)); // Title + 2 windows |
534 | 534 |
535 // Close second window. | 535 // Close second window. |
536 CloseAppWindow(window2); | 536 CloseAppWindow(window2); |
537 // Confirm item stays. | 537 // Confirm item stays. |
538 ASSERT_EQ(item_count, shelf_model()->item_count()); | 538 ASSERT_EQ(item_count, shelf_model()->item_count()); |
539 const ash::ShelfItem& item3 = *shelf_model()->ItemByID(item_id); | 539 const ash::ShelfItem& item3 = *shelf_model()->ItemByID(item_id); |
540 EXPECT_EQ(ash::STATUS_ACTIVE, item3.status); | 540 EXPECT_EQ(ash::STATUS_ACTIVE, item3.status); |
541 EXPECT_EQ(2, GetNumApplicationMenuItems(item3)); // Title + 1 window | 541 EXPECT_EQ(2, GetNumApplicationMenuItems(item3)); // Title + 1 window |
542 | 542 |
543 // Close first window. | 543 // Close first window. |
544 CloseAppWindow(window1); | 544 CloseAppWindow(window1); |
545 // Confirm item is removed. | 545 // Confirm item is removed. |
546 --item_count; | 546 --item_count; |
547 ASSERT_EQ(item_count, shelf_model()->item_count()); | 547 ASSERT_EQ(item_count, shelf_model()->item_count()); |
548 } | 548 } |
549 | 549 |
550 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleApps) { | 550 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleApps) { |
551 int item_count = shelf_model()->item_count(); | 551 int item_count = shelf_model()->item_count(); |
552 | 552 |
553 // First run app. | 553 // First run app. |
554 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); | 554 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); |
555 AppWindow* window1 = CreateAppWindow(extension1); | 555 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension1); |
556 ++item_count; | 556 ++item_count; |
557 ASSERT_EQ(item_count, shelf_model()->item_count()); | 557 ASSERT_EQ(item_count, shelf_model()->item_count()); |
558 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 558 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
559 ash::ShelfID item_id1 = item1.id; | 559 ash::ShelfID item_id1 = item1.id; |
560 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 560 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
561 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 561 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
562 | 562 |
563 // Then run second app. | 563 // Then run second app. |
564 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2", | 564 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2", |
565 "Launched"); | 565 "Launched"); |
566 AppWindow* window2 = CreateAppWindow(extension2); | 566 AppWindow* window2 = CreateAppWindow(browser()->profile(), extension2); |
567 ++item_count; | 567 ++item_count; |
568 ASSERT_EQ(item_count, shelf_model()->item_count()); | 568 ASSERT_EQ(item_count, shelf_model()->item_count()); |
569 const ash::ShelfItem& item2 = GetLastLauncherItem(); | 569 const ash::ShelfItem& item2 = GetLastLauncherItem(); |
570 ash::ShelfID item_id2 = item2.id; | 570 ash::ShelfID item_id2 = item2.id; |
571 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); | 571 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); |
572 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); | 572 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); |
573 | 573 |
574 EXPECT_NE(item_id1, item_id2); | 574 EXPECT_NE(item_id1, item_id2); |
575 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status); | 575 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status); |
576 | 576 |
(...skipping 10 matching lines...) Expand all Loading... |
587 ASSERT_EQ(item_count, shelf_model()->item_count()); | 587 ASSERT_EQ(item_count, shelf_model()->item_count()); |
588 } | 588 } |
589 | 589 |
590 // Confirm that app windows can be reactivated by clicking their icons and that | 590 // Confirm that app windows can be reactivated by clicking their icons and that |
591 // the correct activation order is maintained. | 591 // the correct activation order is maintained. |
592 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowActivation) { | 592 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowActivation) { |
593 int item_count = shelf_model()->item_count(); | 593 int item_count = shelf_model()->item_count(); |
594 | 594 |
595 // First run app. | 595 // First run app. |
596 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); | 596 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); |
597 AppWindow* window1 = CreateAppWindow(extension1); | 597 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension1); |
598 ++item_count; | 598 ++item_count; |
599 ASSERT_EQ(item_count, shelf_model()->item_count()); | 599 ASSERT_EQ(item_count, shelf_model()->item_count()); |
600 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 600 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
601 ash::ShelfID item_id1 = item1.id; | 601 ash::ShelfID item_id1 = item1.id; |
602 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 602 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
603 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 603 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
604 | 604 |
605 // Then run second app. | 605 // Then run second app. |
606 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2", | 606 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2", |
607 "Launched"); | 607 "Launched"); |
608 AppWindow* window2 = CreateAppWindow(extension2); | 608 AppWindow* window2 = CreateAppWindow(browser()->profile(), extension2); |
609 ++item_count; | 609 ++item_count; |
610 ASSERT_EQ(item_count, shelf_model()->item_count()); | 610 ASSERT_EQ(item_count, shelf_model()->item_count()); |
611 const ash::ShelfItem& item2 = GetLastLauncherItem(); | 611 const ash::ShelfItem& item2 = GetLastLauncherItem(); |
612 ash::ShelfID item_id2 = item2.id; | 612 ash::ShelfID item_id2 = item2.id; |
613 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); | 613 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type); |
614 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); | 614 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); |
615 | 615 |
616 EXPECT_NE(item_id1, item_id2); | 616 EXPECT_NE(item_id1, item_id2); |
617 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status); | 617 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status); |
618 | 618 |
619 // Activate first one. | 619 // Activate first one. |
620 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id1)); | 620 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id1)); |
621 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id1)->status); | 621 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id1)->status); |
622 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id2)->status); | 622 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id2)->status); |
623 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); | 623 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
624 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); | 624 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); |
625 | 625 |
626 // Activate second one. | 626 // Activate second one. |
627 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id2)); | 627 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id2)); |
628 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status); | 628 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status); |
629 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id2)->status); | 629 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id2)->status); |
630 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); | 630 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
631 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); | 631 EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); |
632 | 632 |
633 // Add window for app1. This will activate it. | 633 // Add window for app1. This will activate it. |
634 AppWindow* window1b = CreateAppWindow(extension1); | 634 AppWindow* window1b = CreateAppWindow(browser()->profile(), extension1); |
635 ash::wm::ActivateWindow(window1b->GetNativeWindow()); | 635 ash::wm::ActivateWindow(window1b->GetNativeWindow()); |
636 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); | 636 EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
637 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); | 637 EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); |
638 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); | 638 EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); |
639 | 639 |
640 // Activate launcher item for app1, this will activate the first app window. | 640 // Activate launcher item for app1, this will activate the first app window. |
641 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id1)); | 641 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id1)); |
642 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); | 642 EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
643 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); | 643 EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow())); |
644 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id1)); | 644 ActivateShelfItem(shelf_model()->ItemIndexByID(item_id1)); |
(...skipping 23 matching lines...) Expand all Loading... |
668 CloseAppWindow(window1); | 668 CloseAppWindow(window1); |
669 --item_count; | 669 --item_count; |
670 EXPECT_EQ(item_count, shelf_model()->item_count()); | 670 EXPECT_EQ(item_count, shelf_model()->item_count()); |
671 } | 671 } |
672 | 672 |
673 // Confirm the minimizing click behavior for apps. | 673 // Confirm the minimizing click behavior for apps. |
674 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, | 674 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, |
675 PackagedAppClickBehaviorInMinimizeMode) { | 675 PackagedAppClickBehaviorInMinimizeMode) { |
676 // Launch one platform app and create a window for it. | 676 // Launch one platform app and create a window for it. |
677 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); | 677 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); |
678 AppWindow* window1 = CreateAppWindow(extension1); | 678 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension1); |
679 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 679 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
680 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 680 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
681 | 681 |
682 // Confirm that a controller item was created and is the correct state. | 682 // Confirm that a controller item was created and is the correct state. |
683 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 683 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
684 LauncherItemController* item1_controller = GetItemController(item1.id); | 684 LauncherItemController* item1_controller = GetItemController(item1.id); |
685 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 685 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
686 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 686 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
687 EXPECT_EQ(LauncherItemController::TYPE_APP, item1_controller->type()); | 687 EXPECT_EQ(LauncherItemController::TYPE_APP, item1_controller->type()); |
688 // Since it is already active, clicking it should minimize. | 688 // Since it is already active, clicking it should minimize. |
(...skipping 15 matching lines...) Expand all Loading... |
704 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 704 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
705 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 705 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
706 EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized()); | 706 EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized()); |
707 window1->GetBaseWindow()->Restore(); | 707 window1->GetBaseWindow()->Restore(); |
708 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 708 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
709 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 709 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
710 EXPECT_FALSE(window1->GetBaseWindow()->IsMaximized()); | 710 EXPECT_FALSE(window1->GetBaseWindow()->IsMaximized()); |
711 | 711 |
712 // Creating a second window of the same type should change the behavior so | 712 // Creating a second window of the same type should change the behavior so |
713 // that a click does not change the activation state. | 713 // that a click does not change the activation state. |
714 AppWindow* window1a = CreateAppWindow(extension1); | 714 AppWindow* window1a = CreateAppWindow(browser()->profile(), extension1); |
715 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); | 715 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); |
716 EXPECT_TRUE(window1a->GetBaseWindow()->IsActive()); | 716 EXPECT_TRUE(window1a->GetBaseWindow()->IsActive()); |
717 // The first click does nothing. | 717 // The first click does nothing. |
718 item1_controller->ItemSelected(click_event); | 718 item1_controller->ItemSelected(click_event); |
719 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 719 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
720 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); | 720 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); |
721 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 721 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
722 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive()); | 722 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive()); |
723 // The second neither. | 723 // The second neither. |
724 item1_controller->ItemSelected(click_event); | 724 item1_controller->ItemSelected(click_event); |
725 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 725 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
726 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); | 726 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); |
727 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 727 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
728 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive()); | 728 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive()); |
729 } | 729 } |
730 | 730 |
731 // Confirm that click behavior for app panels is correct. | 731 // Confirm that click behavior for app panels is correct. |
732 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, AppPanelClickBehavior) { | 732 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, AppPanelClickBehavior) { |
733 // Enable experimental APIs to allow panel creation. | 733 // Enable experimental APIs to allow panel creation. |
734 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 734 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
735 extensions::switches::kEnableExperimentalExtensionApis); | 735 extensions::switches::kEnableExperimentalExtensionApis); |
736 // Launch a platform app and create a panel window for it. | 736 // Launch a platform app and create a panel window for it. |
737 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); | 737 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); |
738 AppWindow::CreateParams params; | 738 AppWindow::CreateParams params; |
739 params.window_type = AppWindow::WINDOW_TYPE_PANEL; | 739 params.window_type = AppWindow::WINDOW_TYPE_PANEL; |
740 params.focused = false; | 740 params.focused = false; |
741 AppWindow* panel = CreateAppWindowFromParams(extension1, params); | 741 AppWindow* panel = |
| 742 CreateAppWindowFromParams(browser()->profile(), extension1, params); |
742 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); | 743 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); |
743 // Panels should not be active by default. | 744 // Panels should not be active by default. |
744 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); | 745 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); |
745 // Confirm that a controller item was created and is the correct state. | 746 // Confirm that a controller item was created and is the correct state. |
746 const ash::ShelfItem& item1 = GetLastLauncherPanelItem(); | 747 const ash::ShelfItem& item1 = GetLastLauncherPanelItem(); |
747 LauncherItemController* item1_controller = GetItemController(item1.id); | 748 LauncherItemController* item1_controller = GetItemController(item1.id); |
748 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type); | 749 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type); |
749 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); | 750 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); |
750 EXPECT_EQ(LauncherItemController::TYPE_APP_PANEL, item1_controller->type()); | 751 EXPECT_EQ(LauncherItemController::TYPE_APP_PANEL, item1_controller->type()); |
751 // Click the item and confirm that the panel is activated. | 752 // Click the item and confirm that the panel is activated. |
(...skipping 10 matching lines...) Expand all Loading... |
762 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); | 763 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); |
763 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); | 764 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); |
764 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 765 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
765 } | 766 } |
766 | 767 |
767 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) { | 768 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) { |
768 int item_count = shelf_model()->item_count(); | 769 int item_count = shelf_model()->item_count(); |
769 | 770 |
770 // First run app. | 771 // First run app. |
771 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); | 772 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); |
772 CreateAppWindow(extension1); | 773 CreateAppWindow(browser()->profile(), extension1); |
773 ++item_count; | 774 ++item_count; |
774 ASSERT_EQ(item_count, shelf_model()->item_count()); | 775 ASSERT_EQ(item_count, shelf_model()->item_count()); |
775 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 776 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
776 ash::ShelfID item_id1 = item1.id; | 777 ash::ShelfID item_id1 = item1.id; |
777 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 778 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
778 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 779 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
779 | 780 |
780 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow()); | 781 ash::wm::ActivateWindow(browser()->window()->GetNativeWindow()); |
781 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status); | 782 EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->ItemByID(item_id1)->status); |
782 } | 783 } |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 ActivateShelfItem(shortcut_index); | 1360 ActivateShelfItem(shortcut_index); |
1360 EXPECT_EQ(content2, browser()->tab_strip_model()->GetActiveWebContents()); | 1361 EXPECT_EQ(content2, browser()->tab_strip_model()->GetActiveWebContents()); |
1361 } | 1362 } |
1362 | 1363 |
1363 // Check that the keyboard activation of a launcher item tabs properly through | 1364 // Check that the keyboard activation of a launcher item tabs properly through |
1364 // the items at hand. | 1365 // the items at hand. |
1365 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, | 1366 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, |
1366 AltNumberAppsTabbing) { | 1367 AltNumberAppsTabbing) { |
1367 // First run app. | 1368 // First run app. |
1368 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); | 1369 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); |
1369 ui::BaseWindow* window1 = CreateAppWindow(extension1)->GetBaseWindow(); | 1370 ui::BaseWindow* window1 = |
| 1371 CreateAppWindow(browser()->profile(), extension1)->GetBaseWindow(); |
1370 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 1372 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
1371 ash::ShelfID app_id = item1.id; | 1373 ash::ShelfID app_id = item1.id; |
1372 int app_index = shelf_model()->ItemIndexByID(app_id); | 1374 int app_index = shelf_model()->ItemIndexByID(app_id); |
1373 | 1375 |
1374 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | 1376 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
1375 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 1377 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
1376 | 1378 |
1377 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2", | 1379 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2", |
1378 "Launched"); | 1380 "Launched"); |
1379 ui::BaseWindow* window2 = CreateAppWindow(extension2)->GetBaseWindow(); | 1381 ui::BaseWindow* window2 = |
| 1382 CreateAppWindow(browser()->profile(), extension2)->GetBaseWindow(); |
1380 | 1383 |
1381 // By now the browser should be active. Issue Alt keystrokes several times to | 1384 // By now the browser should be active. Issue Alt keystrokes several times to |
1382 // see that we stay on that application. | 1385 // see that we stay on that application. |
1383 EXPECT_TRUE(window2->IsActive()); | 1386 EXPECT_TRUE(window2->IsActive()); |
1384 ActivateShelfItem(app_index); | 1387 ActivateShelfItem(app_index); |
1385 EXPECT_TRUE(window1->IsActive()); | 1388 EXPECT_TRUE(window1->IsActive()); |
1386 ActivateShelfItem(app_index); | 1389 ActivateShelfItem(app_index); |
1387 EXPECT_TRUE(window1->IsActive()); | 1390 EXPECT_TRUE(window1->IsActive()); |
1388 | 1391 |
1389 ui::BaseWindow* window1a = CreateAppWindow(extension1)->GetBaseWindow(); | 1392 ui::BaseWindow* window1a = |
| 1393 CreateAppWindow(browser()->profile(), extension1)->GetBaseWindow(); |
1390 | 1394 |
1391 EXPECT_TRUE(window1a->IsActive()); | 1395 EXPECT_TRUE(window1a->IsActive()); |
1392 EXPECT_FALSE(window1->IsActive()); | 1396 EXPECT_FALSE(window1->IsActive()); |
1393 ActivateShelfItem(app_index); | 1397 ActivateShelfItem(app_index); |
1394 EXPECT_TRUE(window1->IsActive()); | 1398 EXPECT_TRUE(window1->IsActive()); |
1395 ActivateShelfItem(app_index); | 1399 ActivateShelfItem(app_index); |
1396 EXPECT_TRUE(window1a->IsActive()); | 1400 EXPECT_TRUE(window1a->IsActive()); |
1397 } | 1401 } |
1398 | 1402 |
1399 // Test that we can launch a platform app panel and get a running item. | 1403 // Test that we can launch a platform app panel and get a running item. |
1400 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPanelWindow) { | 1404 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPanelWindow) { |
1401 int item_count = shelf_model()->item_count(); | 1405 int item_count = shelf_model()->item_count(); |
1402 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 1406 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
1403 AppWindow::CreateParams params; | 1407 AppWindow::CreateParams params; |
1404 params.window_type = AppWindow::WINDOW_TYPE_PANEL; | 1408 params.window_type = AppWindow::WINDOW_TYPE_PANEL; |
1405 params.focused = false; | 1409 params.focused = false; |
1406 AppWindow* window = CreateAppWindowFromParams(extension, params); | 1410 AppWindow* window = |
| 1411 CreateAppWindowFromParams(browser()->profile(), extension, params); |
1407 ++item_count; | 1412 ++item_count; |
1408 ASSERT_EQ(item_count, shelf_model()->item_count()); | 1413 ASSERT_EQ(item_count, shelf_model()->item_count()); |
1409 const ash::ShelfItem& item = GetLastLauncherPanelItem(); | 1414 const ash::ShelfItem& item = GetLastLauncherPanelItem(); |
1410 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type); | 1415 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type); |
1411 // Opening a panel does not activate it. | 1416 // Opening a panel does not activate it. |
1412 EXPECT_EQ(ash::STATUS_RUNNING, item.status); | 1417 EXPECT_EQ(ash::STATUS_RUNNING, item.status); |
1413 CloseAppWindow(window); | 1418 CloseAppWindow(window); |
1414 --item_count; | 1419 --item_count; |
1415 EXPECT_EQ(item_count, shelf_model()->item_count()); | 1420 EXPECT_EQ(item_count, shelf_model()->item_count()); |
1416 } | 1421 } |
1417 | 1422 |
1418 // Test that we get correct shelf presence with hidden app windows. | 1423 // Test that we get correct shelf presence with hidden app windows. |
1419 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, HiddenAppWindows) { | 1424 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, HiddenAppWindows) { |
1420 int item_count = shelf_model()->item_count(); | 1425 int item_count = shelf_model()->item_count(); |
1421 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 1426 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
1422 AppWindow::CreateParams params; | 1427 AppWindow::CreateParams params; |
1423 | 1428 |
1424 // Create a hidden window. | 1429 // Create a hidden window. |
1425 params.hidden = true; | 1430 params.hidden = true; |
1426 AppWindow* window_1 = CreateAppWindowFromParams(extension, params); | 1431 AppWindow* window_1 = |
| 1432 CreateAppWindowFromParams(browser()->profile(), extension, params); |
1427 EXPECT_EQ(item_count, shelf_model()->item_count()); | 1433 EXPECT_EQ(item_count, shelf_model()->item_count()); |
1428 | 1434 |
1429 // Create a visible window. | 1435 // Create a visible window. |
1430 params.hidden = false; | 1436 params.hidden = false; |
1431 AppWindow* window_2 = CreateAppWindowFromParams(extension, params); | 1437 AppWindow* window_2 = |
| 1438 CreateAppWindowFromParams(browser()->profile(), extension, params); |
1432 ++item_count; | 1439 ++item_count; |
1433 EXPECT_EQ(item_count, shelf_model()->item_count()); | 1440 EXPECT_EQ(item_count, shelf_model()->item_count()); |
1434 | 1441 |
1435 // Minimize the visible window. | 1442 // Minimize the visible window. |
1436 window_2->Minimize(); | 1443 window_2->Minimize(); |
1437 EXPECT_EQ(item_count, shelf_model()->item_count()); | 1444 EXPECT_EQ(item_count, shelf_model()->item_count()); |
1438 | 1445 |
1439 // Hide the visible window. | 1446 // Hide the visible window. |
1440 window_2->Hide(); | 1447 window_2->Hide(); |
1441 --item_count; | 1448 --item_count; |
1442 EXPECT_EQ(item_count, shelf_model()->item_count()); | 1449 EXPECT_EQ(item_count, shelf_model()->item_count()); |
1443 | 1450 |
1444 // Show the originally hidden window. | 1451 // Show the originally hidden window. |
1445 window_1->Show(AppWindow::SHOW_ACTIVE); | 1452 window_1->Show(AppWindow::SHOW_ACTIVE); |
1446 ++item_count; | 1453 ++item_count; |
1447 EXPECT_EQ(item_count, shelf_model()->item_count()); | 1454 EXPECT_EQ(item_count, shelf_model()->item_count()); |
1448 | 1455 |
1449 // Close the originally hidden window. | 1456 // Close the originally hidden window. |
1450 CloseAppWindow(window_1); | 1457 CloseAppWindow(window_1); |
1451 --item_count; | 1458 --item_count; |
1452 EXPECT_EQ(item_count, shelf_model()->item_count()); | 1459 EXPECT_EQ(item_count, shelf_model()->item_count()); |
1453 } | 1460 } |
1454 | 1461 |
1455 // Test attention states of windows. | 1462 // Test attention states of windows. |
1456 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowAttentionStatus) { | 1463 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowAttentionStatus) { |
1457 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 1464 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
1458 AppWindow::CreateParams params; | 1465 AppWindow::CreateParams params; |
1459 params.window_type = AppWindow::WINDOW_TYPE_PANEL; | 1466 params.window_type = AppWindow::WINDOW_TYPE_PANEL; |
1460 params.focused = false; | 1467 params.focused = false; |
1461 AppWindow* panel = CreateAppWindowFromParams(extension, params); | 1468 AppWindow* panel = |
| 1469 CreateAppWindowFromParams(browser()->profile(), extension, params); |
1462 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); | 1470 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); |
1463 // Panels should not be active by default. | 1471 // Panels should not be active by default. |
1464 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); | 1472 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); |
1465 // Confirm that a controller item was created and is the correct state. | 1473 // Confirm that a controller item was created and is the correct state. |
1466 const ash::ShelfItem& item = GetLastLauncherPanelItem(); | 1474 const ash::ShelfItem& item = GetLastLauncherPanelItem(); |
1467 LauncherItemController* item_controller = GetItemController(item.id); | 1475 LauncherItemController* item_controller = GetItemController(item.id); |
1468 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type); | 1476 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type); |
1469 EXPECT_EQ(ash::STATUS_RUNNING, item.status); | 1477 EXPECT_EQ(ash::STATUS_RUNNING, item.status); |
1470 EXPECT_EQ(LauncherItemController::TYPE_APP_PANEL, item_controller->type()); | 1478 EXPECT_EQ(LauncherItemController::TYPE_APP_PANEL, item_controller->type()); |
1471 | 1479 |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2227 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); | 2235 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); |
2228 | 2236 |
2229 // There should be two new browsers. | 2237 // There should be two new browsers. |
2230 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile())); | 2238 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile())); |
2231 | 2239 |
2232 // The apps should now be running, with the last opened app active. | 2240 // The apps should now be running, with the last opened app active. |
2233 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); | 2241 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); |
2234 EXPECT_EQ(ash::STATUS_ACTIVE, | 2242 EXPECT_EQ(ash::STATUS_ACTIVE, |
2235 model_->ItemByID(bookmark_app_shelf_id)->status); | 2243 model_->ItemByID(bookmark_app_shelf_id)->status); |
2236 } | 2244 } |
OLD | NEW |