| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.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 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 base::Value::CreateBooleanValue(false), NULL); | 1066 base::Value::CreateBooleanValue(false), NULL); |
| 1067 provider_.UpdateChromePolicy(policy_map_); | 1067 provider_.UpdateChromePolicy(policy_map_); |
| 1068 #endif // defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) | 1068 #endif // defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) |
| 1069 | 1069 |
| 1070 EXPECT_CALL(provider_, IsInitializationComplete(_)) | 1070 EXPECT_CALL(provider_, IsInitializationComplete(_)) |
| 1071 .WillRepeatedly(Return(true)); | 1071 .WillRepeatedly(Return(true)); |
| 1072 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); | 1072 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); |
| 1073 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 1073 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
| 1074 } | 1074 } |
| 1075 | 1075 |
| 1076 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, SyncPromoForbidden) { | 1076 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
| 1077 // http://crbug.com/314819 |
| 1078 #define MAYBE_SyncPromoForbidden DISABLED_SyncPromoForbidden |
| 1079 #else |
| 1080 #define MAYBE_SyncPromoForbidden SyncPromoForbidden |
| 1081 #endif |
| 1082 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
| 1083 MAYBE_SyncPromoForbidden) { |
| 1077 // Consistently enable the welcome page on all platforms. | 1084 // Consistently enable the welcome page on all platforms. |
| 1078 first_run::SetShouldShowWelcomePage(); | 1085 first_run::SetShouldShowWelcomePage(); |
| 1079 | 1086 |
| 1080 // Simulate the following master_preferences: | 1087 // Simulate the following master_preferences: |
| 1081 // { | 1088 // { |
| 1082 // "sync_promo": { | 1089 // "sync_promo": { |
| 1083 // "show_on_first_run_allowed": false | 1090 // "show_on_first_run_allowed": false |
| 1084 // } | 1091 // } |
| 1085 // } | 1092 // } |
| 1086 StartupBrowserCreator browser_creator; | 1093 StartupBrowserCreator browser_creator; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1100 | 1107 |
| 1101 // Verify that the NTP and the welcome page are shown. | 1108 // Verify that the NTP and the welcome page are shown. |
| 1102 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 1109 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 1103 ASSERT_EQ(2, tab_strip->count()); | 1110 ASSERT_EQ(2, tab_strip->count()); |
| 1104 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), | 1111 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
| 1105 tab_strip->GetWebContentsAt(0)->GetURL()); | 1112 tab_strip->GetWebContentsAt(0)->GetURL()); |
| 1106 EXPECT_EQ(internals::GetWelcomePageURL(), | 1113 EXPECT_EQ(internals::GetWelcomePageURL(), |
| 1107 tab_strip->GetWebContentsAt(1)->GetURL()); | 1114 tab_strip->GetWebContentsAt(1)->GetURL()); |
| 1108 } | 1115 } |
| 1109 | 1116 |
| 1110 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, SyncPromoAllowed) { | 1117 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
| 1118 // http://crbug.com/314819 |
| 1119 #define MAYBE_SyncPromoAllowed DISABLED_SyncPromoAllowed |
| 1120 #else |
| 1121 #define MAYBE_SyncPromoAllowed SyncPromoAllowed |
| 1122 #endif |
| 1123 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
| 1124 MAYBE_SyncPromoAllowed) { |
| 1111 // Consistently enable the welcome page on all platforms. | 1125 // Consistently enable the welcome page on all platforms. |
| 1112 first_run::SetShouldShowWelcomePage(); | 1126 first_run::SetShouldShowWelcomePage(); |
| 1113 | 1127 |
| 1114 // Simulate the following master_preferences: | 1128 // Simulate the following master_preferences: |
| 1115 // { | 1129 // { |
| 1116 // "sync_promo": { | 1130 // "sync_promo": { |
| 1117 // "show_on_first_run_allowed": true | 1131 // "show_on_first_run_allowed": true |
| 1118 // } | 1132 // } |
| 1119 // } | 1133 // } |
| 1120 StartupBrowserCreator browser_creator; | 1134 StartupBrowserCreator browser_creator; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1134 | 1148 |
| 1135 // Verify that the sync promo and the welcome page are shown. | 1149 // Verify that the sync promo and the welcome page are shown. |
| 1136 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 1150 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 1137 ASSERT_EQ(2, tab_strip->count()); | 1151 ASSERT_EQ(2, tab_strip->count()); |
| 1138 EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), | 1152 EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), |
| 1139 tab_strip->GetWebContentsAt(0)->GetURL()); | 1153 tab_strip->GetWebContentsAt(0)->GetURL()); |
| 1140 EXPECT_EQ(internals::GetWelcomePageURL(), | 1154 EXPECT_EQ(internals::GetWelcomePageURL(), |
| 1141 tab_strip->GetWebContentsAt(1)->GetURL()); | 1155 tab_strip->GetWebContentsAt(1)->GetURL()); |
| 1142 } | 1156 } |
| 1143 | 1157 |
| 1158 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
| 1159 // http://crbug.com/314819 |
| 1160 #define MAYBE_FirstRunTabsPromoAllowed DISABLED_FirstRunTabsPromoAllowed |
| 1161 #else |
| 1162 #define MAYBE_FirstRunTabsPromoAllowed FirstRunTabsPromoAllowed |
| 1163 #endif |
| 1144 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, | 1164 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
| 1145 FirstRunTabsPromoAllowed) { | 1165 MAYBE_FirstRunTabsPromoAllowed) { |
| 1146 // Simulate the following master_preferences: | 1166 // Simulate the following master_preferences: |
| 1147 // { | 1167 // { |
| 1148 // "first_run_tabs" : [ | 1168 // "first_run_tabs" : [ |
| 1149 // "files/title1.html" | 1169 // "files/title1.html" |
| 1150 // ], | 1170 // ], |
| 1151 // "sync_promo": { | 1171 // "sync_promo": { |
| 1152 // "show_on_first_run_allowed": true | 1172 // "show_on_first_run_allowed": true |
| 1153 // } | 1173 // } |
| 1154 // } | 1174 // } |
| 1155 StartupBrowserCreator browser_creator; | 1175 StartupBrowserCreator browser_creator; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1170 | 1190 |
| 1171 // Verify that the first-run tab is shown and the sync promo has been added. | 1191 // Verify that the first-run tab is shown and the sync promo has been added. |
| 1172 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 1192 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 1173 ASSERT_EQ(2, tab_strip->count()); | 1193 ASSERT_EQ(2, tab_strip->count()); |
| 1174 EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), | 1194 EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), |
| 1175 tab_strip->GetWebContentsAt(0)->GetURL()); | 1195 tab_strip->GetWebContentsAt(0)->GetURL()); |
| 1176 EXPECT_EQ("title1.html", | 1196 EXPECT_EQ("title1.html", |
| 1177 tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName()); | 1197 tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName()); |
| 1178 } | 1198 } |
| 1179 | 1199 |
| 1200 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
| 1201 // http://crbug.com/314819 |
| 1202 #define MAYBE_FirstRunTabsContainSyncPromo \ |
| 1203 DISABLED_FirstRunTabsContainSyncPromo |
| 1204 #else |
| 1205 #define MAYBE_FirstRunTabsContainSyncPromo FirstRunTabsContainSyncPromo |
| 1206 #endif |
| 1180 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, | 1207 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
| 1181 FirstRunTabsContainSyncPromo) { | 1208 MAYBE_FirstRunTabsContainSyncPromo) { |
| 1182 // Simulate the following master_preferences: | 1209 // Simulate the following master_preferences: |
| 1183 // { | 1210 // { |
| 1184 // "first_run_tabs" : [ | 1211 // "first_run_tabs" : [ |
| 1185 // "files/title1.html", | 1212 // "files/title1.html", |
| 1186 // "chrome://signin/?source=0&next_page=chrome%3A%2F%2Fnewtab%2F" | 1213 // "chrome://signin/?source=0&next_page=chrome%3A%2F%2Fnewtab%2F" |
| 1187 // ], | 1214 // ], |
| 1188 // "sync_promo": { | 1215 // "sync_promo": { |
| 1189 // "show_on_first_run_allowed": true | 1216 // "show_on_first_run_allowed": true |
| 1190 // } | 1217 // } |
| 1191 // } | 1218 // } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1211 // Verify that the first-run tabs are shown and no sync promo has been added | 1238 // Verify that the first-run tabs are shown and no sync promo has been added |
| 1212 // as the first-run tabs contain it already. | 1239 // as the first-run tabs contain it already. |
| 1213 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 1240 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 1214 ASSERT_EQ(2, tab_strip->count()); | 1241 ASSERT_EQ(2, tab_strip->count()); |
| 1215 EXPECT_EQ("title1.html", | 1242 EXPECT_EQ("title1.html", |
| 1216 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1243 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
| 1217 EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), | 1244 EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), |
| 1218 tab_strip->GetWebContentsAt(1)->GetURL()); | 1245 tab_strip->GetWebContentsAt(1)->GetURL()); |
| 1219 } | 1246 } |
| 1220 | 1247 |
| 1248 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
| 1249 // http://crbug.com/314819 |
| 1250 #define MAYBE_FirstRunTabsContainNTPSyncPromoAllowed \ |
| 1251 DISABLED_FirstRunTabsContainNTPSyncPromoAllowed |
| 1252 #else |
| 1253 #define MAYBE_FirstRunTabsContainNTPSyncPromoAllowed \ |
| 1254 FirstRunTabsContainNTPSyncPromoAllowed |
| 1255 #endif |
| 1221 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, | 1256 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
| 1222 FirstRunTabsContainNTPSyncPromoAllowed) { | 1257 MAYBE_FirstRunTabsContainNTPSyncPromoAllowed) { |
| 1223 // Simulate the following master_preferences: | 1258 // Simulate the following master_preferences: |
| 1224 // { | 1259 // { |
| 1225 // "first_run_tabs" : [ | 1260 // "first_run_tabs" : [ |
| 1226 // "new_tab_page", | 1261 // "new_tab_page", |
| 1227 // "files/title1.html" | 1262 // "files/title1.html" |
| 1228 // ], | 1263 // ], |
| 1229 // "sync_promo": { | 1264 // "sync_promo": { |
| 1230 // "show_on_first_run_allowed": true | 1265 // "show_on_first_run_allowed": true |
| 1231 // } | 1266 // } |
| 1232 // } | 1267 // } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1250 // Verify that the first-run tabs are shown but the NTP that they contain has | 1285 // Verify that the first-run tabs are shown but the NTP that they contain has |
| 1251 // been replaced by the sync promo. | 1286 // been replaced by the sync promo. |
| 1252 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 1287 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 1253 ASSERT_EQ(2, tab_strip->count()); | 1288 ASSERT_EQ(2, tab_strip->count()); |
| 1254 EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), | 1289 EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), |
| 1255 tab_strip->GetWebContentsAt(0)->GetURL()); | 1290 tab_strip->GetWebContentsAt(0)->GetURL()); |
| 1256 EXPECT_EQ("title1.html", | 1291 EXPECT_EQ("title1.html", |
| 1257 tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName()); | 1292 tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName()); |
| 1258 } | 1293 } |
| 1259 | 1294 |
| 1295 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
| 1296 // http://crbug.com/314819 |
| 1297 #define MAYBE_FirstRunTabsContainNTPSyncPromoForbidden \ |
| 1298 DISABLED_FirstRunTabsContainNTPSyncPromoForbidden |
| 1299 #else |
| 1300 #define MAYBE_FirstRunTabsContainNTPSyncPromoForbidden \ |
| 1301 FirstRunTabsContainNTPSyncPromoForbidden |
| 1302 #endif |
| 1260 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, | 1303 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
| 1261 FirstRunTabsContainNTPSyncPromoForbidden) { | 1304 MAYBE_FirstRunTabsContainNTPSyncPromoForbidden) { |
| 1262 // Simulate the following master_preferences: | 1305 // Simulate the following master_preferences: |
| 1263 // { | 1306 // { |
| 1264 // "first_run_tabs" : [ | 1307 // "first_run_tabs" : [ |
| 1265 // "new_tab_page", | 1308 // "new_tab_page", |
| 1266 // "files/title1.html" | 1309 // "files/title1.html" |
| 1267 // ], | 1310 // ], |
| 1268 // "sync_promo": { | 1311 // "sync_promo": { |
| 1269 // "show_on_first_run_allowed": false | 1312 // "show_on_first_run_allowed": false |
| 1270 // } | 1313 // } |
| 1271 // } | 1314 // } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1289 // Verify that the first-run tabs are shown, the NTP that they contain has not | 1332 // Verify that the first-run tabs are shown, the NTP that they contain has not |
| 1290 // not been replaced by the sync promo and no sync promo has been added. | 1333 // not been replaced by the sync promo and no sync promo has been added. |
| 1291 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 1334 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 1292 ASSERT_EQ(2, tab_strip->count()); | 1335 ASSERT_EQ(2, tab_strip->count()); |
| 1293 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), | 1336 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
| 1294 tab_strip->GetWebContentsAt(0)->GetURL()); | 1337 tab_strip->GetWebContentsAt(0)->GetURL()); |
| 1295 EXPECT_EQ("title1.html", | 1338 EXPECT_EQ("title1.html", |
| 1296 tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName()); | 1339 tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName()); |
| 1297 } | 1340 } |
| 1298 | 1341 |
| 1342 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
| 1343 // http://crbug.com/314819 |
| 1344 #define MAYBE_FirstRunTabsSyncPromoForbidden \ |
| 1345 DISABLED_FirstRunTabsSyncPromoForbidden |
| 1346 #else |
| 1347 #define MAYBE_FirstRunTabsSyncPromoForbidden FirstRunTabsSyncPromoForbidden |
| 1348 #endif |
| 1299 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, | 1349 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
| 1300 FirstRunTabsSyncPromoForbidden) { | 1350 MAYBE_FirstRunTabsSyncPromoForbidden) { |
| 1301 // Simulate the following master_preferences: | 1351 // Simulate the following master_preferences: |
| 1302 // { | 1352 // { |
| 1303 // "first_run_tabs" : [ | 1353 // "first_run_tabs" : [ |
| 1304 // "files/title1.html" | 1354 // "files/title1.html" |
| 1305 // ], | 1355 // ], |
| 1306 // "sync_promo": { | 1356 // "sync_promo": { |
| 1307 // "show_on_first_run_allowed": false | 1357 // "show_on_first_run_allowed": false |
| 1308 // } | 1358 // } |
| 1309 // } | 1359 // } |
| 1310 StartupBrowserCreator browser_creator; | 1360 StartupBrowserCreator browser_creator; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1324 ASSERT_TRUE(new_browser); | 1374 ASSERT_TRUE(new_browser); |
| 1325 | 1375 |
| 1326 // Verify that the first-run tab is shown and no sync promo has been added. | 1376 // Verify that the first-run tab is shown and no sync promo has been added. |
| 1327 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 1377 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 1328 ASSERT_EQ(1, tab_strip->count()); | 1378 ASSERT_EQ(1, tab_strip->count()); |
| 1329 EXPECT_EQ("title1.html", | 1379 EXPECT_EQ("title1.html", |
| 1330 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1380 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
| 1331 } | 1381 } |
| 1332 | 1382 |
| 1333 #if defined(ENABLE_CONFIGURATION_POLICY) | 1383 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 1384 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
| 1385 // http://crbug.com/314819 |
| 1386 #define MAYBE_RestoreOnStartupURLsPolicySpecified \ |
| 1387 DISABLED_RestoreOnStartupURLsPolicySpecified |
| 1388 #else |
| 1389 #define MAYBE_RestoreOnStartupURLsPolicySpecified \ |
| 1390 RestoreOnStartupURLsPolicySpecified |
| 1391 #endif |
| 1334 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, | 1392 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
| 1335 RestoreOnStartupURLsPolicySpecified) { | 1393 MAYBE_RestoreOnStartupURLsPolicySpecified) { |
| 1336 // Simulate the following master_preferences: | 1394 // Simulate the following master_preferences: |
| 1337 // { | 1395 // { |
| 1338 // "sync_promo": { | 1396 // "sync_promo": { |
| 1339 // "show_on_first_run_allowed": true | 1397 // "show_on_first_run_allowed": true |
| 1340 // } | 1398 // } |
| 1341 // } | 1399 // } |
| 1342 StartupBrowserCreator browser_creator; | 1400 StartupBrowserCreator browser_creator; |
| 1343 browser()->profile()->GetPrefs()->SetBoolean( | 1401 browser()->profile()->GetPrefs()->SetBoolean( |
| 1344 prefs::kSignInPromoShowOnFirstRunAllowed, true); | 1402 prefs::kSignInPromoShowOnFirstRunAllowed, true); |
| 1345 | 1403 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 ASSERT_EQ(1, tab_strip->count()); | 1435 ASSERT_EQ(1, tab_strip->count()); |
| 1378 EXPECT_EQ("title1.html", | 1436 EXPECT_EQ("title1.html", |
| 1379 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1437 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
| 1380 } | 1438 } |
| 1381 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 1439 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
| 1382 | 1440 |
| 1383 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || | 1441 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || |
| 1384 // defined(ENABLE_CONFIGURATION_POLICY) | 1442 // defined(ENABLE_CONFIGURATION_POLICY) |
| 1385 | 1443 |
| 1386 #endif // !defined(OS_CHROMEOS) | 1444 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |