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

Unified Diff: chrome/installer/util/registry_key_backup_unittest.cc

Issue 7890069: Added CopyRegKeyWorkItem in support of IE low rights policy fixes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Changes incorporated Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/installer/util/registry_key_backup_unittest.cc
diff --git a/chrome/installer/util/registry_key_backup_unittest.cc b/chrome/installer/util/registry_key_backup_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2633396fa919813c10c31add65479953c4b22658
--- /dev/null
+++ b/chrome/installer/util/registry_key_backup_unittest.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <windows.h>
+
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/win/registry.h"
+#include "chrome/installer/util/registry_key_backup.h"
+#include "chrome/installer/util/registry_test_data.h"
+#include "chrome/installer/util/work_item.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using base::win::RegKey;
+
+class RegistryKeyBackupTest : public testing::Test {
+ protected:
+ static void TearDownTestCase() {
+ logging::CloseLogFile();
+ }
+
+ virtual void SetUp() {
+ ASSERT_TRUE(test_data_.Initialize(HKEY_CURRENT_USER, L"SOFTWARE\\TmpTmp"));
+ destination_path_.assign(test_data_.base_path()).append(L"\\Destination");
+ }
+
+ RegistryTestData test_data_;
+ std::wstring destination_path_;
+};
+
+// Test that writing an uninitialized backup does nothing.
+TEST_F(RegistryKeyBackupTest, Uninitialized) {
+ RegistryKeyBackup backup;
+
+ EXPECT_TRUE(backup.WriteTo(test_data_.root_key(), destination_path_.c_str()));
+ EXPECT_FALSE(RegKey(test_data_.root_key(), destination_path_.c_str(),
+ KEY_READ).Valid());
+}
+
+// Test that initializing a backup with a non-existent key works, and that
+// writing it back out does nothing.
+TEST_F(RegistryKeyBackupTest, MissingKey) {
+ std::wstring non_existent_key_path(test_data_.base_path() + L"\\NoKeyHere");
+ RegistryKeyBackup backup;
+
+ EXPECT_TRUE(backup.Initialize(test_data_.root_key(),
+ non_existent_key_path.c_str()));
+ EXPECT_TRUE(backup.WriteTo(test_data_.root_key(), destination_path_.c_str()));
+ EXPECT_FALSE(RegKey(test_data_.root_key(), destination_path_.c_str(),
+ KEY_READ).Valid());
+}
+
+// Test that reading some data then writing it out does the right thing.
+TEST_F(RegistryKeyBackupTest, ReadWrite) {
+ RegistryKeyBackup backup;
+
+ EXPECT_TRUE(backup.Initialize(test_data_.root_key(),
+ test_data_.non_empty_key_path().c_str()));
+ EXPECT_TRUE(backup.WriteTo(test_data_.root_key(), destination_path_.c_str()));
+ test_data_.ExpectMatchesNonEmptyKey(test_data_.root_key(),
+ destination_path_.c_str());
+}

Powered by Google App Engine
This is Rietveld 408576698