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