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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
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/macros.h" | 10 #include "base/macros.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // Internet Explorer always exists and always has something to import. | 158 // Internet Explorer always exists and always has something to import. |
159 EXPECT_GT(source_profile_count, 0); | 159 EXPECT_GT(source_profile_count, 0); |
160 #endif | 160 #endif |
161 if (source_profile_count == 0) | 161 if (source_profile_count == 0) |
162 return expected_import_state & ~first_run::AUTO_IMPORT_PROFILE_IMPORTED; | 162 return expected_import_state & ~first_run::AUTO_IMPORT_PROFILE_IMPORTED; |
163 return expected_import_state; | 163 return expected_import_state; |
164 } | 164 } |
165 | 165 |
166 } // namespace | 166 } // namespace |
167 | 167 |
168 extern const char kImportDefault[] = | 168 extern constexpr char kImportDefault[] = |
169 "{\n" | 169 "{\n" |
170 "}\n"; | 170 "}\n"; |
171 typedef FirstRunMasterPrefsBrowserTestT<kImportDefault> | 171 typedef FirstRunMasterPrefsBrowserTestT<kImportDefault> |
172 FirstRunMasterPrefsImportDefault; | 172 FirstRunMasterPrefsImportDefault; |
173 // http://crbug.com/314221 | 173 // http://crbug.com/314221 |
174 #if defined(OS_MACOSX) || (defined(GOOGLE_CHROME_BUILD) && defined(OS_LINUX)) | 174 #if defined(OS_MACOSX) || (defined(GOOGLE_CHROME_BUILD) && defined(OS_LINUX)) |
175 #define MAYBE_ImportDefault DISABLED_ImportDefault | 175 #define MAYBE_ImportDefault DISABLED_ImportDefault |
176 #else | 176 #else |
177 #define MAYBE_ImportDefault ImportDefault | 177 #define MAYBE_ImportDefault ImportDefault |
178 #endif | 178 #endif |
| 179 // No items are imported by default. |
179 IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportDefault, MAYBE_ImportDefault) { | 180 IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportDefault, MAYBE_ImportDefault) { |
180 int auto_import_state = first_run::auto_import_state(); | 181 int auto_import_state = first_run::auto_import_state(); |
| 182 EXPECT_EQ(MaskExpectedImportState(first_run::AUTO_IMPORT_CALLED), |
| 183 auto_import_state); |
| 184 } |
| 185 |
| 186 extern constexpr char kImportAll[] = |
| 187 "{\n" |
| 188 " \"distribution\": {\n" |
| 189 " \"import_bookmarks\": true,\n" |
| 190 " \"import_history\": true,\n" |
| 191 " \"import_home_page\": true,\n" |
| 192 " \"import_search_engine\": true\n" |
| 193 " }\n" |
| 194 "}\n"; |
| 195 typedef FirstRunMasterPrefsBrowserTestT<kImportAll> |
| 196 FirstRunMasterPrefsImportAll; |
| 197 // http://crbug.com/314221 |
| 198 #if defined(OS_MACOSX) || (defined(GOOGLE_CHROME_BUILD) && defined(OS_LINUX)) |
| 199 #define MAYBE_ImportAll DISABLED_ImportAll |
| 200 #else |
| 201 #define MAYBE_ImportAll ImportAll |
| 202 #endif |
| 203 IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportAll, MAYBE_ImportAll) { |
| 204 int auto_import_state = first_run::auto_import_state(); |
181 EXPECT_EQ(MaskExpectedImportState(first_run::AUTO_IMPORT_CALLED | | 205 EXPECT_EQ(MaskExpectedImportState(first_run::AUTO_IMPORT_CALLED | |
182 first_run::AUTO_IMPORT_PROFILE_IMPORTED), | 206 first_run::AUTO_IMPORT_PROFILE_IMPORTED), |
183 auto_import_state); | 207 auto_import_state); |
184 } | 208 } |
185 | 209 |
186 // The bookmarks file doesn't actually need to exist for this integration test | 210 // The bookmarks file doesn't actually need to exist for this integration test |
187 // to trigger the interaction being tested. | 211 // to trigger the interaction being tested. |
188 extern const char kImportBookmarksFile[] = | 212 extern constexpr char kImportBookmarksFile[] = |
189 "{\n" | 213 "{\n" |
190 " \"distribution\": {\n" | 214 " \"distribution\": {\n" |
191 " \"import_bookmarks_from_file\": \"/foo/doesntexists.wtv\"\n" | 215 " \"import_bookmarks_from_file\": \"/foo/doesntexists.wtv\"\n" |
192 " }\n" | 216 " }\n" |
193 "}\n"; | 217 "}\n"; |
194 typedef FirstRunMasterPrefsBrowserTestT<kImportBookmarksFile> | 218 typedef FirstRunMasterPrefsBrowserTestT<kImportBookmarksFile> |
195 FirstRunMasterPrefsImportBookmarksFile; | 219 FirstRunMasterPrefsImportBookmarksFile; |
196 // http://crbug.com/314221 | 220 // http://crbug.com/314221 |
197 #if (defined(GOOGLE_CHROME_BUILD) && defined(OS_LINUX)) || defined(OS_MACOSX) | 221 #if (defined(GOOGLE_CHROME_BUILD) && defined(OS_LINUX)) || defined(OS_MACOSX) |
198 #define MAYBE_ImportBookmarksFile DISABLED_ImportBookmarksFile | 222 #define MAYBE_ImportBookmarksFile DISABLED_ImportBookmarksFile |
199 #else | 223 #else |
200 #define MAYBE_ImportBookmarksFile ImportBookmarksFile | 224 #define MAYBE_ImportBookmarksFile ImportBookmarksFile |
201 #endif | 225 #endif |
202 IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportBookmarksFile, | 226 IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportBookmarksFile, |
203 MAYBE_ImportBookmarksFile) { | 227 MAYBE_ImportBookmarksFile) { |
204 int auto_import_state = first_run::auto_import_state(); | 228 int auto_import_state = first_run::auto_import_state(); |
205 EXPECT_EQ( | 229 EXPECT_EQ( |
206 MaskExpectedImportState(first_run::AUTO_IMPORT_CALLED | | 230 MaskExpectedImportState(first_run::AUTO_IMPORT_CALLED | |
207 first_run::AUTO_IMPORT_PROFILE_IMPORTED | | |
208 first_run::AUTO_IMPORT_BOOKMARKS_FILE_IMPORTED), | 231 first_run::AUTO_IMPORT_BOOKMARKS_FILE_IMPORTED), |
209 auto_import_state); | 232 auto_import_state); |
210 } | 233 } |
211 | 234 |
212 // Test an import with all import options disabled. This is a regression test | 235 // Test an import with all import options disabled. This is a regression test |
213 // for http://crbug.com/169984 where this would cause the import process to | 236 // for http://crbug.com/169984 where this would cause the import process to |
214 // stay running, and the NTP to be loaded with no apps. | 237 // stay running, and the NTP to be loaded with no apps. |
215 extern const char kImportNothing[] = | 238 extern constexpr char kImportNothing[] = |
216 "{\n" | 239 "{\n" |
217 " \"distribution\": {\n" | 240 " \"distribution\": {\n" |
218 " \"import_bookmarks\": false,\n" | 241 " \"import_bookmarks\": false,\n" |
219 " \"import_history\": false,\n" | 242 " \"import_history\": false,\n" |
220 " \"import_home_page\": false,\n" | 243 " \"import_home_page\": false,\n" |
221 " \"import_search_engine\": false\n" | 244 " \"import_search_engine\": false\n" |
222 " }\n" | 245 " }\n" |
223 "}\n"; | 246 "}\n"; |
224 typedef FirstRunMasterPrefsBrowserTestT<kImportNothing> | 247 typedef FirstRunMasterPrefsBrowserTestT<kImportNothing> |
225 FirstRunMasterPrefsImportNothing; | 248 FirstRunMasterPrefsImportNothing; |
226 // http://crbug.com/314221 | 249 // http://crbug.com/314221 |
227 #if defined(GOOGLE_CHROME_BUILD) && (defined(OS_MACOSX) || defined(OS_LINUX)) | 250 #if defined(GOOGLE_CHROME_BUILD) && (defined(OS_MACOSX) || defined(OS_LINUX)) |
228 #define MAYBE_ImportNothingAndShowNewTabPage \ | 251 #define MAYBE_ImportNothingAndShowNewTabPage \ |
229 DISABLED_ImportNothingAndShowNewTabPage | 252 DISABLED_ImportNothingAndShowNewTabPage |
230 #else | 253 #else |
231 #define MAYBE_ImportNothingAndShowNewTabPage ImportNothingAndShowNewTabPage | 254 #define MAYBE_ImportNothingAndShowNewTabPage ImportNothingAndShowNewTabPage |
232 #endif | 255 #endif |
233 IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportNothing, | 256 IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportNothing, |
234 MAYBE_ImportNothingAndShowNewTabPage) { | 257 MAYBE_ImportNothingAndShowNewTabPage) { |
235 EXPECT_EQ(first_run::AUTO_IMPORT_CALLED, first_run::auto_import_state()); | 258 EXPECT_EQ(first_run::AUTO_IMPORT_CALLED, first_run::auto_import_state()); |
236 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 259 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
237 content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); | 260 content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); |
238 EXPECT_TRUE(WaitForLoadStop(tab)); | 261 EXPECT_TRUE(WaitForLoadStop(tab)); |
239 } | 262 } |
240 | 263 |
241 // Test first run with some tracked preferences. | 264 // Test first run with some tracked preferences. |
242 extern const char kWithTrackedPrefs[] = | 265 extern constexpr char kWithTrackedPrefs[] = |
243 "{\n" | 266 "{\n" |
244 " \"homepage\": \"example.com\",\n" | 267 " \"homepage\": \"example.com\",\n" |
245 " \"homepage_is_newtabpage\": false\n" | 268 " \"homepage_is_newtabpage\": false\n" |
246 "}\n"; | 269 "}\n"; |
247 // A test fixture that will run in a first run scenario with master_preferences | 270 // A test fixture that will run in a first run scenario with master_preferences |
248 // set to kWithTrackedPrefs. Parameterizable on the SettingsEnforcement | 271 // set to kWithTrackedPrefs. Parameterizable on the SettingsEnforcement |
249 // experiment to be forced. | 272 // experiment to be forced. |
250 class FirstRunMasterPrefsWithTrackedPreferences | 273 class FirstRunMasterPrefsWithTrackedPreferences |
251 : public FirstRunMasterPrefsBrowserTestT<kWithTrackedPrefs>, | 274 : public FirstRunMasterPrefsBrowserTestT<kWithTrackedPrefs>, |
252 public testing::WithParamInterface<std::string> { | 275 public testing::WithParamInterface<std::string> { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 FirstRunMasterPrefsWithTrackedPreferences, | 328 FirstRunMasterPrefsWithTrackedPreferences, |
306 testing::Values( | 329 testing::Values( |
307 chrome_prefs::internals::kSettingsEnforcementGroupNoEnforcement, | 330 chrome_prefs::internals::kSettingsEnforcementGroupNoEnforcement, |
308 chrome_prefs::internals::kSettingsEnforcementGroupEnforceAlways, | 331 chrome_prefs::internals::kSettingsEnforcementGroupEnforceAlways, |
309 chrome_prefs::internals:: | 332 chrome_prefs::internals:: |
310 kSettingsEnforcementGroupEnforceAlwaysWithDSE, | 333 kSettingsEnforcementGroupEnforceAlwaysWithDSE, |
311 chrome_prefs::internals:: | 334 chrome_prefs::internals:: |
312 kSettingsEnforcementGroupEnforceAlwaysWithExtensionsAndDSE)); | 335 kSettingsEnforcementGroupEnforceAlwaysWithExtensionsAndDSE)); |
313 | 336 |
314 #endif // !defined(OS_CHROMEOS) | 337 #endif // !defined(OS_CHROMEOS) |
OLD | NEW |