summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util/google_update_settings_unittest.cc
diff options
context:
space:
mode:
authorcdn@chromium.org <cdn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-23 19:08:16 +0000
committercdn@chromium.org <cdn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-23 19:08:16 +0000
commit30aad2f5b5fdc9e20179c95c122a9d97d2e448a9 (patch)
tree5448bb763cacdc1d0f049cfc0456c39819522004 /chrome/installer/util/google_update_settings_unittest.cc
parent2779a9892c58b84625a673c2a24c6d29f0978af0 (diff)
downloadchromium_src-30aad2f5b5fdc9e20179c95c122a9d97d2e448a9.zip
chromium_src-30aad2f5b5fdc9e20179c95c122a9d97d2e448a9.tar.gz
chromium_src-30aad2f5b5fdc9e20179c95c122a9d97d2e448a9.tar.bz2
Expose methods to check the installed version of Google Update
BUG=128594 TEST=CompareVersions.*, GetGoogleUpdateVersion.* Review URL: https://chromiumcodereview.appspot.com/10408012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138551 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/google_update_settings_unittest.cc')
-rw-r--r--chrome/installer/util/google_update_settings_unittest.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc
index 4eb5d11..cec1421 100644
--- a/chrome/installer/util/google_update_settings_unittest.cc
+++ b/chrome/installer/util/google_update_settings_unittest.cc
@@ -7,6 +7,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/test/test_reg_util_win.h"
+#include "base/utf_string_conversions.h"
#include "base/win/registry.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/installer/util/browser_distribution.h"
@@ -615,6 +616,66 @@ TEST_P(GetUninstallCommandLine, TestRealValue) {
INSTANTIATE_TEST_CASE_P(GetUninstallCommandLineAtLevel, GetUninstallCommandLine,
testing::Bool());
+// Test GoogleUpdateSettings::GetGoogleUpdateVersion at system- or user-level,
+// according to the param.
+class GetGoogleUpdateVersion : public GoogleUpdateSettingsTest,
+ public testing::WithParamInterface<bool> {
+ protected:
+ static const wchar_t kDummyVersion[];
+
+ virtual void SetUp() OVERRIDE {
+ GoogleUpdateSettingsTest::SetUp();
+ system_install_ = GetParam();
+ root_key_ = system_install_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
+ }
+
+ HKEY root_key_;
+ bool system_install_;
+};
+
+const wchar_t GetGoogleUpdateVersion::kDummyVersion[] = L"1.2.3.4";
+
+// Tests that GetGoogleUpdateVersion returns an empty string if there's no
+// Software\Google\Update key.
+TEST_P(GetGoogleUpdateVersion, TestNoKey) {
+ EXPECT_FALSE(
+ GoogleUpdateSettings::GetGoogleUpdateVersion(system_install_).IsValid());
+}
+
+// Tests that GetGoogleUpdateVersion returns an empty string if there's no
+// version value in the Software\Google\Update key.
+TEST_P(GetGoogleUpdateVersion, TestNoValue) {
+ RegKey(root_key_, google_update::kRegPathGoogleUpdate, KEY_SET_VALUE);
+ EXPECT_FALSE(
+ GoogleUpdateSettings::GetGoogleUpdateVersion(system_install_).IsValid());
+}
+
+// Tests that GetGoogleUpdateVersion returns an empty string if there's an
+// empty version value in the Software\Google\Update key.
+TEST_P(GetGoogleUpdateVersion, TestEmptyValue) {
+ RegKey(root_key_, google_update::kRegPathGoogleUpdate, KEY_SET_VALUE)
+ .WriteValue(google_update::kRegGoogleUpdateVersion, L"");
+ EXPECT_FALSE(
+ GoogleUpdateSettings::GetGoogleUpdateVersion(system_install_).IsValid());
+}
+
+// Tests that GetGoogleUpdateVersion returns the correct string if there's a
+// version value in the Software\Google\Update key.
+TEST_P(GetGoogleUpdateVersion, TestRealValue) {
+ RegKey(root_key_, google_update::kRegPathGoogleUpdate, KEY_SET_VALUE)
+ .WriteValue(google_update::kRegGoogleUpdateVersion, kDummyVersion);
+ Version expected(UTF16ToUTF8(kDummyVersion));
+ EXPECT_TRUE(expected.Equals(
+ GoogleUpdateSettings::GetGoogleUpdateVersion(system_install_)));
+ // Make sure that there's no value in the other level (user or system).
+ EXPECT_FALSE(
+ GoogleUpdateSettings::GetGoogleUpdateVersion(!system_install_)
+ .IsValid());
+}
+
+INSTANTIATE_TEST_CASE_P(GetGoogleUpdateVersionAtLevel, GetGoogleUpdateVersion,
+ testing::Bool());
+
// Test values for use by the CollectStatsConsent test fixture.
class StatsState {
public: