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

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

Issue 11280067: Refactor SetOmahaExperimentLabel out of gcpai and into install_util. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: grt test comments Created 7 years, 11 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/google_update_settings.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/google_update_settings_unittest.cc
diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc
index de3f2e352d5c03797b6da0a4f1d6c07e9091e6fe..511b2e19fa6426b7143c7302e9f12a21d2f3363e 100644
--- a/chrome/installer/util/google_update_settings_unittest.cc
+++ b/chrome/installer/util/google_update_settings_unittest.cc
@@ -36,11 +36,12 @@ const GoogleUpdateSettings::UpdatePolicy kDefaultUpdatePolicy =
#endif
const wchar_t kTestProductGuid[] = L"{89F1B351-B15D-48D4-8F10-1298721CF13D}";
+const wchar_t kTestExperimentLabel[] = L"test_label_value";
// This test fixture redirects the HKLM and HKCU registry hives for
// the duration of the test to make it independent of the machine
// and user settings.
-class GoogleUpdateSettingsTest: public testing::Test {
+class GoogleUpdateSettingsTest : public testing::Test {
protected:
virtual void SetUp() OVERRIDE {
registry_overrides_.OverrideRegistry(HKEY_LOCAL_MACHINE, L"HKLM_pit");
@@ -112,6 +113,46 @@ class GoogleUpdateSettingsTest: public testing::Test {
}
}
+ // Test the writing and deleting functionality of the experiments label
+ // helper.
+ void TestExperimentsLabelHelper(SystemUserInstall install) {
+#ifdef GOOGLE_CHROME_BUILD
grt (UTC plus 2) 2013/01/08 17:06:36 #if defined(GOOGLE_CHROME_BUILD)
SteveT 2013/01/08 17:53:15 Done.
+ EXPECT_TRUE(GoogleUpdateSettings::SetExperimentLabels(
+ install == SYSTEM_INSTALL, kTestExperimentLabel));
+
+ // Validate that something is written. Only worry about the label itself.
+ RegKey key;
+ std::wstring value;
+ BrowserDistribution* chrome =
+ BrowserDistribution::GetSpecificDistribution(
+ BrowserDistribution::CHROME_BROWSER);
+ EXPECT_TRUE(chrome->ShouldSetExperimentLabels());
+
+ HKEY root = install == SYSTEM_INSTALL ?
+ HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
+ string16 state_key = install == SYSTEM_INSTALL ?
+ chrome->GetStateMediumKey() : chrome->GetStateKey();
+
+ EXPECT_EQ(ERROR_SUCCESS,
+ key.Open(root, state_key.c_str(), KEY_QUERY_VALUE));
+ EXPECT_EQ(ERROR_SUCCESS,
+ key.ReadValue(google_update::kExperimentLabels, &value));
+ EXPECT_EQ(kTestExperimentLabel, value);
+
+ // Now that the label is set, test the delete functionality. An empty label
+ // should result in deleting the value.
+ EXPECT_TRUE(GoogleUpdateSettings::SetExperimentLabels(
+ install == SYSTEM_INSTALL, string16()));
+ EXPECT_EQ(ERROR_SUCCESS,
+ key.Open(root, state_key.c_str(), KEY_QUERY_VALUE));
+ EXPECT_EQ(ERROR_FILE_NOT_FOUND,
+ key.ReadValue(google_update::kExperimentLabels, &value));
+ key.Close();
+#else
+ EXPECT_FALSE(chrome->ShouldSetExperimentLabels());
grt (UTC plus 2) 2013/01/08 17:07:39 chrome -> BrowserDistribution::GetSpecificDistribu
SteveT 2013/01/08 17:53:15 Yeah... the trybots caught that error. I refactore
+#endif // GOOGLE_CHROME_BUILD
+ }
+
// Creates "ap" key with the value given as parameter. Also adds work
// items to work_item_list given so that they can be rolled back later.
bool CreateApKey(WorkItemList* work_item_list, const std::wstring& value) {
@@ -555,6 +596,14 @@ TEST_F(GoogleUpdateSettingsTest, GetAppUpdatePolicyAppOverride) {
EXPECT_FALSE(is_overridden);
}
+TEST_F(GoogleUpdateSettingsTest, ExperimentsLabelHelperSystem) {
+ TestExperimentsLabelHelper(SYSTEM_INSTALL);
+}
+
+TEST_F(GoogleUpdateSettingsTest, ExperimentsLabelHelperUser) {
+ TestExperimentsLabelHelper(USER_INSTALL);
+}
+
#endif // defined(GOOGLE_CHROME_BUILD)
// Test GoogleUpdateSettings::GetUninstallCommandLine at system- or user-level,
« no previous file with comments | « chrome/installer/util/google_update_settings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698