OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // Test is crashing on Mac, see http://crbug.com/29424. | 197 // Test is crashing on Mac, see http://crbug.com/29424. |
198 #define MAYBE_JavascriptAlertActivatesTab DISABLED_JavascriptAlertActivatesTab | 198 #define MAYBE_JavascriptAlertActivatesTab DISABLED_JavascriptAlertActivatesTab |
199 #else | 199 #else |
200 #define MAYBE_JavascriptAlertActivatesTab JavascriptAlertActivatesTab | 200 #define MAYBE_JavascriptAlertActivatesTab JavascriptAlertActivatesTab |
201 #endif | 201 #endif |
202 | 202 |
203 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_JavascriptAlertActivatesTab) { | 203 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_JavascriptAlertActivatesTab) { |
204 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 204 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
205 FilePath(kTitle1File))); | 205 FilePath(kTitle1File))); |
206 ui_test_utils::NavigateToURL(browser(), url); | 206 ui_test_utils::NavigateToURL(browser(), url); |
| 207 Browser* browser_used = NULL; |
207 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 0, | 208 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 0, |
208 TabStripModel::ADD_SELECTED, NULL, std::string()); | 209 TabStripModel::ADD_SELECTED, NULL, std::string(), |
| 210 &browser_used); |
| 211 EXPECT_EQ(browser(), browser_used); |
209 EXPECT_EQ(2, browser()->tab_count()); | 212 EXPECT_EQ(2, browser()->tab_count()); |
210 EXPECT_EQ(0, browser()->selected_index()); | 213 EXPECT_EQ(0, browser()->selected_index()); |
211 TabContents* second_tab = browser()->GetTabContentsAt(1); | 214 TabContents* second_tab = browser()->GetTabContentsAt(1); |
212 ASSERT_TRUE(second_tab); | 215 ASSERT_TRUE(second_tab); |
213 second_tab->render_view_host()->ExecuteJavascriptInWebFrame(L"", | 216 second_tab->render_view_host()->ExecuteJavascriptInWebFrame(L"", |
214 L"alert('Activate!');"); | 217 L"alert('Activate!');"); |
215 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 218 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
216 alert->CloseModalDialog(); | 219 alert->CloseModalDialog(); |
217 EXPECT_EQ(2, browser()->tab_count()); | 220 EXPECT_EQ(2, browser()->tab_count()); |
218 EXPECT_EQ(1, browser()->selected_index()); | 221 EXPECT_EQ(1, browser()->selected_index()); |
219 } | 222 } |
220 | 223 |
221 // Create 34 tabs and verify that a lot of processes have been created. The | 224 // Create 34 tabs and verify that a lot of processes have been created. The |
222 // exact number of processes depends on the amount of memory. Previously we | 225 // exact number of processes depends on the amount of memory. Previously we |
223 // had a hard limit of 31 processes and this test is mainly directed at | 226 // had a hard limit of 31 processes and this test is mainly directed at |
224 // verifying that we don't crash when we pass this limit. | 227 // verifying that we don't crash when we pass this limit. |
225 // Warning: this test can take >30 seconds when running on a slow (low | 228 // Warning: this test can take >30 seconds when running on a slow (low |
226 // memory?) Mac builder. | 229 // memory?) Mac builder. |
227 IN_PROC_BROWSER_TEST_F(BrowserTest, ThirtyFourTabs) { | 230 IN_PROC_BROWSER_TEST_F(BrowserTest, ThirtyFourTabs) { |
228 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 231 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
229 FilePath(kTitle2File))); | 232 FilePath(kTitle2File))); |
230 | 233 |
231 // There is one initial tab. | 234 // There is one initial tab. |
232 for (int ix = 0; ix != 33; ++ix) { | 235 for (int ix = 0; ix != 33; ++ix) { |
| 236 Browser* browser_used = NULL; |
233 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 0, | 237 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 0, |
234 TabStripModel::ADD_SELECTED, NULL, std::string()); | 238 TabStripModel::ADD_SELECTED, NULL, std::string(), |
| 239 &browser_used); |
| 240 EXPECT_EQ(browser(), browser_used); |
235 } | 241 } |
236 EXPECT_EQ(34, browser()->tab_count()); | 242 EXPECT_EQ(34, browser()->tab_count()); |
237 | 243 |
238 // See browser\renderer_host\render_process_host.cc for the algorithm to | 244 // See browser\renderer_host\render_process_host.cc for the algorithm to |
239 // decide how many processes to create. | 245 // decide how many processes to create. |
240 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= 2048) { | 246 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= 2048) { |
241 EXPECT_GE(CountRenderProcessHosts(), 24); | 247 EXPECT_GE(CountRenderProcessHosts(), 24); |
242 } else { | 248 } else { |
243 EXPECT_LE(CountRenderProcessHosts(), 23); | 249 EXPECT_LE(CountRenderProcessHosts(), 23); |
244 } | 250 } |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 #endif | 697 #endif |
692 | 698 |
693 // Test that launching an app refocuses a tab already hosting the app. | 699 // Test that launching an app refocuses a tab already hosting the app. |
694 IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenTab) { | 700 IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenTab) { |
695 SetUpExtensionApp(); | 701 SetUpExtensionApp(); |
696 | 702 |
697 ASSERT_EQ(1, browser()->tab_count()); | 703 ASSERT_EQ(1, browser()->tab_count()); |
698 ASSERT_EQ(NULL, Browser::FindAppTab(browser(), extension_app_)); | 704 ASSERT_EQ(NULL, Browser::FindAppTab(browser(), extension_app_)); |
699 | 705 |
700 // Open a tab with the app. | 706 // Open a tab with the app. |
701 TabContents* tab = Browser::OpenApplicationTab(profile_, extension_app_); | 707 TabContents* tab = Browser::OpenApplicationTab(profile_, extension_app_, |
| 708 NULL); |
702 ASSERT_TRUE(WaitForTab(tab)); | 709 ASSERT_TRUE(WaitForTab(tab)); |
703 ASSERT_EQ(2, browser()->tab_count()); | 710 ASSERT_EQ(2, browser()->tab_count()); |
704 | 711 |
705 int app_tab_index = browser()->selected_index(); | 712 int app_tab_index = browser()->selected_index(); |
706 ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab."; | 713 ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab."; |
707 ASSERT_EQ(browser()->GetTabContentsAt(0), | 714 ASSERT_EQ(browser()->GetTabContentsAt(0), |
708 Browser::FindAppTab(browser(), extension_app_)); | 715 Browser::FindAppTab(browser(), extension_app_)); |
709 | 716 |
710 // Open the same app. The existing tab should stay focused. | 717 // Open the same app. The existing tab should stay focused. |
711 tab = Browser::OpenApplication(profile_, extension_app_->id()); | 718 tab = Browser::OpenApplication(profile_, extension_app_->id()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 | 755 |
749 // Test that launching an app refocuses a panel running the app. | 756 // Test that launching an app refocuses a panel running the app. |
750 IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenPanel) { | 757 IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenPanel) { |
751 SetUpExtensionApp(); | 758 SetUpExtensionApp(); |
752 | 759 |
753 ASSERT_EQ(1, browser()->tab_count()); | 760 ASSERT_EQ(1, browser()->tab_count()); |
754 ASSERT_EQ(NULL, Browser::FindAppWindowOrPanel(profile_, extension_app_)); | 761 ASSERT_EQ(NULL, Browser::FindAppWindowOrPanel(profile_, extension_app_)); |
755 | 762 |
756 // Open the app in a panel. | 763 // Open the app in a panel. |
757 Browser::OpenApplicationWindow(profile_, extension_app_, | 764 Browser::OpenApplicationWindow(profile_, extension_app_, |
758 Extension::LAUNCH_PANEL, GURL()); | 765 Extension::LAUNCH_PANEL, GURL(), NULL); |
759 Browser* app_panel = BrowserList::GetLastActive(); | 766 Browser* app_panel = BrowserList::GetLastActive(); |
760 ASSERT_TRUE(app_panel); | 767 ASSERT_TRUE(app_panel); |
761 ASSERT_NE(app_panel, browser()) << "New browser should have opened."; | 768 ASSERT_NE(app_panel, browser()) << "New browser should have opened."; |
762 ASSERT_EQ(app_panel, BrowserList::GetLastActive()); | 769 ASSERT_EQ(app_panel, BrowserList::GetLastActive()); |
763 ASSERT_EQ(app_panel, | 770 ASSERT_EQ(app_panel, |
764 Browser::FindAppWindowOrPanel(profile_, extension_app_)); | 771 Browser::FindAppWindowOrPanel(profile_, extension_app_)); |
765 | 772 |
766 // Focus the initial browser. | 773 // Focus the initial browser. |
767 browser()->window()->Show(); | 774 browser()->window()->Show(); |
768 ASSERT_EQ(browser(), BrowserList::GetLastActive()); | 775 ASSERT_EQ(browser(), BrowserList::GetLastActive()); |
(...skipping 12 matching lines...) Expand all Loading... |
781 | 788 |
782 // Test that launching an app refocuses a window running the app. | 789 // Test that launching an app refocuses a window running the app. |
783 IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenWindow) { | 790 IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenWindow) { |
784 SetUpExtensionApp(); | 791 SetUpExtensionApp(); |
785 | 792 |
786 ASSERT_EQ(1, browser()->tab_count()); | 793 ASSERT_EQ(1, browser()->tab_count()); |
787 ASSERT_EQ(NULL, Browser::FindAppWindowOrPanel(profile_, extension_app_)); | 794 ASSERT_EQ(NULL, Browser::FindAppWindowOrPanel(profile_, extension_app_)); |
788 | 795 |
789 // Open a window with the app. | 796 // Open a window with the app. |
790 Browser::OpenApplicationWindow(profile_, extension_app_, | 797 Browser::OpenApplicationWindow(profile_, extension_app_, |
791 Extension::LAUNCH_WINDOW, GURL()); | 798 Extension::LAUNCH_WINDOW, GURL(), NULL); |
792 Browser* app_window = BrowserList::GetLastActive(); | 799 Browser* app_window = BrowserList::GetLastActive(); |
793 ASSERT_TRUE(app_window); | 800 ASSERT_TRUE(app_window); |
794 ASSERT_NE(app_window, browser()) << "New browser should have opened."; | 801 ASSERT_NE(app_window, browser()) << "New browser should have opened."; |
795 | 802 |
796 // Focus the initial browser. | 803 // Focus the initial browser. |
797 browser()->window()->Show(); | 804 browser()->window()->Show(); |
798 ASSERT_EQ(browser(), BrowserList::GetLastActive()); | 805 ASSERT_EQ(browser(), BrowserList::GetLastActive()); |
799 | 806 |
800 // Open the app. | 807 // Open the app. |
801 Browser::OpenApplication(profile_, extension_app_->id()); | 808 Browser::OpenApplication(profile_, extension_app_->id()); |
802 | 809 |
803 // Focus should move to the window. | 810 // Focus should move to the window. |
804 ASSERT_EQ(app_window, BrowserList::GetLastActive()); | 811 ASSERT_EQ(app_window, BrowserList::GetLastActive()); |
805 ASSERT_EQ(app_window, | 812 ASSERT_EQ(app_window, |
806 Browser::FindAppWindowOrPanel(profile_, extension_app_)); | 813 Browser::FindAppWindowOrPanel(profile_, extension_app_)); |
807 // No new tab should have been created in the initial browser. | 814 // No new tab should have been created in the initial browser. |
808 ASSERT_EQ(1, browser()->tab_count()); | 815 ASSERT_EQ(1, browser()->tab_count()); |
809 } | 816 } |
810 | 817 |
811 // Test that if an app is opened while running in a window and a tab, | 818 // Test that if an app is opened while running in a window and a tab, |
812 // the window is focused. | 819 // the window is focused. |
813 IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_WindowBeforeTab) { | 820 IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_WindowBeforeTab) { |
814 SetUpExtensionApp(); | 821 SetUpExtensionApp(); |
815 | 822 |
816 ASSERT_EQ(1, browser()->tab_count()); | 823 ASSERT_EQ(1, browser()->tab_count()); |
817 | 824 |
818 // Open a tab with the app. | 825 // Open a tab with the app. |
819 Browser::OpenApplicationTab(profile_, extension_app_); | 826 Browser::OpenApplicationTab(profile_, extension_app_, NULL); |
820 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 827 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
821 ASSERT_EQ(2, browser()->tab_count()); | 828 ASSERT_EQ(2, browser()->tab_count()); |
822 int app_tab_index = browser()->selected_index(); | 829 int app_tab_index = browser()->selected_index(); |
823 ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab."; | 830 ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab."; |
824 | 831 |
825 // Open a window with the app. | 832 // Open a window with the app. |
826 Browser::OpenApplicationWindow(profile_, extension_app_, | 833 Browser::OpenApplicationWindow(profile_, extension_app_, |
827 Extension::LAUNCH_WINDOW, GURL()); | 834 Extension::LAUNCH_WINDOW, GURL(), NULL); |
828 Browser* app_window = BrowserList::GetLastActive(); | 835 Browser* app_window = BrowserList::GetLastActive(); |
829 ASSERT_TRUE(app_window); | 836 ASSERT_TRUE(app_window); |
830 ASSERT_NE(app_window, browser()) << "New browser should have opened."; | 837 ASSERT_NE(app_window, browser()) << "New browser should have opened."; |
831 | 838 |
832 // Focus the initial browser. | 839 // Focus the initial browser. |
833 browser()->window()->Show(); | 840 browser()->window()->Show(); |
834 | 841 |
835 // Open the app. Focus should move to the window. | 842 // Open the app. Focus should move to the window. |
836 Browser::OpenApplication(profile_, extension_app_->id()); | 843 Browser::OpenApplication(profile_, extension_app_->id()); |
837 ASSERT_EQ(app_window, BrowserList::GetLastActive()); | 844 ASSERT_EQ(app_window, BrowserList::GetLastActive()); |
838 } | 845 } |
839 | 846 |
840 // Test that if an app is opened while running in a panel and a tab, | 847 // Test that if an app is opened while running in a panel and a tab, |
841 // the panel is focused. | 848 // the panel is focused. |
842 IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_PanelBeforeTab) { | 849 IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_PanelBeforeTab) { |
843 SetUpExtensionApp(); | 850 SetUpExtensionApp(); |
844 | 851 |
845 ASSERT_EQ(1, browser()->tab_count()); | 852 ASSERT_EQ(1, browser()->tab_count()); |
846 | 853 |
847 // Open a tab with the app. | 854 // Open a tab with the app. |
848 TabContents* tab = Browser::OpenApplicationTab(profile_, extension_app_); | 855 TabContents* tab = Browser::OpenApplicationTab(profile_, extension_app_, |
| 856 NULL); |
849 ASSERT_TRUE(WaitForTab(tab)); | 857 ASSERT_TRUE(WaitForTab(tab)); |
850 ASSERT_EQ(2, browser()->tab_count()); | 858 ASSERT_EQ(2, browser()->tab_count()); |
851 int app_tab_index = browser()->selected_index(); | 859 int app_tab_index = browser()->selected_index(); |
852 ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab."; | 860 ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab."; |
853 | 861 |
854 // Open a panel with the app. | 862 // Open a panel with the app. |
855 Browser::OpenApplicationWindow(profile_, extension_app_, | 863 Browser::OpenApplicationWindow(profile_, extension_app_, |
856 Extension::LAUNCH_PANEL, GURL()); | 864 Extension::LAUNCH_PANEL, GURL(), NULL); |
857 Browser* app_panel = BrowserList::GetLastActive(); | 865 Browser* app_panel = BrowserList::GetLastActive(); |
858 ASSERT_TRUE(app_panel); | 866 ASSERT_TRUE(app_panel); |
859 ASSERT_NE(app_panel, browser()) << "New browser should have opened."; | 867 ASSERT_NE(app_panel, browser()) << "New browser should have opened."; |
860 | 868 |
861 // Focus the initial browser. | 869 // Focus the initial browser. |
862 browser()->window()->Show(); | 870 browser()->window()->Show(); |
863 | 871 |
864 // Open the app. Focus should move to the panel. | 872 // Open the app. Focus should move to the panel. |
865 Browser::OpenApplication(profile_, extension_app_->id()); | 873 Browser::OpenApplication(profile_, extension_app_->id()); |
866 ASSERT_EQ(app_panel, BrowserList::GetLastActive()); | 874 ASSERT_EQ(app_panel, BrowserList::GetLastActive()); |
867 } | 875 } |
868 | 876 |
869 // Test that if multiple tabs host an app, and that app is opened, | 877 // Test that if multiple tabs host an app, and that app is opened, |
870 // the tab in the current window gets focus. | 878 // the tab in the current window gets focus. |
871 IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_TabInFocusedWindow) { | 879 IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_TabInFocusedWindow) { |
872 SetUpExtensionApp(); | 880 SetUpExtensionApp(); |
873 | 881 |
874 ASSERT_EQ(1, browser()->tab_count()); | 882 ASSERT_EQ(1, browser()->tab_count()); |
875 | 883 |
876 Browser::OpenApplicationTab(profile_, extension_app_); | 884 Browser::OpenApplicationTab(profile_, extension_app_, NULL); |
877 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 885 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
878 ASSERT_EQ(2, browser()->tab_count()); | 886 ASSERT_EQ(2, browser()->tab_count()); |
879 int app_tab_index = browser()->selected_index(); | 887 int app_tab_index = browser()->selected_index(); |
880 ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab."; | 888 ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab."; |
881 | 889 |
882 // Open a new browser window, add an app tab. | 890 // Open a new browser window, add an app tab. |
883 Browser* extra_browser = CreateBrowser(profile_); | 891 Browser* extra_browser = CreateBrowser(profile_); |
884 ASSERT_EQ(extra_browser, BrowserList::GetLastActive()); | 892 ASSERT_EQ(extra_browser, BrowserList::GetLastActive()); |
885 | 893 |
886 Browser::OpenApplicationTab(profile_, extension_app_); | 894 Browser::OpenApplicationTab(profile_, extension_app_, NULL); |
887 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(extra_browser)); | 895 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(extra_browser)); |
888 ASSERT_EQ(2, extra_browser->tab_count()); | 896 ASSERT_EQ(2, extra_browser->tab_count()); |
889 app_tab_index = extra_browser->selected_index(); | 897 app_tab_index = extra_browser->selected_index(); |
890 ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab"; | 898 ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab"; |
891 | 899 |
892 // Open the app. Focus should move to the panel. | 900 // Open the app. Focus should move to the panel. |
893 Browser::OpenApplication(profile_, extension_app_->id()); | 901 Browser::OpenApplication(profile_, extension_app_->id()); |
894 ASSERT_EQ(extra_browser, BrowserList::GetLastActive()); | 902 ASSERT_EQ(extra_browser, BrowserList::GetLastActive()); |
895 ASSERT_EQ(2, extra_browser->tab_count()); | 903 ASSERT_EQ(2, extra_browser->tab_count()); |
896 | 904 |
(...skipping 27 matching lines...) Expand all Loading... |
924 | 932 |
925 // We start with a normal browser with one tab. | 933 // We start with a normal browser with one tab. |
926 EXPECT_EQ(1, browser()->tab_count()); | 934 EXPECT_EQ(1, browser()->tab_count()); |
927 | 935 |
928 // Open a popup browser with a single blank foreground tab. | 936 // Open a popup browser with a single blank foreground tab. |
929 Browser* popup_browser = browser()->CreateForPopup(browser()->profile()); | 937 Browser* popup_browser = browser()->CreateForPopup(browser()->profile()); |
930 popup_browser->AddBlankTab(true); | 938 popup_browser->AddBlankTab(true); |
931 EXPECT_EQ(1, popup_browser->tab_count()); | 939 EXPECT_EQ(1, popup_browser->tab_count()); |
932 | 940 |
933 // Now try opening another tab in the popup browser. | 941 // Now try opening another tab in the popup browser. |
| 942 Browser* browser_used = NULL; |
934 popup_browser->AddTabWithURL( | 943 popup_browser->AddTabWithURL( |
935 GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1, | 944 GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1, |
936 TabStripModel::ADD_SELECTED, NULL, std::string()); | 945 TabStripModel::ADD_SELECTED, NULL, std::string(), &browser_used); |
| 946 EXPECT_EQ(popup_browser, browser_used); |
937 | 947 |
938 // The popup should still only have one tab. | 948 // The popup should still only have one tab. |
939 EXPECT_EQ(1, popup_browser->tab_count()); | 949 EXPECT_EQ(1, popup_browser->tab_count()); |
940 | 950 |
941 // The normal browser should now have two. | 951 // The normal browser should now have two. |
942 EXPECT_EQ(2, browser()->tab_count()); | 952 EXPECT_EQ(2, browser()->tab_count()); |
943 | 953 |
944 // Open an app frame browser with a single blank foreground tab. | 954 // Open an app frame browser with a single blank foreground tab. |
945 Browser* app_browser = | 955 Browser* app_browser = |
946 browser()->CreateForApp(L"Test", browser()->profile(), false); | 956 browser()->CreateForApp(L"Test", browser()->profile(), false); |
947 app_browser->AddBlankTab(true); | 957 app_browser->AddBlankTab(true); |
948 EXPECT_EQ(1, app_browser->tab_count()); | 958 EXPECT_EQ(1, app_browser->tab_count()); |
949 | 959 |
950 // Now try opening another tab in the app browser. | 960 // Now try opening another tab in the app browser. |
951 app_browser->AddTabWithURL( | 961 app_browser->AddTabWithURL( |
952 GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1, | 962 GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1, |
953 TabStripModel::ADD_SELECTED, NULL, std::string()); | 963 TabStripModel::ADD_SELECTED, NULL, std::string(), &browser_used); |
| 964 EXPECT_EQ(app_browser, browser_used); |
954 | 965 |
955 // The popup should still only have one tab. | 966 // The popup should still only have one tab. |
956 EXPECT_EQ(1, app_browser->tab_count()); | 967 EXPECT_EQ(1, app_browser->tab_count()); |
957 | 968 |
958 // The normal browser should now have three. | 969 // The normal browser should now have three. |
959 EXPECT_EQ(3, browser()->tab_count()); | 970 EXPECT_EQ(3, browser()->tab_count()); |
960 | 971 |
961 // Open an app frame popup browser with a single blank foreground tab. | 972 // Open an app frame popup browser with a single blank foreground tab. |
962 Browser* app_popup_browser = | 973 Browser* app_popup_browser = |
963 browser()->CreateForApp(L"Test", browser()->profile(), false); | 974 browser()->CreateForApp(L"Test", browser()->profile(), false); |
964 app_popup_browser->AddBlankTab(true); | 975 app_popup_browser->AddBlankTab(true); |
965 EXPECT_EQ(1, app_popup_browser->tab_count()); | 976 EXPECT_EQ(1, app_popup_browser->tab_count()); |
966 | 977 |
967 // Now try opening another tab in the app popup browser. | 978 // Now try opening another tab in the app popup browser. |
968 app_popup_browser->AddTabWithURL( | 979 app_popup_browser->AddTabWithURL( |
969 GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1, | 980 GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1, |
970 TabStripModel::ADD_SELECTED, NULL, std::string()); | 981 TabStripModel::ADD_SELECTED, NULL, std::string(), &browser_used); |
| 982 EXPECT_EQ(app_popup_browser, browser_used); |
971 | 983 |
972 // The popup should still only have one tab. | 984 // The popup should still only have one tab. |
973 EXPECT_EQ(1, app_popup_browser->tab_count()); | 985 EXPECT_EQ(1, app_popup_browser->tab_count()); |
974 | 986 |
975 // The normal browser should now have four. | 987 // The normal browser should now have four. |
976 EXPECT_EQ(4, browser()->tab_count()); | 988 EXPECT_EQ(4, browser()->tab_count()); |
977 | 989 |
978 // Close the additional browsers. | 990 // Close the additional browsers. |
979 popup_browser->CloseAllTabs(); | 991 popup_browser->CloseAllTabs(); |
980 app_browser->CloseAllTabs(); | 992 app_browser->CloseAllTabs(); |
981 app_popup_browser->CloseAllTabs(); | 993 app_popup_browser->CloseAllTabs(); |
982 } | 994 } |
983 #endif | 995 #endif |
OLD | NEW |