| 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 <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 weak_factory_(this) {} | 36 weak_factory_(this) {} |
| 37 | 37 |
| 38 ~CrosSettingsTest() override {} | 38 ~CrosSettingsTest() override {} |
| 39 | 39 |
| 40 void TearDown() override { | 40 void TearDown() override { |
| 41 ASSERT_TRUE(expected_props_.empty()); | 41 ASSERT_TRUE(expected_props_.empty()); |
| 42 STLDeleteValues(&expected_props_); | 42 STLDeleteValues(&expected_props_); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void FetchPref(const std::string& pref) { | 45 void FetchPref(const std::string& pref) { |
| 46 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 46 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 47 if (expected_props_.find(pref) == expected_props_.end()) | 47 if (expected_props_.find(pref) == expected_props_.end()) |
| 48 return; | 48 return; |
| 49 | 49 |
| 50 if (CrosSettingsProvider::TRUSTED == | 50 if (CrosSettingsProvider::TRUSTED == |
| 51 settings_.PrepareTrustedValues( | 51 settings_.PrepareTrustedValues( |
| 52 base::Bind(&CrosSettingsTest::FetchPref, | 52 base::Bind(&CrosSettingsTest::FetchPref, |
| 53 weak_factory_.GetWeakPtr(), pref))) { | 53 weak_factory_.GetWeakPtr(), pref))) { |
| 54 scoped_ptr<base::Value> expected_value( | 54 scoped_ptr<base::Value> expected_value( |
| 55 expected_props_.find(pref)->second); | 55 expected_props_.find(pref)->second); |
| 56 const base::Value* pref_value = settings_.GetPref(pref); | 56 const base::Value* pref_value = settings_.GetPref(pref); |
| 57 if (expected_value.get()) { | 57 if (expected_value.get()) { |
| 58 ASSERT_TRUE(pref_value); | 58 ASSERT_TRUE(pref_value); |
| 59 ASSERT_TRUE(expected_value->Equals(pref_value)); | 59 ASSERT_TRUE(expected_value->Equals(pref_value)); |
| 60 } else { | 60 } else { |
| 61 ASSERT_FALSE(pref_value); | 61 ASSERT_FALSE(pref_value); |
| 62 } | 62 } |
| 63 expected_props_.erase(pref); | 63 expected_props_.erase(pref); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 void SetPref(const std::string& pref_name, const base::Value* value) { | 67 void SetPref(const std::string& pref_name, const base::Value* value) { |
| 68 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 68 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 69 settings_.Set(pref_name, *value); | 69 settings_.Set(pref_name, *value); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void AddExpectation(const std::string& pref_name, base::Value* value) { | 72 void AddExpectation(const std::string& pref_name, base::Value* value) { |
| 73 base::Value*& entry = expected_props_[pref_name]; | 73 base::Value*& entry = expected_props_[pref_name]; |
| 74 delete entry; | 74 delete entry; |
| 75 entry = value; | 75 entry = value; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void PrepareEmptyPolicy(em::PolicyData* policy) { | 78 void PrepareEmptyPolicy(em::PolicyData* policy) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 EXPECT_TRUE(wildcard_match); | 259 EXPECT_TRUE(wildcard_match); |
| 260 EXPECT_TRUE(cs->FindEmailInList( | 260 EXPECT_TRUE(cs->FindEmailInList( |
| 261 kAccountsPrefUsers, "user@example.com", &wildcard_match)); | 261 kAccountsPrefUsers, "user@example.com", &wildcard_match)); |
| 262 EXPECT_FALSE(wildcard_match); | 262 EXPECT_FALSE(wildcard_match); |
| 263 EXPECT_TRUE(cs->FindEmailInList( | 263 EXPECT_TRUE(cs->FindEmailInList( |
| 264 kAccountsPrefUsers, "*@example.com", &wildcard_match)); | 264 kAccountsPrefUsers, "*@example.com", &wildcard_match)); |
| 265 EXPECT_TRUE(wildcard_match); | 265 EXPECT_TRUE(wildcard_match); |
| 266 } | 266 } |
| 267 | 267 |
| 268 } // namespace chromeos | 268 } // namespace chromeos |
| OLD | NEW |