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

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 8253002: Move PageTransition into content namespace. While I'm touching all these files, I've also updated... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_init.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #if defined(OS_MACOSX) 9 #if defined(OS_MACOSX)
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 22 matching lines...) Expand all
33 #include "chrome/common/chrome_notification_types.h" 33 #include "chrome/common/chrome_notification_types.h"
34 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
35 #include "chrome/common/extensions/extension.h" 35 #include "chrome/common/extensions/extension.h"
36 #include "chrome/common/url_constants.h" 36 #include "chrome/common/url_constants.h"
37 #include "chrome/test/base/in_process_browser_test.h" 37 #include "chrome/test/base/in_process_browser_test.h"
38 #include "chrome/test/base/ui_test_utils.h" 38 #include "chrome/test/base/ui_test_utils.h"
39 #include "content/browser/renderer_host/render_process_host.h" 39 #include "content/browser/renderer_host/render_process_host.h"
40 #include "content/browser/renderer_host/render_view_host.h" 40 #include "content/browser/renderer_host/render_view_host.h"
41 #include "content/browser/tab_contents/tab_contents.h" 41 #include "content/browser/tab_contents/tab_contents.h"
42 #include "content/common/notification_source.h" 42 #include "content/common/notification_source.h"
43 #include "content/common/page_transition_types.h"
44 #include "content/common/url_constants.h" 43 #include "content/common/url_constants.h"
44 #include "content/public/common/page_transition_types.h"
45 #include "grit/chromium_strings.h" 45 #include "grit/chromium_strings.h"
46 #include "grit/generated_resources.h" 46 #include "grit/generated_resources.h"
47 #include "net/base/mock_host_resolver.h" 47 #include "net/base/mock_host_resolver.h"
48 #include "net/test/test_server.h" 48 #include "net/test/test_server.h"
49 #include "ui/base/l10n/l10n_util.h" 49 #include "ui/base/l10n/l10n_util.h"
50 50
51 #if defined(OS_WIN) 51 #if defined(OS_WIN)
52 #include "base/i18n/rtl.h" 52 #include "base/i18n/rtl.h"
53 #include "chrome/browser/browser_process.h" 53 #include "chrome/browser/browser_process.h"
54 #endif 54 #endif
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 UTF16ToWideHack(browser()->GetWindowTitleForCurrentTab())); 210 UTF16ToWideHack(browser()->GetWindowTitleForCurrentTab()));
211 string16 tab_title; 211 string16 tab_title;
212 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); 212 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title));
213 EXPECT_EQ(WideToUTF16(test_title), tab_title); 213 EXPECT_EQ(WideToUTF16(test_title), tab_title);
214 } 214 }
215 215
216 IN_PROC_BROWSER_TEST_F(BrowserTest, JavascriptAlertActivatesTab) { 216 IN_PROC_BROWSER_TEST_F(BrowserTest, JavascriptAlertActivatesTab) {
217 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 217 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
218 FilePath(kTitle1File))); 218 FilePath(kTitle1File)));
219 ui_test_utils::NavigateToURL(browser(), url); 219 ui_test_utils::NavigateToURL(browser(), url);
220 AddTabAtIndex(0, url, PageTransition::TYPED); 220 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED);
221 EXPECT_EQ(2, browser()->tab_count()); 221 EXPECT_EQ(2, browser()->tab_count());
222 EXPECT_EQ(0, browser()->active_index()); 222 EXPECT_EQ(0, browser()->active_index());
223 TabContents* second_tab = browser()->GetTabContentsAt(1); 223 TabContents* second_tab = browser()->GetTabContentsAt(1);
224 ASSERT_TRUE(second_tab); 224 ASSERT_TRUE(second_tab);
225 second_tab->render_view_host()->ExecuteJavascriptInWebFrame( 225 second_tab->render_view_host()->ExecuteJavascriptInWebFrame(
226 string16(), 226 string16(),
227 ASCIIToUTF16("alert('Activate!');")); 227 ASCIIToUTF16("alert('Activate!');"));
228 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 228 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
229 alert->CloseModalDialog(); 229 alert->CloseModalDialog();
230 EXPECT_EQ(2, browser()->tab_count()); 230 EXPECT_EQ(2, browser()->tab_count());
(...skipping 15 matching lines...) Expand all
246 // had a hard limit of 31 processes and this test is mainly directed at 246 // had a hard limit of 31 processes and this test is mainly directed at
247 // verifying that we don't crash when we pass this limit. 247 // verifying that we don't crash when we pass this limit.
248 // Warning: this test can take >30 seconds when running on a slow (low 248 // Warning: this test can take >30 seconds when running on a slow (low
249 // memory?) Mac builder. 249 // memory?) Mac builder.
250 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_ThirtyFourTabs) { 250 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_ThirtyFourTabs) {
251 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 251 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
252 FilePath(kTitle2File))); 252 FilePath(kTitle2File)));
253 253
254 // There is one initial tab. 254 // There is one initial tab.
255 for (int ix = 0; ix != 33; ++ix) 255 for (int ix = 0; ix != 33; ++ix)
256 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); 256 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED);
257 EXPECT_EQ(34, browser()->tab_count()); 257 EXPECT_EQ(34, browser()->tab_count());
258 258
259 // See browser\renderer_host\render_process_host.cc for the algorithm to 259 // See browser\renderer_host\render_process_host.cc for the algorithm to
260 // decide how many processes to create. 260 // decide how many processes to create.
261 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= 2048) { 261 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= 2048) {
262 EXPECT_GE(CountRenderProcessHosts(), 24); 262 EXPECT_GE(CountRenderProcessHosts(), 24);
263 } else { 263 } else {
264 EXPECT_LE(CountRenderProcessHosts(), 23); 264 EXPECT_LE(CountRenderProcessHosts(), 23);
265 } 265 }
266 } 266 }
(...skipping 20 matching lines...) Expand all
287 // Test for crbug.com/80401. Canceling a before unload dialog should reset 287 // Test for crbug.com/80401. Canceling a before unload dialog should reset
288 // the URL to the previous page's URL. 288 // the URL to the previous page's URL.
289 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) { 289 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) {
290 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 290 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
291 FilePath(kBeforeUnloadFile))); 291 FilePath(kBeforeUnloadFile)));
292 ui_test_utils::NavigateToURL(browser(), url); 292 ui_test_utils::NavigateToURL(browser(), url);
293 293
294 // Navigate to a page that triggers a cross-site transition. 294 // Navigate to a page that triggers a cross-site transition.
295 ASSERT_TRUE(test_server()->Start()); 295 ASSERT_TRUE(test_server()->Start());
296 GURL url2(test_server()->GetURL("files/title1.html")); 296 GURL url2(test_server()->GetURL("files/title1.html"));
297 browser()->OpenURL(url2, GURL(), CURRENT_TAB, PageTransition::TYPED); 297 browser()->OpenURL(url2, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED);
298 298
299 ui_test_utils::WindowedNotificationObserver host_destroyed_observer( 299 ui_test_utils::WindowedNotificationObserver host_destroyed_observer(
300 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 300 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
301 NotificationService::AllSources()); 301 NotificationService::AllSources());
302 302
303 // Cancel the dialog. 303 // Cancel the dialog.
304 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 304 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
305 alert->CloseModalDialog(); 305 alert->CloseModalDialog();
306 EXPECT_FALSE(browser()->GetSelectedTabContents()->IsLoading()); 306 EXPECT_FALSE(browser()->GetSelectedTabContents()->IsLoading());
307 307
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 // Change a tab into an application window. 594 // Change a tab into an application window.
595 // DISABLED: http://crbug.com/72310 595 // DISABLED: http://crbug.com/72310
596 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) { 596 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) {
597 ASSERT_TRUE(test_server()->Start()); 597 ASSERT_TRUE(test_server()->Start());
598 GURL http_url(test_server()->GetURL("")); 598 GURL http_url(test_server()->GetURL(""));
599 ASSERT_TRUE(http_url.SchemeIs(chrome::kHttpScheme)); 599 ASSERT_TRUE(http_url.SchemeIs(chrome::kHttpScheme));
600 600
601 ASSERT_EQ(1, browser()->tab_count()); 601 ASSERT_EQ(1, browser()->tab_count());
602 TabContents* initial_tab = browser()->GetTabContentsAt(0); 602 TabContents* initial_tab = browser()->GetTabContentsAt(0);
603 TabContents* app_tab = browser()->AddSelectedTabWithURL( 603 TabContents* app_tab = browser()->AddSelectedTabWithURL(
604 http_url, PageTransition::TYPED)->tab_contents(); 604 http_url, content::PAGE_TRANSITION_TYPED)->tab_contents();
605 ASSERT_EQ(2, browser()->tab_count()); 605 ASSERT_EQ(2, browser()->tab_count());
606 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); 606 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile()));
607 607
608 // Normal tabs should accept load drops. 608 // Normal tabs should accept load drops.
609 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); 609 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops);
610 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); 610 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops);
611 611
612 // Turn |app_tab| into a tab in an app panel. 612 // Turn |app_tab| into a tab in an app panel.
613 browser()->ConvertContentsToApplication(app_tab); 613 browser()->ConvertContentsToApplication(app_tab);
614 614
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 694
695 const Extension* extension_app = GetExtension(); 695 const Extension* extension_app = GetExtension();
696 696
697 ui_test_utils::NavigateToURL(browser(), url); 697 ui_test_utils::NavigateToURL(browser(), url);
698 698
699 TabContentsWrapper* app_contents = 699 TabContentsWrapper* app_contents =
700 Browser::TabContentsFactory(browser()->profile(), NULL, 700 Browser::TabContentsFactory(browser()->profile(), NULL,
701 MSG_ROUTING_NONE, NULL, NULL); 701 MSG_ROUTING_NONE, NULL, NULL);
702 app_contents->extension_tab_helper()->SetExtensionApp(extension_app); 702 app_contents->extension_tab_helper()->SetExtensionApp(extension_app);
703 703
704 model->AddTabContents(app_contents, 0, 0, TabStripModel::ADD_NONE); 704 model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0),
705 TabStripModel::ADD_NONE);
705 model->SetTabPinned(0, true); 706 model->SetTabPinned(0, true);
706 ui_test_utils::NavigateToURL(browser(), url); 707 ui_test_utils::NavigateToURL(browser(), url);
707 708
708 MockTabStripModelObserver observer; 709 MockTabStripModelObserver observer;
709 model->AddObserver(&observer); 710 model->AddObserver(&observer);
710 711
711 // Uninstall the extension and make sure TabClosing is sent. 712 // Uninstall the extension and make sure TabClosing is sent.
712 ExtensionService* service = browser()->profile()->GetExtensionService(); 713 ExtensionService* service = browser()->profile()->GetExtensionService();
713 service->UninstallExtension(GetExtension()->id(), false, NULL); 714 service->UninstallExtension(GetExtension()->id(), false, NULL);
714 EXPECT_EQ(1, observer.closing_count()); 715 EXPECT_EQ(1, observer.closing_count());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 #define MAYBE_PageLanguageDetection PageLanguageDetection 767 #define MAYBE_PageLanguageDetection PageLanguageDetection
767 #endif 768 #endif
768 // Tests that the CLD (Compact Language Detection) works properly. 769 // Tests that the CLD (Compact Language Detection) works properly.
769 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageLanguageDetection) { 770 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageLanguageDetection) {
770 ASSERT_TRUE(test_server()->Start()); 771 ASSERT_TRUE(test_server()->Start());
771 772
772 std::string lang; 773 std::string lang;
773 774
774 // Open a new tab with a page in English. 775 // Open a new tab with a page in English.
775 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), 776 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")),
776 PageTransition::TYPED); 777 content::PAGE_TRANSITION_TYPED);
777 778
778 TabContents* current_tab = browser()->GetSelectedTabContents(); 779 TabContents* current_tab = browser()->GetSelectedTabContents();
779 TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); 780 TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper();
780 TranslateTabHelper* helper = wrapper->translate_tab_helper(); 781 TranslateTabHelper* helper = wrapper->translate_tab_helper();
781 Source<TabContents> source(current_tab); 782 Source<TabContents> source(current_tab);
782 783
783 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> 784 ui_test_utils::WindowedNotificationObserverWithDetails<std::string>
784 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 785 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
785 source); 786 source);
786 EXPECT_EQ("", helper->language_state().original_language()); 787 EXPECT_EQ("", helper->language_state().original_language());
(...skipping 13 matching lines...) Expand all
800 lang.clear(); 801 lang.clear();
801 EXPECT_TRUE(fr_language_detected_signal.GetDetailsFor( 802 EXPECT_TRUE(fr_language_detected_signal.GetDetailsFor(
802 source.map_key(), &lang)); 803 source.map_key(), &lang));
803 EXPECT_EQ("fr", lang); 804 EXPECT_EQ("fr", lang);
804 EXPECT_EQ("fr", helper->language_state().original_language()); 805 EXPECT_EQ("fr", helper->language_state().original_language());
805 } 806 }
806 807
807 IN_PROC_BROWSER_TEST_F(BrowserTest, TestNewTabExitsFullscreen) { 808 IN_PROC_BROWSER_TEST_F(BrowserTest, TestNewTabExitsFullscreen) {
808 ASSERT_TRUE(test_server()->Start()); 809 ASSERT_TRUE(test_server()->Start());
809 810
810 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), PageTransition::TYPED); 811 AddTabAtIndex(
812 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
811 813
812 TabContents* fullscreen_tab = browser()->GetSelectedTabContents(); 814 TabContents* fullscreen_tab = browser()->GetSelectedTabContents();
813 815
814 { 816 {
815 ui_test_utils::WindowedNotificationObserver fullscreen_observer( 817 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
816 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 818 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
817 NotificationService::AllSources()); 819 NotificationService::AllSources());
818 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); 820 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true);
819 fullscreen_observer.Wait(); 821 fullscreen_observer.Wait();
820 ASSERT_TRUE(browser()->window()->IsFullscreen()); 822 ASSERT_TRUE(browser()->window()->IsFullscreen());
821 } 823 }
822 824
823 { 825 {
824 ui_test_utils::WindowedNotificationObserver fullscreen_observer( 826 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
825 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 827 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
826 NotificationService::AllSources()); 828 NotificationService::AllSources());
827 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL), PageTransition::TYPED); 829 AddTabAtIndex(
830 1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
828 fullscreen_observer.Wait(); 831 fullscreen_observer.Wait();
829 ASSERT_FALSE(browser()->window()->IsFullscreen()); 832 ASSERT_FALSE(browser()->window()->IsFullscreen());
830 } 833 }
831 } 834 }
832 835
833 IN_PROC_BROWSER_TEST_F(BrowserTest, TestTabExitsItselfFromFullscreen) { 836 IN_PROC_BROWSER_TEST_F(BrowserTest, TestTabExitsItselfFromFullscreen) {
834 ASSERT_TRUE(test_server()->Start()); 837 ASSERT_TRUE(test_server()->Start());
835 838
836 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), PageTransition::TYPED); 839 AddTabAtIndex(
840 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
837 841
838 TabContents* fullscreen_tab = browser()->GetSelectedTabContents(); 842 TabContents* fullscreen_tab = browser()->GetSelectedTabContents();
839 843
840 { 844 {
841 ui_test_utils::WindowedNotificationObserver fullscreen_observer( 845 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
842 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 846 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
843 NotificationService::AllSources()); 847 NotificationService::AllSources());
844 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); 848 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true);
845 fullscreen_observer.Wait(); 849 fullscreen_observer.Wait();
846 ASSERT_TRUE(browser()->window()->IsFullscreen()); 850 ASSERT_TRUE(browser()->window()->IsFullscreen());
847 } 851 }
848 852
849 { 853 {
850 ui_test_utils::WindowedNotificationObserver fullscreen_observer( 854 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
851 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 855 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
852 NotificationService::AllSources()); 856 NotificationService::AllSources());
853 browser()->ToggleFullscreenModeForTab(fullscreen_tab, false); 857 browser()->ToggleFullscreenModeForTab(fullscreen_tab, false);
854 fullscreen_observer.Wait(); 858 fullscreen_observer.Wait();
855 ASSERT_FALSE(browser()->window()->IsFullscreen()); 859 ASSERT_FALSE(browser()->window()->IsFullscreen());
856 } 860 }
857 } 861 }
858 862
859 #if defined(OS_MACOSX) 863 #if defined(OS_MACOSX)
860 IN_PROC_BROWSER_TEST_F(BrowserTest, TabEntersPresentationModeFromWindowed) { 864 IN_PROC_BROWSER_TEST_F(BrowserTest, TabEntersPresentationModeFromWindowed) {
861 ASSERT_TRUE(test_server()->Start()); 865 ASSERT_TRUE(test_server()->Start());
862 866
863 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), PageTransition::TYPED); 867 AddTabAtIndex(
868 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
864 869
865 TabContents* fullscreen_tab = browser()->GetSelectedTabContents(); 870 TabContents* fullscreen_tab = browser()->GetSelectedTabContents();
866 871
867 { 872 {
868 ui_test_utils::WindowedNotificationObserver fullscreen_observer( 873 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
869 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 874 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
870 NotificationService::AllSources()); 875 NotificationService::AllSources());
871 EXPECT_FALSE(browser()->window()->IsFullscreen()); 876 EXPECT_FALSE(browser()->window()->IsFullscreen());
872 EXPECT_FALSE(browser()->window()->InPresentationMode()); 877 EXPECT_FALSE(browser()->window()->InPresentationMode());
873 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); 878 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 920 host_resolver()->AddRule("www.example.com", "127.0.0.1");
916 GURL url(test_server()->GetURL("empty.html")); 921 GURL url(test_server()->GetURL("empty.html"));
917 TabStripModel* model = browser()->tabstrip_model(); 922 TabStripModel* model = browser()->tabstrip_model();
918 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); 923 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/")));
919 const Extension* extension_app = GetExtension(); 924 const Extension* extension_app = GetExtension();
920 ui_test_utils::NavigateToURL(browser(), url); 925 ui_test_utils::NavigateToURL(browser(), url);
921 TabContentsWrapper* app_contents = 926 TabContentsWrapper* app_contents =
922 Browser::TabContentsFactory(browser()->profile(), NULL, 927 Browser::TabContentsFactory(browser()->profile(), NULL,
923 MSG_ROUTING_NONE, NULL, NULL); 928 MSG_ROUTING_NONE, NULL, NULL);
924 app_contents->extension_tab_helper()->SetExtensionApp(extension_app); 929 app_contents->extension_tab_helper()->SetExtensionApp(extension_app);
925 model->AddTabContents(app_contents, 0, 0, TabStripModel::ADD_NONE); 930 model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0),
931 TabStripModel::ADD_NONE);
926 model->SetTabPinned(0, true); 932 model->SetTabPinned(0, true);
927 ui_test_utils::NavigateToURL(browser(), url); 933 ui_test_utils::NavigateToURL(browser(), url);
928 934
929 // Add a non pinned tab. 935 // Add a non pinned tab.
930 browser()->NewTab(); 936 browser()->NewTab();
931 937
932 // Add a pinned non-app tab. 938 // Add a pinned non-app tab.
933 browser()->NewTab(); 939 browser()->NewTab();
934 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); 940 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL));
935 model->SetTabPinned(2, true); 941 model->SetTabPinned(2, true);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 // We start with a normal browser with one tab. 1126 // We start with a normal browser with one tab.
1121 EXPECT_EQ(1, browser()->tab_count()); 1127 EXPECT_EQ(1, browser()->tab_count());
1122 1128
1123 // Open a popup browser with a single blank foreground tab. 1129 // Open a popup browser with a single blank foreground tab.
1124 Browser* popup_browser = browser()->CreateForType(Browser::TYPE_POPUP, 1130 Browser* popup_browser = browser()->CreateForType(Browser::TYPE_POPUP,
1125 browser()->profile()); 1131 browser()->profile());
1126 popup_browser->AddBlankTab(true); 1132 popup_browser->AddBlankTab(true);
1127 EXPECT_EQ(1, popup_browser->tab_count()); 1133 EXPECT_EQ(1, popup_browser->tab_count());
1128 1134
1129 // Now try opening another tab in the popup browser. 1135 // Now try opening another tab in the popup browser.
1130 AddTabWithURLParams params1(url, PageTransition::TYPED); 1136 AddTabWithURLParams params1(url, content::PAGE_TRANSITION_TYPED);
1131 popup_browser->AddTabWithURL(&params1); 1137 popup_browser->AddTabWithURL(&params1);
1132 EXPECT_EQ(popup_browser, params1.target); 1138 EXPECT_EQ(popup_browser, params1.target);
1133 1139
1134 // The popup should still only have one tab. 1140 // The popup should still only have one tab.
1135 EXPECT_EQ(1, popup_browser->tab_count()); 1141 EXPECT_EQ(1, popup_browser->tab_count());
1136 1142
1137 // The normal browser should now have two. 1143 // The normal browser should now have two.
1138 EXPECT_EQ(2, browser()->tab_count()); 1144 EXPECT_EQ(2, browser()->tab_count());
1139 1145
1140 // Open an app frame browser with a single blank foreground tab. 1146 // Open an app frame browser with a single blank foreground tab.
1141 Browser* app_browser = 1147 Browser* app_browser =
1142 browser()->CreateForApp(L"Test", browser()->profile(), false); 1148 browser()->CreateForApp(L"Test", browser()->profile(), false);
1143 app_browser->AddBlankTab(true); 1149 app_browser->AddBlankTab(true);
1144 EXPECT_EQ(1, app_browser->tab_count()); 1150 EXPECT_EQ(1, app_browser->tab_count());
1145 1151
1146 // Now try opening another tab in the app browser. 1152 // Now try opening another tab in the app browser.
1147 AddTabWithURLParams params2(GURL(chrome::kAboutBlankURL), 1153 AddTabWithURLParams params2(GURL(chrome::kAboutBlankURL),
1148 PageTransition::TYPED); 1154 content::PAGE_TRANSITION_TYPED);
1149 app_browser->AddTabWithURL(&params2); 1155 app_browser->AddTabWithURL(&params2);
1150 EXPECT_EQ(app_browser, params2.target); 1156 EXPECT_EQ(app_browser, params2.target);
1151 1157
1152 // The popup should still only have one tab. 1158 // The popup should still only have one tab.
1153 EXPECT_EQ(1, app_browser->tab_count()); 1159 EXPECT_EQ(1, app_browser->tab_count());
1154 1160
1155 // The normal browser should now have three. 1161 // The normal browser should now have three.
1156 EXPECT_EQ(3, browser()->tab_count()); 1162 EXPECT_EQ(3, browser()->tab_count());
1157 1163
1158 // Open an app frame popup browser with a single blank foreground tab. 1164 // Open an app frame popup browser with a single blank foreground tab.
1159 Browser* app_popup_browser = 1165 Browser* app_popup_browser =
1160 browser()->CreateForApp(L"Test", browser()->profile(), false); 1166 browser()->CreateForApp(L"Test", browser()->profile(), false);
1161 app_popup_browser->AddBlankTab(true); 1167 app_popup_browser->AddBlankTab(true);
1162 EXPECT_EQ(1, app_popup_browser->tab_count()); 1168 EXPECT_EQ(1, app_popup_browser->tab_count());
1163 1169
1164 // Now try opening another tab in the app popup browser. 1170 // Now try opening another tab in the app popup browser.
1165 AddTabWithURLParams params3(GURL(chrome::kAboutBlankURL), 1171 AddTabWithURLParams params3(GURL(chrome::kAboutBlankURL),
1166 PageTransition::TYPED); 1172 content::PAGE_TRANSITION_TYPED);
1167 app_popup_browser->AddTabWithURL(&params3); 1173 app_popup_browser->AddTabWithURL(&params3);
1168 EXPECT_EQ(app_popup_browser, params3.target); 1174 EXPECT_EQ(app_popup_browser, params3.target);
1169 1175
1170 // The popup should still only have one tab. 1176 // The popup should still only have one tab.
1171 EXPECT_EQ(1, app_popup_browser->tab_count()); 1177 EXPECT_EQ(1, app_popup_browser->tab_count());
1172 1178
1173 // The normal browser should now have four. 1179 // The normal browser should now have four.
1174 EXPECT_EQ(4, browser()->tab_count()); 1180 EXPECT_EQ(4, browser()->tab_count());
1175 1181
1176 // Close the additional browsers. 1182 // Close the additional browsers.
1177 popup_browser->CloseAllTabs(); 1183 popup_browser->CloseAllTabs();
1178 app_browser->CloseAllTabs(); 1184 app_browser->CloseAllTabs();
1179 app_popup_browser->CloseAllTabs(); 1185 app_popup_browser->CloseAllTabs();
1180 } 1186 }
1181 #endif 1187 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698