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

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

Issue 12315094: Remove kDefaultHostDesktopType from browser_finder.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix StartupBrowserCreatorTest.ProfilesWithoutPagesNotLaunched Created 7 years, 9 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_finder.h » ('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) 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) { 782 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) {
783 ASSERT_TRUE(test_server()->Start()); 783 ASSERT_TRUE(test_server()->Start());
784 GURL http_url(test_server()->GetURL("")); 784 GURL http_url(test_server()->GetURL(""));
785 ASSERT_TRUE(http_url.SchemeIs(chrome::kHttpScheme)); 785 ASSERT_TRUE(http_url.SchemeIs(chrome::kHttpScheme));
786 786
787 ASSERT_EQ(1, browser()->tab_strip_model()->count()); 787 ASSERT_EQ(1, browser()->tab_strip_model()->count());
788 WebContents* initial_tab = browser()->tab_strip_model()->GetWebContentsAt(0); 788 WebContents* initial_tab = browser()->tab_strip_model()->GetWebContentsAt(0);
789 WebContents* app_tab = chrome::AddSelectedTabWithURL( 789 WebContents* app_tab = chrome::AddSelectedTabWithURL(
790 browser(), http_url, content::PAGE_TRANSITION_TYPED); 790 browser(), http_url, content::PAGE_TRANSITION_TYPED);
791 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 791 ASSERT_EQ(2, browser()->tab_strip_model()->count());
792 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); 792 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(),
793 browser()->host_desktop_type()));
793 794
794 // Normal tabs should accept load drops. 795 // Normal tabs should accept load drops.
795 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); 796 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops);
796 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); 797 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops);
797 798
798 // Turn |app_tab| into a tab in an app panel. 799 // Turn |app_tab| into a tab in an app panel.
799 chrome::ConvertTabToAppWindow(browser(), app_tab); 800 chrome::ConvertTabToAppWindow(browser(), app_tab);
800 801
801 // The launch should have created a new browser. 802 // The launch should have created a new browser.
802 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); 803 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(),
804 browser()->host_desktop_type()));
803 805
804 // Find the new browser. 806 // Find the new browser.
805 Browser* app_browser = NULL; 807 Browser* app_browser = NULL;
806 for (chrome::BrowserIterator it; !it.done() && !app_browser; it.Next()) { 808 for (chrome::BrowserIterator it; !it.done() && !app_browser; it.Next()) {
807 if (*it != browser()) 809 if (*it != browser())
808 app_browser = *it; 810 app_browser = *it;
809 } 811 }
810 ASSERT_TRUE(app_browser); 812 ASSERT_TRUE(app_browser);
811 813
812 // Check that the tab contents is in the new browser, and not in the old. 814 // Check that the tab contents is in the new browser, and not in the old.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 CommandLine command_line(CommandLine::NO_PROGRAM); 929 CommandLine command_line(CommandLine::NO_PROGRAM);
928 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); 930 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id());
929 931
930 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? 932 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ?
931 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 933 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
932 StartupBrowserCreatorImpl launch(base::FilePath(), command_line, first_run); 934 StartupBrowserCreatorImpl launch(base::FilePath(), command_line, first_run);
933 ASSERT_TRUE(launch.OpenApplicationWindow(browser()->profile(), NULL)); 935 ASSERT_TRUE(launch.OpenApplicationWindow(browser()->profile(), NULL));
934 936
935 // Check that the new browser has an app name. 937 // Check that the new browser has an app name.
936 // The launch should have created a new browser. 938 // The launch should have created a new browser.
937 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); 939 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(),
940 browser()->host_desktop_type()));
938 941
939 // Find the new browser. 942 // Find the new browser.
940 Browser* new_browser = NULL; 943 Browser* new_browser = NULL;
941 for (chrome::BrowserIterator it; !it.done() && !new_browser; it.Next()) { 944 for (chrome::BrowserIterator it; !it.done() && !new_browser; it.Next()) {
942 if (*it != browser()) 945 if (*it != browser())
943 new_browser = *it; 946 new_browser = *it;
944 } 947 }
945 ASSERT_TRUE(new_browser); 948 ASSERT_TRUE(new_browser);
946 ASSERT_TRUE(new_browser != browser()); 949 ASSERT_TRUE(new_browser != browser());
947 950
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 1037
1035 // Simulate launching again. 1038 // Simulate launching again.
1036 CommandLine dummy(CommandLine::NO_PROGRAM); 1039 CommandLine dummy(CommandLine::NO_PROGRAM);
1037 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? 1040 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ?
1038 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 1041 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
1039 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); 1042 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run);
1040 launch.profile_ = browser()->profile(); 1043 launch.profile_ = browser()->profile();
1041 launch.ProcessStartupURLs(std::vector<GURL>()); 1044 launch.ProcessStartupURLs(std::vector<GURL>());
1042 1045
1043 // The launch should have created a new browser. 1046 // The launch should have created a new browser.
1044 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); 1047 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(),
1048 browser()->host_desktop_type()));
1045 1049
1046 // Find the new browser. 1050 // Find the new browser.
1047 Browser* new_browser = NULL; 1051 Browser* new_browser = NULL;
1048 for (chrome::BrowserIterator it; !it.done() && !new_browser; it.Next()) { 1052 for (chrome::BrowserIterator it; !it.done() && !new_browser; it.Next()) {
1049 if (*it != browser()) 1053 if (*it != browser())
1050 new_browser = *it; 1054 new_browser = *it;
1051 } 1055 }
1052 ASSERT_TRUE(new_browser); 1056 ASSERT_TRUE(new_browser);
1053 ASSERT_TRUE(new_browser != browser()); 1057 ASSERT_TRUE(new_browser != browser());
1054 1058
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 ASSERT_TRUE(app_window); 1112 ASSERT_TRUE(app_window);
1109 1113
1110 // Apps launched in a window from the NTP have an extensions tab helper but 1114 // Apps launched in a window from the NTP have an extensions tab helper but
1111 // do not have extension_app set in it. 1115 // do not have extension_app set in it.
1112 ASSERT_TRUE(extensions::TabHelper::FromWebContents(app_window)); 1116 ASSERT_TRUE(extensions::TabHelper::FromWebContents(app_window));
1113 EXPECT_FALSE( 1117 EXPECT_FALSE(
1114 extensions::TabHelper::FromWebContents(app_window)->extension_app()); 1118 extensions::TabHelper::FromWebContents(app_window)->extension_app());
1115 EXPECT_EQ(extension_app->GetFullLaunchURL(), app_window->GetURL()); 1119 EXPECT_EQ(extension_app->GetFullLaunchURL(), app_window->GetURL());
1116 1120
1117 // The launch should have created a new browser. 1121 // The launch should have created a new browser.
1118 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); 1122 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(),
1123 browser()->host_desktop_type()));
1119 1124
1120 // Find the new browser. 1125 // Find the new browser.
1121 Browser* new_browser = NULL; 1126 Browser* new_browser = NULL;
1122 for (chrome::BrowserIterator it; !it.done() && !new_browser; it.Next()) { 1127 for (chrome::BrowserIterator it; !it.done() && !new_browser; it.Next()) {
1123 if (*it != browser()) 1128 if (*it != browser())
1124 new_browser = *it; 1129 new_browser = *it;
1125 } 1130 }
1126 ASSERT_TRUE(new_browser); 1131 ASSERT_TRUE(new_browser);
1127 ASSERT_TRUE(new_browser != browser()); 1132 ASSERT_TRUE(new_browser != browser());
1128 1133
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 // Loads our test page and simulates a single click using the supplied button 1860 // Loads our test page and simulates a single click using the supplied button
1856 // and modifiers. The click will cause either a navigation or the creation of 1861 // and modifiers. The click will cause either a navigation or the creation of
1857 // a new window or foreground or background tab. We verify that the expected 1862 // a new window or foreground or background tab. We verify that the expected
1858 // disposition occurs. 1863 // disposition occurs.
1859 void RunTest(Browser* browser, 1864 void RunTest(Browser* browser,
1860 const GURL& url, 1865 const GURL& url,
1861 int modifiers, 1866 int modifiers,
1862 WebKit::WebMouseEvent::Button button, 1867 WebKit::WebMouseEvent::Button button,
1863 WindowOpenDisposition disposition) { 1868 WindowOpenDisposition disposition) {
1864 ui_test_utils::NavigateToURL(browser, url); 1869 ui_test_utils::NavigateToURL(browser, url);
1865 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile())); 1870 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile(),
1871 browser->host_desktop_type()));
1866 EXPECT_EQ(1, browser->tab_strip_model()->count()); 1872 EXPECT_EQ(1, browser->tab_strip_model()->count());
1867 content::WebContents* web_contents = 1873 content::WebContents* web_contents =
1868 browser->tab_strip_model()->GetActiveWebContents(); 1874 browser->tab_strip_model()->GetActiveWebContents();
1869 EXPECT_EQ(url, web_contents->GetURL()); 1875 EXPECT_EQ(url, web_contents->GetURL());
1870 1876
1871 if (disposition == CURRENT_TAB) { 1877 if (disposition == CURRENT_TAB) {
1872 content::WebContents* web_contents = 1878 content::WebContents* web_contents =
1873 browser->tab_strip_model()->GetActiveWebContents(); 1879 browser->tab_strip_model()->GetActiveWebContents();
1874 NavigationController* controller = 1880 NavigationController* controller =
1875 web_contents ? &web_contents->GetController() : NULL; 1881 web_contents ? &web_contents->GetController() : NULL;
1876 content::TestNavigationObserver same_tab_observer( 1882 content::TestNavigationObserver same_tab_observer(
1877 content::Source<NavigationController>(controller), 1883 content::Source<NavigationController>(controller),
1878 NULL, 1884 NULL,
1879 1); 1885 1);
1880 SimulateMouseClick(web_contents, modifiers, button); 1886 SimulateMouseClick(web_contents, modifiers, button);
1881 base::RunLoop run_loop; 1887 base::RunLoop run_loop;
1882 same_tab_observer.WaitForObservation( 1888 same_tab_observer.WaitForObservation(
1883 base::Bind(&content::RunThisRunLoop, base::Unretained(&run_loop)), 1889 base::Bind(&content::RunThisRunLoop, base::Unretained(&run_loop)),
1884 content::GetQuitTaskForRunLoop(&run_loop)); 1890 content::GetQuitTaskForRunLoop(&run_loop));
1885 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile())); 1891 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile(),
1892 browser->host_desktop_type()));
1886 EXPECT_EQ(1, browser->tab_strip_model()->count()); 1893 EXPECT_EQ(1, browser->tab_strip_model()->count());
1887 EXPECT_EQ(getSecondPageTitle(), web_contents->GetTitle()); 1894 EXPECT_EQ(getSecondPageTitle(), web_contents->GetTitle());
1888 return; 1895 return;
1889 } 1896 }
1890 1897
1891 content::WindowedNotificationObserver observer( 1898 content::WindowedNotificationObserver observer(
1892 chrome::NOTIFICATION_TAB_ADDED, 1899 chrome::NOTIFICATION_TAB_ADDED,
1893 content::NotificationService::AllSources()); 1900 content::NotificationService::AllSources());
1894 SimulateMouseClick(web_contents, modifiers, button); 1901 SimulateMouseClick(web_contents, modifiers, button);
1895 observer.Wait(); 1902 observer.Wait();
1896 1903
1897 if (disposition == NEW_WINDOW) { 1904 if (disposition == NEW_WINDOW) {
1898 EXPECT_EQ(2u, chrome::GetBrowserCount(browser->profile())); 1905 EXPECT_EQ(2u, chrome::GetBrowserCount(browser->profile(),
1906 browser->host_desktop_type()));
1899 return; 1907 return;
1900 } 1908 }
1901 1909
1902 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile())); 1910 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile(),
1911 browser->host_desktop_type()));
1903 EXPECT_EQ(2, browser->tab_strip_model()->count()); 1912 EXPECT_EQ(2, browser->tab_strip_model()->count());
1904 web_contents = browser->tab_strip_model()->GetActiveWebContents(); 1913 web_contents = browser->tab_strip_model()->GetActiveWebContents();
1905 WaitForLoadStop(web_contents); 1914 WaitForLoadStop(web_contents);
1906 if (disposition == NEW_FOREGROUND_TAB) { 1915 if (disposition == NEW_FOREGROUND_TAB) {
1907 EXPECT_EQ(getSecondPageTitle(), web_contents->GetTitle()); 1916 EXPECT_EQ(getSecondPageTitle(), web_contents->GetTitle());
1908 } else { 1917 } else {
1909 ASSERT_EQ(NEW_BACKGROUND_TAB, disposition); 1918 ASSERT_EQ(NEW_BACKGROUND_TAB, disposition);
1910 EXPECT_EQ(getFirstPageTitle(), web_contents->GetTitle()); 1919 EXPECT_EQ(getFirstPageTitle(), web_contents->GetTitle());
1911 } 1920 }
1912 } 1921 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2054 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2046 } 2055 }
2047 2056
2048 // Shift-middle-clicks open in a foreground tab. 2057 // Shift-middle-clicks open in a foreground tab.
2049 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { 2058 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) {
2050 int modifiers = WebKit::WebInputEvent::ShiftKey; 2059 int modifiers = WebKit::WebInputEvent::ShiftKey;
2051 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; 2060 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle;
2052 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 2061 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB;
2053 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2062 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2054 } 2063 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_finder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698