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

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

Issue 6288009: More installer refactoring in the interest of fixing some bugs and cleaning t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months 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
« no previous file with comments | « chrome/installer/util/google_update_settings.cc ('k') | chrome/installer/util/helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <functional> 8 #include <functional>
9 #include <map> 9 #include <map>
10 10
11 #include "base/ref_counted.h" 11 #include "base/ref_counted.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "base/win/registry.h" 13 #include "base/win/registry.h"
14 #include "chrome/installer/util/browser_distribution.h" 14 #include "chrome/installer/util/browser_distribution.h"
15 #include "chrome/installer/util/channel_info.h" 15 #include "chrome/installer/util/channel_info.h"
16 #include "chrome/installer/util/google_update_constants.h" 16 #include "chrome/installer/util/google_update_constants.h"
17 #include "chrome/installer/util/google_update_settings.h" 17 #include "chrome/installer/util/google_update_settings.h"
18 #include "chrome/installer/util/installation_state.h"
19 #include "chrome/installer/util/installer_state.h"
18 #include "chrome/installer/util/master_preferences.h" 20 #include "chrome/installer/util/master_preferences.h"
19 #include "chrome/installer/util/package.h"
20 #include "chrome/installer/util/package_properties.h"
21 #include "chrome/installer/util/product.h" 21 #include "chrome/installer/util/product.h"
22 #include "chrome/installer/util/work_item_list.h" 22 #include "chrome/installer/util/work_item_list.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 24
25 using base::win::RegKey; 25 using base::win::RegKey;
26 using installer::ChannelInfo; 26 using installer::ChannelInfo;
27 27
28 namespace { 28 namespace {
29 29
30 const wchar_t kHKCUReplacement[] = 30 const wchar_t kHKCUReplacement[] =
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 key.DeleteValue(google_update::kRegApField); 397 key.DeleteValue(google_update::kRegApField);
398 work_item_list->Rollback(); 398 work_item_list->Rollback();
399 if (ap_key_deleted) { 399 if (ap_key_deleted) {
400 work_item_list.reset(WorkItem::CreateWorkItemList()); 400 work_item_list.reset(WorkItem::CreateWorkItemList());
401 ASSERT_TRUE(CreateApKey(work_item_list.get(), ap_key_value)) 401 ASSERT_TRUE(CreateApKey(work_item_list.get(), ap_key_value))
402 << "Failed to restore ap key."; 402 << "Failed to restore ap key.";
403 } 403 }
404 } 404 }
405 405
406 TEST_F(GoogleUpdateSettingsTest, SetEULAConsent) { 406 TEST_F(GoogleUpdateSettingsTest, SetEULAConsent) {
407 const bool multi_install = false; 407 const bool multi_install = true;
408 const bool system_level = true; 408 const bool system_level = true;
409 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 409 CommandLine cmd_line = CommandLine::FromString(
410 std::wstring(L"setup.exe") +
411 (multi_install ? L" --multi-install --chrome" : L"") +
412 (system_level ? L" --system-level" : L""));
413 installer::MasterPreferences prefs(cmd_line);
414 installer::InstallationState machine_state;
415 machine_state.Initialize();
416 installer::InstallerState installer_state;
417 installer_state.Initialize(cmd_line, prefs, machine_state);
418 HKEY root = installer_state.root_key();
410 419
411 const installer::MasterPreferences& prefs =
412 installer::MasterPreferences::ForCurrentProcess();
413 installer::ChromePackageProperties properties;
414 BrowserDistribution* distribution =
415 BrowserDistribution::GetSpecificDistribution(
416 BrowserDistribution::CHROME_BROWSER, prefs);
417 scoped_refptr<installer::Package> package(
418 new installer::Package(multi_install, system_level, FilePath(),
419 &properties));
420 scoped_refptr<installer::Product> product(
421 new installer::Product(distribution, package.get()));
422 RegKey key; 420 RegKey key;
423 DWORD value; 421 DWORD value;
422 BrowserDistribution* binaries =
423 installer_state.multi_package_binaries_distribution();
424 EXPECT_EQ(BrowserDistribution::CHROME_BINARIES, binaries->GetType());
425 BrowserDistribution* chrome =
426 installer_state.products()[0]->distribution();
427 EXPECT_EQ(BrowserDistribution::CHROME_BROWSER, chrome->GetType());
424 428
425 // By default, eulaconsent ends up on the package. 429 // By default, eulaconsent ends up on the package.
426 EXPECT_TRUE(GoogleUpdateSettings::SetEULAConsent(*package.get(), true)); 430 EXPECT_TRUE(GoogleUpdateSettings::SetEULAConsent(installer_state, true));
427 EXPECT_EQ(ERROR_SUCCESS, 431 EXPECT_EQ(ERROR_SUCCESS,
428 key.Open(HKEY_LOCAL_MACHINE, properties.GetStateMediumKey().c_str(), 432 key.Open(HKEY_LOCAL_MACHINE, binaries->GetStateMediumKey().c_str(),
429 KEY_QUERY_VALUE | KEY_SET_VALUE)); 433 KEY_QUERY_VALUE | KEY_SET_VALUE));
430 EXPECT_EQ(ERROR_SUCCESS, 434 EXPECT_EQ(ERROR_SUCCESS,
431 key.ReadValueDW(google_update::kRegEULAAceptedField, &value)); 435 key.ReadValueDW(google_update::kRegEULAAceptedField, &value));
432 EXPECT_EQ(1U, value); 436 EXPECT_EQ(1U, value);
433 EXPECT_EQ(ERROR_SUCCESS, 437 EXPECT_EQ(ERROR_SUCCESS,
434 key.DeleteValue(google_update::kRegEULAAceptedField)); 438 key.DeleteValue(google_update::kRegEULAAceptedField));
435 439
436 // But it will end up on the product if needed 440 // But it will end up on the product if needed
437 EXPECT_EQ(ERROR_SUCCESS, 441 EXPECT_EQ(ERROR_SUCCESS,
438 key.Create(HKEY_LOCAL_MACHINE, distribution->GetStateKey().c_str(), 442 key.Create(HKEY_LOCAL_MACHINE, chrome->GetStateKey().c_str(),
439 KEY_SET_VALUE)); 443 KEY_SET_VALUE));
440 EXPECT_EQ(ERROR_SUCCESS, 444 EXPECT_EQ(ERROR_SUCCESS,
441 key.WriteValue(google_update::kRegEULAAceptedField, 445 key.WriteValue(google_update::kRegEULAAceptedField,
442 static_cast<DWORD>(0))); 446 static_cast<DWORD>(0)));
443 EXPECT_TRUE(GoogleUpdateSettings::SetEULAConsent(*package.get(), true)); 447 EXPECT_TRUE(GoogleUpdateSettings::SetEULAConsent(installer_state, true));
444 EXPECT_EQ(ERROR_SUCCESS, 448 EXPECT_EQ(ERROR_SUCCESS,
445 key.Open(HKEY_LOCAL_MACHINE, distribution->GetStateMediumKey().c_str(), 449 key.Open(HKEY_LOCAL_MACHINE, chrome->GetStateMediumKey().c_str(),
446 KEY_QUERY_VALUE | KEY_SET_VALUE)); 450 KEY_QUERY_VALUE | KEY_SET_VALUE));
447 EXPECT_EQ(ERROR_SUCCESS, 451 EXPECT_EQ(ERROR_SUCCESS,
448 key.ReadValueDW(google_update::kRegEULAAceptedField, &value)); 452 key.ReadValueDW(google_update::kRegEULAAceptedField, &value));
449 EXPECT_EQ(1U, value); 453 EXPECT_EQ(1U, value);
450 } 454 }
OLDNEW
« no previous file with comments | « chrome/installer/util/google_update_settings.cc ('k') | chrome/installer/util/helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698