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

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

Issue 7976045: Fix in-use updates for Chrome Frame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sanity check before dcommit 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
« no previous file with comments | « chrome/installer/util/copy_reg_key_work_item.cc ('k') | chrome/installer/util/work_item.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/copy_reg_key_work_item_unittest.cc
diff --git a/chrome/installer/util/copy_reg_key_work_item_unittest.cc b/chrome/installer/util/copy_reg_key_work_item_unittest.cc
index 84a6f642c8d114610de15b5bc758454c481384db..59399e84ac82008808c7d8395f00465ebd7ea469 100644
--- a/chrome/installer/util/copy_reg_key_work_item_unittest.cc
+++ b/chrome/installer/util/copy_reg_key_work_item_unittest.cc
@@ -42,7 +42,8 @@ TEST_F(CopyRegKeyWorkItemTest, TestNoKey) {
const std::wstring& key_path = key_paths[i];
scoped_ptr<CopyRegKeyWorkItem> item(
WorkItem::CreateCopyRegKeyWorkItem(test_data_.root_key(), key_path,
- destination_path_));
+ destination_path_,
+ WorkItem::ALWAYS));
EXPECT_TRUE(item->Do());
EXPECT_NE(ERROR_SUCCESS,
key.Open(test_data_.root_key(), destination_path_.c_str(),
@@ -61,7 +62,8 @@ TEST_F(CopyRegKeyWorkItemTest, TestEmptyKey) {
scoped_ptr<CopyRegKeyWorkItem> item(
WorkItem::CreateCopyRegKeyWorkItem(test_data_.root_key(),
test_data_.empty_key_path(),
- destination_path_));
+ destination_path_,
+ WorkItem::ALWAYS));
EXPECT_TRUE(item->Do());
RegistryTestData::ExpectEmptyKey(test_data_.root_key(),
destination_path_.c_str());
@@ -79,7 +81,8 @@ TEST_F(CopyRegKeyWorkItemTest, TestNonEmptyKey) {
scoped_ptr<CopyRegKeyWorkItem> item(
WorkItem::CreateCopyRegKeyWorkItem(test_data_.root_key(),
test_data_.non_empty_key_path(),
- destination_path_));
+ destination_path_,
+ WorkItem::ALWAYS));
EXPECT_TRUE(item->Do());
test_data_.ExpectMatchesNonEmptyKey(test_data_.root_key(),
destination_path_.c_str());
@@ -90,6 +93,40 @@ TEST_F(CopyRegKeyWorkItemTest, TestNonEmptyKey) {
KEY_READ));
}
+// Test that existing data isn't overwritten.
+TEST_F(CopyRegKeyWorkItemTest, TestNoOverwrite) {
+ RegKey key;
+ // First copy the data into the dest.
+ EXPECT_EQ(ERROR_SUCCESS,
+ key.Create(test_data_.root_key(), destination_path_.c_str(),
+ KEY_WRITE));
+ EXPECT_EQ(ERROR_SUCCESS,
+ SHCopyKey(test_data_.root_key(),
+ test_data_.non_empty_key_path().c_str(), key.Handle(),
+ 0));
+ key.Close();
+
+ // Now copy the empty key into the dest, which should do nothing.
+ scoped_ptr<CopyRegKeyWorkItem> item(
+ WorkItem::CreateCopyRegKeyWorkItem(test_data_.root_key(),
+ test_data_.empty_key_path(),
+ destination_path_,
+ WorkItem::IF_NOT_PRESENT));
+ EXPECT_TRUE(item->Do());
+
+ // Make sure it's all there.
+ test_data_.ExpectMatchesNonEmptyKey(test_data_.root_key(),
+ destination_path_.c_str());
+
+ // Rollback should do nothing.
+ item->Rollback();
+ item.reset();
+
+ // Make sure it's still all there.
+ test_data_.ExpectMatchesNonEmptyKey(test_data_.root_key(),
+ destination_path_.c_str());
+}
+
// Test that copying an empty key over a key with data succeeds, and that
// rollback restores the original data.
TEST_F(CopyRegKeyWorkItemTest, TestOverwriteAndRestore) {
@@ -108,7 +145,8 @@ TEST_F(CopyRegKeyWorkItemTest, TestOverwriteAndRestore) {
scoped_ptr<CopyRegKeyWorkItem> item(
WorkItem::CreateCopyRegKeyWorkItem(test_data_.root_key(),
test_data_.empty_key_path(),
- destination_path_));
+ destination_path_,
+ WorkItem::ALWAYS));
EXPECT_TRUE(item->Do());
// Make sure the dest is now empty.
@@ -131,7 +169,8 @@ TEST_F(CopyRegKeyWorkItemTest, TestIgnoreFailRollback) {
scoped_ptr<CopyRegKeyWorkItem> item(
WorkItem::CreateCopyRegKeyWorkItem(test_data_.root_key(),
test_data_.empty_key_path(),
- test_data_.non_empty_key_path()));
+ test_data_.non_empty_key_path(),
+ WorkItem::ALWAYS));
item->set_ignore_failure(true);
EXPECT_TRUE(item->Do());
item->Rollback();
« no previous file with comments | « chrome/installer/util/copy_reg_key_work_item.cc ('k') | chrome/installer/util/work_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698