| 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 "chrome/browser/chromeos/settings/cros_settings.h" | 5 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 AddExpectation(kAccountsPrefAllowNewUser, new base::FundamentalValue(false)); | 126 AddExpectation(kAccountsPrefAllowNewUser, new base::FundamentalValue(false)); |
| 127 AddExpectation(kAccountsPrefUsers, whitelist.DeepCopy()); | 127 AddExpectation(kAccountsPrefUsers, whitelist.DeepCopy()); |
| 128 SetPref(kAccountsPrefUsers, &whitelist); | 128 SetPref(kAccountsPrefUsers, &whitelist); |
| 129 FetchPref(kAccountsPrefAllowNewUser); | 129 FetchPref(kAccountsPrefAllowNewUser); |
| 130 FetchPref(kAccountsPrefUsers); | 130 FetchPref(kAccountsPrefUsers); |
| 131 } | 131 } |
| 132 | 132 |
| 133 TEST_F(CrosSettingsTest, SetWhitelistWithListOps) { | 133 TEST_F(CrosSettingsTest, SetWhitelistWithListOps) { |
| 134 base::ListValue* whitelist = new base::ListValue(); | 134 base::ListValue* whitelist = new base::ListValue(); |
| 135 base::StringValue hacky_user("h@xxor"); | 135 base::StringValue hacky_user("h@xxor"); |
| 136 whitelist->Append(hacky_user.DeepCopy()); | 136 whitelist->Append(hacky_user.CreateDeepCopy()); |
| 137 AddExpectation(kAccountsPrefAllowNewUser, new base::FundamentalValue(false)); | 137 AddExpectation(kAccountsPrefAllowNewUser, new base::FundamentalValue(false)); |
| 138 AddExpectation(kAccountsPrefUsers, whitelist); | 138 AddExpectation(kAccountsPrefUsers, whitelist); |
| 139 // Add some user to the whitelist. | 139 // Add some user to the whitelist. |
| 140 settings_.AppendToList(kAccountsPrefUsers, &hacky_user); | 140 settings_.AppendToList(kAccountsPrefUsers, &hacky_user); |
| 141 FetchPref(kAccountsPrefAllowNewUser); | 141 FetchPref(kAccountsPrefAllowNewUser); |
| 142 FetchPref(kAccountsPrefUsers); | 142 FetchPref(kAccountsPrefUsers); |
| 143 } | 143 } |
| 144 | 144 |
| 145 TEST_F(CrosSettingsTest, SetWhitelistWithListOps2) { | 145 TEST_F(CrosSettingsTest, SetWhitelistWithListOps2) { |
| 146 base::ListValue whitelist; | 146 base::ListValue whitelist; |
| 147 base::StringValue hacky_user("h@xxor"); | 147 base::StringValue hacky_user("h@xxor"); |
| 148 base::StringValue lamy_user("l@mer"); | 148 base::StringValue lamy_user("l@mer"); |
| 149 whitelist.Append(hacky_user.DeepCopy()); | 149 whitelist.Append(hacky_user.CreateDeepCopy()); |
| 150 base::ListValue* expected_list = whitelist.DeepCopy(); | 150 base::ListValue* expected_list = whitelist.DeepCopy(); |
| 151 whitelist.Append(lamy_user.DeepCopy()); | 151 whitelist.Append(lamy_user.CreateDeepCopy()); |
| 152 AddExpectation(kAccountsPrefAllowNewUser, new base::FundamentalValue(false)); | 152 AddExpectation(kAccountsPrefAllowNewUser, new base::FundamentalValue(false)); |
| 153 AddExpectation(kAccountsPrefUsers, whitelist.DeepCopy()); | 153 AddExpectation(kAccountsPrefUsers, whitelist.DeepCopy()); |
| 154 SetPref(kAccountsPrefUsers, &whitelist); | 154 SetPref(kAccountsPrefUsers, &whitelist); |
| 155 FetchPref(kAccountsPrefAllowNewUser); | 155 FetchPref(kAccountsPrefAllowNewUser); |
| 156 FetchPref(kAccountsPrefUsers); | 156 FetchPref(kAccountsPrefUsers); |
| 157 ASSERT_TRUE(expected_props_.empty()); | 157 ASSERT_TRUE(expected_props_.empty()); |
| 158 // Now try to remove one element from that list. | 158 // Now try to remove one element from that list. |
| 159 AddExpectation(kAccountsPrefUsers, expected_list); | 159 AddExpectation(kAccountsPrefUsers, expected_list); |
| 160 settings_.RemoveFromList(kAccountsPrefUsers, &lamy_user); | 160 settings_.RemoveFromList(kAccountsPrefUsers, &lamy_user); |
| 161 FetchPref(kAccountsPrefAllowNewUser); | 161 FetchPref(kAccountsPrefAllowNewUser); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 EXPECT_TRUE(wildcard_match); | 260 EXPECT_TRUE(wildcard_match); |
| 261 EXPECT_TRUE(cs->FindEmailInList( | 261 EXPECT_TRUE(cs->FindEmailInList( |
| 262 kAccountsPrefUsers, "user@example.com", &wildcard_match)); | 262 kAccountsPrefUsers, "user@example.com", &wildcard_match)); |
| 263 EXPECT_FALSE(wildcard_match); | 263 EXPECT_FALSE(wildcard_match); |
| 264 EXPECT_TRUE(cs->FindEmailInList( | 264 EXPECT_TRUE(cs->FindEmailInList( |
| 265 kAccountsPrefUsers, "*@example.com", &wildcard_match)); | 265 kAccountsPrefUsers, "*@example.com", &wildcard_match)); |
| 266 EXPECT_TRUE(wildcard_match); | 266 EXPECT_TRUE(wildcard_match); |
| 267 } | 267 } |
| 268 | 268 |
| 269 } // namespace chromeos | 269 } // namespace chromeos |
| OLD | NEW |