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

Side by Side Diff: chrome/browser/extensions/api/storage/policy_value_store_unittest.cc

Issue 24021002: Propagate more information about ValueStore errors to callers, notably an (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add Pass*() Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/extensions/api/storage/policy_value_store.h" 5 #include "chrome/browser/extensions/api/storage/policy_value_store.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 policy::PolicyMap policies; 121 policy::PolicyMap policies;
122 base::FundamentalValue expected(123); 122 base::FundamentalValue expected(123);
123 policies.Set("must", policy::POLICY_LEVEL_MANDATORY, 123 policies.Set("must", policy::POLICY_LEVEL_MANDATORY,
124 policy::POLICY_SCOPE_USER, expected.DeepCopy(), NULL); 124 policy::POLICY_SCOPE_USER, expected.DeepCopy(), NULL);
125 policies.Set("may", policy::POLICY_LEVEL_RECOMMENDED, 125 policies.Set("may", policy::POLICY_LEVEL_RECOMMENDED,
126 policy::POLICY_SCOPE_USER, 126 policy::POLICY_SCOPE_USER,
127 new base::FundamentalValue(456), NULL); 127 new base::FundamentalValue(456), NULL);
128 store_->SetCurrentPolicy(policies, false); 128 store_->SetCurrentPolicy(policies, false);
129 ValueStore::ReadResult result = store_->Get(); 129 ValueStore::ReadResult result = store_->Get();
130 ASSERT_FALSE(result->HasError()); 130 ASSERT_FALSE(result->HasError());
131 EXPECT_EQ(1u, result->settings()->size()); 131 EXPECT_EQ(1u, result->settings().size());
132 base::Value* value = NULL; 132 base::Value* value = NULL;
133 EXPECT_FALSE(result->settings()->Get("may", &value)); 133 EXPECT_FALSE(result->settings().Get("may", &value));
134 EXPECT_TRUE(result->settings()->Get("must", &value)); 134 EXPECT_TRUE(result->settings().Get("must", &value));
135 EXPECT_TRUE(base::Value::Equals(&expected, value)); 135 EXPECT_TRUE(base::Value::Equals(&expected, value));
136 } 136 }
137 137
138 TEST_F(PolicyValueStoreTest, ReadOnly) { 138 TEST_F(PolicyValueStoreTest, ReadOnly) {
139 ValueStore::WriteOptions options = ValueStore::DEFAULTS; 139 ValueStore::WriteOptions options = ValueStore::DEFAULTS;
140 140
141 base::StringValue string_value("value"); 141 base::StringValue string_value("value");
142 EXPECT_TRUE(store_->Set(options, "key", string_value)->HasError()); 142 EXPECT_TRUE(store_->Set(options, "key", string_value)->HasError());
143 143
144 base::DictionaryValue dict; 144 base::DictionaryValue dict;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 Mock::VerifyAndClearExpectations(&observer_); 211 Mock::VerifyAndClearExpectations(&observer_);
212 212
213 // Don't notify when there aren't changes. 213 // Don't notify when there aren't changes.
214 EXPECT_CALL(observer_, OnSettingsChanged(_, _, _)).Times(0); 214 EXPECT_CALL(observer_, OnSettingsChanged(_, _, _)).Times(0);
215 store_->SetCurrentPolicy(policies, true); 215 store_->SetCurrentPolicy(policies, true);
216 loop_.RunUntilIdle(); 216 loop_.RunUntilIdle();
217 Mock::VerifyAndClearExpectations(&observer_); 217 Mock::VerifyAndClearExpectations(&observer_);
218 } 218 }
219 219
220 } // namespace extensions 220 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/storage/policy_value_store.cc ('k') | chrome/browser/extensions/api/storage/settings_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698