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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc

Issue 11451019: Remove TabContents from ui/ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/launcher/launcher_model.h" 8 #include "ash/launcher/launcher_model.h"
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/automation/automation_util.h" 12 #include "chrome/browser/automation/automation_util.h"
13 #include "chrome/browser/extensions/extension_apitest.h" 13 #include "chrome/browser/extensions/extension_apitest.h"
14 #include "chrome/browser/extensions/extension_browsertest.h" 14 #include "chrome/browser/extensions/extension_browsertest.h"
15 #include "chrome/browser/extensions/extension_function_test_utils.h" 15 #include "chrome/browser/extensions/extension_function_test_utils.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/extension_system.h" 17 #include "chrome/browser/extensions/extension_system.h"
18 #include "chrome/browser/extensions/extension_test_message_listener.h" 18 #include "chrome/browser/extensions/extension_test_message_listener.h"
19 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 19 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
20 #include "chrome/browser/extensions/shell_window_registry.h" 20 #include "chrome/browser/extensions/shell_window_registry.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_commands.h" 23 #include "chrome/browser/ui/browser_commands.h"
24 #include "chrome/browser/ui/browser_window.h" 24 #include "chrome/browser/ui/browser_window.h"
25 #include "chrome/browser/ui/extensions/application_launch.h" 25 #include "chrome/browser/ui/extensions/application_launch.h"
26 #include "chrome/browser/ui/extensions/shell_window.h" 26 #include "chrome/browser/ui/extensions/shell_window.h"
27 #include "chrome/browser/ui/tabs/tab_strip_model.h" 27 #include "chrome/browser/ui/tabs/tab_strip_model.h"
28 #include "chrome/browser/ui/tab_contents/tab_contents.h"
29 #include "chrome/common/chrome_notification_types.h" 28 #include "chrome/common/chrome_notification_types.h"
30 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
31 #include "chrome/common/extensions/extension_constants.h" 30 #include "chrome/common/extensions/extension_constants.h"
32 #include "chrome/test/base/ui_test_utils.h" 31 #include "chrome/test/base/ui_test_utils.h"
33 #include "content/public/browser/notification_service.h" 32 #include "content/public/browser/notification_service.h"
34 #include "content/public/browser/notification_source.h" 33 #include "content/public/browser/notification_source.h"
35 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
36 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
37 #include "ui/aura/window.h" 36 #include "ui/aura/window.h"
38 37
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 458
460 // Test that we can launch an app with a shortcut. 459 // Test that we can launch an app with a shortcut.
461 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) { 460 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) {
462 TabStripModel* tab_strip = browser()->tab_strip_model(); 461 TabStripModel* tab_strip = browser()->tab_strip_model();
463 int tab_count = tab_strip->count(); 462 int tab_count = tab_strip->count();
464 ash::LauncherID shortcut_id = CreateShortcut("app1"); 463 ash::LauncherID shortcut_id = CreateShortcut("app1");
465 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); 464 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
466 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); 465 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
467 EXPECT_EQ(++tab_count, tab_strip->count()); 466 EXPECT_EQ(++tab_count, tab_strip->count());
468 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); 467 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
469 TabContents* tab = tab_strip->GetActiveTabContents(); 468 WebContents* tab = tab_strip->GetActiveWebContents();
470 content::WindowedNotificationObserver close_observer( 469 content::WindowedNotificationObserver close_observer(
471 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 470 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
472 content::Source<WebContents>(tab->web_contents())); 471 content::Source<WebContents>(tab));
473 browser()->tab_strip_model()->CloseSelectedTabs(); 472 browser()->tab_strip_model()->CloseSelectedTabs();
474 close_observer.Wait(); 473 close_observer.Wait();
475 EXPECT_EQ(--tab_count, tab_strip->count()); 474 EXPECT_EQ(--tab_count, tab_strip->count());
476 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); 475 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
477 } 476 }
478 477
479 // Launch the app first and then create the shortcut. 478 // Launch the app first and then create the shortcut.
480 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchUnpinned) { 479 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchUnpinned) {
481 TabStripModel* tab_strip = browser()->tab_strip_model(); 480 TabStripModel* tab_strip = browser()->tab_strip_model();
482 int tab_count = tab_strip->count(); 481 int tab_count = tab_strip->count();
483 LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB, 482 LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB,
484 NEW_FOREGROUND_TAB); 483 NEW_FOREGROUND_TAB);
485 EXPECT_EQ(++tab_count, tab_strip->count()); 484 EXPECT_EQ(++tab_count, tab_strip->count());
486 ash::LauncherID shortcut_id = CreateShortcut("app1"); 485 ash::LauncherID shortcut_id = CreateShortcut("app1");
487 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); 486 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
488 TabContents* tab = tab_strip->GetActiveTabContents(); 487 WebContents* tab = tab_strip->GetActiveWebContents();
489 content::WindowedNotificationObserver close_observer( 488 content::WindowedNotificationObserver close_observer(
490 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 489 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
491 content::Source<WebContents>(tab->web_contents())); 490 content::Source<WebContents>(tab));
492 browser()->tab_strip_model()->CloseSelectedTabs(); 491 browser()->tab_strip_model()->CloseSelectedTabs();
493 close_observer.Wait(); 492 close_observer.Wait();
494 EXPECT_EQ(--tab_count, tab_strip->count()); 493 EXPECT_EQ(--tab_count, tab_strip->count());
495 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); 494 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
496 } 495 }
497 496
498 // Launches an app in the background and then tries to open it. This is test for 497 // Launches an app in the background and then tries to open it. This is test for
499 // a crash we had. 498 // a crash we had.
500 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchInBackground) { 499 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchInBackground) {
501 TabStripModel* tab_strip = browser()->tab_strip_model(); 500 TabStripModel* tab_strip = browser()->tab_strip_model();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 TabStripModel* tab_strip = browser()->tab_strip_model(); 566 TabStripModel* tab_strip = browser()->tab_strip_model();
568 int tab_count = tab_strip->count(); 567 int tab_count = tab_strip->count();
569 ash::LauncherID shortcut1 = CreateShortcut("app1"); 568 ash::LauncherID shortcut1 = CreateShortcut("app1");
570 EXPECT_EQ(++item_count, model_->item_count()); 569 EXPECT_EQ(++item_count, model_->item_count());
571 ash::LauncherID shortcut2 = CreateShortcut("app2"); 570 ash::LauncherID shortcut2 = CreateShortcut("app2");
572 EXPECT_EQ(++item_count, model_->item_count()); 571 EXPECT_EQ(++item_count, model_->item_count());
573 572
574 // Launch first app. 573 // Launch first app.
575 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut1)); 574 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut1));
576 EXPECT_EQ(++tab_count, tab_strip->count()); 575 EXPECT_EQ(++tab_count, tab_strip->count());
577 TabContents* tab1 = tab_strip->GetActiveTabContents(); 576 WebContents* tab1 = tab_strip->GetActiveWebContents();
578 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status); 577 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status);
579 578
580 // Launch second app. 579 // Launch second app.
581 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut2)); 580 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut2));
582 EXPECT_EQ(++tab_count, tab_strip->count()); 581 EXPECT_EQ(++tab_count, tab_strip->count());
583 TabContents* tab2 = tab_strip->GetActiveTabContents(); 582 WebContents* tab2 = tab_strip->GetActiveWebContents();
584 ASSERT_NE(tab1, tab2); 583 ASSERT_NE(tab1, tab2);
585 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status); 584 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status);
586 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status); 585 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status);
587 586
588 // Reactivate first app. 587 // Reactivate first app.
589 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut1)); 588 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut1));
590 EXPECT_EQ(tab_count, tab_strip->count()); 589 EXPECT_EQ(tab_count, tab_strip->count());
591 EXPECT_EQ(tab_strip->GetActiveTabContents(), tab1); 590 EXPECT_EQ(tab_strip->GetActiveWebContents(), tab1);
592 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status); 591 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status);
593 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut2)).status); 592 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut2)).status);
594 593
595 // Open second tab for second app. This should activate it. 594 // Open second tab for second app. This should activate it.
596 ui_test_utils::NavigateToURLWithDisposition( 595 ui_test_utils::NavigateToURLWithDisposition(
597 browser(), 596 browser(),
598 GURL("http://www.example.com/path3/foo.html"), 597 GURL("http://www.example.com/path3/foo.html"),
599 NEW_FOREGROUND_TAB, 598 NEW_FOREGROUND_TAB,
600 0); 599 0);
601 EXPECT_EQ(++tab_count, tab_strip->count()); 600 EXPECT_EQ(++tab_count, tab_strip->count());
602 TabContents* tab3 = tab_strip->GetActiveTabContents(); 601 WebContents* tab3 = tab_strip->GetActiveWebContents();
603 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status); 602 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status);
604 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status); 603 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status);
605 604
606 // Reactivate first app. 605 // Reactivate first app.
607 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut1)); 606 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut1));
608 EXPECT_EQ(tab_count, tab_strip->count()); 607 EXPECT_EQ(tab_count, tab_strip->count());
609 EXPECT_EQ(tab_strip->GetActiveTabContents(), tab1); 608 EXPECT_EQ(tab_strip->GetActiveWebContents(), tab1);
610 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status); 609 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status);
611 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut2)).status); 610 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut2)).status);
612 611
613 // And second again. This time the second tab should become active. 612 // And second again. This time the second tab should become active.
614 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut2)); 613 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut2));
615 EXPECT_EQ(tab_count, tab_strip->count()); 614 EXPECT_EQ(tab_count, tab_strip->count());
616 EXPECT_EQ(tab_strip->GetActiveTabContents(), tab3); 615 EXPECT_EQ(tab_strip->GetActiveWebContents(), tab3);
617 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status); 616 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status);
618 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status); 617 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status);
619 } 618 }
620 619
621 // Confirm that a page can be navigated from and to while maintaining the 620 // Confirm that a page can be navigated from and to while maintaining the
622 // correct running state. 621 // correct running state.
623 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, Navigation) { 622 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, Navigation) {
624 ash::LauncherID shortcut_id = CreateShortcut("app1"); 623 ash::LauncherID shortcut_id = CreateShortcut("app1");
625 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); 624 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
626 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); 625 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
(...skipping 20 matching lines...) Expand all
647 646
648 // Create new tab owned by app. 647 // Create new tab owned by app.
649 ui_test_utils::NavigateToURLWithDisposition( 648 ui_test_utils::NavigateToURLWithDisposition(
650 browser(), 649 browser(),
651 GURL("http://www.example.com/path2/bar.html"), 650 GURL("http://www.example.com/path2/bar.html"),
652 NEW_FOREGROUND_TAB, 651 NEW_FOREGROUND_TAB,
653 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 652 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
654 EXPECT_EQ(++tab_count, tab_strip->count()); 653 EXPECT_EQ(++tab_count, tab_strip->count());
655 // Confirm app is still active. 654 // Confirm app is still active.
656 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); 655 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
657 TabContents* second_tab = tab_strip->GetActiveTabContents(); 656 WebContents* second_tab = tab_strip->GetActiveWebContents();
658 657
659 // Create new tab not owned by app. 658 // Create new tab not owned by app.
660 ui_test_utils::NavigateToURLWithDisposition( 659 ui_test_utils::NavigateToURLWithDisposition(
661 browser(), 660 browser(),
662 GURL("http://www.example.com/path3/foo.html"), 661 GURL("http://www.example.com/path3/foo.html"),
663 NEW_FOREGROUND_TAB, 662 NEW_FOREGROUND_TAB,
664 0); 663 0);
665 EXPECT_EQ(++tab_count, tab_strip->count()); 664 EXPECT_EQ(++tab_count, tab_strip->count());
666 // No longer active. 665 // No longer active.
667 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status); 666 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status);
668 667
669 // Activating app makes second tab active again. 668 // Activating app makes second tab active again.
670 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); 669 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
671 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); 670 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
672 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab); 671 EXPECT_EQ(tab_strip->GetActiveWebContents(), second_tab);
673 } 672 }
674 673
675 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, RefocusFilter) { 674 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, RefocusFilter) {
676 ChromeLauncherController* controller = 675 ChromeLauncherController* controller =
677 static_cast<ChromeLauncherController*>(launcher_->delegate()); 676 static_cast<ChromeLauncherController*>(launcher_->delegate());
678 TabStripModel* tab_strip = browser()->tab_strip_model(); 677 TabStripModel* tab_strip = browser()->tab_strip_model();
679 int tab_count = tab_strip->count(); 678 int tab_count = tab_strip->count();
680 ash::LauncherID shortcut_id = CreateShortcut("app1"); 679 ash::LauncherID shortcut_id = CreateShortcut("app1");
681 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); 680 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
682 EXPECT_EQ(++tab_count, tab_strip->count()); 681 EXPECT_EQ(++tab_count, tab_strip->count());
683 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); 682 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
684 TabContents* first_tab = tab_strip->GetActiveTabContents(); 683 WebContents* first_tab = tab_strip->GetActiveWebContents();
685 684
686 controller->SetRefocusURLPattern( 685 controller->SetRefocusURLPattern(
687 shortcut_id, GURL("http://www.example.com/path1/*")); 686 shortcut_id, GURL("http://www.example.com/path1/*"));
688 // Create new tab owned by app. 687 // Create new tab owned by app.
689 ui_test_utils::NavigateToURLWithDisposition( 688 ui_test_utils::NavigateToURLWithDisposition(
690 browser(), 689 browser(),
691 GURL("http://www.example.com/path2/bar.html"), 690 GURL("http://www.example.com/path2/bar.html"),
692 NEW_FOREGROUND_TAB, 691 NEW_FOREGROUND_TAB,
693 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 692 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
694 EXPECT_EQ(++tab_count, tab_strip->count()); 693 EXPECT_EQ(++tab_count, tab_strip->count());
695 // Confirm app is still active. 694 // Confirm app is still active.
696 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); 695 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
697 696
698 // Create new tab not owned by app. 697 // Create new tab not owned by app.
699 ui_test_utils::NavigateToURLWithDisposition( 698 ui_test_utils::NavigateToURLWithDisposition(
700 browser(), 699 browser(),
701 GURL("http://www.example.com/path3/foo.html"), 700 GURL("http://www.example.com/path3/foo.html"),
702 NEW_FOREGROUND_TAB, 701 NEW_FOREGROUND_TAB,
703 0); 702 0);
704 EXPECT_EQ(++tab_count, tab_strip->count()); 703 EXPECT_EQ(++tab_count, tab_strip->count());
705 // No longer active. 704 // No longer active.
706 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status); 705 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status);
707 706
708 // Activating app makes first tab active again, because second tab isn't 707 // Activating app makes first tab active again, because second tab isn't
709 // in its refocus url path. 708 // in its refocus url path.
710 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); 709 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
711 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); 710 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
712 EXPECT_EQ(tab_strip->GetActiveTabContents(), first_tab); 711 EXPECT_EQ(tab_strip->GetActiveWebContents(), first_tab);
713 } 712 }
714 713
715 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, RefocusFilterLaunch) { 714 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, RefocusFilterLaunch) {
716 ChromeLauncherController* controller = 715 ChromeLauncherController* controller =
717 static_cast<ChromeLauncherController*>(launcher_->delegate()); 716 static_cast<ChromeLauncherController*>(launcher_->delegate());
718 TabStripModel* tab_strip = browser()->tab_strip_model(); 717 TabStripModel* tab_strip = browser()->tab_strip_model();
719 int tab_count = tab_strip->count(); 718 int tab_count = tab_strip->count();
720 ash::LauncherID shortcut_id = CreateShortcut("app1"); 719 ash::LauncherID shortcut_id = CreateShortcut("app1");
721 controller->SetRefocusURLPattern( 720 controller->SetRefocusURLPattern(
722 shortcut_id, GURL("http://www.example.com/path1/*")); 721 shortcut_id, GURL("http://www.example.com/path1/*"));
723 722
724 // Create new tab owned by app. 723 // Create new tab owned by app.
725 ui_test_utils::NavigateToURLWithDisposition( 724 ui_test_utils::NavigateToURLWithDisposition(
726 browser(), 725 browser(),
727 GURL("http://www.example.com/path2/bar.html"), 726 GURL("http://www.example.com/path2/bar.html"),
728 NEW_FOREGROUND_TAB, 727 NEW_FOREGROUND_TAB,
729 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 728 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
730 EXPECT_EQ(++tab_count, tab_strip->count()); 729 EXPECT_EQ(++tab_count, tab_strip->count());
731 TabContents* first_tab = tab_strip->GetActiveTabContents(); 730 WebContents* first_tab = tab_strip->GetActiveWebContents();
732 // Confirm app is active. 731 // Confirm app is active.
733 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); 732 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
734 733
735 // Activating app should launch new tab, because second tab isn't 734 // Activating app should launch new tab, because second tab isn't
736 // in its refocus url path. 735 // in its refocus url path.
737 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); 736 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
738 EXPECT_EQ(++tab_count, tab_strip->count()); 737 EXPECT_EQ(++tab_count, tab_strip->count());
739 TabContents* second_tab = tab_strip->GetActiveTabContents(); 738 WebContents* second_tab = tab_strip->GetActiveWebContents();
740 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); 739 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
741 EXPECT_NE(first_tab, second_tab); 740 EXPECT_NE(first_tab, second_tab);
742 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab); 741 EXPECT_EQ(tab_strip->GetActiveWebContents(), second_tab);
743 } 742 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698