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

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

Issue 5729004: Merge the installer, installer_util and setup_util namespaces into a single i... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <windows.h> 5 #include <windows.h>
6 #include <shlwapi.h> // For SHDeleteKey. 6 #include <shlwapi.h> // For SHDeleteKey.
7 7
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/win/registry.h" 9 #include "base/win/registry.h"
10 #include "chrome/installer/util/browser_distribution.h" 10 #include "chrome/installer/util/browser_distribution.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelVariousApValuesSystem) { 207 TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelVariousApValuesSystem) {
208 TestCurrentChromeChannelWithVariousApValues(SYSTEM_INSTALL); 208 TestCurrentChromeChannelWithVariousApValues(SYSTEM_INSTALL);
209 } 209 }
210 210
211 TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelVariousApValuesUser) { 211 TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelVariousApValuesUser) {
212 TestCurrentChromeChannelWithVariousApValues(USER_INSTALL); 212 TestCurrentChromeChannelWithVariousApValues(USER_INSTALL);
213 } 213 }
214 214
215 TEST_F(GoogleUpdateSettingsTest, UpdateGoogleUpdateApKey) { 215 TEST_F(GoogleUpdateSettingsTest, UpdateGoogleUpdateApKey) {
216 installer_util::InstallStatus s = installer_util::FIRST_INSTALL_SUCCESS; 216 installer::InstallStatus s = installer::FIRST_INSTALL_SUCCESS;
217 installer_util::InstallStatus f = installer_util::INSTALL_FAILED; 217 installer::InstallStatus f = installer::INSTALL_FAILED;
218 218
219 // Incremental Installer that worked. 219 // Incremental Installer that worked.
220 installer_util::ChannelInfo v; 220 installer::ChannelInfo v;
221 v.set_value(L""); 221 v.set_value(L"");
222 EXPECT_FALSE(GoogleUpdateSettings::UpdateGoogleUpdateApKey(true, s, &v)); 222 EXPECT_FALSE(GoogleUpdateSettings::UpdateGoogleUpdateApKey(true, s, &v));
223 EXPECT_EQ(v.value(), L""); 223 EXPECT_EQ(v.value(), L"");
224 224
225 v.set_value(L"1.1"); 225 v.set_value(L"1.1");
226 EXPECT_FALSE(GoogleUpdateSettings::UpdateGoogleUpdateApKey(true, s, &v)); 226 EXPECT_FALSE(GoogleUpdateSettings::UpdateGoogleUpdateApKey(true, s, &v));
227 EXPECT_EQ(v.value(), L"1.1"); 227 EXPECT_EQ(v.value(), L"1.1");
228 228
229 v.set_value(L"1.1-dev"); 229 v.set_value(L"1.1-dev");
230 EXPECT_FALSE(GoogleUpdateSettings::UpdateGoogleUpdateApKey(true, s, &v)); 230 EXPECT_FALSE(GoogleUpdateSettings::UpdateGoogleUpdateApKey(true, s, &v));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 EXPECT_TRUE(GoogleUpdateSettings::UpdateGoogleUpdateApKey(false, f, &v)); 317 EXPECT_TRUE(GoogleUpdateSettings::UpdateGoogleUpdateApKey(false, f, &v));
318 EXPECT_EQ(v.value(), L"1.1-dev"); 318 EXPECT_EQ(v.value(), L"1.1-dev");
319 } 319 }
320 320
321 TEST_F(GoogleUpdateSettingsTest, UpdateDiffInstallStatusTest) { 321 TEST_F(GoogleUpdateSettingsTest, UpdateDiffInstallStatusTest) {
322 scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList()); 322 scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList());
323 // Test incremental install failure 323 // Test incremental install failure
324 ASSERT_TRUE(CreateApKey(work_item_list.get(), L"")) 324 ASSERT_TRUE(CreateApKey(work_item_list.get(), L""))
325 << "Failed to create ap key."; 325 << "Failed to create ap key.";
326 GoogleUpdateSettings::UpdateDiffInstallStatus(false, true, 326 GoogleUpdateSettings::UpdateDiffInstallStatus(false, true,
327 installer_util::INSTALL_FAILED, 327 installer::INSTALL_FAILED,
328 kTestProductGuid); 328 kTestProductGuid);
329 EXPECT_STREQ(ReadApKeyValue().c_str(), L"-full"); 329 EXPECT_STREQ(ReadApKeyValue().c_str(), L"-full");
330 work_item_list->Rollback(); 330 work_item_list->Rollback();
331 331
332 work_item_list.reset(WorkItem::CreateWorkItemList()); 332 work_item_list.reset(WorkItem::CreateWorkItemList());
333 // Test incremental install success 333 // Test incremental install success
334 ASSERT_TRUE(CreateApKey(work_item_list.get(), L"")) 334 ASSERT_TRUE(CreateApKey(work_item_list.get(), L""))
335 << "Failed to create ap key."; 335 << "Failed to create ap key.";
336 GoogleUpdateSettings::UpdateDiffInstallStatus(false, true, 336 GoogleUpdateSettings::UpdateDiffInstallStatus(false, true,
337 installer_util::FIRST_INSTALL_SUCCESS, 337 installer::FIRST_INSTALL_SUCCESS,
338 kTestProductGuid); 338 kTestProductGuid);
339 EXPECT_STREQ(ReadApKeyValue().c_str(), L""); 339 EXPECT_STREQ(ReadApKeyValue().c_str(), L"");
340 work_item_list->Rollback(); 340 work_item_list->Rollback();
341 341
342 work_item_list.reset(WorkItem::CreateWorkItemList()); 342 work_item_list.reset(WorkItem::CreateWorkItemList());
343 // Test full install failure 343 // Test full install failure
344 ASSERT_TRUE(CreateApKey(work_item_list.get(), L"-full")) 344 ASSERT_TRUE(CreateApKey(work_item_list.get(), L"-full"))
345 << "Failed to create ap key."; 345 << "Failed to create ap key.";
346 GoogleUpdateSettings::UpdateDiffInstallStatus(false, false, 346 GoogleUpdateSettings::UpdateDiffInstallStatus(false, false,
347 installer_util::INSTALL_FAILED, 347 installer::INSTALL_FAILED,
348 kTestProductGuid); 348 kTestProductGuid);
349 EXPECT_STREQ(ReadApKeyValue().c_str(), L""); 349 EXPECT_STREQ(ReadApKeyValue().c_str(), L"");
350 work_item_list->Rollback(); 350 work_item_list->Rollback();
351 351
352 work_item_list.reset(WorkItem::CreateWorkItemList()); 352 work_item_list.reset(WorkItem::CreateWorkItemList());
353 // Test full install success 353 // Test full install success
354 ASSERT_TRUE(CreateApKey(work_item_list.get(), L"-full")) 354 ASSERT_TRUE(CreateApKey(work_item_list.get(), L"-full"))
355 << "Failed to create ap key."; 355 << "Failed to create ap key.";
356 GoogleUpdateSettings::UpdateDiffInstallStatus(false, false, 356 GoogleUpdateSettings::UpdateDiffInstallStatus(false, false,
357 installer_util::FIRST_INSTALL_SUCCESS, 357 installer::FIRST_INSTALL_SUCCESS,
358 kTestProductGuid); 358 kTestProductGuid);
359 EXPECT_STREQ(ReadApKeyValue().c_str(), L""); 359 EXPECT_STREQ(ReadApKeyValue().c_str(), L"");
360 work_item_list->Rollback(); 360 work_item_list->Rollback();
361 361
362 work_item_list.reset(WorkItem::CreateWorkItemList()); 362 work_item_list.reset(WorkItem::CreateWorkItemList());
363 // Test the case of when "ap" key doesnt exist at all 363 // Test the case of when "ap" key doesnt exist at all
364 std::wstring ap_key_value = ReadApKeyValue(); 364 std::wstring ap_key_value = ReadApKeyValue();
365 std::wstring reg_key = GetApKeyPath(); 365 std::wstring reg_key = GetApKeyPath();
366 HKEY reg_root = HKEY_CURRENT_USER; 366 HKEY reg_root = HKEY_CURRENT_USER;
367 bool ap_key_deleted = false; 367 bool ap_key_deleted = false;
368 RegKey key; 368 RegKey key;
369 if (!key.Open(HKEY_CURRENT_USER, reg_key.c_str(), KEY_ALL_ACCESS)) { 369 if (!key.Open(HKEY_CURRENT_USER, reg_key.c_str(), KEY_ALL_ACCESS)) {
370 work_item_list->AddCreateRegKeyWorkItem(reg_root, reg_key); 370 work_item_list->AddCreateRegKeyWorkItem(reg_root, reg_key);
371 ASSERT_TRUE(work_item_list->Do()) << "Failed to create ClientState key."; 371 ASSERT_TRUE(work_item_list->Do()) << "Failed to create ClientState key.";
372 } else if (key.DeleteValue(google_update::kRegApField)) { 372 } else if (key.DeleteValue(google_update::kRegApField)) {
373 ap_key_deleted = true; 373 ap_key_deleted = true;
374 } 374 }
375 // try differential installer 375 // try differential installer
376 GoogleUpdateSettings::UpdateDiffInstallStatus(false, true, 376 GoogleUpdateSettings::UpdateDiffInstallStatus(false, true,
377 installer_util::INSTALL_FAILED, 377 installer::INSTALL_FAILED,
378 kTestProductGuid); 378 kTestProductGuid);
379 EXPECT_STREQ(ReadApKeyValue().c_str(), L"-full"); 379 EXPECT_STREQ(ReadApKeyValue().c_str(), L"-full");
380 // try full installer now 380 // try full installer now
381 GoogleUpdateSettings::UpdateDiffInstallStatus(false, false, 381 GoogleUpdateSettings::UpdateDiffInstallStatus(false, false,
382 installer_util::INSTALL_FAILED, 382 installer::INSTALL_FAILED,
383 kTestProductGuid); 383 kTestProductGuid);
384 EXPECT_STREQ(ReadApKeyValue().c_str(), L""); 384 EXPECT_STREQ(ReadApKeyValue().c_str(), L"");
385 // Now cleanup to leave the system in unchanged state. 385 // Now cleanup to leave the system in unchanged state.
386 // - Diff installer creates an ap key if it didnt exist, so delete this ap key 386 // - Diff installer creates an ap key if it didnt exist, so delete this ap key
387 // - If we created any reg key path for ap, roll it back 387 // - If we created any reg key path for ap, roll it back
388 // - Finally restore the original value of ap key. 388 // - Finally restore the original value of ap key.
389 key.Open(HKEY_CURRENT_USER, reg_key.c_str(), KEY_ALL_ACCESS); 389 key.Open(HKEY_CURRENT_USER, reg_key.c_str(), KEY_ALL_ACCESS);
390 key.DeleteValue(google_update::kRegApField); 390 key.DeleteValue(google_update::kRegApField);
391 work_item_list->Rollback(); 391 work_item_list->Rollback();
392 if (ap_key_deleted) { 392 if (ap_key_deleted) {
393 work_item_list.reset(WorkItem::CreateWorkItemList()); 393 work_item_list.reset(WorkItem::CreateWorkItemList());
394 ASSERT_TRUE(CreateApKey(work_item_list.get(), ap_key_value)) 394 ASSERT_TRUE(CreateApKey(work_item_list.get(), ap_key_value))
395 << "Failed to restore ap key."; 395 << "Failed to restore ap key.";
396 } 396 }
397 } 397 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698