Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <windows.h> | 5 #include <windows.h> |
| 6 #include <shlwapi.h> // For SHDeleteKey. | 6 #include <shlwapi.h> // For SHDeleteKey. |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/test/test_reg_util_win.h" | 9 #include "base/test/test_reg_util_win.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 BrowserDistribution* chrome = | 119 BrowserDistribution* chrome = |
| 120 BrowserDistribution::GetSpecificDistribution( | 120 BrowserDistribution::GetSpecificDistribution( |
| 121 BrowserDistribution::CHROME_BROWSER); | 121 BrowserDistribution::CHROME_BROWSER); |
| 122 #if defined(GOOGLE_CHROME_BUILD) | 122 #if defined(GOOGLE_CHROME_BUILD) |
| 123 EXPECT_TRUE(chrome->ShouldSetExperimentLabels()); | 123 EXPECT_TRUE(chrome->ShouldSetExperimentLabels()); |
| 124 | 124 |
| 125 EXPECT_TRUE(GoogleUpdateSettings::SetExperimentLabels( | 125 EXPECT_TRUE(GoogleUpdateSettings::SetExperimentLabels( |
| 126 install == SYSTEM_INSTALL, kTestExperimentLabel)); | 126 install == SYSTEM_INSTALL, kTestExperimentLabel)); |
| 127 | 127 |
| 128 // Validate that something is written. Only worry about the label itself. | 128 // Validate that something is written. Only worry about the label itself. |
| 129 RegKey key; | |
| 130 std::wstring value; | 129 std::wstring value; |
| 131 HKEY root = install == SYSTEM_INSTALL ? | 130 EXPECT_TRUE(GoogleUpdateSettings::ReadExperimentLabels( |
|
grt (UTC plus 2)
2013/01/09 18:49:51
this tests that Set/Read round-trips properly, but
SteveT
2013/01/09 19:36:10
Makes sense, assuming we trust the validation code
| |
| 132 HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 131 install == SYSTEM_INSTALL, &value)); |
| 133 string16 state_key = install == SYSTEM_INSTALL ? | |
| 134 chrome->GetStateMediumKey() : chrome->GetStateKey(); | |
| 135 | |
| 136 EXPECT_EQ(ERROR_SUCCESS, | |
| 137 key.Open(root, state_key.c_str(), KEY_QUERY_VALUE)); | |
| 138 EXPECT_EQ(ERROR_SUCCESS, | |
| 139 key.ReadValue(google_update::kExperimentLabels, &value)); | |
| 140 EXPECT_EQ(kTestExperimentLabel, value); | 132 EXPECT_EQ(kTestExperimentLabel, value); |
| 141 key.Close(); | |
| 142 | 133 |
| 143 // Now that the label is set, test the delete functionality. An empty label | 134 // Now that the label is set, test the delete functionality. An empty label |
| 144 // should result in deleting the value. | 135 // should result in deleting the value. |
| 145 EXPECT_TRUE(GoogleUpdateSettings::SetExperimentLabels( | 136 EXPECT_TRUE(GoogleUpdateSettings::SetExperimentLabels( |
| 146 install == SYSTEM_INSTALL, string16())); | 137 install == SYSTEM_INSTALL, string16())); |
| 147 EXPECT_EQ(ERROR_SUCCESS, | 138 EXPECT_FALSE(GoogleUpdateSettings::ReadExperimentLabels( |
| 148 key.Open(root, state_key.c_str(), KEY_QUERY_VALUE)); | 139 install == SYSTEM_INSTALL, &value)); |
| 149 EXPECT_EQ(ERROR_FILE_NOT_FOUND, | |
| 150 key.ReadValue(google_update::kExperimentLabels, &value)); | |
| 151 key.Close(); | |
| 152 #else | 140 #else |
| 153 EXPECT_FALSE(chrome->ShouldSetExperimentLabels()); | 141 EXPECT_FALSE(chrome->ShouldSetExperimentLabels()); |
|
grt (UTC plus 2)
2013/01/09 18:49:51
add an expectation that ReadExperimentLables retur
SteveT
2013/01/09 19:36:10
Done.
| |
| 154 #endif // GOOGLE_CHROME_BUILD | 142 #endif // GOOGLE_CHROME_BUILD |
| 155 } | 143 } |
| 156 | 144 |
| 157 // Creates "ap" key with the value given as parameter. Also adds work | 145 // Creates "ap" key with the value given as parameter. Also adds work |
| 158 // items to work_item_list given so that they can be rolled back later. | 146 // items to work_item_list given so that they can be rolled back later. |
| 159 bool CreateApKey(WorkItemList* work_item_list, const std::wstring& value) { | 147 bool CreateApKey(WorkItemList* work_item_list, const std::wstring& value) { |
| 160 HKEY reg_root = HKEY_CURRENT_USER; | 148 HKEY reg_root = HKEY_CURRENT_USER; |
| 161 std::wstring reg_key = GetApKeyPath(); | 149 std::wstring reg_key = GetApKeyPath(); |
| 162 work_item_list->AddCreateRegKeyWorkItem(reg_root, reg_key); | 150 work_item_list->AddCreateRegKeyWorkItem(reg_root, reg_key); |
| 163 work_item_list->AddSetRegValueWorkItem(reg_root, reg_key, | 151 work_item_list->AddSetRegValueWorkItem(reg_root, reg_key, |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 981 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 969 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
| 982 StatsState::FALSE_SETTING, StatsState::FALSE_SETTING), | 970 StatsState::FALSE_SETTING, StatsState::FALSE_SETTING), |
| 983 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 971 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
| 984 StatsState::FALSE_SETTING, StatsState::TRUE_SETTING), | 972 StatsState::FALSE_SETTING, StatsState::TRUE_SETTING), |
| 985 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 973 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
| 986 StatsState::TRUE_SETTING, StatsState::NO_SETTING), | 974 StatsState::TRUE_SETTING, StatsState::NO_SETTING), |
| 987 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 975 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
| 988 StatsState::TRUE_SETTING, StatsState::FALSE_SETTING), | 976 StatsState::TRUE_SETTING, StatsState::FALSE_SETTING), |
| 989 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 977 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
| 990 StatsState::TRUE_SETTING, StatsState::TRUE_SETTING))); | 978 StatsState::TRUE_SETTING, StatsState::TRUE_SETTING))); |
| OLD | NEW |