diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-28 18:24:31 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-28 18:24:31 +0000 |
commit | 2e0c7ca3f0276039e5d132b6aa1502fffa9babd6 (patch) | |
tree | bdfa043d92d891ba72475a6ced9874424c11f9e8 /chrome/installer | |
parent | 221a5d9580d012745509baa02d0e77c9d9f5782e (diff) | |
download | chromium_src-2e0c7ca3f0276039e5d132b6aa1502fffa9babd6.zip chromium_src-2e0c7ca3f0276039e5d132b6aa1502fffa9babd6.tar.gz chromium_src-2e0c7ca3f0276039e5d132b6aa1502fffa9babd6.tar.bz2 |
Correct erroneous display of the channel name "unknown" when the "ap" value is absent (an absent "ap" means the same thing as an empty "ap" value, namely Stable). Do this by causing ChannelInfo::Initialize to not return false when the "ap" value is missing.
Update unit tests that were checking for the old behaviour of ChannelInfo.
BUG=80683
TEST=Install Stable channel Chrome on Windows. Go to the about box. Observe that the string "unknown" does not show up in the version number.
Review URL: http://codereview.chromium.org/6901070
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83365 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r-- | chrome/installer/util/channel_info.cc | 4 | ||||
-rw-r--r-- | chrome/installer/util/channel_info.h | 5 | ||||
-rw-r--r-- | chrome/installer/util/google_update_settings_unittest.cc | 20 |
3 files changed, 18 insertions, 11 deletions
diff --git a/chrome/installer/util/channel_info.cc b/chrome/installer/util/channel_info.cc index f2bb28d..8e6665e 100644 --- a/chrome/installer/util/channel_info.cc +++ b/chrome/installer/util/channel_info.cc @@ -134,7 +134,9 @@ bool SetModifier(ModifierIndex index, bool set, std::wstring* ap_value) { namespace installer { bool ChannelInfo::Initialize(const RegKey& key) { - return (key.ReadValue(google_update::kRegApField, &value_) == ERROR_SUCCESS); + LONG result = key.ReadValue(google_update::kRegApField, &value_); + return result == ERROR_SUCCESS || result == ERROR_FILE_NOT_FOUND || + result == ERROR_INVALID_HANDLE; } bool ChannelInfo::Write(RegKey* key) const { diff --git a/chrome/installer/util/channel_info.h b/chrome/installer/util/channel_info.h index e9c46e1..c032abd 100644 --- a/chrome/installer/util/channel_info.h +++ b/chrome/installer/util/channel_info.h @@ -22,7 +22,10 @@ class ChannelInfo { public: // Initialize an instance from the "ap" value in a given registry key. - // Returns false if the value could not be read from the registry. + // Returns false if the value is present but could not be read from the + // registry. Returns true if the value was not present or could be read. + // Also returns true if the key is not valid. + // An absent "ap" value is treated identically to an empty "ap" value. bool Initialize(const base::win::RegKey& key); // Writes the info to the "ap" value in a given registry key. diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc index 848d900..afe5ab4 100644 --- a/chrome/installer/util/google_update_settings_unittest.cc +++ b/chrome/installer/util/google_update_settings_unittest.cc @@ -181,17 +181,17 @@ class GoogleUpdateSettingsTest: public testing::Test { } // namespace -// Verify that we return failure on no registration, +// Verify that we return success on no registration (which means stable), // whether per-system or per-user install. TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelAbsent) { // Per-system first. std::wstring channel; - EXPECT_FALSE(GoogleUpdateSettings::GetChromeChannel(true, &channel)); - EXPECT_STREQ(L"unknown", channel.c_str()); + EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(true, &channel)); + EXPECT_STREQ(L"", channel.c_str()); // Then per-user. - EXPECT_FALSE(GoogleUpdateSettings::GetChromeChannel(false, &channel)); - EXPECT_STREQ(L"unknown", channel.c_str()); + EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(false, &channel)); + EXPECT_STREQ(L"", channel.c_str()); } // Test an empty Ap key for system and user. @@ -201,15 +201,17 @@ TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelEmptySystem) { EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(true, &channel)); EXPECT_STREQ(L"", channel.c_str()); - // Per-user lookups should fail. - EXPECT_FALSE(GoogleUpdateSettings::GetChromeChannel(false, &channel)); + // Per-user lookups still succeed and return empty string. + EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(false, &channel)); + EXPECT_STREQ(L"", channel.c_str()); } TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelEmptyUser) { SetApField(USER_INSTALL, L""); - // Per-system lookup should fail. + // Per-system lookups still succeed and return empty string. std::wstring channel; - EXPECT_FALSE(GoogleUpdateSettings::GetChromeChannel(true, &channel)); + EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(true, &channel)); + EXPECT_STREQ(L"", channel.c_str()); // Per-user lookup should succeed. EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannel(false, &channel)); |