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

Side by Side Diff: chrome/installer/util/master_preferences_unittest.cc

Issue 1513043002: clang/win: Let remaining chromium_code targets build with -Wextra. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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
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 // Unit tests for master preferences related methods. 5 // Unit tests for master preferences related methods.
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 installer::master_preferences::kDoNotCreateTaskbarShortcut, 94 installer::master_preferences::kDoNotCreateTaskbarShortcut,
95 installer::master_preferences::kDoNotLaunchChrome, 95 installer::master_preferences::kDoNotLaunchChrome,
96 installer::master_preferences::kMakeChromeDefault, 96 installer::master_preferences::kMakeChromeDefault,
97 installer::master_preferences::kMakeChromeDefaultForUser, 97 installer::master_preferences::kMakeChromeDefaultForUser,
98 installer::master_preferences::kSystemLevel, 98 installer::master_preferences::kSystemLevel,
99 installer::master_preferences::kVerboseLogging, 99 installer::master_preferences::kVerboseLogging,
100 installer::master_preferences::kRequireEula, 100 installer::master_preferences::kRequireEula,
101 installer::master_preferences::kAltShortcutText, 101 installer::master_preferences::kAltShortcutText,
102 }; 102 };
103 103
104 for (int i = 0; i < arraysize(expected_true); ++i) { 104 for (size_t i = 0; i < arraysize(expected_true); ++i) {
105 bool value = false; 105 bool value = false;
106 EXPECT_TRUE(prefs.GetBool(expected_true[i], &value)); 106 EXPECT_TRUE(prefs.GetBool(expected_true[i], &value));
107 EXPECT_TRUE(value) << expected_true[i]; 107 EXPECT_TRUE(value) << expected_true[i];
108 } 108 }
109 109
110 std::string str_value; 110 std::string str_value;
111 EXPECT_TRUE(prefs.GetString( 111 EXPECT_TRUE(prefs.GetString(
112 installer::master_preferences::kDistroImportBookmarksFromFilePref, 112 installer::master_preferences::kDistroImportBookmarksFromFilePref,
113 &str_value)); 113 &str_value));
114 EXPECT_STREQ("c:\\foo", str_value.c_str()); 114 EXPECT_STREQ("c:\\foo", str_value.c_str());
(...skipping 30 matching lines...) Expand all
145 145
146 ExpectedBooleans expected_bool[] = { 146 ExpectedBooleans expected_bool[] = {
147 { installer::master_preferences::kDistroImportSearchPref, true }, 147 { installer::master_preferences::kDistroImportSearchPref, true },
148 { installer::master_preferences::kDistroImportBookmarksPref, false }, 148 { installer::master_preferences::kDistroImportBookmarksPref, false },
149 { installer::master_preferences::kDoNotCreateDesktopShortcut, true }, 149 { installer::master_preferences::kDoNotCreateDesktopShortcut, true },
150 { installer::master_preferences::kDoNotCreateQuickLaunchShortcut, true }, 150 { installer::master_preferences::kDoNotCreateQuickLaunchShortcut, true },
151 { installer::master_preferences::kDoNotLaunchChrome, true }, 151 { installer::master_preferences::kDoNotLaunchChrome, true },
152 }; 152 };
153 153
154 bool value = false; 154 bool value = false;
155 for (int i = 0; i < arraysize(expected_bool); ++i) { 155 for (size_t i = 0; i < arraysize(expected_bool); ++i) {
156 EXPECT_TRUE(prefs.GetBool(expected_bool[i].name, &value)); 156 EXPECT_TRUE(prefs.GetBool(expected_bool[i].name, &value));
157 EXPECT_EQ(value, expected_bool[i].expected_value) << expected_bool[i].name; 157 EXPECT_EQ(value, expected_bool[i].expected_value) << expected_bool[i].name;
158 } 158 }
159 159
160 const char* const missing_bools[] = { 160 const char* const missing_bools[] = {
161 installer::master_preferences::kDistroImportHomePagePref, 161 installer::master_preferences::kDistroImportHomePagePref,
162 installer::master_preferences::kDistroWelcomePageOnOSUpgradeEnabled, 162 installer::master_preferences::kDistroWelcomePageOnOSUpgradeEnabled,
163 installer::master_preferences::kDoNotRegisterForUpdateLaunch, 163 installer::master_preferences::kDoNotRegisterForUpdateLaunch,
164 installer::master_preferences::kMakeChromeDefault, 164 installer::master_preferences::kMakeChromeDefault,
165 installer::master_preferences::kMakeChromeDefaultForUser, 165 installer::master_preferences::kMakeChromeDefaultForUser,
166 }; 166 };
167 167
168 for (int i = 0; i < arraysize(missing_bools); ++i) { 168 for (size_t i = 0; i < arraysize(missing_bools); ++i) {
169 EXPECT_FALSE(prefs.GetBool(missing_bools[i], &value)) << missing_bools[i]; 169 EXPECT_FALSE(prefs.GetBool(missing_bools[i], &value)) << missing_bools[i];
170 } 170 }
171 171
172 std::string str_value; 172 std::string str_value;
173 EXPECT_FALSE(prefs.GetString( 173 EXPECT_FALSE(prefs.GetString(
174 installer::master_preferences::kDistroImportBookmarksFromFilePref, 174 installer::master_preferences::kDistroImportBookmarksFromFilePref,
175 &str_value)); 175 &str_value));
176 176
177 int icon_index = 0; 177 int icon_index = 0;
178 EXPECT_FALSE(prefs.GetInt( 178 EXPECT_FALSE(prefs.GetInt(
(...skipping 18 matching lines...) Expand all
197 " \"https://google.com/f2\",\n" 197 " \"https://google.com/f2\",\n"
198 " \"new_tab_page\"\n" 198 " \"new_tab_page\"\n"
199 " ]\n" 199 " ]\n"
200 "} \n"; 200 "} \n";
201 201
202 EXPECT_TRUE(base::WriteFile(prefs_file(), text, 202 EXPECT_TRUE(base::WriteFile(prefs_file(), text,
203 static_cast<int>(strlen(text)))); 203 static_cast<int>(strlen(text))));
204 installer::MasterPreferences prefs(prefs_file()); 204 installer::MasterPreferences prefs(prefs_file());
205 typedef std::vector<std::string> TabsVector; 205 typedef std::vector<std::string> TabsVector;
206 TabsVector tabs = prefs.GetFirstRunTabs(); 206 TabsVector tabs = prefs.GetFirstRunTabs();
207 ASSERT_EQ(3, tabs.size()); 207 ASSERT_EQ(3u, tabs.size());
208 EXPECT_EQ("http://google.com/f1", tabs[0]); 208 EXPECT_EQ("http://google.com/f1", tabs[0]);
209 EXPECT_EQ("https://google.com/f2", tabs[1]); 209 EXPECT_EQ("https://google.com/f2", tabs[1]);
210 EXPECT_EQ("new_tab_page", tabs[2]); 210 EXPECT_EQ("new_tab_page", tabs[2]);
211 } 211 }
212 212
213 // In this test instead of using our synthetic json file, we use an 213 // In this test instead of using our synthetic json file, we use an
214 // actual test case from the extensions unittest. The hope here is that if 214 // actual test case from the extensions unittest. The hope here is that if
215 // they change something in the manifest this test will break, but in 215 // they change something in the manifest this test will break, but in
216 // general it is expected the extension format to be backwards compatible. 216 // general it is expected the extension format to be backwards compatible.
217 TEST(MasterPrefsExtension, ValidateExtensionJSON) { 217 TEST(MasterPrefsExtension, ValidateExtensionJSON) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 270
271 // Check prefs that do not have any equivalent command line option. 271 // Check prefs that do not have any equivalent command line option.
272 ExpectedBooleans expected_bool[] = { 272 ExpectedBooleans expected_bool[] = {
273 { installer::master_preferences::kDoNotLaunchChrome, true }, 273 { installer::master_preferences::kDoNotLaunchChrome, true },
274 { installer::master_preferences::kSystemLevel, true }, 274 { installer::master_preferences::kSystemLevel, true },
275 { installer::master_preferences::kVerboseLogging, false }, 275 { installer::master_preferences::kVerboseLogging, false },
276 }; 276 };
277 277
278 // Now check that prefs got merged correctly. 278 // Now check that prefs got merged correctly.
279 bool value = false; 279 bool value = false;
280 for (int i = 0; i < arraysize(expected_bool); ++i) { 280 for (size_t i = 0; i < arraysize(expected_bool); ++i) {
281 EXPECT_TRUE(prefs.GetBool(expected_bool[i].name, &value)); 281 EXPECT_TRUE(prefs.GetBool(expected_bool[i].name, &value));
282 EXPECT_EQ(value, expected_bool[i].expected_value) << expected_bool[i].name; 282 EXPECT_EQ(value, expected_bool[i].expected_value) << expected_bool[i].name;
283 } 283 }
284 284
285 // Delete temporary prefs file. 285 // Delete temporary prefs file.
286 EXPECT_TRUE(base::DeleteFile(prefs_file, false)); 286 EXPECT_TRUE(base::DeleteFile(prefs_file, false));
287 287
288 // Check that if master prefs doesn't exist, we can still parse the common 288 // Check that if master prefs doesn't exist, we can still parse the common
289 // prefs. 289 // prefs.
290 cmd_str = L"setup.exe --do-not-launch-chrome"; 290 cmd_str = L"setup.exe --do-not-launch-chrome";
291 cmd_line.ParseFromString(cmd_str); 291 cmd_line.ParseFromString(cmd_str);
292 installer::MasterPreferences prefs2(cmd_line); 292 installer::MasterPreferences prefs2(cmd_line);
293 ExpectedBooleans expected_bool2[] = { 293 ExpectedBooleans expected_bool2[] = {
294 { installer::master_preferences::kDoNotLaunchChrome, true }, 294 { installer::master_preferences::kDoNotLaunchChrome, true },
295 }; 295 };
296 296
297 for (int i = 0; i < arraysize(expected_bool2); ++i) { 297 for (size_t i = 0; i < arraysize(expected_bool2); ++i) {
298 EXPECT_TRUE(prefs2.GetBool(expected_bool2[i].name, &value)); 298 EXPECT_TRUE(prefs2.GetBool(expected_bool2[i].name, &value));
299 EXPECT_EQ(value, expected_bool2[i].expected_value) 299 EXPECT_EQ(value, expected_bool2[i].expected_value)
300 << expected_bool2[i].name; 300 << expected_bool2[i].name;
301 } 301 }
302 302
303 EXPECT_FALSE(prefs2.GetBool( 303 EXPECT_FALSE(prefs2.GetBool(
304 installer::master_preferences::kSystemLevel, &value)); 304 installer::master_preferences::kSystemLevel, &value));
305 EXPECT_FALSE(prefs2.GetBool( 305 EXPECT_FALSE(prefs2.GetBool(
306 installer::master_preferences::kVerboseLogging, &value)); 306 installer::master_preferences::kVerboseLogging, &value));
307 } 307 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 prefs.GetBool( 411 prefs.GetBool(
412 installer::master_preferences::kDoNotCreateQuickLaunchShortcut, 412 installer::master_preferences::kDoNotCreateQuickLaunchShortcut,
413 &do_not_create_quick_launch_shortcut); 413 &do_not_create_quick_launch_shortcut);
414 prefs.GetBool( 414 prefs.GetBool(
415 installer::master_preferences::kDoNotCreateTaskbarShortcut, 415 installer::master_preferences::kDoNotCreateTaskbarShortcut,
416 &do_not_create_taskbar_shortcut); 416 &do_not_create_taskbar_shortcut);
417 EXPECT_FALSE(do_not_create_desktop_shortcut); 417 EXPECT_FALSE(do_not_create_desktop_shortcut);
418 EXPECT_FALSE(do_not_create_quick_launch_shortcut); 418 EXPECT_FALSE(do_not_create_quick_launch_shortcut);
419 EXPECT_FALSE(do_not_create_taskbar_shortcut); 419 EXPECT_FALSE(do_not_create_taskbar_shortcut);
420 } 420 }
OLDNEW
« no previous file with comments | « chrome/installer/util/lzma_util_unittest.cc ('k') | chrome/installer/util/self_cleaning_temp_dir_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698