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

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

Issue 10807047: Create content\public\test\test_utils.h to hold common test classes that are used by unit and brows… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
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/browser_navigator_browsertest.h" 5 #include "chrome/browser/ui/browser_navigator_browsertest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/prefs/incognito_mode_prefs.h" 9 #include "chrome/browser/prefs/incognito_mode_prefs.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 896
897 // This test verifies that the settings page isn't opened in the incognito 897 // This test verifies that the settings page isn't opened in the incognito
898 // window from a non-incognito window (bookmark open-in-incognito trigger). 898 // window from a non-incognito window (bookmark open-in-incognito trigger).
899 // Disabled until fixed for uber settings: http://crbug.com/111243 899 // Disabled until fixed for uber settings: http://crbug.com/111243
900 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 900 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
901 DISABLED_Disposition_Settings_UseNonIncognitoWindowForBookmark) { 901 DISABLED_Disposition_Settings_UseNonIncognitoWindowForBookmark) {
902 chrome::NavigateParams params(browser(), GetSettingsURL(), 902 chrome::NavigateParams params(browser(), GetSettingsURL(),
903 content::PAGE_TRANSITION_AUTO_BOOKMARK); 903 content::PAGE_TRANSITION_AUTO_BOOKMARK);
904 params.disposition = OFF_THE_RECORD; 904 params.disposition = OFF_THE_RECORD;
905 { 905 {
906 ui_test_utils::WindowedNotificationObserver observer( 906 content::WindowedNotificationObserver observer(
907 content::NOTIFICATION_LOAD_STOP, 907 content::NOTIFICATION_LOAD_STOP,
908 content::NotificationService::AllSources()); 908 content::NotificationService::AllSources());
909 chrome::Navigate(&params); 909 chrome::Navigate(&params);
910 observer.Wait(); 910 observer.Wait();
911 } 911 }
912 912
913 EXPECT_EQ(1u, BrowserList::size()); 913 EXPECT_EQ(1u, BrowserList::size());
914 EXPECT_EQ(GetSettingsURL(), 914 EXPECT_EQ(GetSettingsURL(),
915 chrome::GetActiveWebContents(browser())->GetURL()); 915 chrome::GetActiveWebContents(browser())->GetURL());
916 } 916 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 981 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
982 ui_test_utils::NavigateToURL(&p); 982 ui_test_utils::NavigateToURL(&p);
983 983
984 // The tab should not be sad anymore. 984 // The tab should not be sad anymore.
985 EXPECT_FALSE(web_contents->IsCrashed()); 985 EXPECT_FALSE(web_contents->IsCrashed());
986 } 986 }
987 987
988 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 988 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
989 NavigateFromDefaultToOptionsInSameTab) { 989 NavigateFromDefaultToOptionsInSameTab) {
990 { 990 {
991 ui_test_utils::WindowedNotificationObserver observer( 991 content::WindowedNotificationObserver observer(
992 content::NOTIFICATION_LOAD_STOP, 992 content::NOTIFICATION_LOAD_STOP,
993 content::NotificationService::AllSources()); 993 content::NotificationService::AllSources());
994 chrome::ShowSettings(browser()); 994 chrome::ShowSettings(browser());
995 observer.Wait(); 995 observer.Wait();
996 } 996 }
997 EXPECT_EQ(1, browser()->tab_count()); 997 EXPECT_EQ(1, browser()->tab_count());
998 EXPECT_EQ(GetSettingsURL(), 998 EXPECT_EQ(GetSettingsURL(),
999 chrome::GetActiveWebContents(browser())->GetURL()); 999 chrome::GetActiveWebContents(browser())->GetURL());
1000 } 1000 }
1001 1001
1002 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1002 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1003 NavigateFromBlankToOptionsInSameTab) { 1003 NavigateFromBlankToOptionsInSameTab) {
1004 chrome::NavigateParams p(MakeNavigateParams()); 1004 chrome::NavigateParams p(MakeNavigateParams());
1005 p.url = GURL(chrome::kAboutBlankURL); 1005 p.url = GURL(chrome::kAboutBlankURL);
1006 ui_test_utils::NavigateToURL(&p); 1006 ui_test_utils::NavigateToURL(&p);
1007 1007
1008 { 1008 {
1009 ui_test_utils::WindowedNotificationObserver observer( 1009 content::WindowedNotificationObserver observer(
1010 content::NOTIFICATION_LOAD_STOP, 1010 content::NOTIFICATION_LOAD_STOP,
1011 content::NotificationService::AllSources()); 1011 content::NotificationService::AllSources());
1012 chrome::ShowSettings(browser()); 1012 chrome::ShowSettings(browser());
1013 observer.Wait(); 1013 observer.Wait();
1014 } 1014 }
1015 EXPECT_EQ(1, browser()->tab_count()); 1015 EXPECT_EQ(1, browser()->tab_count());
1016 EXPECT_EQ(GetSettingsURL(), 1016 EXPECT_EQ(GetSettingsURL(),
1017 chrome::GetActiveWebContents(browser())->GetURL()); 1017 chrome::GetActiveWebContents(browser())->GetURL());
1018 } 1018 }
1019 1019
1020 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1020 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1021 NavigateFromNTPToOptionsInSameTab) { 1021 NavigateFromNTPToOptionsInSameTab) {
1022 chrome::NavigateParams p(MakeNavigateParams()); 1022 chrome::NavigateParams p(MakeNavigateParams());
1023 p.url = GURL(chrome::kChromeUINewTabURL); 1023 p.url = GURL(chrome::kChromeUINewTabURL);
1024 ui_test_utils::NavigateToURL(&p); 1024 ui_test_utils::NavigateToURL(&p);
1025 EXPECT_EQ(1, browser()->tab_count()); 1025 EXPECT_EQ(1, browser()->tab_count());
1026 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), 1026 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
1027 chrome::GetActiveWebContents(browser())->GetURL()); 1027 chrome::GetActiveWebContents(browser())->GetURL());
1028 1028
1029 { 1029 {
1030 ui_test_utils::WindowedNotificationObserver observer( 1030 content::WindowedNotificationObserver observer(
1031 content::NOTIFICATION_LOAD_STOP, 1031 content::NOTIFICATION_LOAD_STOP,
1032 content::NotificationService::AllSources()); 1032 content::NotificationService::AllSources());
1033 chrome::ShowSettings(browser()); 1033 chrome::ShowSettings(browser());
1034 observer.Wait(); 1034 observer.Wait();
1035 } 1035 }
1036 EXPECT_EQ(1, browser()->tab_count()); 1036 EXPECT_EQ(1, browser()->tab_count());
1037 EXPECT_EQ(GetSettingsURL(), 1037 EXPECT_EQ(GetSettingsURL(),
1038 chrome::GetActiveWebContents(browser())->GetURL()); 1038 chrome::GetActiveWebContents(browser())->GetURL());
1039 } 1039 }
1040 1040
1041 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1041 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1042 NavigateFromPageToOptionsInNewTab) { 1042 NavigateFromPageToOptionsInNewTab) {
1043 chrome::NavigateParams p(MakeNavigateParams()); 1043 chrome::NavigateParams p(MakeNavigateParams());
1044 ui_test_utils::NavigateToURL(&p); 1044 ui_test_utils::NavigateToURL(&p);
1045 EXPECT_EQ(GetGoogleURL(), chrome::GetActiveWebContents(browser())->GetURL()); 1045 EXPECT_EQ(GetGoogleURL(), chrome::GetActiveWebContents(browser())->GetURL());
1046 EXPECT_EQ(1u, BrowserList::size()); 1046 EXPECT_EQ(1u, BrowserList::size());
1047 EXPECT_EQ(1, browser()->tab_count()); 1047 EXPECT_EQ(1, browser()->tab_count());
1048 1048
1049 { 1049 {
1050 ui_test_utils::WindowedNotificationObserver observer( 1050 content::WindowedNotificationObserver observer(
1051 content::NOTIFICATION_LOAD_STOP, 1051 content::NOTIFICATION_LOAD_STOP,
1052 content::NotificationService::AllSources()); 1052 content::NotificationService::AllSources());
1053 chrome::ShowSettings(browser()); 1053 chrome::ShowSettings(browser());
1054 observer.Wait(); 1054 observer.Wait();
1055 } 1055 }
1056 EXPECT_EQ(2, browser()->tab_count()); 1056 EXPECT_EQ(2, browser()->tab_count());
1057 EXPECT_EQ(GetSettingsURL(), 1057 EXPECT_EQ(GetSettingsURL(),
1058 chrome::GetActiveWebContents(browser())->GetURL()); 1058 chrome::GetActiveWebContents(browser())->GetURL());
1059 } 1059 }
1060 1060
1061 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1061 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1062 NavigateFromNTPToOptionsSingleton) { 1062 NavigateFromNTPToOptionsSingleton) {
1063 { 1063 {
1064 ui_test_utils::WindowedNotificationObserver observer( 1064 content::WindowedNotificationObserver observer(
1065 content::NOTIFICATION_LOAD_STOP, 1065 content::NOTIFICATION_LOAD_STOP,
1066 content::NotificationService::AllSources()); 1066 content::NotificationService::AllSources());
1067 chrome::ShowSettings(browser()); 1067 chrome::ShowSettings(browser());
1068 observer.Wait(); 1068 observer.Wait();
1069 } 1069 }
1070 EXPECT_EQ(1, browser()->tab_count()); 1070 EXPECT_EQ(1, browser()->tab_count());
1071 1071
1072 chrome::NewTab(browser()); 1072 chrome::NewTab(browser());
1073 EXPECT_EQ(2, browser()->tab_count()); 1073 EXPECT_EQ(2, browser()->tab_count());
1074 1074
1075 { 1075 {
1076 ui_test_utils::WindowedNotificationObserver observer( 1076 content::WindowedNotificationObserver observer(
1077 content::NOTIFICATION_LOAD_STOP, 1077 content::NOTIFICATION_LOAD_STOP,
1078 content::NotificationService::AllSources()); 1078 content::NotificationService::AllSources());
1079 chrome::ShowSettings(browser()); 1079 chrome::ShowSettings(browser());
1080 observer.Wait(); 1080 observer.Wait();
1081 } 1081 }
1082 EXPECT_EQ(2, browser()->tab_count()); 1082 EXPECT_EQ(2, browser()->tab_count());
1083 EXPECT_EQ(GetSettingsURL(), 1083 EXPECT_EQ(GetSettingsURL(),
1084 chrome::GetActiveWebContents(browser())->GetURL()); 1084 chrome::GetActiveWebContents(browser())->GetURL());
1085 } 1085 }
1086 1086
1087 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1087 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1088 NavigateFromNTPToOptionsPageInSameTab) { 1088 NavigateFromNTPToOptionsPageInSameTab) {
1089 { 1089 {
1090 ui_test_utils::WindowedNotificationObserver observer( 1090 content::WindowedNotificationObserver observer(
1091 content::NOTIFICATION_LOAD_STOP, 1091 content::NOTIFICATION_LOAD_STOP,
1092 content::NotificationService::AllSources()); 1092 content::NotificationService::AllSources());
1093 chrome::ShowClearBrowsingDataDialog(browser()); 1093 chrome::ShowClearBrowsingDataDialog(browser());
1094 observer.Wait(); 1094 observer.Wait();
1095 } 1095 }
1096 EXPECT_EQ(1, browser()->tab_count()); 1096 EXPECT_EQ(1, browser()->tab_count());
1097 EXPECT_EQ(GetClearBrowsingDataURL(), 1097 EXPECT_EQ(GetClearBrowsingDataURL(),
1098 chrome::GetActiveWebContents(browser())->GetURL()); 1098 chrome::GetActiveWebContents(browser())->GetURL());
1099 1099
1100 chrome::NewTab(browser()); 1100 chrome::NewTab(browser());
1101 EXPECT_EQ(2, browser()->tab_count()); 1101 EXPECT_EQ(2, browser()->tab_count());
1102 1102
1103 { 1103 {
1104 ui_test_utils::WindowedNotificationObserver observer( 1104 content::WindowedNotificationObserver observer(
1105 content::NOTIFICATION_LOAD_STOP, 1105 content::NOTIFICATION_LOAD_STOP,
1106 content::NotificationService::AllSources()); 1106 content::NotificationService::AllSources());
1107 chrome::ShowClearBrowsingDataDialog(browser()); 1107 chrome::ShowClearBrowsingDataDialog(browser());
1108 observer.Wait(); 1108 observer.Wait();
1109 } 1109 }
1110 EXPECT_EQ(2, browser()->tab_count()); 1110 EXPECT_EQ(2, browser()->tab_count());
1111 EXPECT_EQ(GetClearBrowsingDataURL(), 1111 EXPECT_EQ(GetClearBrowsingDataURL(),
1112 chrome::GetActiveWebContents(browser())->GetURL()); 1112 chrome::GetActiveWebContents(browser())->GetURL());
1113 } 1113 }
1114 1114
1115 // Times out on mac, fails on linux. 1115 // Times out on mac, fails on linux.
1116 // http://crbug.com/119779 1116 // http://crbug.com/119779
1117 #if defined(OS_MACOSX) || defined(OS_LINUX) 1117 #if defined(OS_MACOSX) || defined(OS_LINUX)
1118 #define MAYBE_NavigateFromOtherTabToSingletonOptions DISABLED_NavigateFromOtherT abToSingletonOptions 1118 #define MAYBE_NavigateFromOtherTabToSingletonOptions DISABLED_NavigateFromOtherT abToSingletonOptions
1119 #else 1119 #else
1120 #define MAYBE_NavigateFromOtherTabToSingletonOptions NavigatorFrameOtherTabToSin gletonOptions 1120 #define MAYBE_NavigateFromOtherTabToSingletonOptions NavigatorFrameOtherTabToSin gletonOptions
1121 #endif 1121 #endif
1122 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1122 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1123 MAYBE_NavigateFromOtherTabToSingletonOptions) { 1123 MAYBE_NavigateFromOtherTabToSingletonOptions) {
1124 { 1124 {
1125 ui_test_utils::WindowedNotificationObserver observer( 1125 content::WindowedNotificationObserver observer(
1126 content::NOTIFICATION_LOAD_STOP, 1126 content::NOTIFICATION_LOAD_STOP,
1127 content::NotificationService::AllSources()); 1127 content::NotificationService::AllSources());
1128 chrome::ShowSettings(browser()); 1128 chrome::ShowSettings(browser());
1129 observer.Wait(); 1129 observer.Wait();
1130 } 1130 }
1131 { 1131 {
1132 ui_test_utils::WindowedNotificationObserver observer( 1132 content::WindowedNotificationObserver observer(
1133 content::NOTIFICATION_LOAD_STOP, 1133 content::NOTIFICATION_LOAD_STOP,
1134 content::NotificationService::AllSources()); 1134 content::NotificationService::AllSources());
1135 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 1135 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
1136 content::PAGE_TRANSITION_LINK); 1136 content::PAGE_TRANSITION_LINK);
1137 observer.Wait(); 1137 observer.Wait();
1138 } 1138 }
1139 1139
1140 { 1140 {
1141 ui_test_utils::WindowedNotificationObserver observer( 1141 content::WindowedNotificationObserver observer(
1142 content::NOTIFICATION_LOAD_STOP, 1142 content::NOTIFICATION_LOAD_STOP,
1143 content::NotificationService::AllSources()); 1143 content::NotificationService::AllSources());
1144 chrome::ShowSettings(browser()); 1144 chrome::ShowSettings(browser());
1145 observer.Wait(); 1145 observer.Wait();
1146 } 1146 }
1147 EXPECT_EQ(2, browser()->tab_count()); 1147 EXPECT_EQ(2, browser()->tab_count());
1148 EXPECT_EQ(GetSettingsURL(), 1148 EXPECT_EQ(GetSettingsURL(),
1149 chrome::GetActiveWebContents(browser())->GetURL()); 1149 chrome::GetActiveWebContents(browser())->GetURL());
1150 } 1150 }
1151 1151
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 chrome::SelectPreviousTab(browser()); 1183 chrome::SelectPreviousTab(browser());
1184 EXPECT_EQ(0, browser()->active_index()); 1184 EXPECT_EQ(0, browser()->active_index());
1185 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), 1185 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(),
1186 VIEW_ID_LOCATION_BAR)); 1186 VIEW_ID_LOCATION_BAR));
1187 } 1187 }
1188 1188
1189 // TODO(csilv): Update this for uber page. http://crbug.com/111579. 1189 // TODO(csilv): Update this for uber page. http://crbug.com/111579.
1190 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1190 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1191 DISABLED_NavigateFromDefaultToHistoryInSameTab) { 1191 DISABLED_NavigateFromDefaultToHistoryInSameTab) {
1192 { 1192 {
1193 ui_test_utils::WindowedNotificationObserver observer( 1193 content::WindowedNotificationObserver observer(
1194 content::NOTIFICATION_LOAD_STOP, 1194 content::NOTIFICATION_LOAD_STOP,
1195 content::NotificationService::AllSources()); 1195 content::NotificationService::AllSources());
1196 chrome::ShowHistory(browser()); 1196 chrome::ShowHistory(browser());
1197 observer.Wait(); 1197 observer.Wait();
1198 } 1198 }
1199 EXPECT_EQ(1, browser()->tab_count()); 1199 EXPECT_EQ(1, browser()->tab_count());
1200 EXPECT_EQ(GURL(chrome::kChromeUIHistoryFrameURL), 1200 EXPECT_EQ(GURL(chrome::kChromeUIHistoryFrameURL),
1201 chrome::GetActiveWebContents(browser())->GetURL()); 1201 chrome::GetActiveWebContents(browser())->GetURL());
1202 } 1202 }
1203 1203
1204 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1204 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1205 NavigateFromDefaultToBookmarksInSameTab) { 1205 NavigateFromDefaultToBookmarksInSameTab) {
1206 { 1206 {
1207 ui_test_utils::WindowedNotificationObserver observer( 1207 content::WindowedNotificationObserver observer(
1208 content::NOTIFICATION_LOAD_STOP, 1208 content::NOTIFICATION_LOAD_STOP,
1209 content::NotificationService::AllSources()); 1209 content::NotificationService::AllSources());
1210 chrome::ShowBookmarkManager(browser()); 1210 chrome::ShowBookmarkManager(browser());
1211 observer.Wait(); 1211 observer.Wait();
1212 } 1212 }
1213 EXPECT_EQ(1, browser()->tab_count()); 1213 EXPECT_EQ(1, browser()->tab_count());
1214 EXPECT_EQ(GURL(chrome::kChromeUIBookmarksURL), 1214 EXPECT_EQ(GURL(chrome::kChromeUIBookmarksURL),
1215 chrome::GetActiveWebContents(browser())->GetURL()); 1215 chrome::GetActiveWebContents(browser())->GetURL());
1216 } 1216 }
1217 1217
1218 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1218 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1219 NavigateFromDefaultToDownloadsInSameTab) { 1219 NavigateFromDefaultToDownloadsInSameTab) {
1220 { 1220 {
1221 ui_test_utils::WindowedNotificationObserver observer( 1221 content::WindowedNotificationObserver observer(
1222 content::NOTIFICATION_LOAD_STOP, 1222 content::NOTIFICATION_LOAD_STOP,
1223 content::NotificationService::AllSources()); 1223 content::NotificationService::AllSources());
1224 chrome::ShowDownloads(browser()); 1224 chrome::ShowDownloads(browser());
1225 observer.Wait(); 1225 observer.Wait();
1226 } 1226 }
1227 EXPECT_EQ(1, browser()->tab_count()); 1227 EXPECT_EQ(1, browser()->tab_count());
1228 EXPECT_EQ(GURL(chrome::kChromeUIDownloadsURL), 1228 EXPECT_EQ(GURL(chrome::kChromeUIDownloadsURL),
1229 chrome::GetActiveWebContents(browser())->GetURL()); 1229 chrome::GetActiveWebContents(browser())->GetURL());
1230 } 1230 }
1231 1231
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 EXPECT_EQ(browser(), p2.browser); 1279 EXPECT_EQ(browser(), p2.browser);
1280 1280
1281 // We should now have two windows, the browser() provided by the framework and 1281 // We should now have two windows, the browser() provided by the framework and
1282 // the panel window we opened earlier. The tabbed browser window has 2 tabs. 1282 // the panel window we opened earlier. The tabbed browser window has 2 tabs.
1283 EXPECT_EQ(2u, BrowserList::size()); 1283 EXPECT_EQ(2u, BrowserList::size());
1284 EXPECT_EQ(2, browser()->tab_count()); 1284 EXPECT_EQ(2, browser()->tab_count());
1285 EXPECT_EQ(1, panel_browser->tab_count()); 1285 EXPECT_EQ(1, panel_browser->tab_count());
1286 } 1286 }
1287 1287
1288 } // namespace 1288 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_browsertest.cc ('k') | chrome/browser/ui/cocoa/browser_window_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698