Commit c4be12c2 authored by Greg Thompson's avatar Greg Thompson Committed by Commit Bot

[windows] Add a pair of trivial ValueIterator tests.

There was a fear that the value iterator was flaky on Win 7. If that's
true, a little test coverage should expose it.

BUG=1066801
R=robliao@chromium.org

Change-Id: I984044243886510c9c540bc471b6a62a26212e3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2540447
Commit-Queue: Greg Thompson <grt@chromium.org>
Auto-Submit: Greg Thompson <grt@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828395}
parent 79cda1dc
...@@ -158,6 +158,30 @@ TEST_F(RegistryTest, TruncatedCharTest) { ...@@ -158,6 +158,30 @@ TEST_F(RegistryTest, TruncatedCharTest) {
EXPECT_FALSE(iterator.Valid()); EXPECT_FALSE(iterator.Valid());
} }
// Tests that the value iterator is okay with an empty key.
TEST_F(RegistryTest, ValueIteratorEmptyKey) {
RegistryValueIterator iterator(HKEY_CURRENT_USER, root_key().c_str());
EXPECT_EQ(iterator.ValueCount(), 0U);
EXPECT_FALSE(iterator.Valid());
}
// Tests that the default value is seen by a value iterator.
TEST_F(RegistryTest, ValueIteratorDefaultValue) {
const WStringPiece kTestString(L"i miss you");
ASSERT_EQ(RegKey(HKEY_CURRENT_USER, root_key().c_str(), KEY_SET_VALUE)
.WriteValue(nullptr, kTestString.data()),
ERROR_SUCCESS);
RegistryValueIterator iterator(HKEY_CURRENT_USER, root_key().c_str());
EXPECT_EQ(iterator.ValueCount(), 1U);
ASSERT_TRUE(iterator.Valid());
EXPECT_EQ(WStringPiece(iterator.Name()), WStringPiece());
EXPECT_EQ(iterator.ValueSize(), (kTestString.size() + 1) * sizeof(wchar_t));
EXPECT_EQ(iterator.Type(), REG_SZ);
EXPECT_EQ(WStringPiece(iterator.Value()), kTestString);
++iterator;
EXPECT_FALSE(iterator.Valid());
}
TEST_F(RegistryTest, RecursiveDelete) { TEST_F(RegistryTest, RecursiveDelete) {
RegKey key; RegKey key;
// Create root_key() // Create root_key()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment